mirror of
https://github.com/billz/raspap-webgui.git
synced 2025-03-01 10:31:47 +00:00
Adds @zbchristian's token option, fix private repo handling
This commit is contained in:
@@ -17,6 +17,7 @@
|
||||
# -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)
|
||||
# -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
|
||||
@@ -36,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
|
||||
@@ -50,6 +50,8 @@ function _parse_params() {
|
||||
upgrade=0
|
||||
ovpn_option=1
|
||||
adblock_option=1
|
||||
insiders=0
|
||||
acctoken=""
|
||||
|
||||
while :; do
|
||||
case "${1-}" in
|
||||
@@ -83,7 +85,10 @@ function _parse_params() {
|
||||
upgrade=1
|
||||
;;
|
||||
-i|--insiders)
|
||||
repo="raspap/raspap-insiders"
|
||||
insiders=1
|
||||
;;
|
||||
-t|--token)
|
||||
acctoken="$2"
|
||||
;;
|
||||
-v|--version)
|
||||
_version
|
||||
@@ -129,6 +134,7 @@ 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
|
||||
@@ -153,7 +159,7 @@ EOF
|
||||
|
||||
function _version() {
|
||||
_get_release
|
||||
echo -e "RaspAP v${RASPAP_LATEST} - Simple wireless AP setup & management for Debian-based devices"
|
||||
echo -e "RaspAP v${RASPAP_RELEASE} - Simple wireless AP setup & management for Debian-based devices"
|
||||
exit
|
||||
}
|
||||
|
||||
@@ -167,18 +173,19 @@ 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() {
|
||||
if [ "$repo" == "raspap/raspap-insiders" ]; then
|
||||
readonly RASPAP_LATEST="Insiders"
|
||||
branch="master"
|
||||
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
|
||||
readonly RASPAP_LATEST=$(curl -s "https://api.github.com/repos/$repo/releases/latest" | grep -Po '"tag_name": "\K.*?(?=")' )
|
||||
RASPAP_RELEASE="${RASPAP_LATEST}"
|
||||
fi
|
||||
}
|
||||
|
||||
@@ -214,6 +221,7 @@ function _update_system_packages() {
|
||||
|
||||
# Fetch required installer functions
|
||||
function _load_installer() {
|
||||
|
||||
# fetch latest release tag
|
||||
_get_release
|
||||
|
||||
@@ -223,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