1
0
mirror of https://github.com/billz/raspap-webgui.git synced 2023-10-10 13:37:24 +02:00

Installs php7.0-cgi on Stretch, maintains backwards compatibility

This commit is contained in:
billz 2017-11-16 01:24:02 +00:00
parent 354b387327
commit 0f7658221e
3 changed files with 75 additions and 31 deletions

View File

@ -2,14 +2,20 @@ raspap_dir="/etc/raspap"
raspap_user="www-data" raspap_user="www-data"
version=`sed 's/\..*//' /etc/debian_version` version=`sed 's/\..*//' /etc/debian_version`
# Determine version and set default home location for lighttpd # Determine version, set default home location for lighttpd and
if [ $version -ge 8 ]; then # php package to install
version_msg="Raspian version 8.0 or later" webroot_dir="/var/www/html"
webroot_dir="/var/www/html" if [ $version -eq 9 ]; then
else version_msg="Raspian 9.0 (Stretch)"
version_msg="Raspian version earlier than 8.0" php_package="php7.0-cgi"
webroot_dir="/var/www" elif [ $version -eq 8 ]; then
fi version_msg="Raspian 8.0 (Jessie)"
php_package="php5-cgi"
else
version_msg="Raspian earlier than 8.0 (Wheezy)"
webroot_dir="/var/www"
php_package="php5-cgi"
fi
# Outputs a RaspAP Install log line # Outputs a RaspAP Install log line
function install_log() { function install_log() {
@ -72,8 +78,9 @@ function install_dependencies() {
function enable_php_lighttpd() { function enable_php_lighttpd() {
install_log "Enabling PHP for lighttpd" install_log "Enabling PHP for lighttpd"
sudo lighty-enable-mod fastcgi-php sudo lighttpd-enable-mod fastcgi-php
if [ $? -eq 2 ]; then echo already enabled; else install_error "Cannot enable fastcgi-php for lighttpd"; fi
sudo service lighttpd force-reload
sudo /etc/init.d/lighttpd restart || install_error "Unable to restart lighttpd" sudo /etc/init.d/lighttpd restart || install_error "Unable to restart lighttpd"
} }
@ -84,12 +91,24 @@ function create_raspap_directories() {
sudo mv $raspap_dir "$raspap_dir.`date +%F-%R`" || install_error "Unable to move old '$raspap_dir' out of the way" sudo mv $raspap_dir "$raspap_dir.`date +%F-%R`" || install_error "Unable to move old '$raspap_dir' out of the way"
fi fi
sudo mkdir -p "$raspap_dir" || install_error "Unable to create directory '$raspap_dir'" sudo mkdir -p "$raspap_dir" || install_error "Unable to create directory '$raspap_dir'"
# Create a directory for existing file backups. # Create a directory for existing file backups.
sudo mkdir -p "$raspap_dir/backups" sudo mkdir -p "$raspap_dir/backups"
# Create a directory to store networking configs
sudo mkdir -p "$raspap_dir/networking"
# Copy existing dhcpcd.conf to use as base config
cat /etc/dhcpcd.conf | sudo tee -a /etc/raspap/networking/defaults
sudo chown -R $raspap_user:$raspap_user "$raspap_dir" || install_error "Unable to change file ownership for '$raspap_dir'" sudo chown -R $raspap_user:$raspap_user "$raspap_dir" || install_error "Unable to change file ownership for '$raspap_dir'"
} }
# Generate logging enable/disable files for hostapd
function create_logging_scripts() {
sudo mkdir /etc/raspap/hostapd
sudo mv /var/www/html/installers/*log.sh /etc/raspap/hostapd
}
# Fetches latest files from github to webroot # Fetches latest files from github to webroot
function download_latest_files() { function download_latest_files() {
if [ -d "$webroot_dir" ]; then if [ -d "$webroot_dir" ]; then
@ -132,6 +151,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,12 +179,28 @@ 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"
# 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
function sudo_add() { function sudo_add() {
sudo bash -c "echo \"www-data ALL=(ALL) NOPASSWD:$1\" | (EDITOR=\"tee -a\" visudo)" \ sudo bash -c "echo \"www-data ALL=(ALL) NOPASSWD:$1\" | (EDITOR=\"tee -a\" visudo)" \
|| install_error "Unable to patch /etc/sudoers" || install_error "Unable to patch /etc/sudoers"
} }
@ -168,24 +208,27 @@ function sudo_add() {
function patch_system_files() { function patch_system_files() {
# Set commands array # Set commands array
cmds=( cmds=(
'/sbin/ifdown wlan0' '/sbin/ifdown wlan0'
'/sbin/ifup wlan0' '/sbin/ifup wlan0'
'/bin/cat /etc/wpa_supplicant/wpa_supplicant.conf' '/bin/cat /etc/wpa_supplicant/wpa_supplicant.conf'
'/bin/cp /tmp/wifidata /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_results'
'/sbin/wpa_cli scan' '/sbin/wpa_cli scan'
'/sbin/wpa_cli reconfigure' '/sbin/wpa_cli reconfigure'
'/bin/cp /tmp/hostapddata /etc/hostapd/hostapd.conf' '/bin/cp /tmp/hostapddata /etc/hostapd/hostapd.conf'
'/etc/init.d/hostapd start' '/etc/init.d/hostapd start'
'/etc/init.d/hostapd stop' '/etc/init.d/hostapd stop'
'/etc/init.d/dnsmasq start' '/etc/init.d/dnsmasq start'
'/etc/init.d/dnsmasq stop' '/etc/init.d/dnsmasq stop'
'/bin/cp /tmp/dhcpddata /etc/dnsmasq.conf' '/bin/cp /tmp/dhcpddata /etc/dnsmasq.conf'
'/sbin/shutdown -h now' '/sbin/shutdown -h now'
'/sbin/reboot' '/sbin/reboot'
'/sbin/ip link set wlan0 down' '/sbin/ip link set wlan0 down'
'/sbin/ip link set wlan0 up' '/sbin/ip link set wlan0 up'
'/sbin/ip -s a f label wlan0' '/sbin/ip -s a f label wlan0'
'/bin/cp /etc/raspap/networking/dhcpcd.conf /etc/dhcpcd.conf'
'/etc/raspap/hostapd/enablelog.sh'
'/etc/raspap/hostapd/disablelog.sh'
) )
# Check if sudoers needs patchin # Check if sudoers needs patchin
@ -222,6 +265,7 @@ function install_raspap() {
install_dependencies install_dependencies
enable_php_lighttpd enable_php_lighttpd
create_raspap_directories create_raspap_directories
create_logging_scripts
check_for_old_configs check_for_old_configs
download_latest_files download_latest_files
change_file_ownership change_file_ownership

2
installers/raspbian.sh Normal file → Executable file
View File

@ -9,7 +9,7 @@ function update_system_packages() {
function install_dependencies() { function install_dependencies() {
install_log "Installing required packages" install_log "Installing required packages"
sudo apt-get install lighttpd php-cgi git hostapd dnsmasq || install_error "Unable to install dependencies" sudo apt-get install lighttpd $php_package git hostapd dnsmasq || install_error "Unable to install dependencies"
} }
install_raspap install_raspap

0
installers/uninstall.sh Normal file → Executable file
View File