2019-10-07 00:59:21 +02:00
|
|
|
#!/bin/bash
|
|
|
|
#
|
|
|
|
# RaspAP Quick Installer
|
|
|
|
# author: @billz
|
|
|
|
# license: GNU General Public License v3.0
|
|
|
|
#
|
2019-11-07 14:29:42 +01:00
|
|
|
# Command-line options:
|
|
|
|
# -y, --yes, --assume-yes
|
2019-10-07 00:59:21 +02:00
|
|
|
# Assume "yes" as answer to all prompts and run non-interactively
|
2019-11-07 21:12:41 +01:00
|
|
|
# c, --cert, --certficate
|
2019-11-07 14:29:42 +01:00
|
|
|
# Installs mkcert and generates an SSL certificate for lighttpd
|
2019-11-11 09:51:45 +01:00
|
|
|
# -r, --repo, --repository
|
|
|
|
# Overrides the default GitHub repo (billz/raspap-webgui)
|
|
|
|
# -b, --branch
|
|
|
|
# Overrides the default git branch (master)
|
2019-10-07 00:59:21 +02:00
|
|
|
|
2019-11-11 09:51:45 +01:00
|
|
|
repo="billz/raspap-webgui"
|
|
|
|
branch="master"
|
|
|
|
USAGE=$'Usage: raspbian.sh [OPTION] \n\n'
|
|
|
|
USAGE+=$'-y, --yes, --assume-yes\n\tAssumes "yes" as an answer to all prompts\n'
|
|
|
|
USAGE+=$'-c, --cert, --certficate\n\tInstalls an SSL certificate for lighttpd\n'
|
|
|
|
USAGE+=$'-r, --repo, --repository\n\tOverrides the default GitHub repo (billz/raspap-webgui)\n'
|
|
|
|
USAGE+=$'-b, --branch\n\tOverrides the default git branch (master)\n'
|
2019-09-30 19:58:12 +02:00
|
|
|
assume_yes=0
|
2019-11-07 09:44:13 +01:00
|
|
|
|
|
|
|
while :; do
|
|
|
|
case $1 in
|
2019-11-07 14:29:42 +01:00
|
|
|
-y|--yes|--assume-yes)
|
|
|
|
assume_yes=1
|
|
|
|
apt_option="-y"
|
|
|
|
;;
|
2019-11-07 21:12:41 +01:00
|
|
|
-c|--cert|--certificate)
|
2019-11-07 14:29:42 +01:00
|
|
|
install_cert=1
|
|
|
|
;;
|
2019-11-11 09:51:45 +01:00
|
|
|
-r|--repo|--repository)
|
|
|
|
repo="$2"
|
|
|
|
shift
|
|
|
|
;;
|
|
|
|
-b|--branch)
|
|
|
|
branch="$2"
|
|
|
|
;;
|
2019-11-07 14:29:42 +01:00
|
|
|
-*|--*)
|
2019-11-11 09:51:45 +01:00
|
|
|
echo "Unknown option: $1"
|
2019-11-07 14:29:42 +01:00
|
|
|
echo "$USAGE"
|
|
|
|
exit 1
|
|
|
|
;;
|
|
|
|
*)
|
2019-11-07 09:44:13 +01:00
|
|
|
break
|
|
|
|
;;
|
|
|
|
esac
|
|
|
|
shift
|
2019-09-30 19:58:12 +02:00
|
|
|
done
|
|
|
|
|
2019-11-11 09:51:45 +01:00
|
|
|
VERSION=$(curl -s "https://api.github.com/repos/$repo/releases/latest" | grep -Po '"tag_name": "\K.*?(?=")' )
|
|
|
|
UPDATE_URL="https://raw.githubusercontent.com/$repo/$branch/"
|
|
|
|
|
2019-11-07 09:44:13 +01:00
|
|
|
# Outputs a welcome message
|
|
|
|
function display_welcome() {
|
|
|
|
raspberry='\033[0;35m'
|
|
|
|
green='\033[1;32m'
|
|
|
|
|
|
|
|
echo -e "${raspberry}\n"
|
|
|
|
echo -e " 888888ba .d888888 888888ba"
|
|
|
|
echo -e " 88 8b d8 88 88 8b"
|
|
|
|
echo -e "a88aaaa8P' .d8888b. .d8888b. 88d888b. 88aaaaa88a a88aaaa8P"
|
|
|
|
echo -e " 88 8b. 88 88 Y8ooooo. 88 88 88 88 88"
|
|
|
|
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 ${VERSION}"
|
|
|
|
echo -e "${green}"
|
|
|
|
echo -e "The Quick Installer will guide you through a few easy steps\n\n"
|
|
|
|
}
|
|
|
|
|
|
|
|
# Outputs a RaspAP Install log line
|
|
|
|
function install_log() {
|
|
|
|
echo -e "\033[1;32mRaspAP Install: $*\033[m"
|
|
|
|
}
|
|
|
|
|
|
|
|
# Outputs a RaspAP Install Error log line and exits with status code 1
|
|
|
|
function install_error() {
|
|
|
|
echo -e "\033[1;37;41mRaspAP Install Error: $*\033[m"
|
|
|
|
exit 1
|
|
|
|
}
|
|
|
|
|
|
|
|
# Outputs a RaspAP Warning line
|
|
|
|
function install_warning() {
|
|
|
|
echo -e "\033[1;33mWarning: $*\033[m"
|
|
|
|
}
|
|
|
|
|
2019-11-07 11:41:56 +01:00
|
|
|
# Outputs a RaspAP divider
|
|
|
|
function install_divider() {
|
|
|
|
echo -e "\033[1;32m***************************************************************$*\033[m"
|
|
|
|
}
|
|
|
|
|
2016-06-16 12:03:29 +02:00
|
|
|
function update_system_packages() {
|
|
|
|
install_log "Updating sources"
|
2019-07-10 08:46:58 +02:00
|
|
|
sudo apt-get update || install_error "Unable to update package list"
|
2016-06-16 12:03:29 +02:00
|
|
|
}
|
|
|
|
|
2019-11-07 09:44:13 +01:00
|
|
|
if [ "${install_cert:-}" = 1 ]; then
|
|
|
|
source="mkcert"
|
2019-11-07 21:12:41 +01:00
|
|
|
wget -q ${UPDATE_URL}installers/${source}.sh -O /tmp/raspap_${source}.sh
|
2019-11-07 14:48:30 +01:00
|
|
|
source /tmp/raspap_${source}.sh && rm -f /tmp/raspap_${source}.sh
|
2019-11-07 09:44:13 +01:00
|
|
|
install_certificate
|
|
|
|
else
|
|
|
|
source="common"
|
2019-11-07 21:12:41 +01:00
|
|
|
wget -q ${UPDATE_URL}installers/${source}.sh -O /tmp/raspap_${source}.sh
|
2019-11-07 14:48:30 +01:00
|
|
|
source /tmp/raspap_${source}.sh && rm -f /tmp/raspap_${source}.sh
|
2019-11-07 09:44:13 +01:00
|
|
|
install_raspap
|
|
|
|
fi
|
|
|
|
|