mirror of
https://github.com/billz/raspap-webgui.git
synced 2025-03-01 10:31:47 +00:00
Merge branch 'master' into feature/wireguard
This commit is contained in:
@@ -28,7 +28,12 @@ readonly raspap_network="$raspap_dir/networking/"
|
||||
readonly rulesv4="/etc/iptables/rules.v4"
|
||||
readonly notracking_url="https://raw.githubusercontent.com/notracking/hosts-blocklists/master/"
|
||||
webroot_dir="/var/www/html"
|
||||
git_source_url="https://github.com/$repo" # $repo from install.raspap.com
|
||||
|
||||
if [ "$insiders" == 1 ]; then
|
||||
repo="RaspAP/raspap-insiders"
|
||||
branch=${RASPAP_INSIDERS_LATEST}
|
||||
fi
|
||||
git_source_url="https://github.com/$repo"
|
||||
|
||||
# NOTE: all the below functions are overloadable for system-specific installs
|
||||
function _install_raspap() {
|
||||
@@ -78,7 +83,7 @@ function _config_installation() {
|
||||
fi
|
||||
echo "${opt[1]} lighttpd directory: ${webroot_dir}"
|
||||
if [ "$upgrade" == 1 ]; then
|
||||
echo "This will upgrade your existing install to version ${RASPAP_LATEST}"
|
||||
echo "This will upgrade your existing install to version ${RASPAP_RELEASE}"
|
||||
echo "Your configuration will NOT be changed"
|
||||
fi
|
||||
echo -n "Complete ${opt[2]} with these values? [Y/n]: "
|
||||
@@ -171,6 +176,8 @@ function _create_raspap_directories() {
|
||||
# Create a directory to store networking configs
|
||||
echo "Creating $raspap_dir/networking"
|
||||
sudo mkdir -p "$raspap_dir/networking"
|
||||
echo "Changing file ownership of $raspap_dir"
|
||||
sudo chown -R $raspap_user:$raspap_user "$raspap_dir" || _install_status 1 "Unable to change file ownership for '$raspap_dir'"
|
||||
}
|
||||
|
||||
# Generate hostapd logging and service control scripts
|
||||
@@ -209,14 +216,30 @@ function _install_lighttpd_configs() {
|
||||
|
||||
# Copy config files
|
||||
echo "Copying 50-raspap-router.conf to /etc/lighttpd/conf-available"
|
||||
sudo cp "$webroot_dir/config/50-raspap-router.conf" "/etc/lighttpd/conf-available" || _install_status 1 "Unable to copy lighttpd config file."
|
||||
|
||||
CONFSRC="$webroot_dir/config/50-raspap-router.conf"
|
||||
LTROOT=$(grep "server.document-root" /etc/lighttpd/lighttpd.conf | awk -F '=' '{print $2}' | tr -d " \"")
|
||||
|
||||
# compare values and get difference
|
||||
HTROOT=${webroot_dir/$LTROOT}
|
||||
|
||||
# remove trailing slash if present
|
||||
HTROOT=$(echo "$HTROOT" | sed -e 's/\/$//')
|
||||
|
||||
# substitute values
|
||||
awk "{gsub(\"/REPLACE_ME\",\"$HTROOT\")}1" $CONFSRC > /tmp/50-raspap-router.conf
|
||||
|
||||
# copy into place
|
||||
sudo cp /tmp/50-raspap-router.conf /etc/lighttpd/conf-available/ || _install_status 1 "Unable to copy lighttpd config file into place."
|
||||
|
||||
# link into conf-enabled
|
||||
echo "Creating link to /etc/lighttpd/conf-enabled"|| _install_status 1 "Unable to copy lighttpd config file."
|
||||
sudo ln -s "/etc/lighttpd/conf-available/50-raspap-router.conf" "/etc/lighttpd/conf-enabled/50-raspap-router.conf" || _install_status 1 "Unable to symlink lighttpd config file."
|
||||
echo "Creating link to /etc/lighttpd/conf-enabled"
|
||||
sudo ln -s "/etc/lighttpd/conf-available/50-raspap-router.conf" "/etc/lighttpd/conf-enabled/50-raspap-router.conf" || _install_status 1 "Unable to symlink lighttpd config file (this is normal if the link already exists)."
|
||||
sudo systemctl restart lighttpd.service || _install_status 1 "Unable to restart lighttpd"
|
||||
_install_status 0
|
||||
}
|
||||
|
||||
|
||||
# Prompt to install ad blocking
|
||||
function _prompt_install_adblock() {
|
||||
_install_log "Configure ad blocking (Beta)"
|
||||
@@ -300,19 +323,21 @@ function _prompt_install_openvpn() {
|
||||
|
||||
# Prompt to install WireGuard
|
||||
function _prompt_install_wireguard() {
|
||||
_install_log "Configure WireGuard support"
|
||||
echo -n "Install WireGuard and enable VPN tunnel configuration? [Y/n]: "
|
||||
if [ "$assume_yes" == 0 ]; then
|
||||
read answer < /dev/tty
|
||||
if [ "$answer" != "${answer#[Nn]}" ]; then
|
||||
echo -e
|
||||
else
|
||||
if [ "$insiders" == 1 ]; then
|
||||
_install_log "Configure WireGuard support"
|
||||
echo -n "Install WireGuard and enable VPN tunnel configuration? [Y/n]: "
|
||||
if [ "$assume_yes" == 0 ]; then
|
||||
read answer < /dev/tty
|
||||
if [ "$answer" != "${answer#[Nn]}" ]; then
|
||||
echo -e
|
||||
else
|
||||
_install_wireguard
|
||||
fi
|
||||
elif [ "$wg_option" == 1 ]; then
|
||||
_install_wireguard
|
||||
else
|
||||
echo "(Skipped)"
|
||||
fi
|
||||
elif [ "$wg_option" == 1 ]; then
|
||||
_install_wireguard
|
||||
else
|
||||
echo "(Skipped)"
|
||||
fi
|
||||
}
|
||||
|
||||
|
@@ -17,9 +17,11 @@
|
||||
# -a, --adblock <flag> Used with -y, --yes, sets Adblock install option (0=no install)
|
||||
# -r, --repo, --repository <name> Overrides the default GitHub repo (raspap/raspap-webgui)
|
||||
# -b, --branch <name> Overrides the default git branch (master)
|
||||
# -h, --help Outputs usage notes and exits
|
||||
# -t, --token <accesstoken> Token to access a private repository
|
||||
# -u, --upgrade Upgrades an existing installation to the latest release version
|
||||
# -i, --insiders Installs from the Insiders Edition (raspap/raspap-insiders)
|
||||
# -v, --version Outputs release info and exits
|
||||
# -h, --help Outputs usage notes and exits
|
||||
#
|
||||
# Depending on options passed to the installer, ONE of the following
|
||||
# additional shell scripts will be downloaded and sourced:
|
||||
@@ -35,8 +37,7 @@ set -eo pipefail
|
||||
|
||||
function _main() {
|
||||
# set defaults
|
||||
repo="raspap/raspap-webgui" # override with -r, --repo option
|
||||
|
||||
repo="RaspAP/raspap-webgui" # override with -r, --repo option
|
||||
_parse_params "$@"
|
||||
_setup_colors
|
||||
_log_output
|
||||
@@ -49,6 +50,8 @@ function _parse_params() {
|
||||
upgrade=0
|
||||
ovpn_option=1
|
||||
adblock_option=1
|
||||
insiders=0
|
||||
acctoken=""
|
||||
|
||||
while :; do
|
||||
case "${1-}" in
|
||||
@@ -81,6 +84,12 @@ function _parse_params() {
|
||||
-u|--upgrade)
|
||||
upgrade=1
|
||||
;;
|
||||
-i|--insiders)
|
||||
insiders=1
|
||||
;;
|
||||
-t|--token)
|
||||
acctoken="$2"
|
||||
;;
|
||||
-v|--version)
|
||||
_version
|
||||
;;
|
||||
@@ -125,7 +134,9 @@ OPTIONS:
|
||||
-a, --adblock <flag> Used with -y, --yes, sets Adblock install option (0=no install)
|
||||
-r, --repo, --repository <name> Overrides the default GitHub repo (raspap/raspap-webgui)
|
||||
-b, --branch <name> Overrides the default git branch (latest release)
|
||||
-t, --token <accesstoken> Token to access a private repository
|
||||
-u, --upgrade Upgrades an existing installation to the latest release version
|
||||
-i, --insiders Installs from the Insiders Edition (raspap/raspap-insiders)
|
||||
-v, --version Outputs release info and exits
|
||||
-h, --help Outputs usage notes and exits
|
||||
|
||||
@@ -139,13 +150,16 @@ Examples:
|
||||
Invoke installer remotely, run non-interactively with option flags:
|
||||
curl -sL https://install.raspap.com | bash -s -- --yes --openvpn 1 --adblock 0
|
||||
|
||||
Invoke remotely, uprgrade an existing install to the Insiders Edition:
|
||||
curl -sL https://install.raspap.com | bash -s -- --upgrade --insiders
|
||||
|
||||
EOF
|
||||
exit
|
||||
}
|
||||
|
||||
function _version() {
|
||||
_get_release
|
||||
echo -e "RaspAP v${RASPAP_LATEST} - Simple AP setup & WiFi management for Debian-based devices"
|
||||
echo -e "RaspAP v${RASPAP_RELEASE} - Simple wireless AP setup & management for Debian-based devices"
|
||||
exit
|
||||
}
|
||||
|
||||
@@ -159,14 +173,20 @@ function _display_welcome() {
|
||||
echo -e " 88 88 88. .88 88 88. .88 88 88 88"
|
||||
echo -e " dP dP 88888P8 88888P 88Y888P 88 88 dP"
|
||||
echo -e " 88"
|
||||
echo -e " dP version ${RASPAP_LATEST}"
|
||||
echo -e " dP version ${RASPAP_RELEASE}"
|
||||
echo -e "${ANSI_GREEN}"
|
||||
echo -e "The Quick Installer will guide you through a few easy steps${ANSI_RESET}\n\n"
|
||||
}
|
||||
|
||||
# Fetch latest release from GitHub API
|
||||
# Fetch latest release from GitHub or RaspAP Installer API
|
||||
function _get_release() {
|
||||
readonly RASPAP_LATEST=$(curl -s "https://api.github.com/repos/$repo/releases/latest" | grep -Po '"tag_name": "\K.*?(?=")' )
|
||||
if [ "$insiders" == 1 ]; then
|
||||
RASPAP_INSIDERS_LATEST=$(curl -s "https://install.raspap.com/repos/RaspAP/raspap-insiders/releases/latest/" | grep -Po '"tag_name": "\K.*?(?=")' )
|
||||
RASPAP_RELEASE="${RASPAP_INSIDERS_LATEST} Insiders"
|
||||
else
|
||||
RASPAP_RELEASE="${RASPAP_LATEST}"
|
||||
fi
|
||||
}
|
||||
|
||||
# Outputs a RaspAP Install log line
|
||||
@@ -201,6 +221,7 @@ function _update_system_packages() {
|
||||
|
||||
# Fetch required installer functions
|
||||
function _load_installer() {
|
||||
|
||||
# fetch latest release tag
|
||||
_get_release
|
||||
|
||||
@@ -210,14 +231,18 @@ function _load_installer() {
|
||||
fi
|
||||
|
||||
UPDATE_URL="https://raw.githubusercontent.com/$repo/$branch/"
|
||||
header=()
|
||||
if [[ ! -z "$acctoken" ]]; then
|
||||
header=(--header "Authorization: token $acctoken")
|
||||
fi
|
||||
if [ "${install_cert:-}" = 1 ]; then
|
||||
source="mkcert"
|
||||
wget -q ${UPDATE_URL}installers/${source}.sh -O /tmp/raspap_${source}.sh
|
||||
wget "${header[@]}" -q ${UPDATE_URL}installers/${source}.sh -O /tmp/raspap_${source}.sh
|
||||
source /tmp/raspap_${source}.sh && rm -f /tmp/raspap_${source}.sh
|
||||
_install_certificate || _install_status 1 "Unable to install certificate"
|
||||
else
|
||||
source="common"
|
||||
wget -q ${UPDATE_URL}installers/${source}.sh -O /tmp/raspap_${source}.sh
|
||||
wget "${header[@]}" -q ${UPDATE_URL}installers/${source}.sh -O /tmp/raspap_${source}.sh
|
||||
source /tmp/raspap_${source}.sh && rm -f /tmp/raspap_${source}.sh
|
||||
_install_raspap || _install_status 1 "Unable to install RaspAP"
|
||||
fi
|
||||
|
Reference in New Issue
Block a user