Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Change php5-cgi to php-cgi #124

Merged
merged 3 commits into from
Nov 16, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
94 changes: 49 additions & 45 deletions installers/common.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,20 @@ raspap_dir="/etc/raspap"
raspap_user="www-data"
version=`sed 's/\..*//' /etc/debian_version`

# Determine version and set default home location for lighttpd
if [ $version -ge 8 ]; then
version_msg="Raspian version 8.0 or later"
webroot_dir="/var/www/html"
else
version_msg="Raspian version earlier than 8.0"
webroot_dir="/var/www"
fi
# Determine version, set default home location for lighttpd and
# php package to install
webroot_dir="/var/www/html"
if [ $version -eq 9 ]; then
version_msg="Raspian 9.0 (Stretch)"
php_package="php7.0-cgi"
elif [ $version -eq 8 ]; then
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
function install_log() {
Expand Down Expand Up @@ -72,15 +78,8 @@ function install_dependencies() {
function enable_php_lighttpd() {
install_log "Enabling PHP for lighttpd"

sudo lighty-enable-mod fastcgi-php
ERR=$?
if [ $ERR -eq 2 ]
then
echo ' [already enabled]'
elif [ $ERR -ne 0 ]
then
install_error "Cannot enable fastcgi-php for lighttpd"
fi
sudo lighttpd-enable-mod fastcgi-php
sudo service lighttpd force-reload
sudo /etc/init.d/lighttpd restart || install_error "Unable to restart lighttpd"
}

Expand Down Expand Up @@ -111,6 +110,12 @@ function create_logging_scripts() {
sudo mv /var/www/html/installers/*log.sh /etc/raspap/hostapd
}

# 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
function download_latest_files() {
if [ -d "$webroot_dir" ]; then
Expand Down Expand Up @@ -181,20 +186,19 @@ 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/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"

# 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'
'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
sed -i "s/exit 0/$line\nexit0/" /etc/rc.local
echo "Adding line $line"
fi
done
Expand All @@ -203,35 +207,35 @@ function default_configuration() {

# Add a single entry to the sudoers file
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"
}

# Adds www-data user to the sudoers file with restrictions on what the user can execute
function patch_system_files() {
# 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'
'/sbin/ip link set wlan0 down'
'/sbin/ip link set wlan0 up'
'/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'
'/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'
'/sbin/ip link set wlan0 down'
'/sbin/ip link set wlan0 up'
'/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
Expand Down
2 changes: 1 addition & 1 deletion installers/raspbian.sh
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ function update_system_packages() {

function install_dependencies() {
install_log "Installing required packages"
sudo apt-get install lighttpd php5-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
Empty file modified installers/uninstall.sh
100644 → 100755
Empty file.