From b8b3fd1d31321a59802fd46db86053ac7a48a452 Mon Sep 17 00:00:00 2001 From: Joe Haig Date: Fri, 21 Oct 2016 22:28:00 +0100 Subject: [PATCH 01/13] Move old install directory if it exists --- installers/common.sh | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/installers/common.sh b/installers/common.sh index 1d00ab80..a7dad944 100644 --- a/installers/common.sh +++ b/installers/common.sh @@ -64,9 +64,10 @@ function enable_php_lighttpd() { # Verifies existence and permissions of RaspAP directory function create_raspap_directories() { install_log "Creating RaspAP directories" - if [ ! -d "$raspap_dir" ]; then - sudo mkdir -p "$raspap_dir" || install_error "Unable to create directory '$raspap_dir'" + if [ -d "$raspap_dir" ]; then + sudo mv $raspap_dir $raspap_dir.original || install_error "Unable to move old directory out of the way" fi + sudo mkdir -p "$raspap_dir" || install_error "Unable to create directory '$raspap_dir'" sudo chown -R $raspap_user:$raspap_user "$raspap_dir" || install_error "Unable to change file ownership for '$raspap_dir'" } From fd20d867dc40002ad40357f9ca35827ac0fb0fbf Mon Sep 17 00:00:00 2001 From: Joe Haig Date: Fri, 21 Oct 2016 22:31:51 +0100 Subject: [PATCH 02/13] Install hostapd as a dependency --- installers/raspbian.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/installers/raspbian.sh b/installers/raspbian.sh index e42bf525..58d07b92 100644 --- a/installers/raspbian.sh +++ b/installers/raspbian.sh @@ -9,7 +9,7 @@ function update_system_packages() { function install_dependencies() { install_log "Installing required packages" - sudo apt-get install lighttpd php5-cgi git || install_error "Unable to install dependencies" + sudo apt-get install lighttpd php5-cgi git hostapd || install_error "Unable to install dependencies" } install_raspap From 5f748c4b8478e90866cd123d67f65f1a77f6f016 Mon Sep 17 00:00:00 2001 From: Joe Haig Date: Fri, 21 Oct 2016 22:47:04 +0100 Subject: [PATCH 03/13] Add hostapd install to manual install instructions --- README.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index bedb323f..d37dbfb2 100644 --- a/README.md +++ b/README.md @@ -37,9 +37,9 @@ $ wget -q https://git.io/voEUQ -O /tmp/raspap && bash /tmp/raspap The installer will complete the steps in the manual installation (below) for you. ## Manual installation -Start off by installing lighttpd and php5. +Start off by installing lighttpd, php5 and hostapd. ```sh -$ sudo apt-get install lighttpd php5-cgi +$ sudo apt-get install lighttpd php5-cgi hostapd ``` After that, enable PHP for lighttpd and restart it for the settings to take effect. ```sh From 58bd439b4dfd8b1177f3d6c0e1d4a697b766ed7d Mon Sep 17 00:00:00 2001 From: Joe Haig Date: Sat, 22 Oct 2016 22:02:39 +0100 Subject: [PATCH 04/13] Replace /etc.init.d with service --- README.md | 11 ++++++----- includes/dhcp.php | 4 ++-- includes/functions.php | 8 ++++---- includes/hostapd.php | 4 ++-- installers/common.sh | 10 +++++----- 5 files changed, 19 insertions(+), 18 deletions(-) diff --git a/README.md b/README.md index d37dbfb2..e595f0b7 100644 --- a/README.md +++ b/README.md @@ -40,11 +40,12 @@ The installer will complete the steps in the manual installation (below) for you Start off by installing lighttpd, php5 and hostapd. ```sh $ sudo apt-get install lighttpd php5-cgi hostapd +$ sudo apt-get install rfkill zd1211-firmware hostap-utils iw dnsmasq ``` After that, enable PHP for lighttpd and restart it for the settings to take effect. ```sh sudo lighty-enable-mod fastcgi-php -sudo /etc/init.d/lighttpd restart +sudo service lighttpd restart ``` Now comes the fun part. For security reasons, the `www-data` user which lighttpd runs under is not allowed to start or stop daemons, or run commands like ifdown and ifup, all of which we want our page to do. So what I have done is added the `www-data` user to the sudoers file, but with restrictions on what commands the user can run. @@ -59,10 +60,10 @@ www-data ALL=(ALL) NOPASSWD:/sbin/wpa_cli scan_results www-data ALL=(ALL) NOPASSWD:/sbin/wpa_cli scan www-data ALL=(ALL) NOPASSWD:/sbin/wpa_cli reconfigure www-data ALL=(ALL) NOPASSWD:/bin/cp /tmp/hostapddata /etc/hostapd/hostapd.conf -www-data ALL=(ALL) NOPASSWD:/etc/init.d/hostapd start -www-data ALL=(ALL) NOPASSWD:/etc/init.d/hostapd stop -www-data ALL=(ALL) NOPASSWD:/etc/init.d/dnsmasq start -www-data ALL=(ALL) NOPASSWD:/etc/init.d/dnsmasq stop +www-data ALL=(ALL) NOPASSWD:service hostapd start +www-data ALL=(ALL) NOPASSWD:service hostapd stop +www-data ALL=(ALL) NOPASSWD:service dnsmasq start +www-data ALL=(ALL) NOPASSWD:service dnsmasq stop www-data ALL=(ALL) NOPASSWD:/bin/cp /tmp/dhcpddata /etc/dnsmasq.conf www-data ALL=(ALL) NOPASSWD:/sbin/shutdown -h now www-data ALL=(ALL) NOPASSWD:/sbin/reboot diff --git a/includes/dhcp.php b/includes/dhcp.php index d173547a..2de9ab8f 100755 --- a/includes/dhcp.php +++ b/includes/dhcp.php @@ -35,7 +35,7 @@ function DisplayDHCPConfig() { if ($dnsmasq_state) { $status->addMessage('dnsmasq already running', 'info'); } else { - exec('sudo /etc/init.d/dnsmasq start', $dnsmasq, $return); + exec('sudo service dnsmasq start', $dnsmasq, $return); if ($return == 0) { $status->addMessage('Successfully started dnsmasq', 'success'); $dnsmasq_state = true; @@ -49,7 +49,7 @@ function DisplayDHCPConfig() { } elseif( isset($_POST['stopdhcpd'] ) ) { if (CSRFValidate()) { if ($dnsmasq_state) { - exec('sudo /etc/init.d/dnsmasq stop', $dnsmasq, $return); + exec('sudo service dnsmasq stop', $dnsmasq, $return); if ($return == 0) { $status->addMessage('Successfully stopped dnsmasq', 'success'); $dnsmasq_state = false; diff --git a/includes/functions.php b/includes/functions.php index f391e461..d5cb0b35 100755 --- a/includes/functions.php +++ b/includes/functions.php @@ -412,25 +412,25 @@ function SaveTORAndVPNConfig(){ // TODO } elseif( isset($_POST['StartOpenVPN']) ) { echo "Attempting to start openvpn"; - exec( 'sudo /etc/init.d/openvpn start', $return ); + exec( 'sudo service openvpn start', $return ); foreach( $return as $line ) { echo $line."
"; } } elseif( isset($_POST['StopOpenVPN']) ) { echo "Attempting to stop openvpn"; - exec( 'sudo /etc/init.d/openvpn stop', $return ); + exec( 'sudo service openvpn stop', $return ); foreach( $return as $line ) { echo $line."
"; } } elseif( isset($_POST['StartTOR']) ) { echo "Attempting to start TOR"; - exec( 'sudo /etc/init.d/tor start', $return ); + exec( 'sudo service tor start', $return ); foreach( $return as $line ) { echo $line."
"; } } elseif( isset($_POST['StopTOR']) ) { echo "Attempting to stop TOR"; - exec( 'sudo /etc/init.d/tor stop', $return ); + exec( 'sudo service tor stop', $return ); foreach( $return as $line ) { echo $line."
"; } diff --git a/includes/hostapd.php b/includes/hostapd.php index bd9e3c4b..0b9c65ea 100755 --- a/includes/hostapd.php +++ b/includes/hostapd.php @@ -26,7 +26,7 @@ function DisplayHostAPDConfig(){ } elseif( isset($_POST['StartHotspot']) ) { if (CSRFValidate()) { $status->addMessage('Attempting to start hotspot', 'info'); - exec( 'sudo /etc/init.d/hostapd start', $return ); + exec( 'sudo service hostapd start', $return ); foreach( $return as $line ) { $status->addMessage($line, 'info'); } @@ -36,7 +36,7 @@ function DisplayHostAPDConfig(){ } elseif( isset($_POST['StopHotspot']) ) { if (CSRFValidate()) { $status->addMessage('Attempting to stop hotspot', 'info'); - exec( 'sudo /etc/init.d/hostapd stop', $return ); + exec( 'sudo service hostapd stop', $return ); foreach( $return as $line ) { $status->addMessage($line, 'info'); } diff --git a/installers/common.sh b/installers/common.sh index a7dad944..53b4a917 100644 --- a/installers/common.sh +++ b/installers/common.sh @@ -58,7 +58,7 @@ function enable_php_lighttpd() { install_log "Enabling PHP for lighttpd" sudo lighty-enable-mod fastcgi-php || install_error "Cannot enable fastcgi-php for lighttpd" - sudo /etc/init.d/lighttpd restart || install_error "Unable to restart lighttpd" + sudo service lighttpd restart || install_error "Unable to restart lighttpd" } # Verifies existence and permissions of RaspAP directory @@ -121,10 +121,10 @@ function patch_system_files() { sudo_add '/sbin/wpa_cli scan' sudo_add '/sbin/wpa_cli reconfigure' 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 'service hostapd start' + sudo_add 'service hostapd stop' + sudo_add 'service dnsmasq start' + sudo_add 'service dnsmasq stop' sudo_add '/bin/cp /tmp/dhcpddata /etc/dnsmasq.conf' sudo_add '/sbin/shutdown -h now' sudo_add '/sbin/reboot' From a3bfa51c700574aaa1429e57398f58e1d8f3ae7b Mon Sep 17 00:00:00 2001 From: Joe Haig Date: Sun, 23 Oct 2016 16:39:33 +0100 Subject: [PATCH 05/13] Default hostapd configuration --- config/hostapd.conf | 14 ++++++++++++++ installers/common.sh | 28 ++++++++++++++++++++-------- 2 files changed, 34 insertions(+), 8 deletions(-) create mode 100644 config/hostapd.conf diff --git a/config/hostapd.conf b/config/hostapd.conf new file mode 100644 index 00000000..369d3247 --- /dev/null +++ b/config/hostapd.conf @@ -0,0 +1,14 @@ +driver=nl80211 +ctrl_interface=/etc/wpa_supplicant/wpa_supplicant.conf +ctrl_interface_group=0 +beacon_int=100 +auth_algs=1 +wpa_key_mgmt=WPA-PSK +ssid=raspi-webgui +channel=1 +hw_mode=g +wpa_passphrase=ChangeMe +interface=wlan0 +wpa=WPA2 +wpa_pairwise=TKIP+CCMP +country_code= diff --git a/installers/common.sh b/installers/common.sh index 53b4a917..dd2bce20 100644 --- a/installers/common.sh +++ b/installers/common.sh @@ -65,7 +65,7 @@ function enable_php_lighttpd() { function create_raspap_directories() { install_log "Creating RaspAP directories" if [ -d "$raspap_dir" ]; then - sudo mv $raspap_dir $raspap_dir.original || install_error "Unable to move old directory out of the way" + sudo mv $raspap_dir $raspap_dir.original || install_error "Unable to move old '$raspap_dir' out of the way" fi sudo mkdir -p "$raspap_dir" || install_error "Unable to create directory '$raspap_dir'" @@ -74,12 +74,13 @@ function create_raspap_directories() { # Fetches latest files from github to webroot function download_latest_files() { - if [ ! -d "$webroot_dir" ]; then - install_error "Web root directory doesn't exist" + if [ -d "$webroot_dir" ]; then + sudo mv $webroot_dir /tmp/old_webroot || install_error "Unable to remove old webroot directory" fi install_log "Cloning latest files from github" - sudo git clone https://github.com/billz/raspap-webgui "$webroot_dir" || install_error "Unable to download files from github" + git clone https://github.com/billz/raspap-webgui /tmp/raspap-webgui || install_error "Unable to download files from github" + sudo mv /tmp/raspap-webgui $webroot_dir || install_error "Unable to move raspap-webgui to web root" } # Sets files ownership in web root directory @@ -103,6 +104,16 @@ function move_config_file() { sudo chown -R $raspap_user:$raspap_user "$raspap_dir" || install_error "Unable to change file ownership for '$raspap_dir'" } +# Set up default configuration +function default_configuration() { + install_log "Setting up hostapd" + if [ -f /etc/default/hostapd ]; then + sudo mv /etc/default/hostapd /tmp/default_hostapd.old || install_error "Unable to remove old /etc/default/hostapd file" + fi + sudo echo DAEMON_CONF=$raspap_dir/hostapd.conf > /etc/default/hostapd || install_error "Unable to write new /etc/default/hostapd file" + sudo mv $webroot_dir/config/hostapd.conf $raspap_dir/hostapd.conf || install_error "Unable to move hostapd configuration file" +} + # 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)" \ @@ -121,10 +132,10 @@ function patch_system_files() { sudo_add '/sbin/wpa_cli scan' sudo_add '/sbin/wpa_cli reconfigure' sudo_add '/bin/cp /tmp/hostapddata /etc/hostapd/hostapd.conf' - sudo_add 'service hostapd start' - sudo_add 'service hostapd stop' - sudo_add 'service dnsmasq start' - sudo_add 'service dnsmasq stop' + sudo_add '/usr/sbin/service hostapd start' + sudo_add '/usr/sbin/service hostapd stop' + sudo_add '/usr/sbin/service dnsmasq start' + sudo_add '/usr/sbin/service dnsmasq stop' sudo_add '/bin/cp /tmp/dhcpddata /etc/dnsmasq.conf' sudo_add '/sbin/shutdown -h now' sudo_add '/sbin/reboot' @@ -151,6 +162,7 @@ function install_raspap() { download_latest_files change_file_ownership move_config_file + default_configuration patch_system_files install_complete } From a3ea51077d9ca0d81e5aaccce41b526a3f5e83f8 Mon Sep 17 00:00:00 2001 From: Joe Haig Date: Sun, 23 Oct 2016 17:02:52 +0100 Subject: [PATCH 06/13] Some more default config files * /etc/default/hostapd * /etc/dhcpcd.conf * /etc/dnsmasq.conf --- config/default_hostapd | 12 ++++++++++++ config/dhcpcd.conf | 17 +++++++++++++++++ config/dnsmasq.conf | 3 +++ installers/common.sh | 6 ++++-- 4 files changed, 36 insertions(+), 2 deletions(-) create mode 100644 config/default_hostapd create mode 100644 config/dhcpcd.conf create mode 100644 config/dnsmasq.conf diff --git a/config/default_hostapd b/config/default_hostapd new file mode 100644 index 00000000..f3549a63 --- /dev/null +++ b/config/default_hostapd @@ -0,0 +1,12 @@ +# Location of hostapd configuration file +DAEMON_CONF="/etc/hostapd/hostapd.conf" + +# Additional daemon options to be appended to hostapd command:- +# -d show more debug messages (-dd for even more) +# -K include key data in debug messages +# -t include timestamps in some debug messages +# +# Note that -B (daemon mode) and -P (pidfile) options are automatically +# configured by the init.d script and must not be added to DAEMON_OPTS. +# +#DAEMON_OPTS="" diff --git a/config/dhcpcd.conf b/config/dhcpcd.conf new file mode 100644 index 00000000..ccf0fee1 --- /dev/null +++ b/config/dhcpcd.conf @@ -0,0 +1,17 @@ +# Defaults from Raspberry Pi configuration +hostname +clientid +persistent +option rapid_commit +option domain_name_servers, domain_name, domain_search, host_name +option classless_static_routes +option ntp_servers +require dhcp_server_identifier +slaac private +nohook lookup-hostname + +# RaspAP-WebGui wireless configuration +interface wlan0 +static ip_address=10.3.141.1/24 +static routers=10.3.141.1 +static domain_name_server=8.8.8.8 8.8.4.4 diff --git a/config/dnsmasq.conf b/config/dnsmasq.conf new file mode 100644 index 00000000..6ae8e908 --- /dev/null +++ b/config/dnsmasq.conf @@ -0,0 +1,3 @@ +domain-needed +interface=wlan0 +dhcp-range=10.3.141.50,10.3.141.255,255.255.255.0,12h diff --git a/installers/common.sh b/installers/common.sh index dd2bce20..6dbd284a 100644 --- a/installers/common.sh +++ b/installers/common.sh @@ -110,8 +110,10 @@ function default_configuration() { if [ -f /etc/default/hostapd ]; then sudo mv /etc/default/hostapd /tmp/default_hostapd.old || install_error "Unable to remove old /etc/default/hostapd file" fi - sudo echo DAEMON_CONF=$raspap_dir/hostapd.conf > /etc/default/hostapd || install_error "Unable to write new /etc/default/hostapd file" - sudo mv $webroot_dir/config/hostapd.conf $raspap_dir/hostapd.conf || install_error "Unable to move hostapd configuration file" + sudo mv $webroot_dir/config/default_hostapd /etc/default/hostapd || install_error "Unable to move hostapd defaults 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/dhcpcd.conf /etc/dhcpcd.conf || install_error "Unable to move dhcpcd configuration file" } # Add a single entry to the sudoers file From 294ed85707a94b057f3d35198357daac8b0f9b42 Mon Sep 17 00:00:00 2001 From: Joe Haig Date: Sun, 23 Oct 2016 17:36:52 +0100 Subject: [PATCH 07/13] Correct ctrl_interface in default configuration --- config/hostapd.conf | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/config/hostapd.conf b/config/hostapd.conf index 369d3247..91479b8d 100644 --- a/config/hostapd.conf +++ b/config/hostapd.conf @@ -1,5 +1,5 @@ driver=nl80211 -ctrl_interface=/etc/wpa_supplicant/wpa_supplicant.conf +ctrl_interface=/var/run/hostapd ctrl_interface_group=0 beacon_int=100 auth_algs=1 From ec03171e74accf4833dffc18e95b8c55b67bf509 Mon Sep 17 00:00:00 2001 From: Joe Haig Date: Sun, 23 Oct 2016 17:37:29 +0100 Subject: [PATCH 08/13] Reboot at end of installation --- installers/common.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/installers/common.sh b/installers/common.sh index 6dbd284a..19bdd51e 100644 --- a/installers/common.sh +++ b/installers/common.sh @@ -152,7 +152,7 @@ function install_complete() { echo "Installation aborted." exit 0 fi - sudo shutdown -h now || install_error "Unable to execute shutdown" + sudo shutdown -r now || install_error "Unable to execute shutdown" } function install_raspap() { From 0880ce388c0ce007f79d0a260dff32698cc5a169 Mon Sep 17 00:00:00 2001 From: Joe Haig Date: Sun, 23 Oct 2016 17:58:06 +0100 Subject: [PATCH 09/13] Fix wpa_pairwise setting --- config/hostapd.conf | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/config/hostapd.conf b/config/hostapd.conf index 91479b8d..6af41aa0 100644 --- a/config/hostapd.conf +++ b/config/hostapd.conf @@ -10,5 +10,5 @@ hw_mode=g wpa_passphrase=ChangeMe interface=wlan0 wpa=WPA2 -wpa_pairwise=TKIP+CCMP +wpa_pairwise=TKIP country_code= From c5cb30f9e71a9a4d56454d7a12516e3a0716c9e4 Mon Sep 17 00:00:00 2001 From: Joe Haig Date: Sun, 23 Oct 2016 18:25:07 +0100 Subject: [PATCH 10/13] Install dnsmasq --- README.md | 5 ++--- installers/raspbian.sh | 2 +- 2 files changed, 3 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index e595f0b7..9c66a3fb 100644 --- a/README.md +++ b/README.md @@ -37,10 +37,9 @@ $ wget -q https://git.io/voEUQ -O /tmp/raspap && bash /tmp/raspap The installer will complete the steps in the manual installation (below) for you. ## Manual installation -Start off by installing lighttpd, php5 and hostapd. +Start off by installing lighttpd, php5, hostapd and dnsmasq. ```sh -$ sudo apt-get install lighttpd php5-cgi hostapd -$ sudo apt-get install rfkill zd1211-firmware hostap-utils iw dnsmasq +$ sudo apt-get install lighttpd php5-cgi hostapd dnsmasq ``` After that, enable PHP for lighttpd and restart it for the settings to take effect. ```sh diff --git a/installers/raspbian.sh b/installers/raspbian.sh index 58d07b92..6ec76f75 100644 --- a/installers/raspbian.sh +++ b/installers/raspbian.sh @@ -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 || install_error "Unable to install dependencies" + sudo apt-get install lighttpd php5-cgi git hostapd dnsmasq || install_error "Unable to install dependencies" } install_raspap From d089dbfe434996d7e0138ef52c4e28ffaead5e01 Mon Sep 17 00:00:00 2001 From: Joe Haig Date: Sun, 23 Oct 2016 18:31:45 +0100 Subject: [PATCH 11/13] Fix sudo lines for 'service' --- README.md | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index 9c66a3fb..c18f320d 100644 --- a/README.md +++ b/README.md @@ -59,10 +59,10 @@ www-data ALL=(ALL) NOPASSWD:/sbin/wpa_cli scan_results www-data ALL=(ALL) NOPASSWD:/sbin/wpa_cli scan www-data ALL=(ALL) NOPASSWD:/sbin/wpa_cli reconfigure www-data ALL=(ALL) NOPASSWD:/bin/cp /tmp/hostapddata /etc/hostapd/hostapd.conf -www-data ALL=(ALL) NOPASSWD:service hostapd start -www-data ALL=(ALL) NOPASSWD:service hostapd stop -www-data ALL=(ALL) NOPASSWD:service dnsmasq start -www-data ALL=(ALL) NOPASSWD:service dnsmasq stop +www-data ALL=(ALL) NOPASSWD:/usr/sbin/service hostapd start +www-data ALL=(ALL) NOPASSWD:/usr/sbin/service hostapd stop +www-data ALL=(ALL) NOPASSWD:/usr/sbin/service dnsmasq start +www-data ALL=(ALL) NOPASSWD:/usr/sbin/service dnsmasq stop www-data ALL=(ALL) NOPASSWD:/bin/cp /tmp/dhcpddata /etc/dnsmasq.conf www-data ALL=(ALL) NOPASSWD:/sbin/shutdown -h now www-data ALL=(ALL) NOPASSWD:/sbin/reboot From 2d992fb4ac8d6b3688a8e0a31d16d4caad82b599 Mon Sep 17 00:00:00 2001 From: Joe Haig Date: Sun, 23 Oct 2016 20:08:17 +0100 Subject: [PATCH 12/13] Revert back to using /etc/init.d Don't change too many things at once. --- README.md | 8 ++++---- includes/dhcp.php | 4 ++-- includes/functions.php | 8 ++++---- includes/hostapd.php | 4 ++-- installers/common.sh | 10 +++++----- 5 files changed, 17 insertions(+), 17 deletions(-) diff --git a/README.md b/README.md index c18f320d..d97f6069 100644 --- a/README.md +++ b/README.md @@ -59,10 +59,10 @@ www-data ALL=(ALL) NOPASSWD:/sbin/wpa_cli scan_results www-data ALL=(ALL) NOPASSWD:/sbin/wpa_cli scan www-data ALL=(ALL) NOPASSWD:/sbin/wpa_cli reconfigure www-data ALL=(ALL) NOPASSWD:/bin/cp /tmp/hostapddata /etc/hostapd/hostapd.conf -www-data ALL=(ALL) NOPASSWD:/usr/sbin/service hostapd start -www-data ALL=(ALL) NOPASSWD:/usr/sbin/service hostapd stop -www-data ALL=(ALL) NOPASSWD:/usr/sbin/service dnsmasq start -www-data ALL=(ALL) NOPASSWD:/usr/sbin/service dnsmasq stop +www-data ALL=(ALL) NOPASSWD:/etc/init.d/hostapd start +www-data ALL=(ALL) NOPASSWD:/etc/init.d/hostapd stop +www-data ALL=(ALL) NOPASSWD:/etc/init.d/dnsmasq start +www-data ALL=(ALL) NOPASSWD:/etc/init.d/dnsmasq stop www-data ALL=(ALL) NOPASSWD:/bin/cp /tmp/dhcpddata /etc/dnsmasq.conf www-data ALL=(ALL) NOPASSWD:/sbin/shutdown -h now www-data ALL=(ALL) NOPASSWD:/sbin/reboot diff --git a/includes/dhcp.php b/includes/dhcp.php index 2de9ab8f..d173547a 100755 --- a/includes/dhcp.php +++ b/includes/dhcp.php @@ -35,7 +35,7 @@ function DisplayDHCPConfig() { if ($dnsmasq_state) { $status->addMessage('dnsmasq already running', 'info'); } else { - exec('sudo service dnsmasq start', $dnsmasq, $return); + exec('sudo /etc/init.d/dnsmasq start', $dnsmasq, $return); if ($return == 0) { $status->addMessage('Successfully started dnsmasq', 'success'); $dnsmasq_state = true; @@ -49,7 +49,7 @@ function DisplayDHCPConfig() { } elseif( isset($_POST['stopdhcpd'] ) ) { if (CSRFValidate()) { if ($dnsmasq_state) { - exec('sudo service dnsmasq stop', $dnsmasq, $return); + exec('sudo /etc/init.d/dnsmasq stop', $dnsmasq, $return); if ($return == 0) { $status->addMessage('Successfully stopped dnsmasq', 'success'); $dnsmasq_state = false; diff --git a/includes/functions.php b/includes/functions.php index d5cb0b35..f391e461 100755 --- a/includes/functions.php +++ b/includes/functions.php @@ -412,25 +412,25 @@ function SaveTORAndVPNConfig(){ // TODO } elseif( isset($_POST['StartOpenVPN']) ) { echo "Attempting to start openvpn"; - exec( 'sudo service openvpn start', $return ); + exec( 'sudo /etc/init.d/openvpn start', $return ); foreach( $return as $line ) { echo $line."
"; } } elseif( isset($_POST['StopOpenVPN']) ) { echo "Attempting to stop openvpn"; - exec( 'sudo service openvpn stop', $return ); + exec( 'sudo /etc/init.d/openvpn stop', $return ); foreach( $return as $line ) { echo $line."
"; } } elseif( isset($_POST['StartTOR']) ) { echo "Attempting to start TOR"; - exec( 'sudo service tor start', $return ); + exec( 'sudo /etc/init.d/tor start', $return ); foreach( $return as $line ) { echo $line."
"; } } elseif( isset($_POST['StopTOR']) ) { echo "Attempting to stop TOR"; - exec( 'sudo service tor stop', $return ); + exec( 'sudo /etc/init.d/tor stop', $return ); foreach( $return as $line ) { echo $line."
"; } diff --git a/includes/hostapd.php b/includes/hostapd.php index 0b9c65ea..bd9e3c4b 100755 --- a/includes/hostapd.php +++ b/includes/hostapd.php @@ -26,7 +26,7 @@ function DisplayHostAPDConfig(){ } elseif( isset($_POST['StartHotspot']) ) { if (CSRFValidate()) { $status->addMessage('Attempting to start hotspot', 'info'); - exec( 'sudo service hostapd start', $return ); + exec( 'sudo /etc/init.d/hostapd start', $return ); foreach( $return as $line ) { $status->addMessage($line, 'info'); } @@ -36,7 +36,7 @@ function DisplayHostAPDConfig(){ } elseif( isset($_POST['StopHotspot']) ) { if (CSRFValidate()) { $status->addMessage('Attempting to stop hotspot', 'info'); - exec( 'sudo service hostapd stop', $return ); + exec( 'sudo /etc/init.d/hostapd stop', $return ); foreach( $return as $line ) { $status->addMessage($line, 'info'); } diff --git a/installers/common.sh b/installers/common.sh index 19bdd51e..7080a20e 100644 --- a/installers/common.sh +++ b/installers/common.sh @@ -58,7 +58,7 @@ function enable_php_lighttpd() { install_log "Enabling PHP for lighttpd" sudo lighty-enable-mod fastcgi-php || install_error "Cannot enable fastcgi-php for lighttpd" - sudo service lighttpd restart || install_error "Unable to restart lighttpd" + sudo /etc/init.d/lighttpd restart || install_error "Unable to restart lighttpd" } # Verifies existence and permissions of RaspAP directory @@ -134,10 +134,10 @@ function patch_system_files() { sudo_add '/sbin/wpa_cli scan' sudo_add '/sbin/wpa_cli reconfigure' sudo_add '/bin/cp /tmp/hostapddata /etc/hostapd/hostapd.conf' - sudo_add '/usr/sbin/service hostapd start' - sudo_add '/usr/sbin/service hostapd stop' - sudo_add '/usr/sbin/service dnsmasq start' - sudo_add '/usr/sbin/service dnsmasq stop' + 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' From 92cba363c8380f0a1f99fbabe25b78bca5de0fc3 Mon Sep 17 00:00:00 2001 From: Joe Haig Date: Sun, 23 Oct 2016 21:39:22 +0100 Subject: [PATCH 13/13] Show default configuration details --- README.md | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/README.md b/README.md index d97f6069..5172431c 100644 --- a/README.md +++ b/README.md @@ -36,6 +36,13 @@ $ wget -q https://git.io/voEUQ -O /tmp/raspap && bash /tmp/raspap ``` The installer will complete the steps in the manual installation (below) for you. +After the reboot at the end of the installation the wireless network will be +configured as an access point as follows: +* IP address: 10.3.141.1 +* DHCP range: 10.3.141.50 to 10.3.141.255 +* SSID: `raspi-webgui` +* Password: ChangeMe + ## Manual installation Start off by installing lighttpd, php5, hostapd and dnsmasq. ```sh