diff --git a/installers/common.sh b/installers/common.sh index 3e124d04..70ed7006 100755 --- a/installers/common.sh +++ b/installers/common.sh @@ -286,11 +286,12 @@ function _create_hostapd_scripts() { _install_log "Creating hostapd logging & control scripts" sudo mkdir $raspap_dir/hostapd || _install_status 1 "Unable to create directory '$raspap_dir/hostapd'" - # Move logging shell scripts - sudo cp "$webroot_dir/installers/"*log.sh "$raspap_dir/hostapd" || _install_status 1 "Unable to move logging scripts" - # Move service control shell scripts - sudo cp "$webroot_dir/installers/"service*.sh "$raspap_dir/hostapd" || _install_status 1 "Unable to move service control scripts" - # Make enablelog.sh and disablelog.sh not writable by www-data group. + # Copy logging shell scripts + sudo cp "$webroot_dir/installers/"enablelog.sh "$raspap_dir/hostapd" || _install_status 1 "Unable to move logging scripts" + sudo cp "$webroot_dir/installers/"disablelog.sh "$raspap_dir/hostapd" || _install_status 1 "Unable to move logging scripts" + # Copy service control shell scripts + sudo cp "$webroot_dir/installers/"servicestart.sh "$raspap_dir/hostapd" || _install_status 1 "Unable to move service control scripts" + # Change ownership and permissions of hostapd control scripts sudo chown -c root:root "$raspap_dir/hostapd/"*.sh || _install_status 1 "Unable change owner and/or group" sudo chmod 750 "$raspap_dir/hostapd/"*.sh || _install_status 1 "Unable to change file permissions" _install_status 0 @@ -301,10 +302,10 @@ function _create_lighttpd_scripts() { _install_log "Creating lighttpd control scripts" sudo mkdir $raspap_dir/lighttpd || _install_status 1 "Unable to create directory '$raspap_dir/lighttpd" - # Move service control shell scripts + # Copy service control shell scripts echo "Copying configport.sh to $raspap_dir/lighttpd" sudo cp "$webroot_dir/installers/"configport.sh "$raspap_dir/lighttpd" || _install_status 1 "Unable to move service control scripts" - # Make configport.sh writable by www-data group + # Change ownership and permissions of lighttpd scripts echo "Changing file ownership" sudo chown -c root:root "$raspap_dir/lighttpd/"*.sh || _install_status 1 "Unable change owner and/or group" sudo chmod 750 "$raspap_dir/lighttpd/"*.sh || _install_status 1 "Unable to change file permissions" @@ -539,18 +540,12 @@ function _create_openvpn_scripts() { _install_log "Creating OpenVPN control scripts" sudo mkdir $raspap_dir/openvpn || _install_status 1 "Unable to create directory '$raspap_dir/openvpn'" - _install_log "Creating RaspAP debug log control script" - sudo mkdir $raspap_dir/system || _install_status 1 "Unable to create directory '$raspap_dir/system'" - - # Move service auth control, logging and debug shell scripts + # Copy service auth control and logging scripts sudo cp "$webroot_dir/installers/"configauth.sh "$raspap_dir/openvpn" || _install_status 1 "Unable to move auth control script" sudo cp "$webroot_dir/installers/"openvpnlog.sh "$raspap_dir/openvpn" || _install_status 1 "Unable to move logging script" - sudo cp "$webroot_dir/installers/"debuglog.sh "$raspap_dir/system" || _install_status 1 "Unable to move debug logging script" # Restrict script execution to root user sudo chown -c root:root "$raspap_dir/openvpn/"*.sh || _install_status 1 "Unable change owner and/or group" sudo chmod 750 "$raspap_dir/openvpn/"*.sh || _install_status 1 "Unable to change file permissions" - sudo chown -c root:root "$raspap_dir/system/"*.sh || _install_status 1 "Unable change owner and/or group" - sudo chmod 750 "$raspap_dir/system/"*.sh || _install_status 1 "Unable to change file permissions" _install_status 0 } @@ -750,6 +745,16 @@ function _patch_system_files() { sudo cp "$webroot_dir/installers/raspap.sudoers" $raspap_sudoers || _install_status 1 "Unable to apply raspap.sudoers to $raspap_sudoers" sudo chmod 0440 $raspap_sudoers || _install_status 1 "Unable to change file permissions for $raspap_sudoers" + install_log "Creating RaspAP debug log control script" + sudo mkdir $raspap_dir/system || _install_status 1 "Unable to create directory '$raspap_dir/system'" + + # Copy debug shell script + sudo cp "$webroot_dir/installers/"debuglog.sh "$raspap_dir/system" || _install_status 1 "Unable to move debug logging script" + + # Set ownership and permissions + sudo chown -c root:root "$raspap_dir/system/"*.sh || _install_status 1 "Unable change owner and/or group" + sudo chmod 750 "$raspap_dir/system/"*.sh || _install_status 1 "Unable to change file permissions" + # Add symlink to prevent wpa_cli cmds from breaking with multiple wlan interfaces _install_log "Symlinked wpa_supplicant hooks for multiple wlan interfaces" if [ ! -f /usr/share/dhcpcd/hooks/10-wpa_supplicant ]; then diff --git a/installers/debuglog.sh b/installers/debuglog.sh index 61db216d..d050f203 100755 --- a/installers/debuglog.sh +++ b/installers/debuglog.sh @@ -108,6 +108,7 @@ function _generate_log() { _usb_info _wpa_info _dnsmasq_info + _dhcpcd_info _interface_info _routing_info _iw_dev_info @@ -218,6 +219,17 @@ function _dnsmasq_info() { fi } +function _dhcpcd_info() { + _log_separator "Dhcpcd Contents" + if [ -f "${RASPAP_DHCDPCD}" ]; then + local stdout=$(cat ${RASPAP_DHCDPCD}); + _log_write "${stdout}" + + else + _log_write "${RASPAP_DHCDPCD} not present" + fi +} + function _interface_info() { local stdout=$(ip a) _log_separator "Interfaces" diff --git a/installers/raspbian.sh b/installers/raspbian.sh index e6a1e9da..32b115af 100755 --- a/installers/raspbian.sh +++ b/installers/raspbian.sh @@ -6,7 +6,7 @@ # License: GNU General Public License v3.0 # License URI: https://github.com/raspap/raspap-webgui/blob/master/LICENSE # -# Usage: raspbian.sh options +# Usage: raspbian.sh [options] # # Installs an instance of RaspAP. # @@ -15,6 +15,7 @@ # -c, --cert, --certficate Installs mkcert and generates an SSL certificate for lighttpd # -o, --openvpn Used with -y, --yes, sets OpenVPN install option (0=no install) # -a, --adblock Used with -y, --yes, sets Adblock install option (0=no install) +# -w, --wireguard Used with -y, --yes, sets WireGuard install option (0=no install) # -c, --cert, --certificate Installs an SSL certificate with mkcert and configures lighttpd for HTTPS # -r, --repo, --repository Overrides the default GitHub repo (RaspAP/raspap-webgui) # -b, --branch Overrides the default git branch (master) @@ -59,6 +60,7 @@ function _parse_params() { upgrade=0 ovpn_option=1 adblock_option=1 + wg_option=1 insiders=0 minwrite=0 acctoken="" @@ -77,6 +79,10 @@ function _parse_params() { adblock_option="$2" shift ;; + -w|--wireguard) + wg_option="$2" + shift + ;; -c|--cert|--certificate) install_cert=1 ;; @@ -150,6 +156,7 @@ OPTIONS: -c, --cert, --certificate Installs an SSL certificate for lighttpd -o, --openvpn Used with -y, --yes, sets OpenVPN install option (0=no install) -a, --adblock Used with -y, --yes, sets Adblock install option (0=no install) +-w, --wireguard Used with -y, --yes, sets WireGuard install option (0=no install) -c, --cert, --certificate Installs an SSL certificate with mkcert and configures lighttpd for HTTPS -r, --repo, --repository Overrides the default GitHub repo (RaspAP/raspap-webgui) -b, --branch Overrides the default git branch (latest release) diff --git a/installers/uninstall.sh b/installers/uninstall.sh index 06173755..0e3f95c1 100755 --- a/installers/uninstall.sh +++ b/installers/uninstall.sh @@ -26,13 +26,14 @@ readonly raspap_network="/etc/systemd/network/" readonly rulesv4="/etc/iptables/rules.v4" webroot_dir="/var/www/html" -# Determines host Linux distrubtion details +# Determines host Linux distribution details function _get_linux_distro() { if type lsb_release >/dev/null 2>&1; then # linuxbase.org OS=$(lsb_release -si) RELEASE=$(lsb_release -sr) CODENAME=$(lsb_release -sc) DESC=$(lsb_release -sd) + LONG_BIT=$(getconf LONG_BIT) elif [ -f /etc/os-release ]; then # freedesktop.org . /etc/os-release OS=$ID @@ -47,15 +48,27 @@ function _get_linux_distro() { # Sets php package option based on Linux version, abort if unsupported distro function _set_php_package() { case $RELEASE in - 18.04|19.10) # Ubuntu Server + 23.05|12*) # Debian 12 & Armbian 23.05 + php_package="php8.2-cgi" + phpcgiconf="/etc/php/8.2/cgi/php.ini" ;; + 23.04) # Ubuntu Server 23.04 + php_package="php8.1-cgi" + phpcgiconf="/etc/php/8.1/cgi/php.ini" ;; + 22.04|20.04|18.04|19.10|11*) # Previous Ubuntu Server, Debian & Armbian distros php_package="php7.4-cgi" phpcgiconf="/etc/php/7.4/cgi/php.ini" ;; - 10*) + 10*|11*) php_package="php7.3-cgi" phpcgiconf="/etc/php/7.3/cgi/php.ini" ;; 9*) php_package="php7.0-cgi" phpcgiconf="/etc/php/7.0/cgi/php.ini" ;; + 8) + _install_error "${DESC} and php5 are unsupported." + exit 1 ;; + *) + _install_error "${DESC} is unsupported." + exit 1 ;; esac } @@ -74,7 +87,7 @@ function _install_error() { function _config_uninstallation() { _install_log "Configure uninstall of RaspAP" _get_linux_distro - echo "Detected ${DESC}" + echo "Detected OS: ${DESC} ${LONG_BIT}-bit" echo "RaspAP install directory: ${raspap_dir}" echo -n "Lighttpd install directory: ${webroot_dir}? [Y/n]: " read answer @@ -195,16 +208,23 @@ function _restore_networking() { function _remove_installed_packages() { _install_log "Removing installed packages" _set_php_package + + # Set default + dhcpcd_package="dnsmasq" + if [ ${OS,,} = "debian" ] || [ ${OS,,} = "ubuntu" ]; then dhcpcd_package="dhcpcd5" - else - dhcpcd_package="dnsmasq" + iw_package="iw" fi - echo -n "Remove the following installed packages? lighttpd hostapd iptables-persistent $php_package $dhcpcd_package vnstat qrencode [y/N]: " + if [ ${OS,,} = "raspbian" ] && [[ ${RELEASE} =~ ^(12) ]]; then + dhcpcd_package="dhcpcd dhcpcd-base" + fi + + echo -n "Remove the following installed packages? lighttpd hostapd iptables-persistent $php_package $dhcpcd_package $iw_package vnstat qrencode jq [y/N]: " read answer if [ "$answer" == 'y' ] || [ "$answer" == 'Y' ]; then echo "Removing packages." - sudo apt-get remove lighttpd hostapd iptables-persistent $php_package $dhcpcd_package vnstat qrencode || _install_error "Unable to remove installed packages" + sudo apt-get remove lighttpd hostapd iptables-persistent $php_package $dhcpcd_package $iw_package vnstat qrencode jq || _install_error "Unable to remove installed packages" sudo apt-get autoremove || _install_error "Unable to run apt autoremove" else echo "Leaving packages installed." @@ -230,7 +250,7 @@ function _remove_lighttpd_config() { function _uninstall_complete() { _install_log "Uninstall completed" - echo "It is recommended that you reboot your system as a final step." + echo "Check your network configuration before rebooting to ensure access." } function _remove_raspap() {