mirror of
https://github.com/billz/raspap-webgui.git
synced 2023-10-10 13:37:24 +02:00
Allow installation from a private repository via access token
This commit is contained in:
parent
b978a3d468
commit
dd7873fd41
@ -17,6 +17,7 @@
|
|||||||
# -a, --adblock <flag> Used with -y, --yes, sets Adblock install option (0=no install)
|
# -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)
|
# -r, --repo, --repository <name> Overrides the default GitHub repo (raspap/raspap-webgui)
|
||||||
# -b, --branch <name> Overrides the default git branch (master)
|
# -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
|
# -u, --upgrade Upgrades an existing installation to the latest release version
|
||||||
# -i, --insiders Installs from the Insiders Edition (raspap/raspap-insiders)
|
# -i, --insiders Installs from the Insiders Edition (raspap/raspap-insiders)
|
||||||
# -v, --version Outputs release info and exits
|
# -v, --version Outputs release info and exits
|
||||||
@ -37,7 +38,6 @@ set -eo pipefail
|
|||||||
function _main() {
|
function _main() {
|
||||||
# set defaults
|
# set defaults
|
||||||
repo="raspap/raspap-webgui" # override with -r, --repo option
|
repo="raspap/raspap-webgui" # override with -r, --repo option
|
||||||
|
|
||||||
_parse_params "$@"
|
_parse_params "$@"
|
||||||
_setup_colors
|
_setup_colors
|
||||||
_log_output
|
_log_output
|
||||||
@ -50,6 +50,7 @@ function _parse_params() {
|
|||||||
upgrade=0
|
upgrade=0
|
||||||
ovpn_option=1
|
ovpn_option=1
|
||||||
adblock_option=1
|
adblock_option=1
|
||||||
|
acctoken=""
|
||||||
|
|
||||||
while :; do
|
while :; do
|
||||||
case "${1-}" in
|
case "${1-}" in
|
||||||
@ -85,6 +86,9 @@ function _parse_params() {
|
|||||||
-i|--insiders)
|
-i|--insiders)
|
||||||
repo="raspap/raspap-insiders"
|
repo="raspap/raspap-insiders"
|
||||||
;;
|
;;
|
||||||
|
-t|--token)
|
||||||
|
acctoken="$2"
|
||||||
|
;;
|
||||||
-v|--version)
|
-v|--version)
|
||||||
_version
|
_version
|
||||||
;;
|
;;
|
||||||
@ -176,7 +180,9 @@ function _display_welcome() {
|
|||||||
function _get_release() {
|
function _get_release() {
|
||||||
if [ "$repo" == "raspap/raspap-insiders" ]; then
|
if [ "$repo" == "raspap/raspap-insiders" ]; then
|
||||||
readonly RASPAP_LATEST="Insiders"
|
readonly RASPAP_LATEST="Insiders"
|
||||||
|
if [ -z ${branch} ]; then
|
||||||
branch="master"
|
branch="master"
|
||||||
|
fi
|
||||||
else
|
else
|
||||||
readonly RASPAP_LATEST=$(curl -s "https://api.github.com/repos/$repo/releases/latest" | grep -Po '"tag_name": "\K.*?(?=")' )
|
readonly RASPAP_LATEST=$(curl -s "https://api.github.com/repos/$repo/releases/latest" | grep -Po '"tag_name": "\K.*?(?=")' )
|
||||||
fi
|
fi
|
||||||
@ -214,6 +220,7 @@ function _update_system_packages() {
|
|||||||
|
|
||||||
# Fetch required installer functions
|
# Fetch required installer functions
|
||||||
function _load_installer() {
|
function _load_installer() {
|
||||||
|
|
||||||
# fetch latest release tag
|
# fetch latest release tag
|
||||||
_get_release
|
_get_release
|
||||||
|
|
||||||
@ -223,14 +230,18 @@ function _load_installer() {
|
|||||||
fi
|
fi
|
||||||
|
|
||||||
UPDATE_URL="https://raw.githubusercontent.com/$repo/$branch/"
|
UPDATE_URL="https://raw.githubusercontent.com/$repo/$branch/"
|
||||||
|
header=()
|
||||||
|
if [[ ! -z "$acctoken" ]]; then
|
||||||
|
header=(--header "Authorization: token $acctoken")
|
||||||
|
fi
|
||||||
if [ "${install_cert:-}" = 1 ]; then
|
if [ "${install_cert:-}" = 1 ]; then
|
||||||
source="mkcert"
|
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
|
source /tmp/raspap_${source}.sh && rm -f /tmp/raspap_${source}.sh
|
||||||
_install_certificate || _install_status 1 "Unable to install certificate"
|
_install_certificate || _install_status 1 "Unable to install certificate"
|
||||||
else
|
else
|
||||||
source="common"
|
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
|
source /tmp/raspap_${source}.sh && rm -f /tmp/raspap_${source}.sh
|
||||||
_install_raspap || _install_status 1 "Unable to install RaspAP"
|
_install_raspap || _install_status 1 "Unable to install RaspAP"
|
||||||
fi
|
fi
|
||||||
|
Loading…
Reference in New Issue
Block a user