mirror of
https://github.com/billz/raspap-webgui.git
synced 2023-10-10 13:37:24 +02:00
Merge branch 'master' of https://github.com/billz/raspap-webgui
This commit is contained in:
commit
5d9d58630c
@ -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() {
|
||||
@ -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"
|
||||
}
|
||||
|
||||
@ -112,6 +111,12 @@ function create_logging_scripts() {
|
||||
sudo mv $webroot_dir/installers/*log.sh $raspap_dir/hostapd || install_error "Unable to move logging scripts"
|
||||
}
|
||||
|
||||
# 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
|
||||
@ -182,20 +187,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
|
||||
@ -204,7 +208,7 @@ 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"
|
||||
}
|
||||
|
||||
@ -212,27 +216,27 @@ function sudo_add() {
|
||||
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
|
||||
|
2
installers/raspbian.sh
Normal file → Executable file
2
installers/raspbian.sh
Normal file → Executable file
@ -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
|
||||
|
0
installers/uninstall.sh
Normal file → Executable file
0
installers/uninstall.sh
Normal file → Executable file
Loading…
Reference in New Issue
Block a user