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

Merge pull request #42 from billz/improve_installer

Improve installer
This commit is contained in:
Bill Zimmerman 2016-10-24 10:58:39 +02:00 committed by GitHub
commit cf69055d3c
7 changed files with 78 additions and 10 deletions

View File

@ -36,15 +36,22 @@ $ 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 and php5.
Start off by installing lighttpd, php5, hostapd and dnsmasq.
```sh
$ sudo apt-get install lighttpd php5-cgi
$ 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
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.

12
config/default_hostapd Normal file
View File

@ -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=""

17
config/dhcpcd.conf Normal file
View File

@ -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

3
config/dnsmasq.conf Normal file
View File

@ -0,0 +1,3 @@
domain-needed
interface=wlan0
dhcp-range=10.3.141.50,10.3.141.255,255.255.255.0,12h

14
config/hostapd.conf Normal file
View File

@ -0,0 +1,14 @@
driver=nl80211
ctrl_interface=/var/run/hostapd
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
country_code=

View File

@ -64,21 +64,23 @@ 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 '$raspap_dir' 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'"
}
# 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
@ -102,6 +104,18 @@ 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 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
function sudo_add() {
sudo bash -c "echo \"www-data ALL=(ALL) NOPASSWD:$1\" | (EDITOR=\"tee -a\" visudo)" \
@ -138,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() {
@ -150,6 +164,7 @@ function install_raspap() {
download_latest_files
change_file_ownership
move_config_file
default_configuration
patch_system_files
install_complete
}

View 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 || install_error "Unable to install dependencies"
sudo apt-get install lighttpd php5-cgi git hostapd dnsmasq || install_error "Unable to install dependencies"
}
install_raspap