|
|
@ -1,4 +1,17 @@
|
|
|
|
#!/usr/bin/env bash
|
|
|
|
#!/usr/bin/env bash
|
|
|
|
|
|
|
|
function header_info {
|
|
|
|
|
|
|
|
cat <<"EOF"
|
|
|
|
|
|
|
|
___ v5 __ _
|
|
|
|
|
|
|
|
/ | / /___ (_)___ ___
|
|
|
|
|
|
|
|
/ /| | / / __ \/ / __ \/ _ \
|
|
|
|
|
|
|
|
/ ___ |/ / /_/ / / / / / __/
|
|
|
|
|
|
|
|
/_/ |_/_/ .___/_/_/ /_/\___/
|
|
|
|
|
|
|
|
/_/
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
EOF
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
clear
|
|
|
|
|
|
|
|
header_info
|
|
|
|
echo -e "Loading..."
|
|
|
|
echo -e "Loading..."
|
|
|
|
APP="Alpine"
|
|
|
|
APP="Alpine"
|
|
|
|
var_disk="0.1"
|
|
|
|
var_disk="0.1"
|
|
|
@ -7,7 +20,7 @@ var_ram="512"
|
|
|
|
var_os="alpine"
|
|
|
|
var_os="alpine"
|
|
|
|
var_version="3.16"
|
|
|
|
var_version="3.16"
|
|
|
|
NSAPP=$(echo ${APP,,} | tr -d ' ')
|
|
|
|
NSAPP=$(echo ${APP,,} | tr -d ' ')
|
|
|
|
NEXTID=$(pvesh get /cluster/nextid)
|
|
|
|
var_install="${NSAPP}-v5-install"
|
|
|
|
INTEGER='^[0-9]+$'
|
|
|
|
INTEGER='^[0-9]+$'
|
|
|
|
YW=$(echo "\033[33m")
|
|
|
|
YW=$(echo "\033[33m")
|
|
|
|
BL=$(echo "\033[36m")
|
|
|
|
BL=$(echo "\033[36m")
|
|
|
@ -19,6 +32,7 @@ CL=$(echo "\033[m")
|
|
|
|
BFR="\\r\\033[K"
|
|
|
|
BFR="\\r\\033[K"
|
|
|
|
HOLD="-"
|
|
|
|
HOLD="-"
|
|
|
|
CM="${GN}✓${CL}"
|
|
|
|
CM="${GN}✓${CL}"
|
|
|
|
|
|
|
|
CROSS="${RD}✗${CL}"
|
|
|
|
set -o errexit
|
|
|
|
set -o errexit
|
|
|
|
set -o errtrace
|
|
|
|
set -o errtrace
|
|
|
|
set -o nounset
|
|
|
|
set -o nounset
|
|
|
@ -34,32 +48,22 @@ function error_exit() {
|
|
|
|
echo -e "$flag $msg" 1>&2
|
|
|
|
echo -e "$flag $msg" 1>&2
|
|
|
|
exit $EXIT
|
|
|
|
exit $EXIT
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (whiptail --title "${APP} LXC" --yesno "This will create a New ${APP} LXC. Proceed?" 10 58); then
|
|
|
|
|
|
|
|
echo "User selected Yes"
|
|
|
|
|
|
|
|
else
|
|
|
|
|
|
|
|
clear
|
|
|
|
|
|
|
|
echo -e "⚠ User exited script \n"
|
|
|
|
|
|
|
|
exit
|
|
|
|
|
|
|
|
fi
|
|
|
|
|
|
|
|
function header_info {
|
|
|
|
|
|
|
|
cat <<"EOF"
|
|
|
|
|
|
|
|
___ v4 __ _
|
|
|
|
|
|
|
|
/ | / /___ (_)___ ___
|
|
|
|
|
|
|
|
/ /| | / / __ \/ / __ \/ _ \
|
|
|
|
|
|
|
|
/ ___ |/ / /_/ / / / / / __/
|
|
|
|
|
|
|
|
/_/ |_/_/ .___/_/_/ /_/\___/
|
|
|
|
|
|
|
|
/_/
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
EOF
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
function msg_info() {
|
|
|
|
function msg_info() {
|
|
|
|
local msg="$1"
|
|
|
|
local msg="$1"
|
|
|
|
echo -ne " ${HOLD} ${YW}${msg}..."
|
|
|
|
echo -ne " ${HOLD} ${YW}${msg}..."
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
function msg_ok() {
|
|
|
|
function msg_ok() {
|
|
|
|
local msg="$1"
|
|
|
|
local msg="$1"
|
|
|
|
echo -e "${BFR} ${CM} ${GN}${msg}${CL}"
|
|
|
|
echo -e "${BFR} ${CM} ${GN}${msg}${CL}"
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
function msg_error() {
|
|
|
|
|
|
|
|
local msg="$1"
|
|
|
|
|
|
|
|
echo -e "${BFR} ${CROSS} ${RD}${msg}${CL}"
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
function PVE_CHECK() {
|
|
|
|
function PVE_CHECK() {
|
|
|
|
PVE=$(pveversion | grep "pve-manager/7" | wc -l)
|
|
|
|
PVE=$(pveversion | grep "pve-manager/7" | wc -l)
|
|
|
|
if [[ $PVE != 1 ]]; then
|
|
|
|
if [[ $PVE != 1 ]]; then
|
|
|
@ -69,6 +73,30 @@ function PVE_CHECK() {
|
|
|
|
exit
|
|
|
|
exit
|
|
|
|
fi
|
|
|
|
fi
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if command -v pveversion >/dev/null 2>&1; then
|
|
|
|
|
|
|
|
if (whiptail --title "${APP} LXC" --yesno "This will create a New ${APP} LXC. Proceed?" 10 58); then
|
|
|
|
|
|
|
|
NEXTID=$(pvesh get /cluster/nextid)
|
|
|
|
|
|
|
|
else
|
|
|
|
|
|
|
|
clear
|
|
|
|
|
|
|
|
echo -e "⚠ User exited script \n"
|
|
|
|
|
|
|
|
exit
|
|
|
|
|
|
|
|
fi
|
|
|
|
|
|
|
|
fi
|
|
|
|
|
|
|
|
if ! command -v pveversion >/dev/null 2>&1; then
|
|
|
|
|
|
|
|
if [[ ! -f /etc/apt/sources.list.d/emqx_emqx.list ]]; then
|
|
|
|
|
|
|
|
msg_error "No ${APP} Installation Found!";
|
|
|
|
|
|
|
|
exit
|
|
|
|
|
|
|
|
fi
|
|
|
|
|
|
|
|
if (whiptail --title "${APP} LXC UPDATE" --yesno "This will update ${APP} LXC. Proceed?" 10 58); then
|
|
|
|
|
|
|
|
echo "User selected Update"
|
|
|
|
|
|
|
|
else
|
|
|
|
|
|
|
|
clear
|
|
|
|
|
|
|
|
echo -e "⚠ User exited script \n"
|
|
|
|
|
|
|
|
exit
|
|
|
|
|
|
|
|
fi
|
|
|
|
|
|
|
|
fi
|
|
|
|
|
|
|
|
|
|
|
|
function default_settings() {
|
|
|
|
function default_settings() {
|
|
|
|
echo -e "${DGN}Using Container Type: ${BGN}Unprivileged${CL} ${RD}NO DEVICE PASSTHROUGH${CL}"
|
|
|
|
echo -e "${DGN}Using Container Type: ${BGN}Unprivileged${CL} ${RD}NO DEVICE PASSTHROUGH${CL}"
|
|
|
|
CT_TYPE="1"
|
|
|
|
CT_TYPE="1"
|
|
|
@ -102,6 +130,7 @@ function default_settings() {
|
|
|
|
SSH="no"
|
|
|
|
SSH="no"
|
|
|
|
echo -e "${DGN}Enable Verbose Mode: ${BGN}No${CL}"
|
|
|
|
echo -e "${DGN}Enable Verbose Mode: ${BGN}No${CL}"
|
|
|
|
VERB="no"
|
|
|
|
VERB="no"
|
|
|
|
|
|
|
|
VERB2="silent"
|
|
|
|
echo -e "${BL}Creating a ${APP} LXC using the above default settings${CL}"
|
|
|
|
echo -e "${BL}Creating a ${APP} LXC using the above default settings${CL}"
|
|
|
|
}
|
|
|
|
}
|
|
|
|
function advanced_settings() {
|
|
|
|
function advanced_settings() {
|
|
|
@ -250,9 +279,11 @@ function advanced_settings() {
|
|
|
|
if (whiptail --defaultno --title "VERBOSE MODE" --yesno "Enable Verbose Mode?" 10 58); then
|
|
|
|
if (whiptail --defaultno --title "VERBOSE MODE" --yesno "Enable Verbose Mode?" 10 58); then
|
|
|
|
echo -e "${DGN}Enable Verbose Mode: ${BGN}Yes${CL}"
|
|
|
|
echo -e "${DGN}Enable Verbose Mode: ${BGN}Yes${CL}"
|
|
|
|
VERB="yes"
|
|
|
|
VERB="yes"
|
|
|
|
|
|
|
|
VERB2=""
|
|
|
|
else
|
|
|
|
else
|
|
|
|
echo -e "${DGN}Enable Verbose Mode: ${BGN}No${CL}"
|
|
|
|
echo -e "${DGN}Enable Verbose Mode: ${BGN}No${CL}"
|
|
|
|
VERB="no"
|
|
|
|
VERB="no"
|
|
|
|
|
|
|
|
VERB2="silent"
|
|
|
|
fi
|
|
|
|
fi
|
|
|
|
if (whiptail --title "ADVANCED SETTINGS COMPLETE" --yesno "Ready to create ${APP} LXC?" --no-button Do-Over 10 58); then
|
|
|
|
if (whiptail --title "ADVANCED SETTINGS COMPLETE" --yesno "Ready to create ${APP} LXC?" --no-button Do-Over 10 58); then
|
|
|
|
echo -e "${RD}Creating a ${APP} LXC using the above advanced settings${CL}"
|
|
|
|
echo -e "${RD}Creating a ${APP} LXC using the above advanced settings${CL}"
|
|
|
@ -263,7 +294,7 @@ function advanced_settings() {
|
|
|
|
advanced_settings
|
|
|
|
advanced_settings
|
|
|
|
fi
|
|
|
|
fi
|
|
|
|
}
|
|
|
|
}
|
|
|
|
function start_script() {
|
|
|
|
function install_script() {
|
|
|
|
if (whiptail --title "SETTINGS" --yesno "Use Default Settings?" --no-button Advanced 10 58); then
|
|
|
|
if (whiptail --title "SETTINGS" --yesno "Use Default Settings?" --no-button Advanced 10 58); then
|
|
|
|
header_info
|
|
|
|
header_info
|
|
|
|
echo -e "${BL}Using Default Settings${CL}"
|
|
|
|
echo -e "${BL}Using Default Settings${CL}"
|
|
|
@ -274,8 +305,19 @@ function start_script() {
|
|
|
|
advanced_settings
|
|
|
|
advanced_settings
|
|
|
|
fi
|
|
|
|
fi
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
function update_script() {
|
|
|
|
|
|
|
|
clear
|
|
|
|
|
|
|
|
header_info
|
|
|
|
|
|
|
|
msg_info "Updating ${APP} LXC"
|
|
|
|
|
|
|
|
apt-get update &>/dev/null
|
|
|
|
|
|
|
|
apt-get -y upgrade &>/dev/null
|
|
|
|
|
|
|
|
msg_ok "Updated ${APP} LXC"
|
|
|
|
|
|
|
|
msg_ok "Update Successfull"
|
|
|
|
|
|
|
|
exit
|
|
|
|
|
|
|
|
}
|
|
|
|
clear
|
|
|
|
clear
|
|
|
|
start_script
|
|
|
|
if ! command -v pveversion >/dev/null 2>&1; then update_script; else install_script; fi
|
|
|
|
if [ "$VERB" == "yes" ]; then set -x; fi
|
|
|
|
if [ "$VERB" == "yes" ]; then set -x; fi
|
|
|
|
if [ "$CT_TYPE" == "1" ]; then
|
|
|
|
if [ "$CT_TYPE" == "1" ]; then
|
|
|
|
FEATURES="nesting=1,keyctl=1"
|
|
|
|
FEATURES="nesting=1,keyctl=1"
|
|
|
@ -285,6 +327,7 @@ fi
|
|
|
|
TEMP_DIR=$(mktemp -d)
|
|
|
|
TEMP_DIR=$(mktemp -d)
|
|
|
|
pushd $TEMP_DIR >/dev/null
|
|
|
|
pushd $TEMP_DIR >/dev/null
|
|
|
|
export VERBOSE=$VERB
|
|
|
|
export VERBOSE=$VERB
|
|
|
|
|
|
|
|
export STD=$VERB2
|
|
|
|
export SSH_ROOT=${SSH}
|
|
|
|
export SSH_ROOT=${SSH}
|
|
|
|
export CTID=$CT_ID
|
|
|
|
export CTID=$CT_ID
|
|
|
|
export PCT_OSTYPE=$var_os
|
|
|
|
export PCT_OSTYPE=$var_os
|