mirror of
https://github.com/billz/raspap-webgui.git
synced 2023-10-10 13:37:24 +02:00
Updated install and uninstall scripts to append to rc.local rather than overwrite the file
This commit is contained in:
parent
6fefbf7a2d
commit
908f0de8cb
@ -132,6 +132,11 @@ function check_for_old_configs() {
|
|||||||
sudo cp /etc/dhcpcd.conf "$raspap_dir/backups/dhcpcd.conf.`date +%F-%R`"
|
sudo cp /etc/dhcpcd.conf "$raspap_dir/backups/dhcpcd.conf.`date +%F-%R`"
|
||||||
sudo ln -sf "$raspap_dir/backups/dhcpcd.conf.`date +%F-%R`" "$raspap_dir/backups/dhcpcd.conf"
|
sudo ln -sf "$raspap_dir/backups/dhcpcd.conf.`date +%F-%R`" "$raspap_dir/backups/dhcpcd.conf"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
if [ -f /etc/rc.local ]; then
|
||||||
|
sudo cp /etc/rc.local "$raspap_dir/backups/rc.local.`date +%F-%R`"
|
||||||
|
sudo ln -sf "$raspap_dir/backups/rc.local.`date +%F-%R`" "$raspap_dir/backups/rc.local"
|
||||||
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
# Move configuration file to the correct location
|
# Move configuration file to the correct location
|
||||||
@ -155,7 +160,24 @@ function default_configuration() {
|
|||||||
sudo mv $webroot_dir/config/hostapd.conf /etc/hostapd/hostapd.conf || install_error "Unable to move hostapd configuration file"
|
sudo mv $webroot_dir/config/hostapd.conf /etc/hostapd/hostapd.conf || install_error "Unable to move hostapd configuration file"
|
||||||
sudo mv $webroot_dir/config/dnsmasq.conf /etc/dnsmasq.conf || install_error "Unable to move dnsmasq configuration file"
|
sudo mv $webroot_dir/config/dnsmasq.conf /etc/dnsmasq.conf || install_error "Unable to move dnsmasq configuration file"
|
||||||
sudo mv $webroot_dir/config/dhcpcd.conf /etc/dhcpcd.conf || install_error "Unable to move dhcpcd configuration file"
|
sudo mv $webroot_dir/config/dhcpcd.conf /etc/dhcpcd.conf || install_error "Unable to move dhcpcd configuration file"
|
||||||
sudo mv $webroot_dir/config/rc.local /etc/rc.local || install_error "Unable to move rc.local file"
|
#sudo mv $webroot_dir/config/rc.local /etc/rc.local || install_error "Unable to move rc.local file"
|
||||||
|
# Generate required lines for Rasp AP to place into rc.local file.
|
||||||
|
# #RASPAP is for removal script
|
||||||
|
|
||||||
|
lines=(
|
||||||
|
'echo 1 > /proc/sys/net/ipv4/ip_forward #RASPAP'
|
||||||
|
'iptables -t nat -A POSTROUTING -j MASQUERADE #RASPAP'
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
|
for line in "${lines[@]}"; do
|
||||||
|
if grep "$line" /etc/rc.local > /dev/null; then
|
||||||
|
echo "$line: Line already added"
|
||||||
|
else
|
||||||
|
sed -i "s/exit 0/$line\nexit0/" /etc/rc.local
|
||||||
|
echo "Adding line $line"
|
||||||
|
fi
|
||||||
|
done
|
||||||
}
|
}
|
||||||
|
|
||||||
# Add a single entry to the sudoers file
|
# Add a single entry to the sudoers file
|
||||||
|
@ -63,10 +63,23 @@ function check_for_backups() {
|
|||||||
fi
|
fi
|
||||||
if [ -f "$raspap_dir/backups/dhcpcd.conf" ]; then
|
if [ -f "$raspap_dir/backups/dhcpcd.conf" ]; then
|
||||||
echo -n "Restore the last dhcpcd.conf file? [y/N]: "
|
echo -n "Restore the last dhcpcd.conf file? [y/N]: "
|
||||||
|
read answer
|
||||||
if [[ $answer -eq 'y' ]]; then
|
if [[ $answer -eq 'y' ]]; then
|
||||||
sudo cp "$raspap_dir/backups/dhcpcd.conf" /etc/dhcpcd.conf
|
sudo cp "$raspap_dir/backups/dhcpcd.conf" /etc/dhcpcd.conf
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
|
if [ -f "$raspap_dir/backups/rc.local" ]; then
|
||||||
|
echo -n "Restore the last rc.local file? [y/N]: "
|
||||||
|
read answer
|
||||||
|
if [[ $answer -eq 'y' ]]; then
|
||||||
|
sudo cp "$raspap_dir/backups/rc.local" /etc/rc.local
|
||||||
|
else
|
||||||
|
echo -n "Remove RaspAP Lines from /etc/rc.local? [Y/n]: "
|
||||||
|
if $answer -ne 'n' ]]; then
|
||||||
|
sed -i '/#RASPAP/d' /etc/rc.local
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
fi
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user