1
0
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 into bandwidthmonitoring

This commit is contained in:
D9ping 2018-09-06 21:31:38 +02:00
commit e90b9899a3
3 changed files with 85 additions and 15 deletions

View File

@ -28,6 +28,7 @@ You need to install some extra software in order for the Raspberry Pi to act as
There are many guides available to help you select a WiFi adapter, install a compatible driver, configure HostAPD and so on. The details are outside the scope of this project, although I've had consistently good results with the [**Edimax Wireless 802.11b/g/n nano USB adapter**](http://www.edimax.com/edimax/merchandise/merchandise_detail/data/edimax/global/wireless_adapters_n150/ew-7811un) it's small, cheap and easy to work with. There are many guides available to help you select a WiFi adapter, install a compatible driver, configure HostAPD and so on. The details are outside the scope of this project, although I've had consistently good results with the [**Edimax Wireless 802.11b/g/n nano USB adapter**](http://www.edimax.com/edimax/merchandise/merchandise_detail/data/edimax/global/wireless_adapters_n150/ew-7811un) it's small, cheap and easy to work with.
To configure your RPi as a WiFi router, either of these resources will start you on the right track: To configure your RPi as a WiFi router, either of these resources will start you on the right track:
* [**How-To: Setting up a Raspberry Pi as an access point in a standalone network (Tested with Raspbian Stretch)**](https://github.com/SurferTim/documentation/blob/6bc583965254fa292a470990c40b145f553f6b34/configuration/wireless/access-point.md)
* [**How-To: Use The Raspberry Pi As A Wireless Access Point/Router Part 1**](http://sirlagz.net/2012/08/09/how-to-use-the-raspberry-pi-as-a-wireless-access-pointrouter-part-1/) * [**How-To: Use The Raspberry Pi As A Wireless Access Point/Router Part 1**](http://sirlagz.net/2012/08/09/how-to-use-the-raspberry-pi-as-a-wireless-access-pointrouter-part-1/)
* [**How-To: Turn a Raspberry Pi into a WiFi router**](http://raspberrypihq.com/how-to-turn-a-raspberry-pi-into-a-wifi-router/) (uses isc-dhcp-server instead of dnsmasq) * [**How-To: Turn a Raspberry Pi into a WiFi router**](http://raspberrypihq.com/how-to-turn-a-raspberry-pi-into-a-wifi-router/) (uses isc-dhcp-server instead of dnsmasq)

View File

@ -15,7 +15,14 @@ else
version_msg="Raspian earlier than 8.0 (Wheezy)" version_msg="Raspian earlier than 8.0 (Wheezy)"
webroot_dir="/var/www" webroot_dir="/var/www"
php_package="php5-cgi" php_package="php5-cgi"
fi fi
phpcgiconf=""
if [ "$php_package" = "php7.0-cgi" ]; then
phpcgiconf="/etc/php/7.0/cgi/php.ini"
elif [ "$php_package" = "php5-cgi" ]; then
phpcgiconf="/etc/php5/cgi/php.ini"
fi
# Outputs a RaspAP Install log line # Outputs a RaspAP Install log line
function install_log() { function install_log() {
@ -28,6 +35,11 @@ function install_error() {
exit 1 exit 1
} }
# Outputs a RaspAP Warning line
function install_warning() {
echo -e "\033[1;33mWarning: $*\033[m"
}
# Outputs a welcome message # Outputs a welcome message
function display_welcome() { function display_welcome() {
raspberry='\033[0;35m' raspberry='\033[0;35m'
@ -108,14 +120,12 @@ function create_logging_scripts() {
sudo mkdir $raspap_dir/hostapd || install_error "Unable to create directory '$raspap_dir/hostapd'" sudo mkdir $raspap_dir/hostapd || install_error "Unable to create directory '$raspap_dir/hostapd'"
# Move existing shell scripts # Move existing shell scripts
sudo mv $webroot_dir/installers/*log.sh $raspap_dir/hostapd || install_error "Unable to move logging scripts" sudo mv "$webroot_dir/installers/"*log.sh "$raspap_dir/hostapd" || install_error "Unable to move logging scripts"
# Make enablelog.sh and disablelog.sh not writable by www-data group.
sudo chown -c root:"$raspap_user" "$raspap_dir/hostapd/"*log.sh || install_error "Unable change owner and/or group."
sudo chmod 750 "$raspap_dir/hostapd/"*log.sh || install_error "Unable to change file permissions."
} }
# 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() {
@ -263,13 +273,50 @@ function patch_system_files() {
fi fi
} }
# Optimize configuration of php-cgi.
function optimize_php() {
install_log "Optimize PHP configuration"
if [ ! -f "$phpcgiconf" ]; then
install_warning "PHP configuration could not be found."
return
fi
# Backup php.ini and create symlink for restoring.
datetimephpconf=$(date +%F-%R)
sudo cp "$phpcgiconf" "$raspap_dir/backups/php.ini.$datetimephpconf"
sudo ln -sf "$raspap_dir/backups/php.ini.$datetimephpconf" "$raspap_dir/backups/php.ini"
echo -n "Enable HttpOnly for session cookies (Recommended)? [Y/n]: "
read answer
if [ "$answer" != 'n' ] && [ "$answer" != 'N' ]; then
echo "Php-cgi enabling session.cookie_httponly."
sudo sed -i -E 's/^session\.cookie_httponly\s*=\s*(0|([O|o]ff)|([F|f]alse)|([N|n]o))\s*$/session.cookie_httponly = 1/' "$phpcgiconf"
fi
if [ "$php_package" = "php7.0-cgi" ]; then
echo -n "Enable PHP OPCache? [Y/n]: "
read answer
if [ "$answer" != 'n' ] && [ "$answer" != 'N' ]; then
echo "Php-cgi enabling opcache.enable."
sudo sed -i -E 's/^;?opcache\.enable\s*=\s*(0|([O|o]ff)|([F|f]alse)|([N|n]o))\s*$/opcache.enable = 1/' "$phpcgiconf"
# Make sure opcache extension is turned on.
if [ -f "/usr/sbin/phpenmod" ]; then
sudo phpenmod opcache
else
install_warning "phpenmod not found."
fi
fi
fi
}
function install_complete() { function install_complete() {
install_log "Installation completed!" install_log "Installation completed!"
echo -n "The system needs to be rebooted as a final step. Reboot now? [y/N]: " echo -n "The system needs to be rebooted as a final step. Reboot now? [y/N]: "
read answer read answer
if [[ $answer != "y" ]]; then if [[ $answer != "y" ]]; then
echo "Installation aborted." echo "Installation reboot aborted."
exit 0 exit 0
fi fi
sudo shutdown -r now || install_error "Unable to execute shutdown" sudo shutdown -r now || install_error "Unable to execute shutdown"
@ -280,6 +327,7 @@ function install_raspap() {
config_installation config_installation
update_system_packages update_system_packages
install_dependencies install_dependencies
optimize_php
enable_php_lighttpd enable_php_lighttpd
create_raspap_directories create_raspap_directories
check_for_old_configs check_for_old_configs

View File

@ -4,14 +4,28 @@ 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 and set default home location for lighttpd
if [ $version -ge 8 ]; then webroot_dir="/var/www/html"
version_msg="Raspian version 8.0 or later" if [ $version -eq 9 ]; then
webroot_dir="/var/www/html" version_msg="Raspian 9.0 (Stretch)"
else php_package="php7.0-cgi"
version_msg="Raspian version earlier than 8.0" elif [ $version -eq 8 ]; then
webroot_dir="/var/www" version_msg="Raspian 8.0 (Jessie)"
webroot_dir="/var/www"
php_package="php5-cgi"
else
version_msg="Raspian earlier than 8.0 (Wheezy)"
webroot_dir="/var/www"
php_package="php5-cgi"
fi fi
phpcgiconf=""
if [ "$php_package" = "php7.0-cgi" ]; then
phpcgiconf="/etc/php/7.0/cgi/php.ini"
elif [ "$php_package" = "php5-cgi" ]; then
phpcgiconf="/etc/php5/cgi/php.ini"
fi
# Outputs a RaspAP Install log line # Outputs a RaspAP Install log line
function install_log() { function install_log() {
echo -e "\033[1;32mRaspAP Install: $*\033[m" echo -e "\033[1;32mRaspAP Install: $*\033[m"
@ -68,6 +82,13 @@ function check_for_backups() {
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/php.ini" ] && [ -f "$phpcgiconf" ]; then
echo -n "Restore the last php.ini file? [y/N]: "
read answer
if [[ $answer -eq 'y' ]]; then
sudo cp "$raspap_dir/backups/php.ini" "$phpcgiconf"
fi
fi
if [ -f "$raspap_dir/backups/rc.local" ]; then if [ -f "$raspap_dir/backups/rc.local" ]; then
echo -n "Restore the last rc.local file? [y/N]: " echo -n "Restore the last rc.local file? [y/N]: "
read answer read answer
@ -75,7 +96,7 @@ function check_for_backups() {
sudo cp "$raspap_dir/backups/rc.local" /etc/rc.local sudo cp "$raspap_dir/backups/rc.local" /etc/rc.local
else else
echo -n "Remove RaspAP Lines from /etc/rc.local? [Y/n]: " echo -n "Remove RaspAP Lines from /etc/rc.local? [Y/n]: "
if $answer -ne 'n' ]]; then if [[ $answer -ne 'n' ]]; then
sed -i '/#RASPAP/d' /etc/rc.local sed -i '/#RASPAP/d' /etc/rc.local
fi fi
fi fi