Skip to content

Commit 4bca6fd

Browse files
committed
Merge pull request pi-hole#124 from dschaper/master
Fix merge conflicts
2 parents 86192a6 + 9c1eca2 commit 4bca6fd

File tree

2 files changed

+18
-18
lines changed

2 files changed

+18
-18
lines changed

automated install/basic-install.sh

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -25,10 +25,9 @@ r=$(( rows / 2 ))
2525
c=$(( columns / 2 ))
2626

2727
# Find IP used to route to outside world
28-
IPv4info=$(ip route get 8.8.8.8)
29-
IPv4dev=$(echo $IPv4info| awk '{print $5}')
30-
IPv4addr=$(ip -o -f inet addr show dev $IPv4dev | awk '{print $4}')
31-
IPv4gw=$(echo $IPv4info | awk '{print $3}')
28+
IPv4dev=$(ip route get 8.8.8.8 | awk '{for(i=1;i<=NF;i++)if($i~/dev/)print $(i+1)}')
29+
IPv4addr=$(ip -o -f inet addr show dev $IPv4dev | awk '{print $4}' | awk 'END {print}')
30+
IPv4gw=$(ip route get 8.8.8.8 | awk '{print $3}')
3231

3332
# IPv6 support to be added later
3433
#IPv6eui64=$(ip addr show | awk '/scope\ global/ && /ff:fe/ {print $2}' | cut -d'/' -f1)
@@ -171,16 +170,23 @@ done
171170
fi
172171
}
173172

174-
175-
setStaticIPv4()
176-
{
177-
# Append these lines to /etc/dhcpcd.conf to enable a static IP
173+
setDHCPCD(){
174+
# Append these lines to dhcpcd.conf to enable a static IP
178175
echo "interface $piholeInterface
179176
static ip_address=$IPv4addr
180177
static routers=$IPv4gw
181178
static domain_name_servers=$IPv4gw" | sudo tee -a $dhcpcdFile >/dev/null
182-
echo "Setting IP to $IPv4addr. You may need to restart after the install is complete."
183-
sudo ip addr replace dev $piholeInterface $IPv4addr
179+
}
180+
181+
setStaticIPv4(){
182+
if grep -q $IPv4addr $dhcpcdFile; then
183+
# address already set, noop
184+
:
185+
else
186+
setDHCPCD
187+
sudo ip addr replace dev $piholeInterface $IPv4addr
188+
echo "Setting IP to $IPv4addr. You may need to restart after the install is complete."
189+
fi
184190
}
185191

186192
installScripts(){
@@ -230,11 +236,6 @@ sudo mv /etc/crontab /etc/crontab.orig
230236
sudo curl -o /etc/crontab https://raw.githubusercontent.com/jacobsalmela/pi-hole/master/advanced/pihole.cron
231237
}
232238

233-
installPiLog(){
234-
sudo touch /var/log/pihole.log
235-
sudo chmod 644 /var/log/pihole.log
236-
sudo chown dnsmasq:root /var/log/pihole.log
237-
}
238239
installPihole()
239240
{
240241
installDependencies
@@ -248,7 +249,6 @@ installConfigs
248249
installWebAdmin
249250
installPiholeWeb
250251
installCron
251-
installPiLog
252252
sudo /usr/local/bin/gravity.sh
253253
}
254254

gravity.sh

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,8 @@ if [[ -f $piholeIPfile ]];then
1212
rm $piholeIPfile
1313
else
1414
# Otherwise, the IP address can be taken directly from the machine, which will happen when the script is run by the user and not the installation script
15-
IPv4dev=$(ip route get 8.8.8.8 | awk '{print $5}')
16-
piholeIPCIDR=$(ip -o -f inet addr show dev $IPv4dev | awk '{print $4}')
15+
IPv4dev=$(ip route get 8.8.8.8 | awk '{for(i=1;i<=NF;i++)if($i~/dev/)print $(i+1)}')
16+
piholeIPCIDR=$(ip -o -f inet addr show dev $IPv4dev | awk '{print $4}' | awk 'END {print}')
1717
piholeIP=${piholeIPCIDR%/*}
1818
fi
1919

0 commit comments

Comments
 (0)