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