mirror of
https://github.com/billz/raspap-webgui.git
synced 2023-10-10 13:37:24 +02:00
Updated installer script to backup more configuration files and appends dates when renaming old installation files when doing an inplace reinstall
This commit is contained in:
parent
61d450d1c7
commit
de7303883b
@ -114,11 +114,23 @@ function change_file_ownership() {
|
|||||||
# Check for existing /etc/network/interfaces and /etc/hostapd/hostapd.conf files
|
# Check for existing /etc/network/interfaces and /etc/hostapd/hostapd.conf files
|
||||||
function check_for_old_configs() {
|
function check_for_old_configs() {
|
||||||
if [ -f /etc/network/interfaces ]; then
|
if [ -f /etc/network/interfaces ]; then
|
||||||
sudo mv /etc/network/interfaces "$raspap_dir/backups"
|
sudo mv /etc/network/interfaces "$raspap_dir/backups/interfaces.`date +%F-%R`"
|
||||||
|
ln -s "$raspap_dir/backups/interfaces.`date +%F-%R`" "$raspap_dir/backups/interfaces"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [ -f /etc/hostapd/hostapd.conf ]; then
|
if [ -f /etc/hostapd/hostapd.conf ]; then
|
||||||
sudo mv /etc/hostapd/hostapd.conf "$raspap_dir/backups"
|
sudo mv /etc/hostapd/hostapd.conf "$raspap_dir/backups/hostapd.conf.`date +%F-%R`"
|
||||||
|
ln -s "$raspap_dir/backups/hostapd.conf.`date +%F-%R`" "$raspap_dir/backups/hostapd.conf"
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [ -f /etc/dnsmasq.conf ]; then
|
||||||
|
sudo mv /etc/dnsmasq.conf "$raspap_dir/backups/dnsmasq.conf.`date +%F-%R`"
|
||||||
|
ln -s "$raspap_dir/backups/dnsmasq.conf.`date +%F-%R`" "$raspap_dir/backups/dnsmasq.conf"
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [ -f /etc/dhcpcd.conf ]; then
|
||||||
|
sudo mv /etc/dhcpcd.conf "$raspap_dir/backups/dhcpcd.conf.`date +%F-%R`"
|
||||||
|
ln -s "$raspap_dir/backups/dhcpcd.conf.`date +%F-%R`" "$raspap_dir/backups/dhcpcd.conf"
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -154,23 +166,38 @@ function sudo_add() {
|
|||||||
|
|
||||||
# Adds www-data user to the sudoers file with restrictions on what the user can execute
|
# Adds www-data user to the sudoers file with restrictions on what the user can execute
|
||||||
function patch_system_files() {
|
function patch_system_files() {
|
||||||
# patch /etc/sudoers file
|
# Set commands array
|
||||||
|
cmds=(
|
||||||
|
'/sbin/ifdown wlan0'
|
||||||
|
'/sbin/ifup wlan0'
|
||||||
|
'/bin/cat /etc/wpa_supplicant/wpa_supplicant.conf'
|
||||||
|
'/bin/cp /tmp/wifidata /etc/wpa_supplicant/wpa_supplicant.conf'
|
||||||
|
'/sbin/wpa_cli scan_results'
|
||||||
|
'/sbin/wpa_cli scan'
|
||||||
|
'/sbin/wpa_cli reconfigure'
|
||||||
|
'/bin/cp /tmp/hostapddata /etc/hostapd/hostapd.conf'
|
||||||
|
'/etc/init.d/hostapd start'
|
||||||
|
'/etc/init.d/hostapd stop'
|
||||||
|
'/etc/init.d/dnsmasq start'
|
||||||
|
'/etc/init.d/dnsmasq stop'
|
||||||
|
'/bin/cp /tmp/dhcpddata /etc/dnsmasq.conf'
|
||||||
|
'/sbin/shutdown -h now'
|
||||||
|
'/sbin/reboot'
|
||||||
|
)
|
||||||
|
|
||||||
|
# Check if sudoers needs patchin
|
||||||
|
if [ $(sudo grep -c www-data /etc/sudoers) -ne 15 ]; then
|
||||||
|
# Sudoers file has incorrect number of commands. Wiping them out.
|
||||||
|
install_log "Cleaning sudoers file"
|
||||||
|
sudo sed -i '/www-data/d' /etc/sudoers
|
||||||
install_log "Patching system sudoers file"
|
install_log "Patching system sudoers file"
|
||||||
sudo_add '/sbin/ifdown wlan0'
|
# patch /etc/sudoers file
|
||||||
sudo_add '/sbin/ifup wlan0'
|
for cmd in "${cmds[@]}"; do
|
||||||
sudo_add '/bin/cat /etc/wpa_supplicant/wpa_supplicant.conf'
|
sudo_add $cmd
|
||||||
sudo_add '/bin/cp /tmp/wifidata /etc/wpa_supplicant/wpa_supplicant.conf'
|
done
|
||||||
sudo_add '/sbin/wpa_cli scan_results'
|
else
|
||||||
sudo_add '/sbin/wpa_cli scan'
|
install_log "Sudoers file already patched"
|
||||||
sudo_add '/sbin/wpa_cli reconfigure'
|
fi
|
||||||
sudo_add '/bin/cp /tmp/hostapddata /etc/hostapd/hostapd.conf'
|
|
||||||
sudo_add '/etc/init.d/hostapd start'
|
|
||||||
sudo_add '/etc/init.d/hostapd stop'
|
|
||||||
sudo_add '/etc/init.d/dnsmasq start'
|
|
||||||
sudo_add '/etc/init.d/dnsmasq stop'
|
|
||||||
sudo_add '/bin/cp /tmp/dhcpddata /etc/dnsmasq.conf'
|
|
||||||
sudo_add '/sbin/shutdown -h now'
|
|
||||||
sudo_add '/sbin/reboot'
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function install_complete() {
|
function install_complete() {
|
||||||
|
Loading…
Reference in New Issue
Block a user