mirror of https://github.com/tteck/Proxmox.git
purge (#884)
This commit is contained in:
parent
fce1839580
commit
049b2cf770
162
ct/adguard-v1.sh
162
ct/adguard-v1.sh
|
@ -1,162 +0,0 @@
|
||||||
#!/usr/bin/env bash
|
|
||||||
|
|
||||||
while true; do
|
|
||||||
read -p "This will create a New AdGuard Home LXC. Proceed(y/n)?" yn
|
|
||||||
case $yn in
|
|
||||||
[Yy]* ) break;;
|
|
||||||
[Nn]* ) exit;;
|
|
||||||
* ) echo "Please answer yes or no.";;
|
|
||||||
esac
|
|
||||||
done
|
|
||||||
|
|
||||||
set -o errexit
|
|
||||||
set -o errtrace
|
|
||||||
set -o nounset
|
|
||||||
set -o pipefail
|
|
||||||
shopt -s expand_aliases
|
|
||||||
alias die='EXIT=$? LINE=$LINENO error_exit'
|
|
||||||
CHECKMARK='\033[0;32m\xE2\x9C\x94\033[0m'
|
|
||||||
trap die ERR
|
|
||||||
trap cleanup EXIT
|
|
||||||
|
|
||||||
function error_exit() {
|
|
||||||
trap - ERR
|
|
||||||
local DEFAULT='Unknown failure occured.'
|
|
||||||
local REASON="\e[97m${1:-$DEFAULT}\e[39m"
|
|
||||||
local FLAG="\e[91m[ERROR] \e[93m$EXIT@$LINE"
|
|
||||||
msg "$FLAG $REASON"
|
|
||||||
[ ! -z ${CTID-} ] && cleanup_ctid
|
|
||||||
exit $EXIT
|
|
||||||
}
|
|
||||||
function warn() {
|
|
||||||
local REASON="\e[97m$1\e[39m"
|
|
||||||
local FLAG="\e[93m[WARNING]\e[39m"
|
|
||||||
msg "$FLAG $REASON"
|
|
||||||
}
|
|
||||||
function info() {
|
|
||||||
local REASON="$1"
|
|
||||||
local FLAG="\e[36m[INFO]\e[39m"
|
|
||||||
msg "$FLAG $REASON"
|
|
||||||
}
|
|
||||||
function msg() {
|
|
||||||
local TEXT="$1"
|
|
||||||
echo -e "$TEXT"
|
|
||||||
}
|
|
||||||
function cleanup_ctid() {
|
|
||||||
if [ ! -z ${MOUNT+x} ]; then
|
|
||||||
pct unmount $CTID
|
|
||||||
fi
|
|
||||||
if $(pct status $CTID &>/dev/null); then
|
|
||||||
if [ "$(pct status $CTID | awk '{print $2}')" == "running" ]; then
|
|
||||||
pct stop $CTID
|
|
||||||
fi
|
|
||||||
pct destroy $CTID
|
|
||||||
elif [ "$(pvesm list $STORAGE --vmid $CTID)" != "" ]; then
|
|
||||||
pvesm free $ROOTFS
|
|
||||||
fi
|
|
||||||
}
|
|
||||||
function cleanup() {
|
|
||||||
popd >/dev/null
|
|
||||||
rm -rf $TEMP_DIR
|
|
||||||
}
|
|
||||||
function load_module() {
|
|
||||||
if ! $(lsmod | grep -Fq $1); then
|
|
||||||
modprobe $1 &>/dev/null || \
|
|
||||||
die "Failed to load '$1' module."
|
|
||||||
fi
|
|
||||||
MODULES_PATH=/etc/modules
|
|
||||||
if ! $(grep -Fxq "$1" $MODULES_PATH); then
|
|
||||||
echo "$1" >> $MODULES_PATH || \
|
|
||||||
die "Failed to add '$1' module to load at boot."
|
|
||||||
fi
|
|
||||||
}
|
|
||||||
TEMP_DIR=$(mktemp -d)
|
|
||||||
pushd $TEMP_DIR >/dev/null
|
|
||||||
|
|
||||||
wget -qL https://raw.githubusercontent.com/tteck/Proxmox/main/setup/adguard_setup.sh
|
|
||||||
|
|
||||||
load_module overlay
|
|
||||||
|
|
||||||
while read -r line; do
|
|
||||||
TAG=$(echo $line | awk '{print $1}')
|
|
||||||
TYPE=$(echo $line | awk '{printf "%-10s", $2}')
|
|
||||||
FREE=$(echo $line | numfmt --field 4-6 --from-unit=K --to=iec --format %.2f | awk '{printf( "%9sB", $6)}')
|
|
||||||
ITEM=" Type: $TYPE Free: $FREE "
|
|
||||||
OFFSET=2
|
|
||||||
if [[ $((${#ITEM} + $OFFSET)) -gt ${MSG_MAX_LENGTH:-} ]]; then
|
|
||||||
MSG_MAX_LENGTH=$((${#ITEM} + $OFFSET))
|
|
||||||
fi
|
|
||||||
STORAGE_MENU+=( "$TAG" "$ITEM" "OFF" )
|
|
||||||
done < <(pvesm status -content rootdir | awk 'NR>1')
|
|
||||||
if [ $((${#STORAGE_MENU[@]}/3)) -eq 0 ]; then
|
|
||||||
warn "'Container' needs to be selected for at least one storage location."
|
|
||||||
die "Unable to detect valid storage location."
|
|
||||||
elif [ $((${#STORAGE_MENU[@]}/3)) -eq 1 ]; then
|
|
||||||
STORAGE=${STORAGE_MENU[0]}
|
|
||||||
else
|
|
||||||
while [ -z "${STORAGE:+x}" ]; do
|
|
||||||
STORAGE=$(whiptail --title "Storage Pools" --radiolist \
|
|
||||||
"Which storage pool you would like to use for the container?\n\n" \
|
|
||||||
16 $(($MSG_MAX_LENGTH + 23)) 6 \
|
|
||||||
"${STORAGE_MENU[@]}" 3>&1 1>&2 2>&3) || exit
|
|
||||||
done
|
|
||||||
fi
|
|
||||||
info "Using '$STORAGE' for storage location."
|
|
||||||
|
|
||||||
CTID=$(pvesh get /cluster/nextid)
|
|
||||||
info "LXC ID is $CTID."
|
|
||||||
|
|
||||||
echo -e "${CHECKMARK} \e[1;92m Updating LXC Template List... \e[0m"
|
|
||||||
pveam update >/dev/null
|
|
||||||
|
|
||||||
echo -e "${CHECKMARK} \e[1;92m Downloading LXC Template... \e[0m"
|
|
||||||
OSTYPE=debian
|
|
||||||
OSVERSION=${OSTYPE}-11
|
|
||||||
mapfile -t TEMPLATES < <(pveam available -section system | sed -n "s/.*\($OSVERSION.*\)/\1/p" | sort -t - -k 2 -V)
|
|
||||||
TEMPLATE="${TEMPLATES[-1]}"
|
|
||||||
pveam download local $TEMPLATE >/dev/null ||
|
|
||||||
die "A problem occured while downloading the LXC template."
|
|
||||||
|
|
||||||
STORAGE_TYPE=$(pvesm status -storage $STORAGE | awk 'NR>1 {print $2}')
|
|
||||||
case $STORAGE_TYPE in
|
|
||||||
dir|nfs)
|
|
||||||
DISK_EXT=".raw"
|
|
||||||
DISK_REF="$CTID/"
|
|
||||||
;;
|
|
||||||
zfspool)
|
|
||||||
DISK_PREFIX="subvol"
|
|
||||||
DISK_FORMAT="subvol"
|
|
||||||
;;
|
|
||||||
esac
|
|
||||||
DISK=${DISK_PREFIX:-vm}-${CTID}-disk-0${DISK_EXT-}
|
|
||||||
ROOTFS=${STORAGE}:${DISK_REF-}${DISK}
|
|
||||||
|
|
||||||
echo -e "${CHECKMARK} \e[1;92m Creating LXC... \e[0m"
|
|
||||||
DISK_SIZE=2G
|
|
||||||
pvesm alloc $STORAGE $CTID $DISK $DISK_SIZE --format ${DISK_FORMAT:-raw} >/dev/null
|
|
||||||
if [ "$STORAGE_TYPE" == "zfspool" ]; then
|
|
||||||
warn "Some containers may not work properly due to ZFS not supporting 'fallocate'."
|
|
||||||
else
|
|
||||||
mkfs.ext4 $(pvesm path $ROOTFS) &>/dev/null
|
|
||||||
fi
|
|
||||||
ARCH=$(dpkg --print-architecture)
|
|
||||||
HOSTNAME=adguard
|
|
||||||
TEMPLATE_STRING="local:vztmpl/${TEMPLATE}"
|
|
||||||
pct create $CTID $TEMPLATE_STRING -arch $ARCH -features nesting=1 \
|
|
||||||
-hostname $HOSTNAME -net0 name=eth0,bridge=vmbr0,ip=dhcp -onboot 1 -cores 1 -memory 512 \
|
|
||||||
-ostype $OSTYPE -rootfs $ROOTFS,size=$DISK_SIZE -storage $STORAGE >/dev/null
|
|
||||||
|
|
||||||
MOUNT=$(pct mount $CTID | cut -d"'" -f 2)
|
|
||||||
ln -fs $(readlink /etc/localtime) ${MOUNT}/etc/localtime
|
|
||||||
pct unmount $CTID && unset MOUNT
|
|
||||||
|
|
||||||
echo -e "${CHECKMARK} \e[1;92m Starting LXC... \e[0m"
|
|
||||||
pct start $CTID
|
|
||||||
pct push $CTID adguard_setup.sh /adguard_setup.sh -perms 755
|
|
||||||
pct exec $CTID /adguard_setup.sh
|
|
||||||
|
|
||||||
IP=$(pct exec $CTID ip a s dev eth0 | sed -n '/inet / s/\// /p' | awk '{print $2}')
|
|
||||||
info "Successfully created a AdGuard Home LXC to $CTID"
|
|
||||||
echo -e "\e[1;92m AdGuard Home Setup should be reachable by going to the following URL.
|
|
||||||
http://${IP}:3000
|
|
||||||
\e[0m"
|
|
256
ct/adguard-v2.sh
256
ct/adguard-v2.sh
|
@ -1,256 +0,0 @@
|
||||||
#!/usr/bin/env bash
|
|
||||||
|
|
||||||
YW=`echo "\033[33m"`
|
|
||||||
BL=`echo "\033[36m"`
|
|
||||||
RD=`echo "\033[01;31m"`
|
|
||||||
CM='\xE2\x9C\x94\033'
|
|
||||||
GN=`echo "\033[1;92m"`
|
|
||||||
CL=`echo "\033[m"`
|
|
||||||
while true; do
|
|
||||||
read -p "This will create a New Adguard Home LXC. Proceed(y/n)?" yn
|
|
||||||
case $yn in
|
|
||||||
[Yy]* ) break;;
|
|
||||||
[Nn]* ) exit;;
|
|
||||||
* ) echo "Please answer yes or no.";;
|
|
||||||
esac
|
|
||||||
done
|
|
||||||
clear
|
|
||||||
function header_info {
|
|
||||||
echo -e "${GN}
|
|
||||||
_ _
|
|
||||||
/\ | | | |
|
|
||||||
/ \ __| | __ _ _ _ __ _ _ __ __| |
|
|
||||||
/ /\ \ / _ |/ _ | | | |/ _ | __/ _ |
|
|
||||||
/ ____ \ (_| | (_| | |_| | (_| | | | (_| |
|
|
||||||
/_/ \_\__,_|\__, |\__,_|\__,_|_| \__,_|
|
|
||||||
__/ |
|
|
||||||
|___/
|
|
||||||
|
|
||||||
${CL}"
|
|
||||||
}
|
|
||||||
|
|
||||||
header_info
|
|
||||||
show_menu(){
|
|
||||||
printf " ${YW} 1)${YW} Privileged ${CL}\n"
|
|
||||||
printf " ${YW} 2)${GN} Unprivileged ${CL}\n"
|
|
||||||
|
|
||||||
printf "Please choose a Install Method and hit enter or ${RD}x${CL} to exit."
|
|
||||||
read opt
|
|
||||||
}
|
|
||||||
|
|
||||||
option_picked(){
|
|
||||||
message1=${@:-"${CL}Error: No message passed"}
|
|
||||||
printf " ${YW}${message1}${CL}\n"
|
|
||||||
}
|
|
||||||
show_menu
|
|
||||||
while [ "$opt" != " " ]
|
|
||||||
do
|
|
||||||
case $opt in
|
|
||||||
1) clear;
|
|
||||||
header_info;
|
|
||||||
option_picked "Using Privileged Install";
|
|
||||||
IM=0
|
|
||||||
break;
|
|
||||||
;;
|
|
||||||
2) clear;
|
|
||||||
header_info;
|
|
||||||
option_picked "Using Unprivileged Install";
|
|
||||||
IM=1
|
|
||||||
break;
|
|
||||||
;;
|
|
||||||
|
|
||||||
x)exit;
|
|
||||||
;;
|
|
||||||
\n)exit;
|
|
||||||
;;
|
|
||||||
*)clear;
|
|
||||||
option_picked "Please choose a Install Method from the menu";
|
|
||||||
show_menu;
|
|
||||||
;;
|
|
||||||
esac
|
|
||||||
done
|
|
||||||
show_menu2(){
|
|
||||||
printf " ${YW} 1)${GN} Use Automatic Login ${CL}\n"
|
|
||||||
printf " ${YW} 2)${GN} Use Password (changeme) ${CL}\n"
|
|
||||||
|
|
||||||
printf "Please choose a Password Type and hit enter or ${RD}x${CL} to exit."
|
|
||||||
read opt
|
|
||||||
}
|
|
||||||
|
|
||||||
option_picked(){
|
|
||||||
message2=${@:-"${CL}Error: No message passed"}
|
|
||||||
printf " ${YW}${message1}${CL}\n"
|
|
||||||
printf " ${YW}${message2}${CL}\n"
|
|
||||||
}
|
|
||||||
show_menu2
|
|
||||||
while [ "$opt" != " " ]
|
|
||||||
do
|
|
||||||
case $opt in
|
|
||||||
1) clear;
|
|
||||||
header_info;
|
|
||||||
option_picked "Using Automatic Login";
|
|
||||||
PW=" "
|
|
||||||
break;
|
|
||||||
;;
|
|
||||||
2) clear;
|
|
||||||
header_info;
|
|
||||||
option_picked "Using Password (changeme)";
|
|
||||||
PW="-password changeme"
|
|
||||||
break;
|
|
||||||
;;
|
|
||||||
|
|
||||||
x)exit;
|
|
||||||
;;
|
|
||||||
\n)exit;
|
|
||||||
;;
|
|
||||||
*)clear;
|
|
||||||
option_picked "Please choose a Password Type from the menu";
|
|
||||||
show_menu2;
|
|
||||||
;;
|
|
||||||
esac
|
|
||||||
done
|
|
||||||
show_menu3(){
|
|
||||||
printf " ${YW} 1)${GN} Automatic DHCP ${CL}\n"
|
|
||||||
printf " ${YW} 2)${GN} Manual DHCP ${CL}\n"
|
|
||||||
|
|
||||||
printf "Please choose a DHCP Type and hit enter or ${RD}x${CL} to exit."
|
|
||||||
read opt
|
|
||||||
}
|
|
||||||
|
|
||||||
option_picked(){
|
|
||||||
message3=${@:-"${CL}Error: No message passed"}
|
|
||||||
printf " ${YW}${message1}${CL}\n"
|
|
||||||
printf " ${YW}${message2}${CL}\n"
|
|
||||||
printf " ${YW}${message3}${CL}\n"
|
|
||||||
}
|
|
||||||
show_menu3
|
|
||||||
while [ "$opt" != " " ]
|
|
||||||
do
|
|
||||||
case $opt in
|
|
||||||
1) clear;
|
|
||||||
header_info;
|
|
||||||
option_picked "Using Automatic DHCP";
|
|
||||||
DHCP=" "
|
|
||||||
break;
|
|
||||||
;;
|
|
||||||
2) clear;
|
|
||||||
header_info;
|
|
||||||
option_picked "Using Manual DHCP";
|
|
||||||
DHCP="1"
|
|
||||||
break;
|
|
||||||
;;
|
|
||||||
|
|
||||||
x)exit;
|
|
||||||
;;
|
|
||||||
\n)exit;
|
|
||||||
;;
|
|
||||||
*)clear;
|
|
||||||
option_picked "Please choose a DHCP Type from the menu";
|
|
||||||
show_menu3;
|
|
||||||
;;
|
|
||||||
esac
|
|
||||||
done
|
|
||||||
|
|
||||||
set -o errexit
|
|
||||||
set -o errtrace
|
|
||||||
set -o nounset
|
|
||||||
set -o pipefail
|
|
||||||
shopt -s expand_aliases
|
|
||||||
alias die='EXIT=$? LINE=$LINENO error_exit'
|
|
||||||
trap die ERR
|
|
||||||
trap cleanup EXIT
|
|
||||||
|
|
||||||
function error_exit() {
|
|
||||||
trap - ERR
|
|
||||||
local DEFAULT='Unknown failure occured.'
|
|
||||||
local REASON="\e[97m${1:-$DEFAULT}\e[39m"
|
|
||||||
local FLAG="\e[91m[ERROR] \e[93m$EXIT@$LINE"
|
|
||||||
msg "$FLAG $REASON"
|
|
||||||
[ ! -z ${CTID-} ] && cleanup_ctid
|
|
||||||
exit $EXIT
|
|
||||||
}
|
|
||||||
function warn() {
|
|
||||||
local REASON="\e[97m$1\e[39m"
|
|
||||||
local FLAG="\e[93m[WARNING]\e[39m"
|
|
||||||
msg "$FLAG $REASON"
|
|
||||||
}
|
|
||||||
function info() {
|
|
||||||
local REASON="$1"
|
|
||||||
local FLAG="\e[36m[INFO]\e[39m"
|
|
||||||
msg "$FLAG $REASON"
|
|
||||||
}
|
|
||||||
function msg() {
|
|
||||||
local TEXT="$1"
|
|
||||||
echo -e "$TEXT"
|
|
||||||
}
|
|
||||||
function cleanup_ctid() {
|
|
||||||
if $(pct status $CTID &>/dev/null); then
|
|
||||||
if [ "$(pct status $CTID | awk '{print $2}')" == "running" ]; then
|
|
||||||
pct stop $CTID
|
|
||||||
fi
|
|
||||||
pct destroy $CTID
|
|
||||||
elif [ "$(pvesm list $STORAGE --vmid $CTID)" != "" ]; then
|
|
||||||
pvesm free $ROOTFS
|
|
||||||
fi
|
|
||||||
}
|
|
||||||
function cleanup() {
|
|
||||||
popd >/dev/null
|
|
||||||
rm -rf $TEMP_DIR
|
|
||||||
}
|
|
||||||
if [ "$IM" == "1" ]; then
|
|
||||||
FEATURES="nesting=1,keyctl=1"
|
|
||||||
else
|
|
||||||
FEATURES="nesting=1"
|
|
||||||
fi
|
|
||||||
|
|
||||||
TEMP_DIR=$(mktemp -d)
|
|
||||||
pushd $TEMP_DIR >/dev/null
|
|
||||||
|
|
||||||
export CTID=$(pvesh get /cluster/nextid)
|
|
||||||
export PCT_OSTYPE=debian
|
|
||||||
export PCT_OSVERSION=11
|
|
||||||
export PCT_DISK_SIZE=2
|
|
||||||
export PCT_OPTIONS="
|
|
||||||
-features $FEATURES
|
|
||||||
-hostname adguard
|
|
||||||
-net0 name=eth0,bridge=vmbr0,ip=dhcp
|
|
||||||
-onboot 1
|
|
||||||
-cores 1
|
|
||||||
-memory 512
|
|
||||||
-unprivileged ${IM}
|
|
||||||
${PW}
|
|
||||||
"
|
|
||||||
bash -c "$(wget -qLO - https://raw.githubusercontent.com/tteck/Proxmox/main/ct/create_lxc.sh)" || exit
|
|
||||||
|
|
||||||
STORAGE_TYPE=$(pvesm status -storage $(pct config $CTID | grep rootfs | awk -F ":" '{print $2}') | awk 'NR>1 {print $2}')
|
|
||||||
if [ "$STORAGE_TYPE" == "zfspool" ]; then
|
|
||||||
warn "Some addons may not work due to ZFS not supporting 'fallocate'."
|
|
||||||
fi
|
|
||||||
if [ "$DHCP" == "1" ]; then
|
|
||||||
MAC=$(pct config $CTID \
|
|
||||||
| grep -i hwaddr \
|
|
||||||
| awk '{print substr($2, 31, length($3) 17 ) }') \
|
|
||||||
|
|
||||||
echo -e "MAC Address ${BL}$MAC${CL}"
|
|
||||||
|
|
||||||
dhcp_reservation(){
|
|
||||||
printf "Please set DHCP reservation and press Enter."
|
|
||||||
read
|
|
||||||
}
|
|
||||||
dhcp_reservation
|
|
||||||
fi
|
|
||||||
|
|
||||||
echo -en "${GN} Starting LXC Container... "
|
|
||||||
pct start $CTID
|
|
||||||
echo -e "${CM}${CL} \r"
|
|
||||||
|
|
||||||
alias lxc-cmd="lxc-attach -n $CTID --"
|
|
||||||
|
|
||||||
lxc-cmd bash -c "$(wget -qLO - https://raw.githubusercontent.com/tteck/Proxmox/main/setup/adguard-install.sh)" || exit
|
|
||||||
|
|
||||||
IP=$(pct exec $CTID ip a s dev eth0 | sed -n '/inet / s/\// /p' | awk '{print $2}')
|
|
||||||
|
|
||||||
echo -e "${GN}Successfully created Adguard Home LXC to${CL} ${BL}$CTID${CL}.
|
|
||||||
${GN}Adguard${CL} Setup should be reachable by going to the following URL.
|
|
||||||
${BL}http://${IP}:3000${CL} \n"
|
|
||||||
|
|
358
ct/adguard-v3.sh
358
ct/adguard-v3.sh
|
@ -1,358 +0,0 @@
|
||||||
#!/usr/bin/env bash
|
|
||||||
echo -e "Loading..."
|
|
||||||
NEXTID=$(pvesh get /cluster/nextid)
|
|
||||||
INTEGER='^[0-9]+$'
|
|
||||||
YW=`echo "\033[33m"`
|
|
||||||
BL=`echo "\033[36m"`
|
|
||||||
RD=`echo "\033[01;31m"`
|
|
||||||
BGN=`echo "\033[4;92m"`
|
|
||||||
GN=`echo "\033[1;92m"`
|
|
||||||
DGN=`echo "\033[32m"`
|
|
||||||
CL=`echo "\033[m"`
|
|
||||||
BFR="\\r\\033[K"
|
|
||||||
HOLD="-"
|
|
||||||
CM="${GN}✓${CL}"
|
|
||||||
APP="Adguard"
|
|
||||||
NSAPP=$(echo ${APP,,} | tr -d ' ')
|
|
||||||
set -o errexit
|
|
||||||
set -o errtrace
|
|
||||||
set -o nounset
|
|
||||||
set -o pipefail
|
|
||||||
shopt -s expand_aliases
|
|
||||||
alias die='EXIT=$? LINE=$LINENO error_exit'
|
|
||||||
trap die ERR
|
|
||||||
|
|
||||||
function error_exit() {
|
|
||||||
trap - ERR
|
|
||||||
local reason="Unknown failure occurred."
|
|
||||||
local msg="${1:-$reason}"
|
|
||||||
local flag="${RD}‼ ERROR ${CL}$EXIT@$LINE"
|
|
||||||
echo -e "$flag $msg" 1>&2
|
|
||||||
exit $EXIT
|
|
||||||
}
|
|
||||||
|
|
||||||
while true; do
|
|
||||||
clear
|
|
||||||
read -p "This will create a New ${APP} LXC. Proceed(y/n)?" yn
|
|
||||||
case $yn in
|
|
||||||
[Yy]* ) break;;
|
|
||||||
[Nn]* ) exit;;
|
|
||||||
* ) echo "Please answer yes or no.";;
|
|
||||||
esac
|
|
||||||
done
|
|
||||||
clear
|
|
||||||
function header_info {
|
|
||||||
echo -e "${GN}
|
|
||||||
_ _
|
|
||||||
/\ | | | |
|
|
||||||
/ \ __| | __ _ _ _ __ _ _ __ __| |
|
|
||||||
/ /\ \ / _ |/ _ | | | |/ _ | __/ _ |
|
|
||||||
/ ____ \ (_| | (_| | |_| | (_| | | | (_| |
|
|
||||||
/_/ \_\__,_|\__, |\__,_|\__,_|_| \__,_|
|
|
||||||
v3__/ |
|
|
||||||
|___/
|
|
||||||
${CL}"
|
|
||||||
}
|
|
||||||
|
|
||||||
header_info
|
|
||||||
|
|
||||||
function msg_info() {
|
|
||||||
local msg="$1"
|
|
||||||
echo -ne " ${HOLD} ${YW}${msg}..."
|
|
||||||
}
|
|
||||||
|
|
||||||
function msg_ok() {
|
|
||||||
local msg="$1"
|
|
||||||
echo -e "${BFR} ${CM} ${GN}${msg}${CL}"
|
|
||||||
}
|
|
||||||
|
|
||||||
function PVE_CHECK() {
|
|
||||||
PVE=$(pveversion | grep "pve-manager/7" | wc -l)
|
|
||||||
|
|
||||||
if [[ $PVE != 1 ]]; then
|
|
||||||
echo -e "${RD}This script requires Proxmox Virtual Environment 7.0 or greater${CL}"
|
|
||||||
echo -e "Exiting..."
|
|
||||||
sleep 2
|
|
||||||
exit
|
|
||||||
fi
|
|
||||||
}
|
|
||||||
|
|
||||||
function default_settings() {
|
|
||||||
clear
|
|
||||||
header_info
|
|
||||||
echo -e "${BL}Using Default Settings${CL}"
|
|
||||||
echo -e "${DGN}Using CT Type ${BGN}Unprivileged${CL} ${RD}NO DEVICE PASSTHROUGH${CL}"
|
|
||||||
CT_TYPE="1"
|
|
||||||
echo -e "${DGN}Using CT Password ${BGN}Automatic Login${CL}"
|
|
||||||
PW=" "
|
|
||||||
echo -e "${DGN}Using CT ID ${BGN}$NEXTID${CL}"
|
|
||||||
CT_ID=$NEXTID
|
|
||||||
echo -e "${DGN}Using CT Name ${BGN}$NSAPP${CL}"
|
|
||||||
HN=$NSAPP
|
|
||||||
echo -e "${DGN}Using Disk Size ${BGN}2${CL}${DGN}GB${CL}"
|
|
||||||
DISK_SIZE="2"
|
|
||||||
echo -e "${DGN}Using ${BGN}1${CL}${DGN}vCPU${CL}"
|
|
||||||
CORE_COUNT="1"
|
|
||||||
echo -e "${DGN}Using ${BGN}512${CL}${DGN}MiB RAM${CL}"
|
|
||||||
RAM_SIZE="512"
|
|
||||||
echo -e "${DGN}Using Bridge ${BGN}vmbr0${CL}"
|
|
||||||
BRG="vmbr0"
|
|
||||||
echo -e "${DGN}Using Static IP Address ${BGN}DHCP${CL}"
|
|
||||||
NET=dhcp
|
|
||||||
echo -e "${DGN}Using Gateway Address ${BGN}NONE${CL}"
|
|
||||||
GATE=""
|
|
||||||
echo -e "${DGN}Using VLAN Tag ${BGN}NONE${CL}"
|
|
||||||
VLAN=""
|
|
||||||
}
|
|
||||||
|
|
||||||
function advanced_settings() {
|
|
||||||
clear
|
|
||||||
header_info
|
|
||||||
echo -e "${RD}Using Advanced Settings${CL}"
|
|
||||||
echo -e "${YW}Type Privileged, or Press [ENTER] for Default: Unprivileged (${RD}NO DEVICE PASSTHROUGH${CL}${YW})"
|
|
||||||
read CT_TYPE1
|
|
||||||
if [ -z $CT_TYPE1 ]; then CT_TYPE1="Unprivileged" CT_TYPE="1";
|
|
||||||
echo -en "${DGN}Set CT Type ${BL}$CT_TYPE1${CL}"
|
|
||||||
else
|
|
||||||
CT_TYPE1="Privileged"
|
|
||||||
CT_TYPE="0"
|
|
||||||
echo -en "${DGN}Set CT Type ${BL}Privileged${CL}"
|
|
||||||
fi;
|
|
||||||
echo -e " ${CM}${CL} \r"
|
|
||||||
sleep 1
|
|
||||||
clear
|
|
||||||
header_info
|
|
||||||
echo -e "${RD}Using Advanced Settings${CL}"
|
|
||||||
echo -e "${DGN}Using CT Type ${BGN}$CT_TYPE1${CL}"
|
|
||||||
echo -e "${YW}Set Password, or Press [ENTER] for Default: Automatic Login "
|
|
||||||
read PW1
|
|
||||||
if [ -z $PW1 ]; then PW1="Automatic Login" PW=" ";
|
|
||||||
echo -en "${DGN}Set CT ${BL}$PW1${CL}"
|
|
||||||
else
|
|
||||||
PW="-password $PW1"
|
|
||||||
echo -en "${DGN}Set CT Password ${BL}$PW1${CL}"
|
|
||||||
fi;
|
|
||||||
echo -e " ${CM}${CL} \r"
|
|
||||||
sleep 1
|
|
||||||
clear
|
|
||||||
header_info
|
|
||||||
echo -e "${RD}Using Advanced Settings${CL}"
|
|
||||||
echo -e "${DGN}Using CT Type ${BGN}$CT_TYPE1${CL}"
|
|
||||||
echo -e "${DGN}Using CT Password ${BGN}$PW1${CL}"
|
|
||||||
echo -e "${YW}Enter the CT ID, or Press [ENTER] to automatically generate (${NEXTID}) "
|
|
||||||
read CT_ID
|
|
||||||
if [ -z $CT_ID ]; then CT_ID=$NEXTID; fi;
|
|
||||||
echo -en "${DGN}Set CT ID To ${BL}$CT_ID${CL}"
|
|
||||||
echo -e " ${CM}${CL} \r"
|
|
||||||
sleep 1
|
|
||||||
clear
|
|
||||||
header_info
|
|
||||||
echo -e "${RD}Using Advanced Settings${CL}"
|
|
||||||
echo -e "${DGN}Using CT Type ${BGN}$CT_TYPE1${CL}"
|
|
||||||
echo -e "${DGN}Using CT Password ${BGN}$PW1${CL}"
|
|
||||||
echo -e "${DGN}Using CT ID ${BGN}$CT_ID${CL}"
|
|
||||||
echo -e "${YW}Enter CT Name (no-spaces), or Press [ENTER] for Default: $NSAPP "
|
|
||||||
read CT_NAME
|
|
||||||
if [ -z $CT_NAME ]; then
|
|
||||||
HN=$NSAPP
|
|
||||||
else
|
|
||||||
HN=$(echo ${CT_NAME,,} | tr -d ' ')
|
|
||||||
fi
|
|
||||||
echo -en "${DGN}Set CT Name To ${BL}$HN${CL}"
|
|
||||||
echo -e " ${CM}${CL} \r"
|
|
||||||
sleep 1
|
|
||||||
clear
|
|
||||||
header_info
|
|
||||||
echo -e "${RD}Using Advanced Settings${CL}"
|
|
||||||
echo -e "${DGN}Using CT Type ${BGN}$CT_TYPE1${CL}"
|
|
||||||
echo -e "${DGN}Using CT Password ${BGN}$PW1${CL}"
|
|
||||||
echo -e "${DGN}Using CT ID ${BGN}$CT_ID${CL}"
|
|
||||||
echo -e "${DGN}Using CT Name ${BGN}$HN${CL}"
|
|
||||||
echo -e "${YW}Enter a Disk Size, or Press [ENTER] for Default: 2 "
|
|
||||||
read DISK_SIZE
|
|
||||||
if [ -z $DISK_SIZE ]; then DISK_SIZE="2"; fi;
|
|
||||||
if ! [[ $DISK_SIZE =~ $INTEGER ]] ; then echo "ERROR! DISK SIZE MUST HAVE INTEGER NUMBER!"; exit; fi;
|
|
||||||
echo -en "${DGN}Set Disk Size To ${BL}$DISK_SIZE${CL}${DGN}GB${CL}"
|
|
||||||
echo -e " ${CM}${CL} \r"
|
|
||||||
sleep 1
|
|
||||||
clear
|
|
||||||
header_info
|
|
||||||
echo -e "${RD}Using Advanced Settings${CL}"
|
|
||||||
echo -e "${DGN}Using CT Type ${BGN}$CT_TYPE1${CL}"
|
|
||||||
echo -e "${DGN}Using CT Password ${BGN}$PW1${CL}"
|
|
||||||
echo -e "${DGN}Using CT ID ${BGN}$CT_ID${CL}"
|
|
||||||
echo -e "${DGN}Using CT Name ${BGN}$HN${CL}"
|
|
||||||
echo -e "${DGN}Using Disk Size ${BGN}$DISK_SIZE${CL}${DGN}GB${CL}"
|
|
||||||
echo -e "${YW}Allocate CPU cores, or Press [ENTER] for Default: 1 "
|
|
||||||
read CORE_COUNT
|
|
||||||
if [ -z $CORE_COUNT ]; then CORE_COUNT="1"; fi;
|
|
||||||
echo -en "${DGN}Set Cores To ${BL}$CORE_COUNT${CL}${DGN}vCPU${CL}"
|
|
||||||
echo -e " ${CM}${CL} \r"
|
|
||||||
sleep 1
|
|
||||||
clear
|
|
||||||
header_info
|
|
||||||
echo -e "${RD}Using Advanced Settings${CL}"
|
|
||||||
echo -e "${DGN}Using CT Type ${BGN}$CT_TYPE1${CL}"
|
|
||||||
echo -e "${DGN}Using CT Password ${BGN}$PW1${CL}"
|
|
||||||
echo -e "${DGN}Using CT ID ${BGN}$CT_ID${CL}"
|
|
||||||
echo -e "${DGN}Using CT Name ${BGN}$HN${CL}"
|
|
||||||
echo -e "${DGN}Using Disk Size ${BGN}$DISK_SIZE${CL}${DGN}GB${CL}"
|
|
||||||
echo -e "${DGN}Using ${BGN}${CORE_COUNT}${CL}${DGN}vCPU${CL}"
|
|
||||||
echo -e "${YW}Allocate RAM in MiB, or Press [ENTER] for Default: 512 "
|
|
||||||
read RAM_SIZE
|
|
||||||
if [ -z $RAM_SIZE ]; then RAM_SIZE="512"; fi;
|
|
||||||
echo -en "${DGN}Set RAM To ${BL}$RAM_SIZE${CL}${DGN}MiB RAM${CL}"
|
|
||||||
echo -e " ${CM}${CL} \n"
|
|
||||||
sleep 1
|
|
||||||
clear
|
|
||||||
header_info
|
|
||||||
echo -e "${RD}Using Advanced Settings${CL}"
|
|
||||||
echo -e "${DGN}Using CT Type ${BGN}$CT_TYPE1${CL}"
|
|
||||||
echo -e "${DGN}Using CT Password ${BGN}$PW1${CL}"
|
|
||||||
echo -e "${DGN}Using CT ID ${BGN}$CT_ID${CL}"
|
|
||||||
echo -e "${DGN}Using CT Name ${BGN}$HN${CL}"
|
|
||||||
echo -e "${DGN}Using Disk Size ${BGN}$DISK_SIZE${CL}${DGN}GB${CL}"
|
|
||||||
echo -e "${DGN}Using ${BGN}${CORE_COUNT}${CL}${DGN}vCPU${CL}"
|
|
||||||
echo -e "${DGN}Using ${BGN}${RAM_SIZE}${CL}${DGN}MiB RAM${CL}"
|
|
||||||
echo -e "${YW}Enter a Bridge, or Press [ENTER] for Default: vmbr0 "
|
|
||||||
read BRG
|
|
||||||
if [ -z $BRG ]; then BRG="vmbr0"; fi;
|
|
||||||
echo -en "${DGN}Set Bridge To ${BL}$BRG${CL}"
|
|
||||||
echo -e " ${CM}${CL} \n"
|
|
||||||
sleep 1
|
|
||||||
clear
|
|
||||||
header_info
|
|
||||||
echo -e "${RD}Using Advanced Settings${CL}"
|
|
||||||
echo -e "${DGN}Using CT Type ${BGN}$CT_TYPE1${CL}"
|
|
||||||
echo -e "${DGN}Using CT Password ${BGN}$PW1${CL}"
|
|
||||||
echo -e "${DGN}Using CT ID ${BGN}$CT_ID${CL}"
|
|
||||||
echo -e "${DGN}Using CT Name ${BGN}$HN${CL}"
|
|
||||||
echo -e "${DGN}Using Disk Size ${BGN}$DISK_SIZE${CL}${DGN}GB${CL}"
|
|
||||||
echo -e "${DGN}Using ${BGN}${CORE_COUNT}${CL}${DGN}vCPU${CL}"
|
|
||||||
echo -e "${DGN}Using ${BGN}${RAM_SIZE}${CL}${DGN}MiB RAM${CL}"
|
|
||||||
echo -e "${DGN}Using Bridge ${BGN}${BRG}${CL}"
|
|
||||||
echo -e "${YW}Enter a Static IPv4 CIDR Address, or Press [ENTER] for Default: DHCP "
|
|
||||||
read NET
|
|
||||||
if [ -z $NET ]; then NET="dhcp"; fi;
|
|
||||||
echo -en "${DGN}Set Static IP Address To ${BL}$NET${CL}"
|
|
||||||
echo -e " ${CM}${CL} \n"
|
|
||||||
sleep 1
|
|
||||||
clear
|
|
||||||
header_info
|
|
||||||
echo -e "${RD}Using Advanced Settings${CL}"
|
|
||||||
echo -e "${DGN}Using CT Type ${BGN}$CT_TYPE1${CL}"
|
|
||||||
echo -e "${DGN}Using CT Password ${BGN}$PW1${CL}"
|
|
||||||
echo -e "${DGN}Using CT ID ${BGN}$CT_ID${CL}"
|
|
||||||
echo -e "${DGN}Using CT Name ${BGN}$HN${CL}"
|
|
||||||
echo -e "${DGN}Using Disk Size ${BGN}$DISK_SIZE${CL}${DGN}GB${CL}"
|
|
||||||
echo -e "${DGN}Using ${BGN}${CORE_COUNT}${CL}${DGN}vCPU${CL}"
|
|
||||||
echo -e "${DGN}Using ${BGN}${RAM_SIZE}${CL}${DGN}MiB RAM${CL}"
|
|
||||||
echo -e "${DGN}Using Bridge ${BGN}${BRG}${CL}"
|
|
||||||
echo -e "${DGN}Using Static IP Address ${BGN}$NET${CL}"
|
|
||||||
echo -e "${YW}Enter a Gateway IP (mandatory if static IP is used), or Press [ENTER] for Default: NONE "
|
|
||||||
read GATE1
|
|
||||||
if [ -z $GATE1 ]; then GATE1="NONE" GATE="";
|
|
||||||
echo -en "${DGN}Set Gateway IP To ${BL}$GATE1${CL}"
|
|
||||||
else
|
|
||||||
GATE=",gw=$GATE1"
|
|
||||||
echo -en "${DGN}Set Gateway IP To ${BL}$GATE1${CL}"
|
|
||||||
fi;
|
|
||||||
echo -e " ${CM}${CL} \n"
|
|
||||||
sleep 1
|
|
||||||
clear
|
|
||||||
header_info
|
|
||||||
|
|
||||||
echo -e "${RD}Using Advanced Settings${CL}"
|
|
||||||
echo -e "${DGN}Using CT Type ${BGN}$CT_TYPE1${CL}"
|
|
||||||
echo -e "${DGN}Using CT Password ${BGN}$PW1${CL}"
|
|
||||||
echo -e "${DGN}Using CT ID ${BGN}$CT_ID${CL}"
|
|
||||||
echo -e "${DGN}Using CT Name ${BGN}$HN${CL}"
|
|
||||||
echo -e "${DGN}Using Disk Size ${BGN}$DISK_SIZE${CL}${DGN}GB${CL}"
|
|
||||||
echo -e "${DGN}Using ${BGN}${CORE_COUNT}${CL}${DGN}vCPU${CL}"
|
|
||||||
echo -e "${DGN}Using ${BGN}${RAM_SIZE}${CL}${DGN}MiB RAM${CL}"
|
|
||||||
echo -e "${DGN}Using Bridge ${BGN}${BRG}${CL}"
|
|
||||||
echo -e "${DGN}Using Static IP Address ${BGN}$NET${CL}"
|
|
||||||
echo -e "${DGN}Using Gateway IP Address ${BGN}$GATE1${CL}"
|
|
||||||
echo -e "${YW}Enter a VLAN Tag, or Press [ENTER] for Default: NONE "
|
|
||||||
read VLAN1
|
|
||||||
if [ -z $VLAN1 ]; then VLAN1="NONE" VLAN="";
|
|
||||||
echo -en "${DGN}Set VLAN Tag To ${BL}$VLAN1${CL}"
|
|
||||||
else
|
|
||||||
VLAN=",tag=$VLAN1"
|
|
||||||
echo -en "${DGN}Set VLAN Tag To ${BL}$VLAN1${CL}"
|
|
||||||
fi;
|
|
||||||
echo -e " ${CM}${CL} \n"
|
|
||||||
sleep 1
|
|
||||||
clear
|
|
||||||
header_info
|
|
||||||
echo -e "${RD}Using Advanced Settings${CL}"
|
|
||||||
echo -e "${DGN}Using CT Type ${BGN}$CT_TYPE1${CL}"
|
|
||||||
echo -e "${DGN}Using CT Password ${BGN}$PW1${CL}"
|
|
||||||
echo -e "${DGN}Using CT ID ${BGN}$CT_ID${CL}"
|
|
||||||
echo -e "${DGN}Using CT Name ${BGN}$HN${CL}"
|
|
||||||
echo -e "${DGN}Using Disk Size ${BGN}$DISK_SIZE${CL}${DGN}GB${CL}"
|
|
||||||
echo -e "${DGN}Using ${BGN}${CORE_COUNT}${CL}${DGN}vCPU${CL}"
|
|
||||||
echo -e "${DGN}Using ${BGN}${RAM_SIZE}${CL}${DGN}MiB RAM${CL}"
|
|
||||||
echo -e "${DGN}Using Bridge ${BGN}${BRG}${CL}"
|
|
||||||
echo -e "${DGN}Using Static IP Address ${BGN}$NET${CL}"
|
|
||||||
echo -e "${DGN}Using Gateway IP Address ${BGN}$GATE1${CL}"
|
|
||||||
echo -e "${DGN}Using VLAN Tag ${BGN}$VLAN1${CL}"
|
|
||||||
|
|
||||||
read -p "Are these settings correct(y/n)? " -n 1 -r
|
|
||||||
echo
|
|
||||||
if [[ ! $REPLY =~ ^[Yy]$ ]]
|
|
||||||
then
|
|
||||||
advanced_settings
|
|
||||||
fi
|
|
||||||
}
|
|
||||||
|
|
||||||
function start_script() {
|
|
||||||
echo -e "${YW}Type Advanced, or Press [ENTER] for Default Settings "
|
|
||||||
read SETTINGS
|
|
||||||
if [ -z $SETTINGS ]; then default_settings;
|
|
||||||
else
|
|
||||||
advanced_settings
|
|
||||||
fi;
|
|
||||||
}
|
|
||||||
|
|
||||||
start_script
|
|
||||||
|
|
||||||
if [ "$CT_TYPE" == "1" ]; then
|
|
||||||
FEATURES="nesting=1,keyctl=1"
|
|
||||||
else
|
|
||||||
FEATURES="nesting=1"
|
|
||||||
fi
|
|
||||||
|
|
||||||
TEMP_DIR=$(mktemp -d)
|
|
||||||
pushd $TEMP_DIR >/dev/null
|
|
||||||
|
|
||||||
export CTID=$CT_ID
|
|
||||||
export PCT_OSTYPE=debian
|
|
||||||
export PCT_OSVERSION=11
|
|
||||||
export PCT_DISK_SIZE=$DISK_SIZE
|
|
||||||
export PCT_OPTIONS="
|
|
||||||
-features $FEATURES
|
|
||||||
-hostname $HN
|
|
||||||
-net0 name=eth0,bridge=$BRG,ip=$NET$GATE$VLAN
|
|
||||||
-onboot 1
|
|
||||||
-cores $CORE_COUNT
|
|
||||||
-memory $RAM_SIZE
|
|
||||||
-unprivileged $CT_TYPE
|
|
||||||
$PW
|
|
||||||
"
|
|
||||||
bash -c "$(wget -qLO - https://raw.githubusercontent.com/tteck/Proxmox/main/ct/create_lxc.sh)" || exit
|
|
||||||
|
|
||||||
msg_info "Starting LXC Container"
|
|
||||||
pct start $CTID
|
|
||||||
msg_ok "Started LXC Container"
|
|
||||||
|
|
||||||
lxc-attach -n $CTID -- bash -c "$(wget -qLO - https://raw.githubusercontent.com/tteck/Proxmox/main/setup/adguard-install.sh)" || exit
|
|
||||||
|
|
||||||
IP=$(pct exec $CTID ip a s dev eth0 | sed -n '/inet / s/\// /p' | awk '{print $2}')
|
|
||||||
|
|
||||||
pct set $CTID -description "# AdGuard Home LXC
|
|
||||||
### https://github.com/tteck/Proxmox"
|
|
||||||
|
|
||||||
msg_ok "Completed Successfully!\n"
|
|
||||||
echo -e "Adguard Setup should be reachable by going to the following URL.
|
|
||||||
${BL}http://${IP}:3000${CL} \n"
|
|
|
@ -310,7 +310,7 @@ bash -c "$(wget -qLO - https://raw.githubusercontent.com/tteck/Proxmox/main/ct/c
|
||||||
msg_info "Starting LXC Container"
|
msg_info "Starting LXC Container"
|
||||||
pct start $CTID
|
pct start $CTID
|
||||||
msg_ok "Started LXC Container"
|
msg_ok "Started LXC Container"
|
||||||
lxc-attach -n $CTID -- bash -c "$(wget -qLO - https://raw.githubusercontent.com/tteck/Proxmox/main/setup/$var_install.sh)" || exit
|
lxc-attach -n $CTID -- bash -c "$(wget -qLO - https://raw.githubusercontent.com/tteck/Proxmox/main/install/$var_install.sh)" || exit
|
||||||
IP=$(pct exec $CTID ip a s dev eth0 | sed -n '/inet / s/\// /p' | awk '{print $2}')
|
IP=$(pct exec $CTID ip a s dev eth0 | sed -n '/inet / s/\// /p' | awk '{print $2}')
|
||||||
pct set $CTID -description "# ${APP} LXC
|
pct set $CTID -description "# ${APP} LXC
|
||||||
### https://tteck.github.io/Proxmox/
|
### https://tteck.github.io/Proxmox/
|
||||||
|
|
|
@ -310,7 +310,7 @@ bash -c "$(wget -qLO - https://raw.githubusercontent.com/tteck/Proxmox/main/ct/c
|
||||||
msg_info "Starting LXC Container"
|
msg_info "Starting LXC Container"
|
||||||
pct start $CTID
|
pct start $CTID
|
||||||
msg_ok "Started LXC Container"
|
msg_ok "Started LXC Container"
|
||||||
lxc-attach -n $CTID -- bash -c "$(wget -qLO - https://raw.githubusercontent.com/tteck/Proxmox/main/setup/$var_install.sh)" || exit
|
lxc-attach -n $CTID -- bash -c "$(wget -qLO - https://raw.githubusercontent.com/tteck/Proxmox/main/install/$var_install.sh)" || exit
|
||||||
IP=$(pct exec $CTID ip a s dev eth0 | sed -n '/inet / s/\// /p' | awk '{print $2}')
|
IP=$(pct exec $CTID ip a s dev eth0 | sed -n '/inet / s/\// /p' | awk '{print $2}')
|
||||||
pct set $CTID -description "# ${APP} LXC
|
pct set $CTID -description "# ${APP} LXC
|
||||||
### https://tteck.github.io/Proxmox/
|
### https://tteck.github.io/Proxmox/
|
||||||
|
|
|
@ -325,7 +325,7 @@ EOF
|
||||||
msg_info "Starting LXC Container"
|
msg_info "Starting LXC Container"
|
||||||
pct start $CTID
|
pct start $CTID
|
||||||
msg_ok "Started LXC Container"
|
msg_ok "Started LXC Container"
|
||||||
lxc-attach -n $CTID -- bash -c "$(wget -qLO - https://raw.githubusercontent.com/tteck/Proxmox/main/setup/$var_install.sh)" || exit
|
lxc-attach -n $CTID -- bash -c "$(wget -qLO - https://raw.githubusercontent.com/tteck/Proxmox/main/install/$var_install.sh)" || exit
|
||||||
IP=$(pct exec $CTID ip a s dev eth0 | sed -n '/inet / s/\// /p' | awk '{print $2}')
|
IP=$(pct exec $CTID ip a s dev eth0 | sed -n '/inet / s/\// /p' | awk '{print $2}')
|
||||||
pct set $CTID -description "# ${APP} LXC
|
pct set $CTID -description "# ${APP} LXC
|
||||||
### https://tteck.github.io/Proxmox/
|
### https://tteck.github.io/Proxmox/
|
||||||
|
|
|
@ -310,7 +310,7 @@ bash -c "$(wget -qLO - https://raw.githubusercontent.com/tteck/Proxmox/main/ct/c
|
||||||
msg_info "Starting LXC Container"
|
msg_info "Starting LXC Container"
|
||||||
pct start $CTID
|
pct start $CTID
|
||||||
msg_ok "Started LXC Container"
|
msg_ok "Started LXC Container"
|
||||||
lxc-attach -n $CTID -- bash -c "$(wget -qLO - https://raw.githubusercontent.com/tteck/Proxmox/main/setup/$var_install.sh)" || exit
|
lxc-attach -n $CTID -- bash -c "$(wget -qLO - https://raw.githubusercontent.com/tteck/Proxmox/main/install/$var_install.sh)" || exit
|
||||||
IP=$(pct exec $CTID ip a s dev eth0 | sed -n '/inet / s/\// /p' | awk '{print $2}')
|
IP=$(pct exec $CTID ip a s dev eth0 | sed -n '/inet / s/\// /p' | awk '{print $2}')
|
||||||
pct set $CTID -description "# ${APP} LXC
|
pct set $CTID -description "# ${APP} LXC
|
||||||
### https://tteck.github.io/Proxmox/
|
### https://tteck.github.io/Proxmox/
|
||||||
|
|
|
@ -1,253 +0,0 @@
|
||||||
#!/usr/bin/env bash
|
|
||||||
YW=`echo "\033[33m"`
|
|
||||||
BL=`echo "\033[36m"`
|
|
||||||
RD=`echo "\033[01;31m"`
|
|
||||||
CM='\xE2\x9C\x94\033'
|
|
||||||
GN=`echo "\033[1;92m"`
|
|
||||||
CL=`echo "\033[m"`
|
|
||||||
while true; do
|
|
||||||
read -p "This will create a New Daemon Sync Server LXC. Proceed(y/n)?" yn
|
|
||||||
case $yn in
|
|
||||||
[Yy]* ) break;;
|
|
||||||
[Nn]* ) exit;;
|
|
||||||
* ) echo "Please answer yes or no.";;
|
|
||||||
esac
|
|
||||||
done
|
|
||||||
clear
|
|
||||||
function header_info {
|
|
||||||
echo -e "${BL}
|
|
||||||
_____ _____
|
|
||||||
| __ \ / ____|
|
|
||||||
| | | | __ _ ___ _ __ ___ ___ _ __ | (___ _ _ _ __ ___
|
|
||||||
| | | |/ _ |/ _ \ _ _ \ / _ \| _ \ \___ \| | | | _ \ / __|
|
|
||||||
| |__| | (_| | __/ | | | | | (_) | | | | ____) | |_| | | | | (__
|
|
||||||
|_____/ \__,_|\___|_| |_| |_|\___/|_| |_| |_____/ \__, |_| |_|\___|
|
|
||||||
__/ |
|
|
||||||
|___/
|
|
||||||
${CL}"
|
|
||||||
}
|
|
||||||
|
|
||||||
header_info
|
|
||||||
show_menu(){
|
|
||||||
printf " ${YW} 1)${YW} Privileged ${CL}\n"
|
|
||||||
printf " ${YW} 2)${GN} Unprivileged ${CL}\n"
|
|
||||||
|
|
||||||
printf "Please choose a Install Method and hit enter or ${RD}x${CL} to exit."
|
|
||||||
read opt
|
|
||||||
}
|
|
||||||
|
|
||||||
option_picked(){
|
|
||||||
message1=${@:-"${CL}Error: No message passed"}
|
|
||||||
printf " ${YW}${message1}${CL}\n"
|
|
||||||
}
|
|
||||||
show_menu
|
|
||||||
while [ "$opt" != " " ]
|
|
||||||
do
|
|
||||||
case $opt in
|
|
||||||
1) clear;
|
|
||||||
header_info;
|
|
||||||
option_picked "Using Privileged Install";
|
|
||||||
IM=0
|
|
||||||
break;
|
|
||||||
;;
|
|
||||||
2) clear;
|
|
||||||
header_info;
|
|
||||||
option_picked "Using Unprivileged Install";
|
|
||||||
IM=1
|
|
||||||
break;
|
|
||||||
;;
|
|
||||||
|
|
||||||
x)exit;
|
|
||||||
;;
|
|
||||||
\n)exit;
|
|
||||||
;;
|
|
||||||
*)clear;
|
|
||||||
option_picked "Please choose a Install Method from the menu";
|
|
||||||
show_menu;
|
|
||||||
;;
|
|
||||||
esac
|
|
||||||
done
|
|
||||||
show_menu2(){
|
|
||||||
printf " ${YW} 1)${GN} Use Automatic Login ${CL}\n"
|
|
||||||
printf " ${YW} 2)${GN} Use Password (changeme) ${CL}\n"
|
|
||||||
|
|
||||||
printf "Please choose a Password Type and hit enter or ${RD}x${CL} to exit."
|
|
||||||
read opt
|
|
||||||
}
|
|
||||||
|
|
||||||
option_picked(){
|
|
||||||
message2=${@:-"${CL}Error: No message passed"}
|
|
||||||
printf " ${YW}${message1}${CL}\n"
|
|
||||||
printf " ${YW}${message2}${CL}\n"
|
|
||||||
}
|
|
||||||
show_menu2
|
|
||||||
while [ "$opt" != " " ]
|
|
||||||
do
|
|
||||||
case $opt in
|
|
||||||
1) clear;
|
|
||||||
header_info;
|
|
||||||
option_picked "Using Automatic Login";
|
|
||||||
PW=" "
|
|
||||||
break;
|
|
||||||
;;
|
|
||||||
2) clear;
|
|
||||||
header_info;
|
|
||||||
option_picked "Using Password (changeme)";
|
|
||||||
PW="-password changeme"
|
|
||||||
break;
|
|
||||||
;;
|
|
||||||
|
|
||||||
x)exit;
|
|
||||||
;;
|
|
||||||
\n)exit;
|
|
||||||
;;
|
|
||||||
*)clear;
|
|
||||||
option_picked "Please choose a Password Type from the menu";
|
|
||||||
show_menu2;
|
|
||||||
;;
|
|
||||||
esac
|
|
||||||
done
|
|
||||||
show_menu3(){
|
|
||||||
printf " ${YW} 1)${GN} Automatic DHCP ${CL}\n"
|
|
||||||
printf " ${YW} 2)${GN} Manual DHCP ${CL}\n"
|
|
||||||
|
|
||||||
printf "Please choose a DHCP Type and hit enter or ${RD}x${CL} to exit."
|
|
||||||
read opt
|
|
||||||
}
|
|
||||||
|
|
||||||
option_picked(){
|
|
||||||
message3=${@:-"${CL}Error: No message passed"}
|
|
||||||
printf " ${YW}${message1}${CL}\n"
|
|
||||||
printf " ${YW}${message2}${CL}\n"
|
|
||||||
printf " ${YW}${message3}${CL}\n"
|
|
||||||
}
|
|
||||||
show_menu3
|
|
||||||
while [ "$opt" != " " ]
|
|
||||||
do
|
|
||||||
case $opt in
|
|
||||||
1) clear;
|
|
||||||
header_info;
|
|
||||||
option_picked "Using Automatic DHCP";
|
|
||||||
DHCP=" "
|
|
||||||
break;
|
|
||||||
;;
|
|
||||||
2) clear;
|
|
||||||
header_info;
|
|
||||||
option_picked "Using Manual DHCP";
|
|
||||||
DHCP="1"
|
|
||||||
break;
|
|
||||||
;;
|
|
||||||
|
|
||||||
x)exit;
|
|
||||||
;;
|
|
||||||
\n)exit;
|
|
||||||
;;
|
|
||||||
*)clear;
|
|
||||||
option_picked "Please choose a DHCP Type from the menu";
|
|
||||||
show_menu3;
|
|
||||||
;;
|
|
||||||
esac
|
|
||||||
done
|
|
||||||
|
|
||||||
set -o errexit
|
|
||||||
set -o errtrace
|
|
||||||
set -o nounset
|
|
||||||
set -o pipefail
|
|
||||||
shopt -s expand_aliases
|
|
||||||
alias die='EXIT=$? LINE=$LINENO error_exit'
|
|
||||||
trap die ERR
|
|
||||||
trap cleanup EXIT
|
|
||||||
|
|
||||||
function error_exit() {
|
|
||||||
trap - ERR
|
|
||||||
local DEFAULT='Unknown failure occured.'
|
|
||||||
local REASON="\e[97m${1:-$DEFAULT}\e[39m"
|
|
||||||
local FLAG="\e[91m[ERROR] \e[93m$EXIT@$LINE"
|
|
||||||
msg "$FLAG $REASON"
|
|
||||||
[ ! -z ${CTID-} ] && cleanup_ctid
|
|
||||||
exit $EXIT
|
|
||||||
}
|
|
||||||
function warn() {
|
|
||||||
local REASON="\e[97m$1\e[39m"
|
|
||||||
local FLAG="\e[93m[WARNING]\e[39m"
|
|
||||||
msg "$FLAG $REASON"
|
|
||||||
}
|
|
||||||
function info() {
|
|
||||||
local REASON="$1"
|
|
||||||
local FLAG="\e[36m[INFO]\e[39m"
|
|
||||||
msg "$FLAG $REASON"
|
|
||||||
}
|
|
||||||
function msg() {
|
|
||||||
local TEXT="$1"
|
|
||||||
echo -e "$TEXT"
|
|
||||||
}
|
|
||||||
function cleanup_ctid() {
|
|
||||||
if $(pct status $CTID &>/dev/null); then
|
|
||||||
if [ "$(pct status $CTID | awk '{print $2}')" == "running" ]; then
|
|
||||||
pct stop $CTID
|
|
||||||
fi
|
|
||||||
pct destroy $CTID
|
|
||||||
elif [ "$(pvesm list $STORAGE --vmid $CTID)" != "" ]; then
|
|
||||||
pvesm free $ROOTFS
|
|
||||||
fi
|
|
||||||
}
|
|
||||||
function cleanup() {
|
|
||||||
popd >/dev/null
|
|
||||||
rm -rf $TEMP_DIR
|
|
||||||
}
|
|
||||||
if [ "$IM" == "1" ]; then
|
|
||||||
FEATURES="nesting=1,keyctl=1"
|
|
||||||
else
|
|
||||||
FEATURES="nesting=1"
|
|
||||||
fi
|
|
||||||
|
|
||||||
TEMP_DIR=$(mktemp -d)
|
|
||||||
pushd $TEMP_DIR >/dev/null
|
|
||||||
|
|
||||||
export CTID=$(pvesh get /cluster/nextid)
|
|
||||||
export PCT_OSTYPE=debian
|
|
||||||
export PCT_OSVERSION=11
|
|
||||||
export PCT_DISK_SIZE=8
|
|
||||||
export PCT_OPTIONS="
|
|
||||||
-features $FEATURES
|
|
||||||
-hostname daemonsync
|
|
||||||
-net0 name=eth0,bridge=vmbr0,ip=dhcp
|
|
||||||
-onboot 1
|
|
||||||
-cores 1
|
|
||||||
-memory 512
|
|
||||||
-unprivileged ${IM}
|
|
||||||
${PW}
|
|
||||||
"
|
|
||||||
bash -c "$(wget -qLO - https://raw.githubusercontent.com/tteck/Proxmox/main/ct/create_lxc.sh)" || exit
|
|
||||||
|
|
||||||
STORAGE_TYPE=$(pvesm status -storage $(pct config $CTID | grep rootfs | awk -F ":" '{print $2}') | awk 'NR>1 {print $2}')
|
|
||||||
if [ "$STORAGE_TYPE" == "zfspool" ]; then
|
|
||||||
warn "Some addons may not work due to ZFS not supporting 'fallocate'."
|
|
||||||
fi
|
|
||||||
if [ "$DHCP" == "1" ]; then
|
|
||||||
MAC=$(pct config $CTID \
|
|
||||||
| grep -i hwaddr \
|
|
||||||
| awk '{print substr($2, 31, length($3) 17 ) }') \
|
|
||||||
|
|
||||||
echo -e "MAC Address ${BL}$MAC${CL}"
|
|
||||||
|
|
||||||
dhcp_reservation(){
|
|
||||||
printf "Please set DHCP reservation and press Enter."
|
|
||||||
read
|
|
||||||
}
|
|
||||||
dhcp_reservation
|
|
||||||
fi
|
|
||||||
|
|
||||||
echo -en "${GN} Starting LXC Container... "
|
|
||||||
pct start $CTID
|
|
||||||
echo -e "${CM}${CL} \r"
|
|
||||||
|
|
||||||
alias lxc-cmd="lxc-attach -n $CTID --"
|
|
||||||
|
|
||||||
lxc-cmd bash -c "$(wget -qLO - https://raw.githubusercontent.com/tteck/Proxmox/main/setup/daemonsync-install.sh)" || exit
|
|
||||||
|
|
||||||
IP=$(pct exec $CTID ip a s dev eth0 | sed -n '/inet / s/\// /p' | awk '{print $2}')
|
|
||||||
|
|
||||||
echo -e "${GN}Successfully created Daemon Sync Server LXC to${CL} ${BL}$CTID${CL}.
|
|
||||||
Daemon Sync should be reachable by going to the following URL.
|
|
||||||
${BL}http://${IP}:8084${CL} \n"
|
|
|
@ -1,358 +0,0 @@
|
||||||
#!/usr/bin/env bash
|
|
||||||
echo -e "Loading..."
|
|
||||||
NEXTID=$(pvesh get /cluster/nextid)
|
|
||||||
INTEGER='^[0-9]+$'
|
|
||||||
YW=`echo "\033[33m"`
|
|
||||||
BL=`echo "\033[36m"`
|
|
||||||
RD=`echo "\033[01;31m"`
|
|
||||||
BGN=`echo "\033[4;92m"`
|
|
||||||
GN=`echo "\033[1;92m"`
|
|
||||||
DGN=`echo "\033[32m"`
|
|
||||||
CL=`echo "\033[m"`
|
|
||||||
BFR="\\r\\033[K"
|
|
||||||
HOLD="-"
|
|
||||||
CM="${GN}✓${CL}"
|
|
||||||
APP="Daemon Sync"
|
|
||||||
NSAPP=$(echo ${APP,,} | tr -d ' ')
|
|
||||||
set -o errexit
|
|
||||||
set -o errtrace
|
|
||||||
set -o nounset
|
|
||||||
set -o pipefail
|
|
||||||
shopt -s expand_aliases
|
|
||||||
alias die='EXIT=$? LINE=$LINENO error_exit'
|
|
||||||
trap die ERR
|
|
||||||
|
|
||||||
function error_exit() {
|
|
||||||
trap - ERR
|
|
||||||
local reason="Unknown failure occurred."
|
|
||||||
local msg="${1:-$reason}"
|
|
||||||
local flag="${RD}‼ ERROR ${CL}$EXIT@$LINE"
|
|
||||||
echo -e "$flag $msg" 1>&2
|
|
||||||
exit $EXIT
|
|
||||||
}
|
|
||||||
|
|
||||||
while true; do
|
|
||||||
clear
|
|
||||||
read -p "This will create a New ${APP} LXC. Proceed(y/n)?" yn
|
|
||||||
case $yn in
|
|
||||||
[Yy]* ) break;;
|
|
||||||
[Nn]* ) exit;;
|
|
||||||
* ) echo "Please answer yes or no.";;
|
|
||||||
esac
|
|
||||||
done
|
|
||||||
clear
|
|
||||||
function header_info {
|
|
||||||
echo -e "${BL}
|
|
||||||
_____ _____
|
|
||||||
| __ \ / ____|
|
|
||||||
| | | | __ _v3___ _ __ ___ ___ _ __ | (___ _ _ _ __ ___
|
|
||||||
| | | |/ _ |/ _ \ _ _ \ / _ \| _ \ \___ \| | | | _ \ / __|
|
|
||||||
| |__| | (_| | __/ | | | | | (_) | | | | ____) | |_| | | | | (__
|
|
||||||
|_____/ \__,_|\___|_| |_| |_|\___/|_| |_| |_____/ \__, |_| |_|\___|
|
|
||||||
__/ |
|
|
||||||
|___/
|
|
||||||
${CL}"
|
|
||||||
}
|
|
||||||
|
|
||||||
header_info
|
|
||||||
|
|
||||||
function msg_info() {
|
|
||||||
local msg="$1"
|
|
||||||
echo -ne " ${HOLD} ${YW}${msg}..."
|
|
||||||
}
|
|
||||||
|
|
||||||
function msg_ok() {
|
|
||||||
local msg="$1"
|
|
||||||
echo -e "${BFR} ${CM} ${GN}${msg}${CL}"
|
|
||||||
}
|
|
||||||
|
|
||||||
function PVE_CHECK() {
|
|
||||||
PVE=$(pveversion | grep "pve-manager/7" | wc -l)
|
|
||||||
|
|
||||||
if [[ $PVE != 1 ]]; then
|
|
||||||
echo -e "${RD}This script requires Proxmox Virtual Environment 7.0 or greater${CL}"
|
|
||||||
echo -e "Exiting..."
|
|
||||||
sleep 2
|
|
||||||
exit
|
|
||||||
fi
|
|
||||||
}
|
|
||||||
|
|
||||||
function default_settings() {
|
|
||||||
clear
|
|
||||||
header_info
|
|
||||||
echo -e "${BL}Using Default Settings${CL}"
|
|
||||||
echo -e "${DGN}Using CT Type ${BGN}Unprivileged${CL} ${RD}NO DEVICE PASSTHROUGH${CL}"
|
|
||||||
CT_TYPE="1"
|
|
||||||
echo -e "${DGN}Using CT Password ${BGN}Automatic Login${CL}"
|
|
||||||
PW=" "
|
|
||||||
echo -e "${DGN}Using CT ID ${BGN}$NEXTID${CL}"
|
|
||||||
CT_ID=$NEXTID
|
|
||||||
echo -e "${DGN}Using CT Name ${BGN}$NSAPP${CL}"
|
|
||||||
HN=$NSAPP
|
|
||||||
echo -e "${DGN}Using Disk Size ${BGN}8${CL}${DGN}GB${CL}"
|
|
||||||
DISK_SIZE="8"
|
|
||||||
echo -e "${DGN}Using ${BGN}1${CL}${DGN}vCPU${CL}"
|
|
||||||
CORE_COUNT="1"
|
|
||||||
echo -e "${DGN}Using ${BGN}512${CL}${DGN}MiB RAM${CL}"
|
|
||||||
RAM_SIZE="512"
|
|
||||||
echo -e "${DGN}Using Bridge ${BGN}vmbr0${CL}"
|
|
||||||
BRG="vmbr0"
|
|
||||||
echo -e "${DGN}Using Static IP Address ${BGN}DHCP${CL}"
|
|
||||||
NET=dhcp
|
|
||||||
echo -e "${DGN}Using Gateway Address ${BGN}NONE${CL}"
|
|
||||||
GATE=""
|
|
||||||
echo -e "${DGN}Using VLAN Tag ${BGN}NONE${CL}"
|
|
||||||
VLAN=""
|
|
||||||
}
|
|
||||||
|
|
||||||
function advanced_settings() {
|
|
||||||
clear
|
|
||||||
header_info
|
|
||||||
echo -e "${RD}Using Advanced Settings${CL}"
|
|
||||||
echo -e "${YW}Type Privileged, or Press [ENTER] for Default: Unprivileged (${RD}NO DEVICE PASSTHROUGH${CL}${YW})"
|
|
||||||
read CT_TYPE1
|
|
||||||
if [ -z $CT_TYPE1 ]; then CT_TYPE1="Unprivileged" CT_TYPE="1";
|
|
||||||
echo -en "${DGN}Set CT Type ${BL}$CT_TYPE1${CL}"
|
|
||||||
else
|
|
||||||
CT_TYPE1="Privileged"
|
|
||||||
CT_TYPE="0"
|
|
||||||
echo -en "${DGN}Set CT Type ${BL}Privileged${CL}"
|
|
||||||
fi;
|
|
||||||
echo -e " ${CM}${CL} \r"
|
|
||||||
sleep 1
|
|
||||||
clear
|
|
||||||
header_info
|
|
||||||
echo -e "${RD}Using Advanced Settings${CL}"
|
|
||||||
echo -e "${DGN}Using CT Type ${BGN}$CT_TYPE1${CL}"
|
|
||||||
echo -e "${YW}Set Password, or Press [ENTER] for Default: Automatic Login "
|
|
||||||
read PW1
|
|
||||||
if [ -z $PW1 ]; then PW1="Automatic Login" PW=" ";
|
|
||||||
echo -en "${DGN}Set CT ${BL}$PW1${CL}"
|
|
||||||
else
|
|
||||||
PW="-password $PW1"
|
|
||||||
echo -en "${DGN}Set CT Password ${BL}$PW1${CL}"
|
|
||||||
fi;
|
|
||||||
echo -e " ${CM}${CL} \r"
|
|
||||||
sleep 1
|
|
||||||
clear
|
|
||||||
header_info
|
|
||||||
echo -e "${RD}Using Advanced Settings${CL}"
|
|
||||||
echo -e "${DGN}Using CT Type ${BGN}$CT_TYPE1${CL}"
|
|
||||||
echo -e "${DGN}Using CT Password ${BGN}$PW1${CL}"
|
|
||||||
echo -e "${YW}Enter the CT ID, or Press [ENTER] to automatically generate (${NEXTID}) "
|
|
||||||
read CT_ID
|
|
||||||
if [ -z $CT_ID ]; then CT_ID=$NEXTID; fi;
|
|
||||||
echo -en "${DGN}Set CT ID To ${BL}$CT_ID${CL}"
|
|
||||||
echo -e " ${CM}${CL} \r"
|
|
||||||
sleep 1
|
|
||||||
clear
|
|
||||||
header_info
|
|
||||||
echo -e "${RD}Using Advanced Settings${CL}"
|
|
||||||
echo -e "${DGN}Using CT Type ${BGN}$CT_TYPE1${CL}"
|
|
||||||
echo -e "${DGN}Using CT Password ${BGN}$PW1${CL}"
|
|
||||||
echo -e "${DGN}Using CT ID ${BGN}$CT_ID${CL}"
|
|
||||||
echo -e "${YW}Enter CT Name (no-spaces), or Press [ENTER] for Default: $NSAPP "
|
|
||||||
read CT_NAME
|
|
||||||
if [ -z $CT_NAME ]; then
|
|
||||||
HN=$NSAPP
|
|
||||||
else
|
|
||||||
HN=$(echo ${CT_NAME,,} | tr -d ' ')
|
|
||||||
fi
|
|
||||||
echo -en "${DGN}Set CT Name To ${BL}$HN${CL}"
|
|
||||||
echo -e " ${CM}${CL} \r"
|
|
||||||
sleep 1
|
|
||||||
clear
|
|
||||||
header_info
|
|
||||||
echo -e "${RD}Using Advanced Settings${CL}"
|
|
||||||
echo -e "${DGN}Using CT Type ${BGN}$CT_TYPE1${CL}"
|
|
||||||
echo -e "${DGN}Using CT Password ${BGN}$PW1${CL}"
|
|
||||||
echo -e "${DGN}Using CT ID ${BGN}$CT_ID${CL}"
|
|
||||||
echo -e "${DGN}Using CT Name ${BGN}$HN${CL}"
|
|
||||||
echo -e "${YW}Enter a Disk Size, or Press [ENTER] for Default: 8 "
|
|
||||||
read DISK_SIZE
|
|
||||||
if [ -z $DISK_SIZE ]; then DISK_SIZE="8"; fi;
|
|
||||||
if ! [[ $DISK_SIZE =~ $INTEGER ]] ; then echo "ERROR! DISK SIZE MUST HAVE INTEGER NUMBER!"; exit; fi;
|
|
||||||
echo -en "${DGN}Set Disk Size To ${BL}$DISK_SIZE${CL}${DGN}GB${CL}"
|
|
||||||
echo -e " ${CM}${CL} \r"
|
|
||||||
sleep 1
|
|
||||||
clear
|
|
||||||
header_info
|
|
||||||
echo -e "${RD}Using Advanced Settings${CL}"
|
|
||||||
echo -e "${DGN}Using CT Type ${BGN}$CT_TYPE1${CL}"
|
|
||||||
echo -e "${DGN}Using CT Password ${BGN}$PW1${CL}"
|
|
||||||
echo -e "${DGN}Using CT ID ${BGN}$CT_ID${CL}"
|
|
||||||
echo -e "${DGN}Using CT Name ${BGN}$HN${CL}"
|
|
||||||
echo -e "${DGN}Using Disk Size ${BGN}$DISK_SIZE${CL}${DGN}GB${CL}"
|
|
||||||
echo -e "${YW}Allocate CPU cores, or Press [ENTER] for Default: 1 "
|
|
||||||
read CORE_COUNT
|
|
||||||
if [ -z $CORE_COUNT ]; then CORE_COUNT="1"; fi;
|
|
||||||
echo -en "${DGN}Set Cores To ${BL}$CORE_COUNT${CL}${DGN}vCPU${CL}"
|
|
||||||
echo -e " ${CM}${CL} \r"
|
|
||||||
sleep 1
|
|
||||||
clear
|
|
||||||
header_info
|
|
||||||
echo -e "${RD}Using Advanced Settings${CL}"
|
|
||||||
echo -e "${DGN}Using CT Type ${BGN}$CT_TYPE1${CL}"
|
|
||||||
echo -e "${DGN}Using CT Password ${BGN}$PW1${CL}"
|
|
||||||
echo -e "${DGN}Using CT ID ${BGN}$CT_ID${CL}"
|
|
||||||
echo -e "${DGN}Using CT Name ${BGN}$HN${CL}"
|
|
||||||
echo -e "${DGN}Using Disk Size ${BGN}$DISK_SIZE${CL}${DGN}GB${CL}"
|
|
||||||
echo -e "${DGN}Using ${BGN}${CORE_COUNT}${CL}${DGN}vCPU${CL}"
|
|
||||||
echo -e "${YW}Allocate RAM in MiB, or Press [ENTER] for Default: 512 "
|
|
||||||
read RAM_SIZE
|
|
||||||
if [ -z $RAM_SIZE ]; then RAM_SIZE="512"; fi;
|
|
||||||
echo -en "${DGN}Set RAM To ${BL}$RAM_SIZE${CL}${DGN}MiB RAM${CL}"
|
|
||||||
echo -e " ${CM}${CL} \n"
|
|
||||||
sleep 1
|
|
||||||
clear
|
|
||||||
header_info
|
|
||||||
echo -e "${RD}Using Advanced Settings${CL}"
|
|
||||||
echo -e "${DGN}Using CT Type ${BGN}$CT_TYPE1${CL}"
|
|
||||||
echo -e "${DGN}Using CT Password ${BGN}$PW1${CL}"
|
|
||||||
echo -e "${DGN}Using CT ID ${BGN}$CT_ID${CL}"
|
|
||||||
echo -e "${DGN}Using CT Name ${BGN}$HN${CL}"
|
|
||||||
echo -e "${DGN}Using Disk Size ${BGN}$DISK_SIZE${CL}${DGN}GB${CL}"
|
|
||||||
echo -e "${DGN}Using ${BGN}${CORE_COUNT}${CL}${DGN}vCPU${CL}"
|
|
||||||
echo -e "${DGN}Using ${BGN}${RAM_SIZE}${CL}${DGN}MiB RAM${CL}"
|
|
||||||
echo -e "${YW}Enter a Bridge, or Press [ENTER] for Default: vmbr0 "
|
|
||||||
read BRG
|
|
||||||
if [ -z $BRG ]; then BRG="vmbr0"; fi;
|
|
||||||
echo -en "${DGN}Set Bridge To ${BL}$BRG${CL}"
|
|
||||||
echo -e " ${CM}${CL} \n"
|
|
||||||
sleep 1
|
|
||||||
clear
|
|
||||||
header_info
|
|
||||||
echo -e "${RD}Using Advanced Settings${CL}"
|
|
||||||
echo -e "${DGN}Using CT Type ${BGN}$CT_TYPE1${CL}"
|
|
||||||
echo -e "${DGN}Using CT Password ${BGN}$PW1${CL}"
|
|
||||||
echo -e "${DGN}Using CT ID ${BGN}$CT_ID${CL}"
|
|
||||||
echo -e "${DGN}Using CT Name ${BGN}$HN${CL}"
|
|
||||||
echo -e "${DGN}Using Disk Size ${BGN}$DISK_SIZE${CL}${DGN}GB${CL}"
|
|
||||||
echo -e "${DGN}Using ${BGN}${CORE_COUNT}${CL}${DGN}vCPU${CL}"
|
|
||||||
echo -e "${DGN}Using ${BGN}${RAM_SIZE}${CL}${DGN}MiB RAM${CL}"
|
|
||||||
echo -e "${DGN}Using Bridge ${BGN}${BRG}${CL}"
|
|
||||||
echo -e "${YW}Enter a Static IPv4 CIDR Address, or Press [ENTER] for Default: DHCP "
|
|
||||||
read NET
|
|
||||||
if [ -z $NET ]; then NET="dhcp"; fi;
|
|
||||||
echo -en "${DGN}Set Static IP Address To ${BL}$NET${CL}"
|
|
||||||
echo -e " ${CM}${CL} \n"
|
|
||||||
sleep 1
|
|
||||||
clear
|
|
||||||
header_info
|
|
||||||
echo -e "${RD}Using Advanced Settings${CL}"
|
|
||||||
echo -e "${DGN}Using CT Type ${BGN}$CT_TYPE1${CL}"
|
|
||||||
echo -e "${DGN}Using CT Password ${BGN}$PW1${CL}"
|
|
||||||
echo -e "${DGN}Using CT ID ${BGN}$CT_ID${CL}"
|
|
||||||
echo -e "${DGN}Using CT Name ${BGN}$HN${CL}"
|
|
||||||
echo -e "${DGN}Using Disk Size ${BGN}$DISK_SIZE${CL}${DGN}GB${CL}"
|
|
||||||
echo -e "${DGN}Using ${BGN}${CORE_COUNT}${CL}${DGN}vCPU${CL}"
|
|
||||||
echo -e "${DGN}Using ${BGN}${RAM_SIZE}${CL}${DGN}MiB RAM${CL}"
|
|
||||||
echo -e "${DGN}Using Bridge ${BGN}${BRG}${CL}"
|
|
||||||
echo -e "${DGN}Using Static IP Address ${BGN}$NET${CL}"
|
|
||||||
echo -e "${YW}Enter a Gateway IP (mandatory if static IP is used), or Press [ENTER] for Default: NONE "
|
|
||||||
read GATE1
|
|
||||||
if [ -z $GATE1 ]; then GATE1="NONE" GATE="";
|
|
||||||
echo -en "${DGN}Set Gateway IP To ${BL}$GATE1${CL}"
|
|
||||||
else
|
|
||||||
GATE=",gw=$GATE1"
|
|
||||||
echo -en "${DGN}Set Gateway IP To ${BL}$GATE1${CL}"
|
|
||||||
fi;
|
|
||||||
echo -e " ${CM}${CL} \n"
|
|
||||||
sleep 1
|
|
||||||
clear
|
|
||||||
header_info
|
|
||||||
|
|
||||||
echo -e "${RD}Using Advanced Settings${CL}"
|
|
||||||
echo -e "${DGN}Using CT Type ${BGN}$CT_TYPE1${CL}"
|
|
||||||
echo -e "${DGN}Using CT Password ${BGN}$PW1${CL}"
|
|
||||||
echo -e "${DGN}Using CT ID ${BGN}$CT_ID${CL}"
|
|
||||||
echo -e "${DGN}Using CT Name ${BGN}$HN${CL}"
|
|
||||||
echo -e "${DGN}Using Disk Size ${BGN}$DISK_SIZE${CL}${DGN}GB${CL}"
|
|
||||||
echo -e "${DGN}Using ${BGN}${CORE_COUNT}${CL}${DGN}vCPU${CL}"
|
|
||||||
echo -e "${DGN}Using ${BGN}${RAM_SIZE}${CL}${DGN}MiB RAM${CL}"
|
|
||||||
echo -e "${DGN}Using Bridge ${BGN}${BRG}${CL}"
|
|
||||||
echo -e "${DGN}Using Static IP Address ${BGN}$NET${CL}"
|
|
||||||
echo -e "${DGN}Using Gateway IP Address ${BGN}$GATE1${CL}"
|
|
||||||
echo -e "${YW}Enter a VLAN Tag, or Press [ENTER] for Default: NONE "
|
|
||||||
read VLAN1
|
|
||||||
if [ -z $VLAN1 ]; then VLAN1="NONE" VLAN="";
|
|
||||||
echo -en "${DGN}Set VLAN Tag To ${BL}$VLAN1${CL}"
|
|
||||||
else
|
|
||||||
VLAN=",tag=$VLAN1"
|
|
||||||
echo -en "${DGN}Set VLAN Tag To ${BL}$VLAN1${CL}"
|
|
||||||
fi;
|
|
||||||
echo -e " ${CM}${CL} \n"
|
|
||||||
sleep 1
|
|
||||||
clear
|
|
||||||
header_info
|
|
||||||
echo -e "${RD}Using Advanced Settings${CL}"
|
|
||||||
echo -e "${DGN}Using CT Type ${BGN}$CT_TYPE1${CL}"
|
|
||||||
echo -e "${DGN}Using CT Password ${BGN}$PW1${CL}"
|
|
||||||
echo -e "${DGN}Using CT ID ${BGN}$CT_ID${CL}"
|
|
||||||
echo -e "${DGN}Using CT Name ${BGN}$HN${CL}"
|
|
||||||
echo -e "${DGN}Using Disk Size ${BGN}$DISK_SIZE${CL}${DGN}GB${CL}"
|
|
||||||
echo -e "${DGN}Using ${BGN}${CORE_COUNT}${CL}${DGN}vCPU${CL}"
|
|
||||||
echo -e "${DGN}Using ${BGN}${RAM_SIZE}${CL}${DGN}MiB RAM${CL}"
|
|
||||||
echo -e "${DGN}Using Bridge ${BGN}${BRG}${CL}"
|
|
||||||
echo -e "${DGN}Using Static IP Address ${BGN}$NET${CL}"
|
|
||||||
echo -e "${DGN}Using Gateway IP Address ${BGN}$GATE1${CL}"
|
|
||||||
echo -e "${DGN}Using VLAN Tag ${BGN}$VLAN1${CL}"
|
|
||||||
|
|
||||||
read -p "Are these settings correct(y/n)? " -n 1 -r
|
|
||||||
echo
|
|
||||||
if [[ ! $REPLY =~ ^[Yy]$ ]]
|
|
||||||
then
|
|
||||||
advanced_settings
|
|
||||||
fi
|
|
||||||
}
|
|
||||||
|
|
||||||
function start_script() {
|
|
||||||
echo -e "${YW}Type Advanced, or Press [ENTER] for Default Settings "
|
|
||||||
read SETTINGS
|
|
||||||
if [ -z $SETTINGS ]; then default_settings;
|
|
||||||
else
|
|
||||||
advanced_settings
|
|
||||||
fi;
|
|
||||||
}
|
|
||||||
|
|
||||||
start_script
|
|
||||||
|
|
||||||
if [ "$CT_TYPE" == "1" ]; then
|
|
||||||
FEATURES="nesting=1,keyctl=1"
|
|
||||||
else
|
|
||||||
FEATURES="nesting=1"
|
|
||||||
fi
|
|
||||||
|
|
||||||
TEMP_DIR=$(mktemp -d)
|
|
||||||
pushd $TEMP_DIR >/dev/null
|
|
||||||
|
|
||||||
export CTID=$CT_ID
|
|
||||||
export PCT_OSTYPE=debian
|
|
||||||
export PCT_OSVERSION=11
|
|
||||||
export PCT_DISK_SIZE=$DISK_SIZE
|
|
||||||
export PCT_OPTIONS="
|
|
||||||
-features $FEATURES
|
|
||||||
-hostname $HN
|
|
||||||
-net0 name=eth0,bridge=$BRG,ip=$NET$GATE$VLAN
|
|
||||||
-onboot 1
|
|
||||||
-cores $CORE_COUNT
|
|
||||||
-memory $RAM_SIZE
|
|
||||||
-unprivileged $CT_TYPE
|
|
||||||
$PW
|
|
||||||
"
|
|
||||||
bash -c "$(wget -qLO - https://raw.githubusercontent.com/tteck/Proxmox/main/ct/create_lxc.sh)" || exit
|
|
||||||
|
|
||||||
msg_info "Starting LXC Container"
|
|
||||||
pct start $CTID
|
|
||||||
msg_ok "Started LXC Container"
|
|
||||||
|
|
||||||
lxc-attach -n $CTID -- bash -c "$(wget -qLO - https://raw.githubusercontent.com/tteck/Proxmox/main/setup/daemonsync-install.sh)" || exit
|
|
||||||
|
|
||||||
IP=$(pct exec $CTID ip a s dev eth0 | sed -n '/inet / s/\// /p' | awk '{print $2}')
|
|
||||||
|
|
||||||
pct set $CTID -description "# ${APP} LXC
|
|
||||||
### https://github.com/tteck/Proxmox"
|
|
||||||
|
|
||||||
msg_ok "Completed Successfully!\n"
|
|
||||||
echo -e "${APP} should be reachable by going to the following URL.
|
|
||||||
${BL}http://${IP}:8084${CL} \n"
|
|
|
@ -310,7 +310,7 @@ bash -c "$(wget -qLO - https://raw.githubusercontent.com/tteck/Proxmox/main/ct/c
|
||||||
msg_info "Starting LXC Container"
|
msg_info "Starting LXC Container"
|
||||||
pct start $CTID
|
pct start $CTID
|
||||||
msg_ok "Started LXC Container"
|
msg_ok "Started LXC Container"
|
||||||
lxc-attach -n $CTID -- bash -c "$(wget -qLO - https://raw.githubusercontent.com/tteck/Proxmox/main/setup/$var_install.sh)" || exit
|
lxc-attach -n $CTID -- bash -c "$(wget -qLO - https://raw.githubusercontent.com/tteck/Proxmox/main/install/$var_install.sh)" || exit
|
||||||
IP=$(pct exec $CTID ip a s dev eth0 | sed -n '/inet / s/\// /p' | awk '{print $2}')
|
IP=$(pct exec $CTID ip a s dev eth0 | sed -n '/inet / s/\// /p' | awk '{print $2}')
|
||||||
pct set $CTID -description "# ${APP} LXC
|
pct set $CTID -description "# ${APP} LXC
|
||||||
### https://tteck.github.io/Proxmox/
|
### https://tteck.github.io/Proxmox/
|
||||||
|
|
254
ct/dashy-v2.sh
254
ct/dashy-v2.sh
|
@ -1,254 +0,0 @@
|
||||||
#!/usr/bin/env bash
|
|
||||||
clear
|
|
||||||
YW=`echo "\033[33m"`
|
|
||||||
BL=`echo "\033[36m"`
|
|
||||||
RD=`echo "\033[01;31m"`
|
|
||||||
CM='\xE2\x9C\x94\033'
|
|
||||||
GN=`echo "\033[1;92m"`
|
|
||||||
CL=`echo "\033[m"`
|
|
||||||
while true; do
|
|
||||||
read -p "This will create a New Dashy LXC. Proceed(y/n)?" yn
|
|
||||||
case $yn in
|
|
||||||
[Yy]* ) break;;
|
|
||||||
[Nn]* ) exit;;
|
|
||||||
* ) echo "Please answer yes or no.";;
|
|
||||||
esac
|
|
||||||
done
|
|
||||||
clear
|
|
||||||
function header_info {
|
|
||||||
echo -e "${RD}
|
|
||||||
_____ _
|
|
||||||
| __ \ | |
|
|
||||||
| | | | __ _ ___| |__ _ _
|
|
||||||
| | | |/ _ / __| _ \| | | |
|
|
||||||
| |__| | (_| \__ \ | | | |_| |
|
|
||||||
|_____/ \__,_|___/_| |_|\__, |
|
|
||||||
__/ |
|
|
||||||
|___/
|
|
||||||
${CL}"
|
|
||||||
}
|
|
||||||
|
|
||||||
header_info
|
|
||||||
show_menu(){
|
|
||||||
printf " ${YW} 1)${YW} Privileged ${CL}\n"
|
|
||||||
printf " ${YW} 2)${GN} Unprivileged ${CL}\n"
|
|
||||||
|
|
||||||
printf "Please choose a Install Method and hit enter or ${RD}x${CL} to exit."
|
|
||||||
read opt
|
|
||||||
}
|
|
||||||
|
|
||||||
option_picked(){
|
|
||||||
message1=${@:-"${CL}Error: No message passed"}
|
|
||||||
printf " ${YW}${message1}${CL}\n"
|
|
||||||
}
|
|
||||||
show_menu
|
|
||||||
while [ "$opt" != " " ]
|
|
||||||
do
|
|
||||||
case $opt in
|
|
||||||
1) clear;
|
|
||||||
header_info;
|
|
||||||
option_picked "Using Privileged Install";
|
|
||||||
IM=0
|
|
||||||
break;
|
|
||||||
;;
|
|
||||||
2) clear;
|
|
||||||
header_info;
|
|
||||||
option_picked "Using Unprivileged Install";
|
|
||||||
IM=1
|
|
||||||
break;
|
|
||||||
;;
|
|
||||||
|
|
||||||
x)exit;
|
|
||||||
;;
|
|
||||||
\n)exit;
|
|
||||||
;;
|
|
||||||
*)clear;
|
|
||||||
option_picked "Please choose a Install Method from the menu";
|
|
||||||
show_menu;
|
|
||||||
;;
|
|
||||||
esac
|
|
||||||
done
|
|
||||||
show_menu2(){
|
|
||||||
printf " ${YW} 1)${GN} Use Automatic Login ${CL}\n"
|
|
||||||
printf " ${YW} 2)${GN} Use Password (changeme) ${CL}\n"
|
|
||||||
|
|
||||||
printf "Please choose a Password Type and hit enter or ${RD}x${CL} to exit."
|
|
||||||
read opt
|
|
||||||
}
|
|
||||||
|
|
||||||
option_picked(){
|
|
||||||
message2=${@:-"${CL}Error: No message passed"}
|
|
||||||
printf " ${YW}${message1}${CL}\n"
|
|
||||||
printf " ${YW}${message2}${CL}\n"
|
|
||||||
}
|
|
||||||
show_menu2
|
|
||||||
while [ "$opt" != " " ]
|
|
||||||
do
|
|
||||||
case $opt in
|
|
||||||
1) clear;
|
|
||||||
header_info;
|
|
||||||
option_picked "Using Automatic Login";
|
|
||||||
PW=" "
|
|
||||||
break;
|
|
||||||
;;
|
|
||||||
2) clear;
|
|
||||||
header_info;
|
|
||||||
option_picked "Using Password (changeme)";
|
|
||||||
PW="-password changeme"
|
|
||||||
break;
|
|
||||||
;;
|
|
||||||
|
|
||||||
x)exit;
|
|
||||||
;;
|
|
||||||
\n)exit;
|
|
||||||
;;
|
|
||||||
*)clear;
|
|
||||||
option_picked "Please choose a Password Type from the menu";
|
|
||||||
show_menu2;
|
|
||||||
;;
|
|
||||||
esac
|
|
||||||
done
|
|
||||||
show_menu3(){
|
|
||||||
printf " ${YW} 1)${GN} Automatic DHCP ${CL}\n"
|
|
||||||
printf " ${YW} 2)${GN} Manual DHCP ${CL}\n"
|
|
||||||
|
|
||||||
printf "Please choose a DHCP Type and hit enter or ${RD}x${CL} to exit."
|
|
||||||
read opt
|
|
||||||
}
|
|
||||||
|
|
||||||
option_picked(){
|
|
||||||
message3=${@:-"${CL}Error: No message passed"}
|
|
||||||
printf " ${YW}${message1}${CL}\n"
|
|
||||||
printf " ${YW}${message2}${CL}\n"
|
|
||||||
printf " ${YW}${message3}${CL}\n"
|
|
||||||
}
|
|
||||||
show_menu3
|
|
||||||
while [ "$opt" != " " ]
|
|
||||||
do
|
|
||||||
case $opt in
|
|
||||||
1) clear;
|
|
||||||
header_info;
|
|
||||||
option_picked "Using Automatic DHCP";
|
|
||||||
DHCP=" "
|
|
||||||
break;
|
|
||||||
;;
|
|
||||||
2) clear;
|
|
||||||
header_info;
|
|
||||||
option_picked "Using Manual DHCP";
|
|
||||||
DHCP="1"
|
|
||||||
break;
|
|
||||||
;;
|
|
||||||
|
|
||||||
x)exit;
|
|
||||||
;;
|
|
||||||
\n)exit;
|
|
||||||
;;
|
|
||||||
*)clear;
|
|
||||||
option_picked "Please choose a DHCP Type from the menu";
|
|
||||||
show_menu3;
|
|
||||||
;;
|
|
||||||
esac
|
|
||||||
done
|
|
||||||
|
|
||||||
set -o errexit
|
|
||||||
set -o errtrace
|
|
||||||
set -o nounset
|
|
||||||
set -o pipefail
|
|
||||||
shopt -s expand_aliases
|
|
||||||
alias die='EXIT=$? LINE=$LINENO error_exit'
|
|
||||||
trap die ERR
|
|
||||||
trap cleanup EXIT
|
|
||||||
|
|
||||||
function error_exit() {
|
|
||||||
trap - ERR
|
|
||||||
local DEFAULT='Unknown failure occured.'
|
|
||||||
local REASON="\e[97m${1:-$DEFAULT}\e[39m"
|
|
||||||
local FLAG="\e[91m[ERROR] \e[93m$EXIT@$LINE"
|
|
||||||
msg "$FLAG $REASON"
|
|
||||||
[ ! -z ${CTID-} ] && cleanup_ctid
|
|
||||||
exit $EXIT
|
|
||||||
}
|
|
||||||
function warn() {
|
|
||||||
local REASON="\e[97m$1\e[39m"
|
|
||||||
local FLAG="\e[93m[WARNING]\e[39m"
|
|
||||||
msg "$FLAG $REASON"
|
|
||||||
}
|
|
||||||
function info() {
|
|
||||||
local REASON="$1"
|
|
||||||
local FLAG="\e[36m[INFO]\e[39m"
|
|
||||||
msg "$FLAG $REASON"
|
|
||||||
}
|
|
||||||
function msg() {
|
|
||||||
local TEXT="$1"
|
|
||||||
echo -e "$TEXT"
|
|
||||||
}
|
|
||||||
function cleanup_ctid() {
|
|
||||||
if $(pct status $CTID &>/dev/null); then
|
|
||||||
if [ "$(pct status $CTID | awk '{print $2}')" == "running" ]; then
|
|
||||||
pct stop $CTID
|
|
||||||
fi
|
|
||||||
pct destroy $CTID
|
|
||||||
elif [ "$(pvesm list $STORAGE --vmid $CTID)" != "" ]; then
|
|
||||||
pvesm free $ROOTFS
|
|
||||||
fi
|
|
||||||
}
|
|
||||||
function cleanup() {
|
|
||||||
popd >/dev/null
|
|
||||||
rm -rf $TEMP_DIR
|
|
||||||
}
|
|
||||||
if [ "$IM" == "1" ]; then
|
|
||||||
FEATURES="nesting=1,keyctl=1"
|
|
||||||
else
|
|
||||||
FEATURES="nesting=1"
|
|
||||||
fi
|
|
||||||
|
|
||||||
TEMP_DIR=$(mktemp -d)
|
|
||||||
pushd $TEMP_DIR >/dev/null
|
|
||||||
|
|
||||||
export CTID=$(pvesh get /cluster/nextid)
|
|
||||||
export PCT_OSTYPE=debian
|
|
||||||
export PCT_OSVERSION=11
|
|
||||||
export PCT_DISK_SIZE=3
|
|
||||||
export PCT_OPTIONS="
|
|
||||||
-features $FEATURES
|
|
||||||
-hostname dashy
|
|
||||||
-net0 name=eth0,bridge=vmbr0,ip=dhcp
|
|
||||||
-onboot 1
|
|
||||||
-cores 2
|
|
||||||
-memory 2048
|
|
||||||
-unprivileged ${IM}
|
|
||||||
${PW}
|
|
||||||
"
|
|
||||||
bash -c "$(wget -qLO - https://raw.githubusercontent.com/tteck/Proxmox/main/ct/create_lxc.sh)" || exit
|
|
||||||
|
|
||||||
STORAGE_TYPE=$(pvesm status -storage $(pct config $CTID | grep rootfs | awk -F ":" '{print $2}') | awk 'NR>1 {print $2}')
|
|
||||||
if [ "$STORAGE_TYPE" == "zfspool" ]; then
|
|
||||||
warn "Some addons may not work due to ZFS not supporting 'fallocate'."
|
|
||||||
fi
|
|
||||||
if [ "$DHCP" == "1" ]; then
|
|
||||||
MAC=$(pct config $CTID \
|
|
||||||
| grep -i hwaddr \
|
|
||||||
| awk '{print substr($2, 31, length($3) 17 ) }') \
|
|
||||||
|
|
||||||
echo -e "MAC Address ${BL}$MAC${CL}"
|
|
||||||
|
|
||||||
dhcp_reservation(){
|
|
||||||
printf "Please set DHCP reservation and press Enter."
|
|
||||||
read
|
|
||||||
}
|
|
||||||
dhcp_reservation
|
|
||||||
fi
|
|
||||||
|
|
||||||
echo -en "${GN} Starting LXC Container... "
|
|
||||||
pct start $CTID
|
|
||||||
echo -e "${CM}${CL} \r"
|
|
||||||
|
|
||||||
alias lxc-cmd="lxc-attach -n $CTID --"
|
|
||||||
|
|
||||||
lxc-cmd bash -c "$(wget -qLO - https://raw.githubusercontent.com/tteck/Proxmox/main/setup/dashy-install.sh)" || exit
|
|
||||||
|
|
||||||
IP=$(pct exec $CTID ip a s dev eth0 | sed -n '/inet / s/\// /p' | awk '{print $2}')
|
|
||||||
|
|
||||||
echo -e "${GN}Successfully created Dashy LXC to${CL} ${BL}$CTID${CL}.
|
|
||||||
${BL}Dashy${CL} should be reachable by going to the following URL.
|
|
||||||
${BL}http://${IP}:4000${CL} \n"
|
|
358
ct/dashy-v3.sh
358
ct/dashy-v3.sh
|
@ -1,358 +0,0 @@
|
||||||
#!/usr/bin/env bash
|
|
||||||
echo -e "Loading..."
|
|
||||||
NEXTID=$(pvesh get /cluster/nextid)
|
|
||||||
INTEGER='^[0-9]+$'
|
|
||||||
YW=`echo "\033[33m"`
|
|
||||||
BL=`echo "\033[36m"`
|
|
||||||
RD=`echo "\033[01;31m"`
|
|
||||||
BGN=`echo "\033[4;92m"`
|
|
||||||
GN=`echo "\033[1;92m"`
|
|
||||||
DGN=`echo "\033[32m"`
|
|
||||||
CL=`echo "\033[m"`
|
|
||||||
BFR="\\r\\033[K"
|
|
||||||
HOLD="-"
|
|
||||||
CM="${GN}✓${CL}"
|
|
||||||
APP="Dashy"
|
|
||||||
NSAPP=$(echo ${APP,,} | tr -d ' ')
|
|
||||||
set -o errexit
|
|
||||||
set -o errtrace
|
|
||||||
set -o nounset
|
|
||||||
set -o pipefail
|
|
||||||
shopt -s expand_aliases
|
|
||||||
alias die='EXIT=$? LINE=$LINENO error_exit'
|
|
||||||
trap die ERR
|
|
||||||
|
|
||||||
function error_exit() {
|
|
||||||
trap - ERR
|
|
||||||
local reason="Unknown failure occurred."
|
|
||||||
local msg="${1:-$reason}"
|
|
||||||
local flag="${RD}‼ ERROR ${CL}$EXIT@$LINE"
|
|
||||||
echo -e "$flag $msg" 1>&2
|
|
||||||
exit $EXIT
|
|
||||||
}
|
|
||||||
|
|
||||||
while true; do
|
|
||||||
clear
|
|
||||||
read -p "This will create a New ${APP} LXC. Proceed(y/n)?" yn
|
|
||||||
case $yn in
|
|
||||||
[Yy]* ) break;;
|
|
||||||
[Nn]* ) exit;;
|
|
||||||
* ) echo "Please answer yes or no.";;
|
|
||||||
esac
|
|
||||||
done
|
|
||||||
clear
|
|
||||||
function header_info {
|
|
||||||
echo -e "${RD}
|
|
||||||
_____ _
|
|
||||||
| __ \ | |
|
|
||||||
| | | | __ _ ___| |__ _ _
|
|
||||||
| | | |/ _ / __| _ \| | | |
|
|
||||||
| |__| | (_| \__ \ | | | |_| |
|
|
||||||
|_____/ \__,_|___/_| |_|\__, |
|
|
||||||
v3__/ |
|
|
||||||
|___/
|
|
||||||
${CL}"
|
|
||||||
}
|
|
||||||
|
|
||||||
header_info
|
|
||||||
|
|
||||||
function msg_info() {
|
|
||||||
local msg="$1"
|
|
||||||
echo -ne " ${HOLD} ${YW}${msg}..."
|
|
||||||
}
|
|
||||||
|
|
||||||
function msg_ok() {
|
|
||||||
local msg="$1"
|
|
||||||
echo -e "${BFR} ${CM} ${GN}${msg}${CL}"
|
|
||||||
}
|
|
||||||
|
|
||||||
function PVE_CHECK() {
|
|
||||||
PVE=$(pveversion | grep "pve-manager/7" | wc -l)
|
|
||||||
|
|
||||||
if [[ $PVE != 1 ]]; then
|
|
||||||
echo -e "${RD}This script requires Proxmox Virtual Environment 7.0 or greater${CL}"
|
|
||||||
echo -e "Exiting..."
|
|
||||||
sleep 2
|
|
||||||
exit
|
|
||||||
fi
|
|
||||||
}
|
|
||||||
|
|
||||||
function default_settings() {
|
|
||||||
clear
|
|
||||||
header_info
|
|
||||||
echo -e "${BL}Using Default Settings${CL}"
|
|
||||||
echo -e "${DGN}Using CT Type ${BGN}Unprivileged${CL} ${RD}NO DEVICE PASSTHROUGH${CL}"
|
|
||||||
CT_TYPE="1"
|
|
||||||
echo -e "${DGN}Using CT Password ${BGN}Automatic Login${CL}"
|
|
||||||
PW=" "
|
|
||||||
echo -e "${DGN}Using CT ID ${BGN}$NEXTID${CL}"
|
|
||||||
CT_ID=$NEXTID
|
|
||||||
echo -e "${DGN}Using CT Name ${BGN}$NSAPP${CL}"
|
|
||||||
HN=$NSAPP
|
|
||||||
echo -e "${DGN}Using Disk Size ${BGN}3${CL}${DGN}GB${CL}"
|
|
||||||
DISK_SIZE="3"
|
|
||||||
echo -e "${DGN}Using ${BGN}2${CL}${DGN}vCPU${CL}"
|
|
||||||
CORE_COUNT="2"
|
|
||||||
echo -e "${DGN}Using ${BGN}2048${CL}${DGN}MiB RAM${CL}"
|
|
||||||
RAM_SIZE="2048"
|
|
||||||
echo -e "${DGN}Using Bridge ${BGN}vmbr0${CL}"
|
|
||||||
BRG="vmbr0"
|
|
||||||
echo -e "${DGN}Using Static IP Address ${BGN}DHCP${CL}"
|
|
||||||
NET=dhcp
|
|
||||||
echo -e "${DGN}Using Gateway Address ${BGN}NONE${CL}"
|
|
||||||
GATE=""
|
|
||||||
echo -e "${DGN}Using VLAN Tag ${BGN}NONE${CL}"
|
|
||||||
VLAN=""
|
|
||||||
}
|
|
||||||
|
|
||||||
function advanced_settings() {
|
|
||||||
clear
|
|
||||||
header_info
|
|
||||||
echo -e "${RD}Using Advanced Settings${CL}"
|
|
||||||
echo -e "${YW}Type Privileged, or Press [ENTER] for Default: Unprivileged (${RD}NO DEVICE PASSTHROUGH${CL}${YW})"
|
|
||||||
read CT_TYPE1
|
|
||||||
if [ -z $CT_TYPE1 ]; then CT_TYPE1="Unprivileged" CT_TYPE="1";
|
|
||||||
echo -en "${DGN}Set CT Type ${BL}$CT_TYPE1${CL}"
|
|
||||||
else
|
|
||||||
CT_TYPE1="Privileged"
|
|
||||||
CT_TYPE="0"
|
|
||||||
echo -en "${DGN}Set CT Type ${BL}Privileged${CL}"
|
|
||||||
fi;
|
|
||||||
echo -e " ${CM}${CL} \r"
|
|
||||||
sleep 1
|
|
||||||
clear
|
|
||||||
header_info
|
|
||||||
echo -e "${RD}Using Advanced Settings${CL}"
|
|
||||||
echo -e "${DGN}Using CT Type ${BGN}$CT_TYPE1${CL}"
|
|
||||||
echo -e "${YW}Set Password, or Press [ENTER] for Default: Automatic Login "
|
|
||||||
read PW1
|
|
||||||
if [ -z $PW1 ]; then PW1="Automatic Login" PW=" ";
|
|
||||||
echo -en "${DGN}Set CT ${BL}$PW1${CL}"
|
|
||||||
else
|
|
||||||
PW="-password $PW1"
|
|
||||||
echo -en "${DGN}Set CT Password ${BL}$PW1${CL}"
|
|
||||||
fi;
|
|
||||||
echo -e " ${CM}${CL} \r"
|
|
||||||
sleep 1
|
|
||||||
clear
|
|
||||||
header_info
|
|
||||||
echo -e "${RD}Using Advanced Settings${CL}"
|
|
||||||
echo -e "${DGN}Using CT Type ${BGN}$CT_TYPE1${CL}"
|
|
||||||
echo -e "${DGN}Using CT Password ${BGN}$PW1${CL}"
|
|
||||||
echo -e "${YW}Enter the CT ID, or Press [ENTER] to automatically generate (${NEXTID}) "
|
|
||||||
read CT_ID
|
|
||||||
if [ -z $CT_ID ]; then CT_ID=$NEXTID; fi;
|
|
||||||
echo -en "${DGN}Set CT ID To ${BL}$CT_ID${CL}"
|
|
||||||
echo -e " ${CM}${CL} \r"
|
|
||||||
sleep 1
|
|
||||||
clear
|
|
||||||
header_info
|
|
||||||
echo -e "${RD}Using Advanced Settings${CL}"
|
|
||||||
echo -e "${DGN}Using CT Type ${BGN}$CT_TYPE1${CL}"
|
|
||||||
echo -e "${DGN}Using CT Password ${BGN}$PW1${CL}"
|
|
||||||
echo -e "${DGN}Using CT ID ${BGN}$CT_ID${CL}"
|
|
||||||
echo -e "${YW}Enter CT Name (no-spaces), or Press [ENTER] for Default: $NSAPP "
|
|
||||||
read CT_NAME
|
|
||||||
if [ -z $CT_NAME ]; then
|
|
||||||
HN=$NSAPP
|
|
||||||
else
|
|
||||||
HN=$(echo ${CT_NAME,,} | tr -d ' ')
|
|
||||||
fi
|
|
||||||
echo -en "${DGN}Set CT Name To ${BL}$HN${CL}"
|
|
||||||
echo -e " ${CM}${CL} \r"
|
|
||||||
sleep 1
|
|
||||||
clear
|
|
||||||
header_info
|
|
||||||
echo -e "${RD}Using Advanced Settings${CL}"
|
|
||||||
echo -e "${DGN}Using CT Type ${BGN}$CT_TYPE1${CL}"
|
|
||||||
echo -e "${DGN}Using CT Password ${BGN}$PW1${CL}"
|
|
||||||
echo -e "${DGN}Using CT ID ${BGN}$CT_ID${CL}"
|
|
||||||
echo -e "${DGN}Using CT Name ${BGN}$HN${CL}"
|
|
||||||
echo -e "${YW}Enter a Disk Size, or Press [ENTER] for Default: 3 "
|
|
||||||
read DISK_SIZE
|
|
||||||
if [ -z $DISK_SIZE ]; then DISK_SIZE="3"; fi;
|
|
||||||
if ! [[ $DISK_SIZE =~ $INTEGER ]] ; then echo "ERROR! DISK SIZE MUST HAVE INTEGER NUMBER!"; exit; fi;
|
|
||||||
echo -en "${DGN}Set Disk Size To ${BL}$DISK_SIZE${CL}${DGN}GB${CL}"
|
|
||||||
echo -e " ${CM}${CL} \r"
|
|
||||||
sleep 1
|
|
||||||
clear
|
|
||||||
header_info
|
|
||||||
echo -e "${RD}Using Advanced Settings${CL}"
|
|
||||||
echo -e "${DGN}Using CT Type ${BGN}$CT_TYPE1${CL}"
|
|
||||||
echo -e "${DGN}Using CT Password ${BGN}$PW1${CL}"
|
|
||||||
echo -e "${DGN}Using CT ID ${BGN}$CT_ID${CL}"
|
|
||||||
echo -e "${DGN}Using CT Name ${BGN}$HN${CL}"
|
|
||||||
echo -e "${DGN}Using Disk Size ${BGN}$DISK_SIZE${CL}${DGN}GB${CL}"
|
|
||||||
echo -e "${YW}Allocate CPU cores, or Press [ENTER] for Default: 2 "
|
|
||||||
read CORE_COUNT
|
|
||||||
if [ -z $CORE_COUNT ]; then CORE_COUNT="2"; fi;
|
|
||||||
echo -en "${DGN}Set Cores To ${BL}$CORE_COUNT${CL}${DGN}vCPU${CL}"
|
|
||||||
echo -e " ${CM}${CL} \r"
|
|
||||||
sleep 1
|
|
||||||
clear
|
|
||||||
header_info
|
|
||||||
echo -e "${RD}Using Advanced Settings${CL}"
|
|
||||||
echo -e "${DGN}Using CT Type ${BGN}$CT_TYPE1${CL}"
|
|
||||||
echo -e "${DGN}Using CT Password ${BGN}$PW1${CL}"
|
|
||||||
echo -e "${DGN}Using CT ID ${BGN}$CT_ID${CL}"
|
|
||||||
echo -e "${DGN}Using CT Name ${BGN}$HN${CL}"
|
|
||||||
echo -e "${DGN}Using Disk Size ${BGN}$DISK_SIZE${CL}${DGN}GB${CL}"
|
|
||||||
echo -e "${DGN}Using ${BGN}${CORE_COUNT}${CL}${DGN}vCPU${CL}"
|
|
||||||
echo -e "${YW}Allocate RAM in MiB, or Press [ENTER] for Default: 2048 "
|
|
||||||
read RAM_SIZE
|
|
||||||
if [ -z $RAM_SIZE ]; then RAM_SIZE="2048"; fi;
|
|
||||||
echo -en "${DGN}Set RAM To ${BL}$RAM_SIZE${CL}${DGN}MiB RAM${CL}"
|
|
||||||
echo -e " ${CM}${CL} \n"
|
|
||||||
sleep 1
|
|
||||||
clear
|
|
||||||
header_info
|
|
||||||
echo -e "${RD}Using Advanced Settings${CL}"
|
|
||||||
echo -e "${DGN}Using CT Type ${BGN}$CT_TYPE1${CL}"
|
|
||||||
echo -e "${DGN}Using CT Password ${BGN}$PW1${CL}"
|
|
||||||
echo -e "${DGN}Using CT ID ${BGN}$CT_ID${CL}"
|
|
||||||
echo -e "${DGN}Using CT Name ${BGN}$HN${CL}"
|
|
||||||
echo -e "${DGN}Using Disk Size ${BGN}$DISK_SIZE${CL}${DGN}GB${CL}"
|
|
||||||
echo -e "${DGN}Using ${BGN}${CORE_COUNT}${CL}${DGN}vCPU${CL}"
|
|
||||||
echo -e "${DGN}Using ${BGN}${RAM_SIZE}${CL}${DGN}MiB RAM${CL}"
|
|
||||||
echo -e "${YW}Enter a Bridge, or Press [ENTER] for Default: vmbr0 "
|
|
||||||
read BRG
|
|
||||||
if [ -z $BRG ]; then BRG="vmbr0"; fi;
|
|
||||||
echo -en "${DGN}Set Bridge To ${BL}$BRG${CL}"
|
|
||||||
echo -e " ${CM}${CL} \n"
|
|
||||||
sleep 1
|
|
||||||
clear
|
|
||||||
header_info
|
|
||||||
echo -e "${RD}Using Advanced Settings${CL}"
|
|
||||||
echo -e "${DGN}Using CT Type ${BGN}$CT_TYPE1${CL}"
|
|
||||||
echo -e "${DGN}Using CT Password ${BGN}$PW1${CL}"
|
|
||||||
echo -e "${DGN}Using CT ID ${BGN}$CT_ID${CL}"
|
|
||||||
echo -e "${DGN}Using CT Name ${BGN}$HN${CL}"
|
|
||||||
echo -e "${DGN}Using Disk Size ${BGN}$DISK_SIZE${CL}${DGN}GB${CL}"
|
|
||||||
echo -e "${DGN}Using ${BGN}${CORE_COUNT}${CL}${DGN}vCPU${CL}"
|
|
||||||
echo -e "${DGN}Using ${BGN}${RAM_SIZE}${CL}${DGN}MiB RAM${CL}"
|
|
||||||
echo -e "${DGN}Using Bridge ${BGN}${BRG}${CL}"
|
|
||||||
echo -e "${YW}Enter a Static IPv4 CIDR Address, or Press [ENTER] for Default: DHCP "
|
|
||||||
read NET
|
|
||||||
if [ -z $NET ]; then NET="dhcp"; fi;
|
|
||||||
echo -en "${DGN}Set Static IP Address To ${BL}$NET${CL}"
|
|
||||||
echo -e " ${CM}${CL} \n"
|
|
||||||
sleep 1
|
|
||||||
clear
|
|
||||||
header_info
|
|
||||||
echo -e "${RD}Using Advanced Settings${CL}"
|
|
||||||
echo -e "${DGN}Using CT Type ${BGN}$CT_TYPE1${CL}"
|
|
||||||
echo -e "${DGN}Using CT Password ${BGN}$PW1${CL}"
|
|
||||||
echo -e "${DGN}Using CT ID ${BGN}$CT_ID${CL}"
|
|
||||||
echo -e "${DGN}Using CT Name ${BGN}$HN${CL}"
|
|
||||||
echo -e "${DGN}Using Disk Size ${BGN}$DISK_SIZE${CL}${DGN}GB${CL}"
|
|
||||||
echo -e "${DGN}Using ${BGN}${CORE_COUNT}${CL}${DGN}vCPU${CL}"
|
|
||||||
echo -e "${DGN}Using ${BGN}${RAM_SIZE}${CL}${DGN}MiB RAM${CL}"
|
|
||||||
echo -e "${DGN}Using Bridge ${BGN}${BRG}${CL}"
|
|
||||||
echo -e "${DGN}Using Static IP Address ${BGN}$NET${CL}"
|
|
||||||
echo -e "${YW}Enter a Gateway IP (mandatory if static IP is used), or Press [ENTER] for Default: NONE "
|
|
||||||
read GATE1
|
|
||||||
if [ -z $GATE1 ]; then GATE1="NONE" GATE="";
|
|
||||||
echo -en "${DGN}Set Gateway IP To ${BL}$GATE1${CL}"
|
|
||||||
else
|
|
||||||
GATE=",gw=$GATE1"
|
|
||||||
echo -en "${DGN}Set Gateway IP To ${BL}$GATE1${CL}"
|
|
||||||
fi;
|
|
||||||
echo -e " ${CM}${CL} \n"
|
|
||||||
sleep 1
|
|
||||||
clear
|
|
||||||
header_info
|
|
||||||
|
|
||||||
echo -e "${RD}Using Advanced Settings${CL}"
|
|
||||||
echo -e "${DGN}Using CT Type ${BGN}$CT_TYPE1${CL}"
|
|
||||||
echo -e "${DGN}Using CT Password ${BGN}$PW1${CL}"
|
|
||||||
echo -e "${DGN}Using CT ID ${BGN}$CT_ID${CL}"
|
|
||||||
echo -e "${DGN}Using CT Name ${BGN}$HN${CL}"
|
|
||||||
echo -e "${DGN}Using Disk Size ${BGN}$DISK_SIZE${CL}${DGN}GB${CL}"
|
|
||||||
echo -e "${DGN}Using ${BGN}${CORE_COUNT}${CL}${DGN}vCPU${CL}"
|
|
||||||
echo -e "${DGN}Using ${BGN}${RAM_SIZE}${CL}${DGN}MiB RAM${CL}"
|
|
||||||
echo -e "${DGN}Using Bridge ${BGN}${BRG}${CL}"
|
|
||||||
echo -e "${DGN}Using Static IP Address ${BGN}$NET${CL}"
|
|
||||||
echo -e "${DGN}Using Gateway IP Address ${BGN}$GATE1${CL}"
|
|
||||||
echo -e "${YW}Enter a VLAN Tag, or Press [ENTER] for Default: NONE "
|
|
||||||
read VLAN1
|
|
||||||
if [ -z $VLAN1 ]; then VLAN1="NONE" VLAN="";
|
|
||||||
echo -en "${DGN}Set VLAN Tag To ${BL}$VLAN1${CL}"
|
|
||||||
else
|
|
||||||
VLAN=",tag=$VLAN1"
|
|
||||||
echo -en "${DGN}Set VLAN Tag To ${BL}$VLAN1${CL}"
|
|
||||||
fi;
|
|
||||||
echo -e " ${CM}${CL} \n"
|
|
||||||
sleep 1
|
|
||||||
clear
|
|
||||||
header_info
|
|
||||||
echo -e "${RD}Using Advanced Settings${CL}"
|
|
||||||
echo -e "${DGN}Using CT Type ${BGN}$CT_TYPE1${CL}"
|
|
||||||
echo -e "${DGN}Using CT Password ${BGN}$PW1${CL}"
|
|
||||||
echo -e "${DGN}Using CT ID ${BGN}$CT_ID${CL}"
|
|
||||||
echo -e "${DGN}Using CT Name ${BGN}$HN${CL}"
|
|
||||||
echo -e "${DGN}Using Disk Size ${BGN}$DISK_SIZE${CL}${DGN}GB${CL}"
|
|
||||||
echo -e "${DGN}Using ${BGN}${CORE_COUNT}${CL}${DGN}vCPU${CL}"
|
|
||||||
echo -e "${DGN}Using ${BGN}${RAM_SIZE}${CL}${DGN}MiB RAM${CL}"
|
|
||||||
echo -e "${DGN}Using Bridge ${BGN}${BRG}${CL}"
|
|
||||||
echo -e "${DGN}Using Static IP Address ${BGN}$NET${CL}"
|
|
||||||
echo -e "${DGN}Using Gateway IP Address ${BGN}$GATE1${CL}"
|
|
||||||
echo -e "${DGN}Using VLAN Tag ${BGN}$VLAN1${CL}"
|
|
||||||
|
|
||||||
read -p "Are these settings correct(y/n)? " -n 1 -r
|
|
||||||
echo
|
|
||||||
if [[ ! $REPLY =~ ^[Yy]$ ]]
|
|
||||||
then
|
|
||||||
advanced_settings
|
|
||||||
fi
|
|
||||||
}
|
|
||||||
|
|
||||||
function start_script() {
|
|
||||||
echo -e "${YW}Type Advanced, or Press [ENTER] for Default Settings "
|
|
||||||
read SETTINGS
|
|
||||||
if [ -z $SETTINGS ]; then default_settings;
|
|
||||||
else
|
|
||||||
advanced_settings
|
|
||||||
fi;
|
|
||||||
}
|
|
||||||
|
|
||||||
start_script
|
|
||||||
|
|
||||||
if [ "$CT_TYPE" == "1" ]; then
|
|
||||||
FEATURES="nesting=1,keyctl=1"
|
|
||||||
else
|
|
||||||
FEATURES="nesting=1"
|
|
||||||
fi
|
|
||||||
|
|
||||||
TEMP_DIR=$(mktemp -d)
|
|
||||||
pushd $TEMP_DIR >/dev/null
|
|
||||||
|
|
||||||
export CTID=$CT_ID
|
|
||||||
export PCT_OSTYPE=debian
|
|
||||||
export PCT_OSVERSION=11
|
|
||||||
export PCT_DISK_SIZE=$DISK_SIZE
|
|
||||||
export PCT_OPTIONS="
|
|
||||||
-features $FEATURES
|
|
||||||
-hostname $HN
|
|
||||||
-net0 name=eth0,bridge=$BRG,ip=$NET$GATE$VLAN
|
|
||||||
-onboot 1
|
|
||||||
-cores $CORE_COUNT
|
|
||||||
-memory $RAM_SIZE
|
|
||||||
-unprivileged $CT_TYPE
|
|
||||||
$PW
|
|
||||||
"
|
|
||||||
bash -c "$(wget -qLO - https://raw.githubusercontent.com/tteck/Proxmox/main/ct/create_lxc.sh)" || exit
|
|
||||||
|
|
||||||
msg_info "Starting LXC Container"
|
|
||||||
pct start $CTID
|
|
||||||
msg_ok "Started LXC Container"
|
|
||||||
|
|
||||||
lxc-attach -n $CTID -- bash -c "$(wget -qLO - https://raw.githubusercontent.com/tteck/Proxmox/main/setup/dashy-install.sh)" || exit
|
|
||||||
|
|
||||||
IP=$(pct exec $CTID ip a s dev eth0 | sed -n '/inet / s/\// /p' | awk '{print $2}')
|
|
||||||
|
|
||||||
pct set $CTID -description "# ${APP} LXC
|
|
||||||
### https://github.com/tteck/Proxmox"
|
|
||||||
|
|
||||||
msg_ok "Completed Successfully!\n"
|
|
||||||
echo -e "${APP} should be reachable by going to the following URL.
|
|
||||||
${BL}http://${IP}:4000${CL} \n"
|
|
|
@ -310,7 +310,7 @@ bash -c "$(wget -qLO - https://raw.githubusercontent.com/tteck/Proxmox/main/ct/c
|
||||||
msg_info "Starting LXC Container"
|
msg_info "Starting LXC Container"
|
||||||
pct start $CTID
|
pct start $CTID
|
||||||
msg_ok "Started LXC Container"
|
msg_ok "Started LXC Container"
|
||||||
lxc-attach -n $CTID -- bash -c "$(wget -qLO - https://raw.githubusercontent.com/tteck/Proxmox/main/setup/$var_install.sh)" || exit
|
lxc-attach -n $CTID -- bash -c "$(wget -qLO - https://raw.githubusercontent.com/tteck/Proxmox/main/install/$var_install.sh)" || exit
|
||||||
IP=$(pct exec $CTID ip a s dev eth0 | sed -n '/inet / s/\// /p' | awk '{print $2}')
|
IP=$(pct exec $CTID ip a s dev eth0 | sed -n '/inet / s/\// /p' | awk '{print $2}')
|
||||||
pct set $CTID -description "# ${APP} LXC
|
pct set $CTID -description "# ${APP} LXC
|
||||||
### https://tteck.github.io/Proxmox/
|
### https://tteck.github.io/Proxmox/
|
||||||
|
|
165
ct/debian-v1.sh
165
ct/debian-v1.sh
|
@ -1,165 +0,0 @@
|
||||||
#!/usr/bin/env bash
|
|
||||||
|
|
||||||
while true; do
|
|
||||||
read -p "This will create a New Debian 11 LXC Container. Proceed(y/n)?" yn
|
|
||||||
case $yn in
|
|
||||||
[Yy]* ) break;;
|
|
||||||
[Nn]* ) exit;;
|
|
||||||
* ) echo "Please answer yes or no.";;
|
|
||||||
esac
|
|
||||||
done
|
|
||||||
|
|
||||||
set -o errexit
|
|
||||||
set -o errtrace
|
|
||||||
set -o nounset
|
|
||||||
set -o pipefail
|
|
||||||
shopt -s expand_aliases
|
|
||||||
alias die='EXIT=$? LINE=$LINENO error_exit'
|
|
||||||
CHECKMARK='\033[0;32m\xE2\x9C\x94\033[0m'
|
|
||||||
trap die ERR
|
|
||||||
trap cleanup EXIT
|
|
||||||
|
|
||||||
function error_exit() {
|
|
||||||
trap - ERR
|
|
||||||
local DEFAULT='Unknown failure occured.'
|
|
||||||
local REASON="\e[97m${1:-$DEFAULT}\e[39m"
|
|
||||||
local FLAG="\e[91m[ERROR] \e[93m$EXIT@$LINE"
|
|
||||||
msg "$FLAG $REASON"
|
|
||||||
[ ! -z ${CTID-} ] && cleanup_ctid
|
|
||||||
exit $EXIT
|
|
||||||
}
|
|
||||||
function warn() {
|
|
||||||
local REASON="\e[97m$1\e[39m"
|
|
||||||
local FLAG="\e[93m[WARNING]\e[39m"
|
|
||||||
msg "$FLAG $REASON"
|
|
||||||
}
|
|
||||||
function info() {
|
|
||||||
local REASON="$1"
|
|
||||||
local FLAG="\e[36m[INFO]\e[39m"
|
|
||||||
msg "$FLAG $REASON"
|
|
||||||
}
|
|
||||||
function msg() {
|
|
||||||
local TEXT="$1"
|
|
||||||
echo -e "$TEXT"
|
|
||||||
}
|
|
||||||
function cleanup_ctid() {
|
|
||||||
if [ ! -z ${MOUNT+x} ]; then
|
|
||||||
pct unmount $CTID
|
|
||||||
fi
|
|
||||||
if $(pct status $CTID &>/dev/null); then
|
|
||||||
if [ "$(pct status $CTID | awk '{print $2}')" == "running" ]; then
|
|
||||||
pct stop $CTID
|
|
||||||
fi
|
|
||||||
pct destroy $CTID
|
|
||||||
elif [ "$(pvesm list $STORAGE --vmid $CTID)" != "" ]; then
|
|
||||||
pvesm free $ROOTFS
|
|
||||||
fi
|
|
||||||
}
|
|
||||||
function cleanup() {
|
|
||||||
popd >/dev/null
|
|
||||||
rm -rf $TEMP_DIR
|
|
||||||
}
|
|
||||||
function load_module() {
|
|
||||||
if ! $(lsmod | grep -Fq $1); then
|
|
||||||
modprobe $1 &>/dev/null || \
|
|
||||||
die "Failed to load '$1' module."
|
|
||||||
fi
|
|
||||||
MODULES_PATH=/etc/modules
|
|
||||||
if ! $(grep -Fxq "$1" $MODULES_PATH); then
|
|
||||||
echo "$1" >> $MODULES_PATH || \
|
|
||||||
die "Failed to add '$1' module to load at boot."
|
|
||||||
fi
|
|
||||||
}
|
|
||||||
TEMP_DIR=$(mktemp -d)
|
|
||||||
pushd $TEMP_DIR >/dev/null
|
|
||||||
|
|
||||||
wget -qL https://raw.githubusercontent.com/tteck/Proxmox/main/setup/debian11_setup.sh
|
|
||||||
|
|
||||||
load_module overlay
|
|
||||||
|
|
||||||
while read -r line; do
|
|
||||||
TAG=$(echo $line | awk '{print $1}')
|
|
||||||
TYPE=$(echo $line | awk '{printf "%-10s", $2}')
|
|
||||||
FREE=$(echo $line | numfmt --field 4-6 --from-unit=K --to=iec --format %.2f | awk '{printf( "%9sB", $6)}')
|
|
||||||
ITEM=" Type: $TYPE Free: $FREE "
|
|
||||||
OFFSET=2
|
|
||||||
if [[ $((${#ITEM} + $OFFSET)) -gt ${MSG_MAX_LENGTH:-} ]]; then
|
|
||||||
MSG_MAX_LENGTH=$((${#ITEM} + $OFFSET))
|
|
||||||
fi
|
|
||||||
STORAGE_MENU+=( "$TAG" "$ITEM" "OFF" )
|
|
||||||
done < <(pvesm status -content rootdir | awk 'NR>1')
|
|
||||||
if [ $((${#STORAGE_MENU[@]}/3)) -eq 0 ]; then
|
|
||||||
warn "'Container' needs to be selected for at least one storage location."
|
|
||||||
die "Unable to detect valid storage location."
|
|
||||||
elif [ $((${#STORAGE_MENU[@]}/3)) -eq 1 ]; then
|
|
||||||
STORAGE=${STORAGE_MENU[0]}
|
|
||||||
else
|
|
||||||
while [ -z "${STORAGE:+x}" ]; do
|
|
||||||
STORAGE=$(whiptail --title "Storage Pools" --radiolist \
|
|
||||||
"Which storage pool you would like to use for the container?\n\n" \
|
|
||||||
16 $(($MSG_MAX_LENGTH + 23)) 6 \
|
|
||||||
"${STORAGE_MENU[@]}" 3>&1 1>&2 2>&3) || exit
|
|
||||||
done
|
|
||||||
fi
|
|
||||||
info "Using '$STORAGE' for storage location."
|
|
||||||
|
|
||||||
CTID=$(pvesh get /cluster/nextid)
|
|
||||||
info "Container ID is $CTID."
|
|
||||||
|
|
||||||
echo -e "${CHECKMARK} \e[1;92m Updating LXC Template List... \e[0m"
|
|
||||||
pveam update >/dev/null
|
|
||||||
|
|
||||||
echo -e "${CHECKMARK} \e[1;92m Downloading LXC Template... \e[0m"
|
|
||||||
OSTYPE=debian
|
|
||||||
OSVERSION=${OSTYPE}-11
|
|
||||||
mapfile -t TEMPLATES < <(pveam available -section system | sed -n "s/.*\($OSVERSION.*\)/\1/p" | sort -t - -k 2 -V)
|
|
||||||
TEMPLATE="${TEMPLATES[-1]}"
|
|
||||||
pveam download local $TEMPLATE >/dev/null ||
|
|
||||||
die "A problem occured while downloading the LXC template."
|
|
||||||
|
|
||||||
STORAGE_TYPE=$(pvesm status -storage $STORAGE | awk 'NR>1 {print $2}')
|
|
||||||
case $STORAGE_TYPE in
|
|
||||||
dir|nfs)
|
|
||||||
DISK_EXT=".raw"
|
|
||||||
DISK_REF="$CTID/"
|
|
||||||
;;
|
|
||||||
zfspool)
|
|
||||||
DISK_PREFIX="subvol"
|
|
||||||
DISK_FORMAT="subvol"
|
|
||||||
;;
|
|
||||||
esac
|
|
||||||
DISK=${DISK_PREFIX:-vm}-${CTID}-disk-0${DISK_EXT-}
|
|
||||||
ROOTFS=${STORAGE}:${DISK_REF-}${DISK}
|
|
||||||
|
|
||||||
echo -e "${CHECKMARK} \e[1;92m Creating LXC Container... \e[0m"
|
|
||||||
DISK_SIZE=2G
|
|
||||||
pvesm alloc $STORAGE $CTID $DISK $DISK_SIZE --format ${DISK_FORMAT:-raw} >/dev/null
|
|
||||||
if [ "$STORAGE_TYPE" == "zfspool" ]; then
|
|
||||||
warn "Some containers may not work properly due to ZFS not supporting 'fallocate'."
|
|
||||||
else
|
|
||||||
mkfs.ext4 $(pvesm path $ROOTFS) &>/dev/null
|
|
||||||
fi
|
|
||||||
ARCH=$(dpkg --print-architecture)
|
|
||||||
HOSTNAME=debian11
|
|
||||||
TEMPLATE_STRING="local:vztmpl/${TEMPLATE}"
|
|
||||||
pct create $CTID $TEMPLATE_STRING -arch $ARCH -features nesting=1 \
|
|
||||||
-hostname $HOSTNAME -net0 name=eth0,bridge=vmbr0,ip=dhcp -onboot 1 -cores 1 -memory 512\
|
|
||||||
-ostype $OSTYPE -rootfs $ROOTFS,size=$DISK_SIZE -storage $STORAGE >/dev/null
|
|
||||||
|
|
||||||
LXC_CONFIG=/etc/pve/lxc/${CTID}.conf
|
|
||||||
cat <<EOF >> $LXC_CONFIG
|
|
||||||
lxc.cgroup2.devices.allow: a
|
|
||||||
lxc.cap.drop:
|
|
||||||
EOF
|
|
||||||
|
|
||||||
MOUNT=$(pct mount $CTID | cut -d"'" -f 2)
|
|
||||||
ln -fs $(readlink /etc/localtime) ${MOUNT}/etc/localtime
|
|
||||||
pct unmount $CTID && unset MOUNT
|
|
||||||
|
|
||||||
echo -e "${CHECKMARK} \e[1;92m Starting LXC Container... \e[0m"
|
|
||||||
pct start $CTID
|
|
||||||
pct push $CTID debian11_setup.sh /debian11_setup.sh -perms 755
|
|
||||||
pct exec $CTID /debian11_setup.sh
|
|
||||||
|
|
||||||
IP=$(pct exec $CTID ip a s dev eth0 | sed -n '/inet / s/\// /p' | awk '{print $2}')
|
|
||||||
info "Successfully created a Debian 11 LXC Container to $CTID at IP Address ${IP}"
|
|
257
ct/debian-v2.sh
257
ct/debian-v2.sh
|
@ -1,257 +0,0 @@
|
||||||
#!/usr/bin/env bash
|
|
||||||
YW=`echo "\033[33m"`
|
|
||||||
BL=`echo "\033[36m"`
|
|
||||||
RD=`echo "\033[01;31m"`
|
|
||||||
CM='\xE2\x9C\x94\033'
|
|
||||||
GN=`echo "\033[32m"`
|
|
||||||
CL=`echo "\033[m"`
|
|
||||||
APP="Debian"
|
|
||||||
HN=$(echo ${APP,,} | tr -d ' ')
|
|
||||||
while true; do
|
|
||||||
read -p "This will create a New ${APP} LXC. Proceed(y/n)?" yn
|
|
||||||
case $yn in
|
|
||||||
[Yy]* ) break;;
|
|
||||||
[Nn]* ) exit;;
|
|
||||||
* ) echo "Please answer yes or no.";;
|
|
||||||
esac
|
|
||||||
done
|
|
||||||
clear
|
|
||||||
function header_info {
|
|
||||||
echo -e "${RD}
|
|
||||||
_____ _ _
|
|
||||||
| __ \ | | (_)
|
|
||||||
| | | | ___| |__ _ __ _ _ __
|
|
||||||
| | | |/ _ \ _ \| |/ _ | _ \
|
|
||||||
| |__| | __/ |_) | | (_| | | | |
|
|
||||||
|_____/ \___|_.__/|_|\__,_|_| |_|
|
|
||||||
|
|
||||||
${CL}"
|
|
||||||
}
|
|
||||||
|
|
||||||
header_info
|
|
||||||
show_menu(){
|
|
||||||
printf " ${YW} 1)${YW} Privileged ${CL}\n"
|
|
||||||
printf " ${YW} 2)${GN} Unprivileged ${CL}\n"
|
|
||||||
|
|
||||||
printf "Please choose a Install Method and hit enter or ${RD}x${CL} to exit."
|
|
||||||
read opt
|
|
||||||
}
|
|
||||||
|
|
||||||
option_picked(){
|
|
||||||
message1=${@:-"${CL}Error: No message passed"}
|
|
||||||
printf " ${YW}${message1}${CL}\n"
|
|
||||||
}
|
|
||||||
show_menu
|
|
||||||
while [ "$opt" != " " ]
|
|
||||||
do
|
|
||||||
case $opt in
|
|
||||||
1) clear;
|
|
||||||
header_info;
|
|
||||||
option_picked "Using Privileged Install";
|
|
||||||
IM=0
|
|
||||||
break;
|
|
||||||
;;
|
|
||||||
2) clear;
|
|
||||||
header_info;
|
|
||||||
option_picked "Using Unprivileged Install";
|
|
||||||
IM=1
|
|
||||||
break;
|
|
||||||
;;
|
|
||||||
|
|
||||||
x)exit;
|
|
||||||
;;
|
|
||||||
\n)exit;
|
|
||||||
;;
|
|
||||||
*)clear;
|
|
||||||
option_picked "Please choose a Install Method from the menu";
|
|
||||||
show_menu;
|
|
||||||
;;
|
|
||||||
esac
|
|
||||||
done
|
|
||||||
show_menu2(){
|
|
||||||
printf " ${YW} 1)${GN} Use Automatic Login ${CL}\n"
|
|
||||||
printf " ${YW} 2)${GN} Use Password (changeme) ${CL}\n"
|
|
||||||
|
|
||||||
printf "Please choose a Password Type and hit enter or ${RD}x${CL} to exit."
|
|
||||||
read opt
|
|
||||||
}
|
|
||||||
|
|
||||||
option_picked(){
|
|
||||||
message2=${@:-"${CL}Error: No message passed"}
|
|
||||||
printf " ${YW}${message1}${CL}\n"
|
|
||||||
printf " ${YW}${message2}${CL}\n"
|
|
||||||
}
|
|
||||||
show_menu2
|
|
||||||
while [ "$opt" != " " ]
|
|
||||||
do
|
|
||||||
case $opt in
|
|
||||||
1) clear;
|
|
||||||
header_info;
|
|
||||||
option_picked "Using Automatic Login";
|
|
||||||
PW=" "
|
|
||||||
break;
|
|
||||||
;;
|
|
||||||
2) clear;
|
|
||||||
header_info;
|
|
||||||
option_picked "Using Password (changeme)";
|
|
||||||
PW="-password changeme"
|
|
||||||
break;
|
|
||||||
;;
|
|
||||||
|
|
||||||
x)exit;
|
|
||||||
;;
|
|
||||||
\n)exit;
|
|
||||||
;;
|
|
||||||
*)clear;
|
|
||||||
option_picked "Please choose a Password Type from the menu";
|
|
||||||
show_menu2;
|
|
||||||
;;
|
|
||||||
esac
|
|
||||||
done
|
|
||||||
show_menu3(){
|
|
||||||
printf " ${YW} 1)${GN} Automatic DHCP ${CL}\n"
|
|
||||||
printf " ${YW} 2)${GN} Manual DHCP ${CL}\n"
|
|
||||||
|
|
||||||
printf "Please choose a DHCP Type and hit enter or ${RD}x${CL} to exit."
|
|
||||||
read opt
|
|
||||||
}
|
|
||||||
|
|
||||||
option_picked(){
|
|
||||||
message3=${@:-"${CL}Error: No message passed"}
|
|
||||||
printf " ${YW}${message1}${CL}\n"
|
|
||||||
printf " ${YW}${message2}${CL}\n"
|
|
||||||
printf " ${YW}${message3}${CL}\n"
|
|
||||||
}
|
|
||||||
show_menu3
|
|
||||||
while [ "$opt" != " " ]
|
|
||||||
do
|
|
||||||
case $opt in
|
|
||||||
1) clear;
|
|
||||||
header_info;
|
|
||||||
option_picked "Using Automatic DHCP";
|
|
||||||
DHCP=" "
|
|
||||||
break;
|
|
||||||
;;
|
|
||||||
2) clear;
|
|
||||||
header_info;
|
|
||||||
option_picked "Using Manual DHCP";
|
|
||||||
DHCP="1"
|
|
||||||
break;
|
|
||||||
;;
|
|
||||||
|
|
||||||
x)exit;
|
|
||||||
;;
|
|
||||||
\n)exit;
|
|
||||||
;;
|
|
||||||
*)clear;
|
|
||||||
option_picked "Please choose a DHCP Type from the menu";
|
|
||||||
show_menu3;
|
|
||||||
;;
|
|
||||||
esac
|
|
||||||
done
|
|
||||||
|
|
||||||
set -o errexit
|
|
||||||
set -o errtrace
|
|
||||||
set -o nounset
|
|
||||||
set -o pipefail
|
|
||||||
shopt -s expand_aliases
|
|
||||||
alias die='EXIT=$? LINE=$LINENO error_exit'
|
|
||||||
trap die ERR
|
|
||||||
trap cleanup EXIT
|
|
||||||
|
|
||||||
function error_exit() {
|
|
||||||
trap - ERR
|
|
||||||
local DEFAULT='Unknown failure occured.'
|
|
||||||
local REASON="\e[97m${1:-$DEFAULT}\e[39m"
|
|
||||||
local FLAG="\e[91m[ERROR] \e[93m$EXIT@$LINE"
|
|
||||||
msg "$FLAG $REASON"
|
|
||||||
[ ! -z ${CTID-} ] && cleanup_ctid
|
|
||||||
exit $EXIT
|
|
||||||
}
|
|
||||||
function warn() {
|
|
||||||
local REASON="\e[97m$1\e[39m"
|
|
||||||
local FLAG="\e[93m[WARNING]\e[39m"
|
|
||||||
msg "$FLAG $REASON"
|
|
||||||
}
|
|
||||||
function info() {
|
|
||||||
local REASON="$1"
|
|
||||||
local FLAG="\e[36m[INFO]\e[39m"
|
|
||||||
msg "$FLAG $REASON"
|
|
||||||
}
|
|
||||||
function msg() {
|
|
||||||
local TEXT="$1"
|
|
||||||
echo -e "$TEXT"
|
|
||||||
}
|
|
||||||
function cleanup_ctid() {
|
|
||||||
if $(pct status $CTID &>/dev/null); then
|
|
||||||
if [ "$(pct status $CTID | awk '{print $2}')" == "running" ]; then
|
|
||||||
pct stop $CTID
|
|
||||||
fi
|
|
||||||
pct destroy $CTID
|
|
||||||
elif [ "$(pvesm list $STORAGE --vmid $CTID)" != "" ]; then
|
|
||||||
pvesm free $ROOTFS
|
|
||||||
fi
|
|
||||||
}
|
|
||||||
function cleanup() {
|
|
||||||
popd >/dev/null
|
|
||||||
rm -rf $TEMP_DIR
|
|
||||||
}
|
|
||||||
if [ "$IM" == "1" ]; then
|
|
||||||
FEATURES="nesting=1,keyctl=1"
|
|
||||||
else
|
|
||||||
FEATURES="nesting=1"
|
|
||||||
fi
|
|
||||||
|
|
||||||
TEMP_DIR=$(mktemp -d)
|
|
||||||
pushd $TEMP_DIR >/dev/null
|
|
||||||
|
|
||||||
export CTID=$(pvesh get /cluster/nextid)
|
|
||||||
export PCT_OSTYPE=debian
|
|
||||||
export PCT_OSVERSION=11
|
|
||||||
export PCT_DISK_SIZE=2
|
|
||||||
export PCT_OPTIONS="
|
|
||||||
-features $FEATURES
|
|
||||||
-hostname $HN
|
|
||||||
-net0 name=eth0,bridge=vmbr0,ip=dhcp
|
|
||||||
-onboot 1
|
|
||||||
-cores 1
|
|
||||||
-memory 512
|
|
||||||
-unprivileged ${IM}
|
|
||||||
${PW}
|
|
||||||
"
|
|
||||||
bash -c "$(wget -qLO - https://raw.githubusercontent.com/tteck/Proxmox/main/ct/create_lxc.sh)" || exit
|
|
||||||
|
|
||||||
STORAGE_TYPE=$(pvesm status -storage $(pct config $CTID | grep rootfs | awk -F ":" '{print $2}') | awk 'NR>1 {print $2}')
|
|
||||||
if [ "$STORAGE_TYPE" == "zfspool" ]; then
|
|
||||||
warn "Some applications may not work properly due to ZFS not supporting 'fallocate'."
|
|
||||||
fi
|
|
||||||
LXC_CONFIG=/etc/pve/lxc/${CTID}.conf
|
|
||||||
cat <<EOF >> $LXC_CONFIG
|
|
||||||
lxc.cgroup2.devices.allow: a
|
|
||||||
lxc.cap.drop:
|
|
||||||
EOF
|
|
||||||
if [ "$DHCP" == "1" ]; then
|
|
||||||
MAC=$(pct config $CTID \
|
|
||||||
| grep -i hwaddr \
|
|
||||||
| awk '{print substr($2, 31, length($3) 17 ) }') \
|
|
||||||
|
|
||||||
echo -e "MAC Address ${BL}$MAC${CL}"
|
|
||||||
|
|
||||||
dhcp_reservation(){
|
|
||||||
printf "Please set DHCP reservation and press Enter."
|
|
||||||
read
|
|
||||||
}
|
|
||||||
dhcp_reservation
|
|
||||||
fi
|
|
||||||
|
|
||||||
echo -en "${GN} Starting LXC Container... "
|
|
||||||
pct start $CTID
|
|
||||||
echo -e "${CM}${CL} \r"
|
|
||||||
|
|
||||||
alias lxc-cmd="lxc-attach -n $CTID --"
|
|
||||||
|
|
||||||
lxc-cmd bash -c "$(wget -qLO - https://raw.githubusercontent.com/tteck/Proxmox/main/setup/$HN-install.sh)" || exit
|
|
||||||
|
|
||||||
IP=$(pct exec $CTID ip a s dev eth0 | sed -n '/inet / s/\// /p' | awk '{print $2}')
|
|
||||||
|
|
||||||
echo -e "${GN}Successfully created ${APP} LXC to${CL} ${BL}$CTID${CL}. \n"
|
|
357
ct/debian-v3.sh
357
ct/debian-v3.sh
|
@ -1,357 +0,0 @@
|
||||||
#!/usr/bin/env bash
|
|
||||||
echo -e "Loading..."
|
|
||||||
APP="Debian"
|
|
||||||
var_disk="2"
|
|
||||||
var_cpu="1"
|
|
||||||
var_ram="512"
|
|
||||||
var_os="debian"
|
|
||||||
var_version="11"
|
|
||||||
NEXTID=$(pvesh get /cluster/nextid)
|
|
||||||
INTEGER='^[0-9]+$'
|
|
||||||
NSAPP=$(echo ${APP,,} | tr -d ' ')
|
|
||||||
var_install="${NSAPP}-install"
|
|
||||||
YW=`echo "\033[33m"`
|
|
||||||
BL=`echo "\033[36m"`
|
|
||||||
RD=`echo "\033[01;31m"`
|
|
||||||
BGN=`echo "\033[4;92m"`
|
|
||||||
GN=`echo "\033[1;92m"`
|
|
||||||
DGN=`echo "\033[32m"`
|
|
||||||
CL=`echo "\033[m"`
|
|
||||||
BFR="\\r\\033[K"
|
|
||||||
HOLD="-"
|
|
||||||
CM="${GN}✓${CL}"
|
|
||||||
set -o errexit
|
|
||||||
set -o errtrace
|
|
||||||
set -o nounset
|
|
||||||
set -o pipefail
|
|
||||||
shopt -s expand_aliases
|
|
||||||
alias die='EXIT=$? LINE=$LINENO error_exit'
|
|
||||||
trap die ERR
|
|
||||||
|
|
||||||
function error_exit() {
|
|
||||||
trap - ERR
|
|
||||||
local reason="Unknown failure occurred."
|
|
||||||
local msg="${1:-$reason}"
|
|
||||||
local flag="${RD}‼ ERROR ${CL}$EXIT@$LINE"
|
|
||||||
echo -e "$flag $msg" 1>&2
|
|
||||||
exit $EXIT
|
|
||||||
}
|
|
||||||
|
|
||||||
function msg_info() {
|
|
||||||
local msg="$1"
|
|
||||||
echo -ne " ${HOLD} ${YW}${msg}..."
|
|
||||||
}
|
|
||||||
|
|
||||||
function msg_ok() {
|
|
||||||
local msg="$1"
|
|
||||||
echo -e "${BFR} ${CM} ${GN}${msg}${CL}"
|
|
||||||
}
|
|
||||||
|
|
||||||
while true; do
|
|
||||||
clear
|
|
||||||
read -p "This will create a New ${APP} LXC. Proceed(y/n)?" yn
|
|
||||||
case $yn in
|
|
||||||
[Yy]* ) break;;
|
|
||||||
[Nn]* ) exit;;
|
|
||||||
* ) echo "Please answer yes or no.";;
|
|
||||||
esac
|
|
||||||
done
|
|
||||||
clear
|
|
||||||
function header_info {
|
|
||||||
echo -e "${RD}
|
|
||||||
_____ _ _
|
|
||||||
| __ \ | | (_)
|
|
||||||
| | | | ___| |__ _ __ _ _ __
|
|
||||||
| | | |/ _ \ _ \| |/ _ | _ \
|
|
||||||
| |__| | __/ |_) | | (_| | | | |
|
|
||||||
|_${YW}v3${RD}__/ \___|_.__/|_|\__,_|_| |_|
|
|
||||||
${CL}"
|
|
||||||
}
|
|
||||||
|
|
||||||
header_info
|
|
||||||
|
|
||||||
function PVE_CHECK() {
|
|
||||||
PVE=$(pveversion | grep "pve-manager/7" | wc -l)
|
|
||||||
|
|
||||||
if [[ $PVE != 1 ]]; then
|
|
||||||
echo -e "${RD}This script requires Proxmox Virtual Environment 7.0 or greater${CL}"
|
|
||||||
echo -e "Exiting..."
|
|
||||||
sleep 2
|
|
||||||
exit
|
|
||||||
fi
|
|
||||||
}
|
|
||||||
|
|
||||||
function default_settings() {
|
|
||||||
clear
|
|
||||||
header_info
|
|
||||||
echo -e "${BL}Using Default Settings${CL}"
|
|
||||||
echo -e "${DGN}Using CT Type ${BGN}Unprivileged${CL} ${RD}NO DEVICE PASSTHROUGH${CL}"
|
|
||||||
CT_TYPE="1"
|
|
||||||
echo -e "${DGN}Using CT Password ${BGN}Automatic Login${CL}"
|
|
||||||
PW=" "
|
|
||||||
echo -e "${DGN}Using CT ID ${BGN}$NEXTID${CL}"
|
|
||||||
CT_ID=$NEXTID
|
|
||||||
echo -e "${DGN}Using CT Name ${BGN}$NSAPP${CL}"
|
|
||||||
HN=$NSAPP
|
|
||||||
echo -e "${DGN}Using Disk Size ${BGN}$var_disk${CL}${DGN}GB${CL}"
|
|
||||||
DISK_SIZE="$var_disk"
|
|
||||||
echo -e "${DGN}Using ${BGN}$var_cpu${CL}${DGN}vCPU${CL}"
|
|
||||||
CORE_COUNT="$var_cpu"
|
|
||||||
echo -e "${DGN}Using ${BGN}$var_ram${CL}${DGN}MiB RAM${CL}"
|
|
||||||
RAM_SIZE="$var_ram"
|
|
||||||
echo -e "${DGN}Using Bridge ${BGN}vmbr0${CL}"
|
|
||||||
BRG="vmbr0"
|
|
||||||
echo -e "${DGN}Using Static IP Address ${BGN}DHCP${CL}"
|
|
||||||
NET=dhcp
|
|
||||||
echo -e "${DGN}Using Gateway Address ${BGN}NONE${CL}"
|
|
||||||
GATE=""
|
|
||||||
echo -e "${DGN}Using VLAN Tag ${BGN}NONE${CL}"
|
|
||||||
VLAN=""
|
|
||||||
}
|
|
||||||
|
|
||||||
function advanced_settings() {
|
|
||||||
clear
|
|
||||||
header_info
|
|
||||||
echo -e "${RD}Using Advanced Settings${CL}"
|
|
||||||
echo -e "${YW}Type Privileged, or Press [ENTER] for Default: Unprivileged (${RD}NO DEVICE PASSTHROUGH${CL}${YW})"
|
|
||||||
read CT_TYPE1
|
|
||||||
if [ -z $CT_TYPE1 ]; then CT_TYPE1="Unprivileged" CT_TYPE="1";
|
|
||||||
echo -en "${DGN}Set CT Type ${BL}$CT_TYPE1${CL}"
|
|
||||||
else
|
|
||||||
CT_TYPE1="Privileged"
|
|
||||||
CT_TYPE="0"
|
|
||||||
echo -en "${DGN}Set CT Type ${BL}Privileged${CL}"
|
|
||||||
fi;
|
|
||||||
echo -e " ${CM}${CL} \r"
|
|
||||||
sleep 1
|
|
||||||
clear
|
|
||||||
header_info
|
|
||||||
echo -e "${RD}Using Advanced Settings${CL}"
|
|
||||||
echo -e "${DGN}Using CT Type ${BGN}$CT_TYPE1${CL}"
|
|
||||||
echo -e "${YW}Set Password, or Press [ENTER] for Default: Automatic Login "
|
|
||||||
read PW1
|
|
||||||
if [ -z $PW1 ]; then PW1="Automatic Login" PW=" ";
|
|
||||||
echo -en "${DGN}Set CT ${BL}$PW1${CL}"
|
|
||||||
else
|
|
||||||
PW="-password $PW1"
|
|
||||||
echo -en "${DGN}Set CT Password ${BL}$PW1${CL}"
|
|
||||||
fi;
|
|
||||||
echo -e " ${CM}${CL} \r"
|
|
||||||
sleep 1
|
|
||||||
clear
|
|
||||||
header_info
|
|
||||||
echo -e "${RD}Using Advanced Settings${CL}"
|
|
||||||
echo -e "${DGN}Using CT Type ${BGN}$CT_TYPE1${CL}"
|
|
||||||
echo -e "${DGN}Using CT Password ${BGN}$PW1${CL}"
|
|
||||||
echo -e "${YW}Enter the CT ID, or Press [ENTER] to automatically generate (${NEXTID}) "
|
|
||||||
read CT_ID
|
|
||||||
if [ -z $CT_ID ]; then CT_ID=$NEXTID; fi;
|
|
||||||
echo -en "${DGN}Set CT ID To ${BL}$CT_ID${CL}"
|
|
||||||
echo -e " ${CM}${CL} \r"
|
|
||||||
sleep 1
|
|
||||||
clear
|
|
||||||
header_info
|
|
||||||
echo -e "${RD}Using Advanced Settings${CL}"
|
|
||||||
echo -e "${DGN}Using CT Type ${BGN}$CT_TYPE1${CL}"
|
|
||||||
echo -e "${DGN}Using CT Password ${BGN}$PW1${CL}"
|
|
||||||
echo -e "${DGN}Using CT ID ${BGN}$CT_ID${CL}"
|
|
||||||
echo -e "${YW}Enter CT Name (no-spaces), or Press [ENTER] for Default: $NSAPP "
|
|
||||||
read CT_NAME
|
|
||||||
if [ -z $CT_NAME ]; then
|
|
||||||
HN=$NSAPP
|
|
||||||
else
|
|
||||||
HN=$(echo ${CT_NAME,,} | tr -d ' ')
|
|
||||||
fi
|
|
||||||
echo -en "${DGN}Set CT Name To ${BL}$HN${CL}"
|
|
||||||
echo -e " ${CM}${CL} \r"
|
|
||||||
sleep 1
|
|
||||||
clear
|
|
||||||
header_info
|
|
||||||
echo -e "${RD}Using Advanced Settings${CL}"
|
|
||||||
echo -e "${DGN}Using CT Type ${BGN}$CT_TYPE1${CL}"
|
|
||||||
echo -e "${DGN}Using CT Password ${BGN}$PW1${CL}"
|
|
||||||
echo -e "${DGN}Using CT ID ${BGN}$CT_ID${CL}"
|
|
||||||
echo -e "${DGN}Using CT Name ${BGN}$HN${CL}"
|
|
||||||
echo -e "${YW}Enter a Disk Size, or Press [ENTER] for Default: $var_disk "
|
|
||||||
read DISK_SIZE
|
|
||||||
if [ -z $DISK_SIZE ]; then DISK_SIZE="$var_disk"; fi;
|
|
||||||
if ! [[ $DISK_SIZE =~ $INTEGER ]] ; then echo "ERROR! DISK SIZE MUST HAVE INTEGER NUMBER!"; exit; fi;
|
|
||||||
echo -en "${DGN}Set Disk Size To ${BL}$DISK_SIZE${CL}${DGN}GB${CL}"
|
|
||||||
echo -e " ${CM}${CL} \r"
|
|
||||||
sleep 1
|
|
||||||
clear
|
|
||||||
header_info
|
|
||||||
echo -e "${RD}Using Advanced Settings${CL}"
|
|
||||||
echo -e "${DGN}Using CT Type ${BGN}$CT_TYPE1${CL}"
|
|
||||||
echo -e "${DGN}Using CT Password ${BGN}$PW1${CL}"
|
|
||||||
echo -e "${DGN}Using CT ID ${BGN}$CT_ID${CL}"
|
|
||||||
echo -e "${DGN}Using CT Name ${BGN}$HN${CL}"
|
|
||||||
echo -e "${DGN}Using Disk Size ${BGN}$DISK_SIZE${CL}${DGN}GB${CL}"
|
|
||||||
echo -e "${YW}Allocate CPU cores, or Press [ENTER] for Default: $var_cpu "
|
|
||||||
read CORE_COUNT
|
|
||||||
if [ -z $CORE_COUNT ]; then CORE_COUNT="$var_cpu"; fi;
|
|
||||||
echo -en "${DGN}Set Cores To ${BL}$CORE_COUNT${CL}${DGN}vCPU${CL}"
|
|
||||||
echo -e " ${CM}${CL} \r"
|
|
||||||
sleep 1
|
|
||||||
clear
|
|
||||||
header_info
|
|
||||||
echo -e "${RD}Using Advanced Settings${CL}"
|
|
||||||
echo -e "${DGN}Using CT Type ${BGN}$CT_TYPE1${CL}"
|
|
||||||
echo -e "${DGN}Using CT Password ${BGN}$PW1${CL}"
|
|
||||||
echo -e "${DGN}Using CT ID ${BGN}$CT_ID${CL}"
|
|
||||||
echo -e "${DGN}Using CT Name ${BGN}$HN${CL}"
|
|
||||||
echo -e "${DGN}Using Disk Size ${BGN}$DISK_SIZE${CL}${DGN}GB${CL}"
|
|
||||||
echo -e "${DGN}Using ${BGN}${CORE_COUNT}${CL}${DGN}vCPU${CL}"
|
|
||||||
echo -e "${YW}Allocate RAM in MiB, or Press [ENTER] for Default: $var_ram "
|
|
||||||
read RAM_SIZE
|
|
||||||
if [ -z $RAM_SIZE ]; then RAM_SIZE="$var_ram"; fi;
|
|
||||||
echo -en "${DGN}Set RAM To ${BL}$RAM_SIZE${CL}${DGN}MiB RAM${CL}"
|
|
||||||
echo -e " ${CM}${CL} \n"
|
|
||||||
sleep 1
|
|
||||||
clear
|
|
||||||
header_info
|
|
||||||
echo -e "${RD}Using Advanced Settings${CL}"
|
|
||||||
echo -e "${DGN}Using CT Type ${BGN}$CT_TYPE1${CL}"
|
|
||||||
echo -e "${DGN}Using CT Password ${BGN}$PW1${CL}"
|
|
||||||
echo -e "${DGN}Using CT ID ${BGN}$CT_ID${CL}"
|
|
||||||
echo -e "${DGN}Using CT Name ${BGN}$HN${CL}"
|
|
||||||
echo -e "${DGN}Using Disk Size ${BGN}$DISK_SIZE${CL}${DGN}GB${CL}"
|
|
||||||
echo -e "${DGN}Using ${BGN}${CORE_COUNT}${CL}${DGN}vCPU${CL}"
|
|
||||||
echo -e "${DGN}Using ${BGN}${RAM_SIZE}${CL}${DGN}MiB RAM${CL}"
|
|
||||||
echo -e "${YW}Enter a Bridge, or Press [ENTER] for Default: vmbr0 "
|
|
||||||
read BRG
|
|
||||||
if [ -z $BRG ]; then BRG="vmbr0"; fi;
|
|
||||||
echo -en "${DGN}Set Bridge To ${BL}$BRG${CL}"
|
|
||||||
echo -e " ${CM}${CL} \n"
|
|
||||||
sleep 1
|
|
||||||
clear
|
|
||||||
header_info
|
|
||||||
echo -e "${RD}Using Advanced Settings${CL}"
|
|
||||||
echo -e "${DGN}Using CT Type ${BGN}$CT_TYPE1${CL}"
|
|
||||||
echo -e "${DGN}Using CT Password ${BGN}$PW1${CL}"
|
|
||||||
echo -e "${DGN}Using CT ID ${BGN}$CT_ID${CL}"
|
|
||||||
echo -e "${DGN}Using CT Name ${BGN}$HN${CL}"
|
|
||||||
echo -e "${DGN}Using Disk Size ${BGN}$DISK_SIZE${CL}${DGN}GB${CL}"
|
|
||||||
echo -e "${DGN}Using ${BGN}${CORE_COUNT}${CL}${DGN}vCPU${CL}"
|
|
||||||
echo -e "${DGN}Using ${BGN}${RAM_SIZE}${CL}${DGN}MiB RAM${CL}"
|
|
||||||
echo -e "${DGN}Using Bridge ${BGN}${BRG}${CL}"
|
|
||||||
echo -e "${YW}Enter a Static IPv4 CIDR Address, or Press [ENTER] for Default: DHCP "
|
|
||||||
read NET
|
|
||||||
if [ -z $NET ]; then NET="dhcp"; fi;
|
|
||||||
echo -en "${DGN}Set Static IP Address To ${BL}$NET${CL}"
|
|
||||||
echo -e " ${CM}${CL} \n"
|
|
||||||
sleep 1
|
|
||||||
clear
|
|
||||||
header_info
|
|
||||||
echo -e "${RD}Using Advanced Settings${CL}"
|
|
||||||
echo -e "${DGN}Using CT Type ${BGN}$CT_TYPE1${CL}"
|
|
||||||
echo -e "${DGN}Using CT Password ${BGN}$PW1${CL}"
|
|
||||||
echo -e "${DGN}Using CT ID ${BGN}$CT_ID${CL}"
|
|
||||||
echo -e "${DGN}Using CT Name ${BGN}$HN${CL}"
|
|
||||||
echo -e "${DGN}Using Disk Size ${BGN}$DISK_SIZE${CL}${DGN}GB${CL}"
|
|
||||||
echo -e "${DGN}Using ${BGN}${CORE_COUNT}${CL}${DGN}vCPU${CL}"
|
|
||||||
echo -e "${DGN}Using ${BGN}${RAM_SIZE}${CL}${DGN}MiB RAM${CL}"
|
|
||||||
echo -e "${DGN}Using Bridge ${BGN}${BRG}${CL}"
|
|
||||||
echo -e "${DGN}Using Static IP Address ${BGN}$NET${CL}"
|
|
||||||
echo -e "${YW}Enter a Gateway IP (mandatory if static IP is used), or Press [ENTER] for Default: NONE "
|
|
||||||
read GATE1
|
|
||||||
if [ -z $GATE1 ]; then GATE1="NONE" GATE="";
|
|
||||||
echo -en "${DGN}Set Gateway IP To ${BL}$GATE1${CL}"
|
|
||||||
else
|
|
||||||
GATE=",gw=$GATE1"
|
|
||||||
echo -en "${DGN}Set Gateway IP To ${BL}$GATE1${CL}"
|
|
||||||
fi;
|
|
||||||
echo -e " ${CM}${CL} \n"
|
|
||||||
sleep 1
|
|
||||||
clear
|
|
||||||
header_info
|
|
||||||
|
|
||||||
echo -e "${RD}Using Advanced Settings${CL}"
|
|
||||||
echo -e "${DGN}Using CT Type ${BGN}$CT_TYPE1${CL}"
|
|
||||||
echo -e "${DGN}Using CT Password ${BGN}$PW1${CL}"
|
|
||||||
echo -e "${DGN}Using CT ID ${BGN}$CT_ID${CL}"
|
|
||||||
echo -e "${DGN}Using CT Name ${BGN}$HN${CL}"
|
|
||||||
echo -e "${DGN}Using Disk Size ${BGN}$DISK_SIZE${CL}${DGN}GB${CL}"
|
|
||||||
echo -e "${DGN}Using ${BGN}${CORE_COUNT}${CL}${DGN}vCPU${CL}"
|
|
||||||
echo -e "${DGN}Using ${BGN}${RAM_SIZE}${CL}${DGN}MiB RAM${CL}"
|
|
||||||
echo -e "${DGN}Using Bridge ${BGN}${BRG}${CL}"
|
|
||||||
echo -e "${DGN}Using Static IP Address ${BGN}$NET${CL}"
|
|
||||||
echo -e "${DGN}Using Gateway IP Address ${BGN}$GATE1${CL}"
|
|
||||||
echo -e "${YW}Enter a VLAN Tag, or Press [ENTER] for Default: NONE "
|
|
||||||
read VLAN1
|
|
||||||
if [ -z $VLAN1 ]; then VLAN1="NONE" VLAN="";
|
|
||||||
echo -en "${DGN}Set VLAN Tag To ${BL}$VLAN1${CL}"
|
|
||||||
else
|
|
||||||
VLAN=",tag=$VLAN1"
|
|
||||||
echo -en "${DGN}Set VLAN Tag To ${BL}$VLAN1${CL}"
|
|
||||||
fi;
|
|
||||||
echo -e " ${CM}${CL} \n"
|
|
||||||
sleep 1
|
|
||||||
clear
|
|
||||||
header_info
|
|
||||||
echo -e "${RD}Using Advanced Settings${CL}"
|
|
||||||
echo -e "${DGN}Using CT Type ${BGN}$CT_TYPE1${CL}"
|
|
||||||
echo -e "${DGN}Using CT Password ${BGN}$PW1${CL}"
|
|
||||||
echo -e "${DGN}Using CT ID ${BGN}$CT_ID${CL}"
|
|
||||||
echo -e "${DGN}Using CT Name ${BGN}$HN${CL}"
|
|
||||||
echo -e "${DGN}Using Disk Size ${BGN}$DISK_SIZE${CL}${DGN}GB${CL}"
|
|
||||||
echo -e "${DGN}Using ${BGN}${CORE_COUNT}${CL}${DGN}vCPU${CL}"
|
|
||||||
echo -e "${DGN}Using ${BGN}${RAM_SIZE}${CL}${DGN}MiB RAM${CL}"
|
|
||||||
echo -e "${DGN}Using Bridge ${BGN}${BRG}${CL}"
|
|
||||||
echo -e "${DGN}Using Static IP Address ${BGN}$NET${CL}"
|
|
||||||
echo -e "${DGN}Using Gateway IP Address ${BGN}$GATE1${CL}"
|
|
||||||
echo -e "${DGN}Using VLAN Tag ${BGN}$VLAN1${CL}"
|
|
||||||
|
|
||||||
read -p "Are these settings correct(y/n)? " -n 1 -r
|
|
||||||
echo
|
|
||||||
if [[ ! $REPLY =~ ^[Yy]$ ]]
|
|
||||||
then
|
|
||||||
advanced_settings
|
|
||||||
fi
|
|
||||||
}
|
|
||||||
|
|
||||||
function start_script() {
|
|
||||||
echo -e "${YW}Type Advanced, or Press [ENTER] for Default Settings "
|
|
||||||
read SETTINGS
|
|
||||||
if [ -z $SETTINGS ]; then default_settings;
|
|
||||||
else
|
|
||||||
advanced_settings
|
|
||||||
fi;
|
|
||||||
}
|
|
||||||
|
|
||||||
start_script
|
|
||||||
|
|
||||||
if [ "$CT_TYPE" == "1" ]; then
|
|
||||||
FEATURES="nesting=1,keyctl=1"
|
|
||||||
else
|
|
||||||
FEATURES="nesting=1"
|
|
||||||
fi
|
|
||||||
|
|
||||||
export CTID=$CT_ID
|
|
||||||
export PCT_OSTYPE=$var_os
|
|
||||||
export PCT_OSVERSION=$var_version
|
|
||||||
export PCT_DISK_SIZE=$DISK_SIZE
|
|
||||||
export PCT_OPTIONS="
|
|
||||||
-features $FEATURES
|
|
||||||
-hostname $HN
|
|
||||||
-net0 name=eth0,bridge=$BRG,ip=$NET$GATE$VLAN
|
|
||||||
-onboot 1
|
|
||||||
-cores $CORE_COUNT
|
|
||||||
-memory $RAM_SIZE
|
|
||||||
-unprivileged $CT_TYPE
|
|
||||||
$PW
|
|
||||||
"
|
|
||||||
bash -c "$(wget -qLO - https://raw.githubusercontent.com/tteck/Proxmox/main/ct/create_lxc.sh)" || exit
|
|
||||||
|
|
||||||
msg_info "Starting LXC Container"
|
|
||||||
pct start $CTID
|
|
||||||
msg_ok "Started LXC Container"
|
|
||||||
|
|
||||||
lxc-attach -n $CTID -- bash -c "$(wget -qLO - https://raw.githubusercontent.com/tteck/Proxmox/main/setup/$var_install.sh)" || exit
|
|
||||||
|
|
||||||
IP=$(pct exec $CTID ip a s dev eth0 | sed -n '/inet / s/\// /p' | awk '{print $2}')
|
|
||||||
|
|
||||||
pct set $CTID -description "# ${APP} LXC
|
|
||||||
### https://github.com/tteck/Proxmox"
|
|
||||||
|
|
||||||
msg_ok "Completed Successfully!\n"
|
|
|
@ -309,7 +309,7 @@ bash -c "$(wget -qLO - https://raw.githubusercontent.com/tteck/Proxmox/main/ct/c
|
||||||
msg_info "Starting LXC Container"
|
msg_info "Starting LXC Container"
|
||||||
pct start $CTID
|
pct start $CTID
|
||||||
msg_ok "Started LXC Container"
|
msg_ok "Started LXC Container"
|
||||||
lxc-attach -n $CTID -- bash -c "$(wget -qLO - https://raw.githubusercontent.com/tteck/Proxmox/main/setup/$var_install.sh)" || exit
|
lxc-attach -n $CTID -- bash -c "$(wget -qLO - https://raw.githubusercontent.com/tteck/Proxmox/main/install/$var_install.sh)" || exit
|
||||||
IP=$(pct exec $CTID ip a s dev eth0 | sed -n '/inet / s/\// /p' | awk '{print $2}')
|
IP=$(pct exec $CTID ip a s dev eth0 | sed -n '/inet / s/\// /p' | awk '{print $2}')
|
||||||
pct set $CTID -description "# ${APP} ${var_version} LXC
|
pct set $CTID -description "# ${APP} ${var_version} LXC
|
||||||
### https://tteck.github.io/Proxmox/
|
### https://tteck.github.io/Proxmox/
|
||||||
|
|
371
ct/deconz-v3.sh
371
ct/deconz-v3.sh
|
@ -1,371 +0,0 @@
|
||||||
#!/usr/bin/env bash
|
|
||||||
echo -e "Loading..."
|
|
||||||
APP="deCONZ"
|
|
||||||
var_disk="4"
|
|
||||||
var_cpu="2"
|
|
||||||
var_ram="1024"
|
|
||||||
var_os="ubuntu"
|
|
||||||
var_version="20.04"
|
|
||||||
NEXTID=$(pvesh get /cluster/nextid)
|
|
||||||
INTEGER='^[0-9]+$'
|
|
||||||
NSAPP=$(echo ${APP,,} | tr -d ' ')
|
|
||||||
var_install="${NSAPP}-install"
|
|
||||||
YW=`echo "\033[33m"`
|
|
||||||
BL=`echo "\033[36m"`
|
|
||||||
RD=`echo "\033[01;31m"`
|
|
||||||
BGN=`echo "\033[4;92m"`
|
|
||||||
GN=`echo "\033[1;92m"`
|
|
||||||
DGN=`echo "\033[32m"`
|
|
||||||
CL=`echo "\033[m"`
|
|
||||||
BFR="\\r\\033[K"
|
|
||||||
HOLD="-"
|
|
||||||
CM="${GN}✓${CL}"
|
|
||||||
set -o errexit
|
|
||||||
set -o errtrace
|
|
||||||
set -o nounset
|
|
||||||
set -o pipefail
|
|
||||||
shopt -s expand_aliases
|
|
||||||
alias die='EXIT=$? LINE=$LINENO error_exit'
|
|
||||||
trap die ERR
|
|
||||||
|
|
||||||
function error_exit() {
|
|
||||||
trap - ERR
|
|
||||||
local reason="Unknown failure occurred."
|
|
||||||
local msg="${1:-$reason}"
|
|
||||||
local flag="${RD}‼ ERROR ${CL}$EXIT@$LINE"
|
|
||||||
echo -e "$flag $msg" 1>&2
|
|
||||||
exit $EXIT
|
|
||||||
}
|
|
||||||
|
|
||||||
function msg_info() {
|
|
||||||
local msg="$1"
|
|
||||||
echo -ne " ${HOLD} ${YW}${msg}..."
|
|
||||||
}
|
|
||||||
|
|
||||||
function msg_ok() {
|
|
||||||
local msg="$1"
|
|
||||||
echo -e "${BFR} ${CM} ${GN}${msg}${CL}"
|
|
||||||
}
|
|
||||||
|
|
||||||
while true; do
|
|
||||||
clear
|
|
||||||
read -p "This will create a New ${APP} LXC. Proceed(y/n)?" yn
|
|
||||||
case $yn in
|
|
||||||
[Yy]* ) break;;
|
|
||||||
[Nn]* ) exit;;
|
|
||||||
* ) echo "Please answer yes or no.";;
|
|
||||||
esac
|
|
||||||
done
|
|
||||||
clear
|
|
||||||
function header_info {
|
|
||||||
echo -e "${YW}
|
|
||||||
_ _____
|
|
||||||
| | / ____|
|
|
||||||
__| | v3_| | ___ _ __ ____
|
|
||||||
/ _ |/ _ \ | / _ \| _ \|_ /
|
|
||||||
| (_| | __/ |___| (_) | | | |/ /
|
|
||||||
\__,_|\___|\_____\___/|_| |_/___|
|
|
||||||
${CL}"
|
|
||||||
}
|
|
||||||
|
|
||||||
header_info
|
|
||||||
|
|
||||||
function PVE_CHECK() {
|
|
||||||
PVE=$(pveversion | grep "pve-manager/7" | wc -l)
|
|
||||||
|
|
||||||
if [[ $PVE != 1 ]]; then
|
|
||||||
echo -e "${RD}This script requires Proxmox Virtual Environment 7.0 or greater${CL}"
|
|
||||||
echo -e "Exiting..."
|
|
||||||
sleep 2
|
|
||||||
exit
|
|
||||||
fi
|
|
||||||
}
|
|
||||||
|
|
||||||
function default_settings() {
|
|
||||||
clear
|
|
||||||
header_info
|
|
||||||
echo -e "${BL}Using Default Settings${CL}"
|
|
||||||
echo -e "${DGN}Using CT Type ${BGN}Privileged${CL}"
|
|
||||||
CT_TYPE="0"
|
|
||||||
echo -e "${DGN}Using CT Password ${BGN}Automatic Login${CL}"
|
|
||||||
PW=" "
|
|
||||||
echo -e "${DGN}Using CT ID ${BGN}$NEXTID${CL}"
|
|
||||||
CT_ID=$NEXTID
|
|
||||||
echo -e "${DGN}Using CT Name ${BGN}$NSAPP${CL}"
|
|
||||||
HN=$NSAPP
|
|
||||||
echo -e "${DGN}Using Disk Size ${BGN}$var_disk${CL}${DGN}GB${CL}"
|
|
||||||
DISK_SIZE="$var_disk"
|
|
||||||
echo -e "${DGN}Using ${BGN}$var_cpu${CL}${DGN}vCPU${CL}"
|
|
||||||
CORE_COUNT="$var_cpu"
|
|
||||||
echo -e "${DGN}Using ${BGN}$var_ram${CL}${DGN}MiB RAM${CL}"
|
|
||||||
RAM_SIZE="$var_ram"
|
|
||||||
echo -e "${DGN}Using Bridge ${BGN}vmbr0${CL}"
|
|
||||||
BRG="vmbr0"
|
|
||||||
echo -e "${DGN}Using Static IP Address ${BGN}DHCP${CL}"
|
|
||||||
NET=dhcp
|
|
||||||
echo -e "${DGN}Using Gateway Address ${BGN}NONE${CL}"
|
|
||||||
GATE=""
|
|
||||||
echo -e "${DGN}Using VLAN Tag ${BGN}NONE${CL}"
|
|
||||||
VLAN=""
|
|
||||||
}
|
|
||||||
|
|
||||||
function advanced_settings() {
|
|
||||||
clear
|
|
||||||
header_info
|
|
||||||
echo -e "${RD}Using Advanced Settings${CL}"
|
|
||||||
echo -e "${YW}Type Unprivileged, or Press [ENTER] for Default: Privileged"
|
|
||||||
read CT_TYPE1
|
|
||||||
if [ -z $CT_TYPE1 ]; then CT_TYPE1="Privileged" CT_TYPE="0";
|
|
||||||
echo -en "${DGN}Set CT Type ${BL}$CT_TYPE1${CL}"
|
|
||||||
else
|
|
||||||
CT_TYPE1="Unprivileged"
|
|
||||||
CT_TYPE="1"
|
|
||||||
echo -en "${DGN}Set CT Type ${BL}Unprivileged${CL}"
|
|
||||||
fi;
|
|
||||||
echo -e " ${CM}${CL} \r"
|
|
||||||
sleep 1
|
|
||||||
clear
|
|
||||||
header_info
|
|
||||||
echo -e "${RD}Using Advanced Settings${CL}"
|
|
||||||
echo -e "${DGN}Using CT Type ${BGN}$CT_TYPE1${CL}"
|
|
||||||
echo -e "${YW}Set Password, or Press [ENTER] for Default: Automatic Login "
|
|
||||||
read PW1
|
|
||||||
if [ -z $PW1 ]; then PW1="Automatic Login" PW=" ";
|
|
||||||
echo -en "${DGN}Set CT ${BL}$PW1${CL}"
|
|
||||||
else
|
|
||||||
PW="-password $PW1"
|
|
||||||
echo -en "${DGN}Set CT Password ${BL}$PW1${CL}"
|
|
||||||
fi;
|
|
||||||
echo -e " ${CM}${CL} \r"
|
|
||||||
sleep 1
|
|
||||||
clear
|
|
||||||
header_info
|
|
||||||
echo -e "${RD}Using Advanced Settings${CL}"
|
|
||||||
echo -e "${DGN}Using CT Type ${BGN}$CT_TYPE1${CL}"
|
|
||||||
echo -e "${DGN}Using CT Password ${BGN}$PW1${CL}"
|
|
||||||
echo -e "${YW}Enter the CT ID, or Press [ENTER] to automatically generate (${NEXTID}) "
|
|
||||||
read CT_ID
|
|
||||||
if [ -z $CT_ID ]; then CT_ID=$NEXTID; fi;
|
|
||||||
echo -en "${DGN}Set CT ID To ${BL}$CT_ID${CL}"
|
|
||||||
echo -e " ${CM}${CL} \r"
|
|
||||||
sleep 1
|
|
||||||
clear
|
|
||||||
header_info
|
|
||||||
echo -e "${RD}Using Advanced Settings${CL}"
|
|
||||||
echo -e "${DGN}Using CT Type ${BGN}$CT_TYPE1${CL}"
|
|
||||||
echo -e "${DGN}Using CT Password ${BGN}$PW1${CL}"
|
|
||||||
echo -e "${DGN}Using CT ID ${BGN}$CT_ID${CL}"
|
|
||||||
echo -e "${YW}Enter CT Name (no-spaces), or Press [ENTER] for Default: $NSAPP "
|
|
||||||
read CT_NAME
|
|
||||||
if [ -z $CT_NAME ]; then
|
|
||||||
HN=$NSAPP
|
|
||||||
else
|
|
||||||
HN=$(echo ${CT_NAME,,} | tr -d ' ')
|
|
||||||
fi
|
|
||||||
echo -en "${DGN}Set CT Name To ${BL}$HN${CL}"
|
|
||||||
echo -e " ${CM}${CL} \r"
|
|
||||||
sleep 1
|
|
||||||
clear
|
|
||||||
header_info
|
|
||||||
echo -e "${RD}Using Advanced Settings${CL}"
|
|
||||||
echo -e "${DGN}Using CT Type ${BGN}$CT_TYPE1${CL}"
|
|
||||||
echo -e "${DGN}Using CT Password ${BGN}$PW1${CL}"
|
|
||||||
echo -e "${DGN}Using CT ID ${BGN}$CT_ID${CL}"
|
|
||||||
echo -e "${DGN}Using CT Name ${BGN}$HN${CL}"
|
|
||||||
echo -e "${YW}Enter a Disk Size, or Press [ENTER] for Default: $var_disk "
|
|
||||||
read DISK_SIZE
|
|
||||||
if [ -z $DISK_SIZE ]; then DISK_SIZE="$var_disk"; fi;
|
|
||||||
if ! [[ $DISK_SIZE =~ $INTEGER ]] ; then echo "ERROR! DISK SIZE MUST HAVE INTEGER NUMBER!"; exit; fi;
|
|
||||||
echo -en "${DGN}Set Disk Size To ${BL}$DISK_SIZE${CL}${DGN}GB${CL}"
|
|
||||||
echo -e " ${CM}${CL} \r"
|
|
||||||
sleep 1
|
|
||||||
clear
|
|
||||||
header_info
|
|
||||||
echo -e "${RD}Using Advanced Settings${CL}"
|
|
||||||
echo -e "${DGN}Using CT Type ${BGN}$CT_TYPE1${CL}"
|
|
||||||
echo -e "${DGN}Using CT Password ${BGN}$PW1${CL}"
|
|
||||||
echo -e "${DGN}Using CT ID ${BGN}$CT_ID${CL}"
|
|
||||||
echo -e "${DGN}Using CT Name ${BGN}$HN${CL}"
|
|
||||||
echo -e "${DGN}Using Disk Size ${BGN}$DISK_SIZE${CL}${DGN}GB${CL}"
|
|
||||||
echo -e "${YW}Allocate CPU cores, or Press [ENTER] for Default: $var_cpu "
|
|
||||||
read CORE_COUNT
|
|
||||||
if [ -z $CORE_COUNT ]; then CORE_COUNT="$var_cpu"; fi;
|
|
||||||
echo -en "${DGN}Set Cores To ${BL}$CORE_COUNT${CL}${DGN}vCPU${CL}"
|
|
||||||
echo -e " ${CM}${CL} \r"
|
|
||||||
sleep 1
|
|
||||||
clear
|
|
||||||
header_info
|
|
||||||
echo -e "${RD}Using Advanced Settings${CL}"
|
|
||||||
echo -e "${DGN}Using CT Type ${BGN}$CT_TYPE1${CL}"
|
|
||||||
echo -e "${DGN}Using CT Password ${BGN}$PW1${CL}"
|
|
||||||
echo -e "${DGN}Using CT ID ${BGN}$CT_ID${CL}"
|
|
||||||
echo -e "${DGN}Using CT Name ${BGN}$HN${CL}"
|
|
||||||
echo -e "${DGN}Using Disk Size ${BGN}$DISK_SIZE${CL}${DGN}GB${CL}"
|
|
||||||
echo -e "${DGN}Using ${BGN}${CORE_COUNT}${CL}${DGN}vCPU${CL}"
|
|
||||||
echo -e "${YW}Allocate RAM in MiB, or Press [ENTER] for Default: $var_ram "
|
|
||||||
read RAM_SIZE
|
|
||||||
if [ -z $RAM_SIZE ]; then RAM_SIZE="$var_ram"; fi;
|
|
||||||
echo -en "${DGN}Set RAM To ${BL}$RAM_SIZE${CL}${DGN}MiB RAM${CL}"
|
|
||||||
echo -e " ${CM}${CL} \n"
|
|
||||||
sleep 1
|
|
||||||
clear
|
|
||||||
header_info
|
|
||||||
echo -e "${RD}Using Advanced Settings${CL}"
|
|
||||||
echo -e "${DGN}Using CT Type ${BGN}$CT_TYPE1${CL}"
|
|
||||||
echo -e "${DGN}Using CT Password ${BGN}$PW1${CL}"
|
|
||||||
echo -e "${DGN}Using CT ID ${BGN}$CT_ID${CL}"
|
|
||||||
echo -e "${DGN}Using CT Name ${BGN}$HN${CL}"
|
|
||||||
echo -e "${DGN}Using Disk Size ${BGN}$DISK_SIZE${CL}${DGN}GB${CL}"
|
|
||||||
echo -e "${DGN}Using ${BGN}${CORE_COUNT}${CL}${DGN}vCPU${CL}"
|
|
||||||
echo -e "${DGN}Using ${BGN}${RAM_SIZE}${CL}${DGN}MiB RAM${CL}"
|
|
||||||
echo -e "${YW}Enter a Bridge, or Press [ENTER] for Default: vmbr0 "
|
|
||||||
read BRG
|
|
||||||
if [ -z $BRG ]; then BRG="vmbr0"; fi;
|
|
||||||
echo -en "${DGN}Set Bridge To ${BL}$BRG${CL}"
|
|
||||||
echo -e " ${CM}${CL} \n"
|
|
||||||
sleep 1
|
|
||||||
clear
|
|
||||||
header_info
|
|
||||||
echo -e "${RD}Using Advanced Settings${CL}"
|
|
||||||
echo -e "${DGN}Using CT Type ${BGN}$CT_TYPE1${CL}"
|
|
||||||
echo -e "${DGN}Using CT Password ${BGN}$PW1${CL}"
|
|
||||||
echo -e "${DGN}Using CT ID ${BGN}$CT_ID${CL}"
|
|
||||||
echo -e "${DGN}Using CT Name ${BGN}$HN${CL}"
|
|
||||||
echo -e "${DGN}Using Disk Size ${BGN}$DISK_SIZE${CL}${DGN}GB${CL}"
|
|
||||||
echo -e "${DGN}Using ${BGN}${CORE_COUNT}${CL}${DGN}vCPU${CL}"
|
|
||||||
echo -e "${DGN}Using ${BGN}${RAM_SIZE}${CL}${DGN}MiB RAM${CL}"
|
|
||||||
echo -e "${DGN}Using Bridge ${BGN}${BRG}${CL}"
|
|
||||||
echo -e "${YW}Enter a Static IPv4 CIDR Address, or Press [ENTER] for Default: DHCP "
|
|
||||||
read NET
|
|
||||||
if [ -z $NET ]; then NET="dhcp"; fi;
|
|
||||||
echo -en "${DGN}Set Static IP Address To ${BL}$NET${CL}"
|
|
||||||
echo -e " ${CM}${CL} \n"
|
|
||||||
sleep 1
|
|
||||||
clear
|
|
||||||
header_info
|
|
||||||
echo -e "${RD}Using Advanced Settings${CL}"
|
|
||||||
echo -e "${DGN}Using CT Type ${BGN}$CT_TYPE1${CL}"
|
|
||||||
echo -e "${DGN}Using CT Password ${BGN}$PW1${CL}"
|
|
||||||
echo -e "${DGN}Using CT ID ${BGN}$CT_ID${CL}"
|
|
||||||
echo -e "${DGN}Using CT Name ${BGN}$HN${CL}"
|
|
||||||
echo -e "${DGN}Using Disk Size ${BGN}$DISK_SIZE${CL}${DGN}GB${CL}"
|
|
||||||
echo -e "${DGN}Using ${BGN}${CORE_COUNT}${CL}${DGN}vCPU${CL}"
|
|
||||||
echo -e "${DGN}Using ${BGN}${RAM_SIZE}${CL}${DGN}MiB RAM${CL}"
|
|
||||||
echo -e "${DGN}Using Bridge ${BGN}${BRG}${CL}"
|
|
||||||
echo -e "${DGN}Using Static IP Address ${BGN}$NET${CL}"
|
|
||||||
echo -e "${YW}Enter a Gateway IP (mandatory if static IP is used), or Press [ENTER] for Default: NONE "
|
|
||||||
read GATE1
|
|
||||||
if [ -z $GATE1 ]; then GATE1="NONE" GATE="";
|
|
||||||
echo -en "${DGN}Set Gateway IP To ${BL}$GATE1${CL}"
|
|
||||||
else
|
|
||||||
GATE=",gw=$GATE1"
|
|
||||||
echo -en "${DGN}Set Gateway IP To ${BL}$GATE1${CL}"
|
|
||||||
fi;
|
|
||||||
echo -e " ${CM}${CL} \n"
|
|
||||||
sleep 1
|
|
||||||
clear
|
|
||||||
header_info
|
|
||||||
|
|
||||||
echo -e "${RD}Using Advanced Settings${CL}"
|
|
||||||
echo -e "${DGN}Using CT Type ${BGN}$CT_TYPE1${CL}"
|
|
||||||
echo -e "${DGN}Using CT Password ${BGN}$PW1${CL}"
|
|
||||||
echo -e "${DGN}Using CT ID ${BGN}$CT_ID${CL}"
|
|
||||||
echo -e "${DGN}Using CT Name ${BGN}$HN${CL}"
|
|
||||||
echo -e "${DGN}Using Disk Size ${BGN}$DISK_SIZE${CL}${DGN}GB${CL}"
|
|
||||||
echo -e "${DGN}Using ${BGN}${CORE_COUNT}${CL}${DGN}vCPU${CL}"
|
|
||||||
echo -e "${DGN}Using ${BGN}${RAM_SIZE}${CL}${DGN}MiB RAM${CL}"
|
|
||||||
echo -e "${DGN}Using Bridge ${BGN}${BRG}${CL}"
|
|
||||||
echo -e "${DGN}Using Static IP Address ${BGN}$NET${CL}"
|
|
||||||
echo -e "${DGN}Using Gateway IP Address ${BGN}$GATE1${CL}"
|
|
||||||
echo -e "${YW}Enter a VLAN Tag, or Press [ENTER] for Default: NONE "
|
|
||||||
read VLAN1
|
|
||||||
if [ -z $VLAN1 ]; then VLAN1="NONE" VLAN="";
|
|
||||||
echo -en "${DGN}Set VLAN Tag To ${BL}$VLAN1${CL}"
|
|
||||||
else
|
|
||||||
VLAN=",tag=$VLAN1"
|
|
||||||
echo -en "${DGN}Set VLAN Tag To ${BL}$VLAN1${CL}"
|
|
||||||
fi;
|
|
||||||
echo -e " ${CM}${CL} \n"
|
|
||||||
sleep 1
|
|
||||||
clear
|
|
||||||
header_info
|
|
||||||
echo -e "${RD}Using Advanced Settings${CL}"
|
|
||||||
echo -e "${DGN}Using CT Type ${BGN}$CT_TYPE1${CL}"
|
|
||||||
echo -e "${DGN}Using CT Password ${BGN}$PW1${CL}"
|
|
||||||
echo -e "${DGN}Using CT ID ${BGN}$CT_ID${CL}"
|
|
||||||
echo -e "${DGN}Using CT Name ${BGN}$HN${CL}"
|
|
||||||
echo -e "${DGN}Using Disk Size ${BGN}$DISK_SIZE${CL}${DGN}GB${CL}"
|
|
||||||
echo -e "${DGN}Using ${BGN}${CORE_COUNT}${CL}${DGN}vCPU${CL}"
|
|
||||||
echo -e "${DGN}Using ${BGN}${RAM_SIZE}${CL}${DGN}MiB RAM${CL}"
|
|
||||||
echo -e "${DGN}Using Bridge ${BGN}${BRG}${CL}"
|
|
||||||
echo -e "${DGN}Using Static IP Address ${BGN}$NET${CL}"
|
|
||||||
echo -e "${DGN}Using Gateway IP Address ${BGN}$GATE1${CL}"
|
|
||||||
echo -e "${DGN}Using VLAN Tag ${BGN}$VLAN1${CL}"
|
|
||||||
|
|
||||||
read -p "Are these settings correct(y/n)? " -n 1 -r
|
|
||||||
echo
|
|
||||||
if [[ ! $REPLY =~ ^[Yy]$ ]]
|
|
||||||
then
|
|
||||||
advanced_settings
|
|
||||||
fi
|
|
||||||
}
|
|
||||||
|
|
||||||
function start_script() {
|
|
||||||
echo -e "${YW}Type Advanced, or Press [ENTER] for Default Settings "
|
|
||||||
read SETTINGS
|
|
||||||
if [ -z $SETTINGS ]; then default_settings;
|
|
||||||
else
|
|
||||||
advanced_settings
|
|
||||||
fi;
|
|
||||||
}
|
|
||||||
|
|
||||||
start_script
|
|
||||||
|
|
||||||
if [ "$CT_TYPE" == "1" ]; then
|
|
||||||
FEATURES="nesting=1,keyctl=1"
|
|
||||||
else
|
|
||||||
FEATURES="nesting=1"
|
|
||||||
fi
|
|
||||||
|
|
||||||
export CTID=$CT_ID
|
|
||||||
export PCT_OSTYPE=$var_os
|
|
||||||
export PCT_OSVERSION=$var_version
|
|
||||||
export PCT_DISK_SIZE=$DISK_SIZE
|
|
||||||
export PCT_OPTIONS="
|
|
||||||
-features $FEATURES
|
|
||||||
-hostname $HN
|
|
||||||
-net0 name=eth0,bridge=$BRG,ip=$NET$GATE$VLAN
|
|
||||||
-onboot 1
|
|
||||||
-cores $CORE_COUNT
|
|
||||||
-memory $RAM_SIZE
|
|
||||||
-unprivileged $CT_TYPE
|
|
||||||
$PW
|
|
||||||
"
|
|
||||||
bash -c "$(wget -qLO - https://raw.githubusercontent.com/tteck/Proxmox/main/ct/create_lxc.sh)" || exit
|
|
||||||
|
|
||||||
LXC_CONFIG=/etc/pve/lxc/${CTID}.conf
|
|
||||||
cat <<EOF >> $LXC_CONFIG
|
|
||||||
lxc.cgroup2.devices.allow: a
|
|
||||||
lxc.cap.drop:
|
|
||||||
lxc.cgroup2.devices.allow: c 188:* rwm
|
|
||||||
lxc.cgroup2.devices.allow: c 189:* rwm
|
|
||||||
lxc.mount.entry: /dev/serial/by-id dev/serial/by-id none bind,optional,create=dir
|
|
||||||
lxc.mount.entry: /dev/ttyUSB0 dev/ttyUSB0 none bind,optional,create=file
|
|
||||||
lxc.mount.entry: /dev/ttyACM0 dev/ttyACM0 none bind,optional,create=file
|
|
||||||
lxc.mount.entry: /dev/ttyACM1 dev/ttyACM1 none bind,optional,create=file
|
|
||||||
EOF
|
|
||||||
|
|
||||||
msg_info "Starting LXC Container"
|
|
||||||
pct start $CTID
|
|
||||||
msg_ok "Started LXC Container"
|
|
||||||
|
|
||||||
lxc-attach -n $CTID -- bash -c "$(wget -qLO - https://raw.githubusercontent.com/tteck/Proxmox/main/setup/$var_install.sh)" || exit
|
|
||||||
|
|
||||||
IP=$(pct exec $CTID ip a s dev eth0 | sed -n '/inet / s/\// /p' | awk '{print $2}')
|
|
||||||
|
|
||||||
pct set $CTID -description "# ${APP} LXC
|
|
||||||
### https://github.com/tteck/Proxmox"
|
|
||||||
|
|
||||||
msg_ok "Completed Successfully!\n"
|
|
||||||
echo -e "${APP} should be reachable by going to the following URL.
|
|
||||||
${BL}http://${IP}${CL} \n"
|
|
|
@ -324,7 +324,7 @@ fi
|
||||||
msg_info "Starting LXC Container"
|
msg_info "Starting LXC Container"
|
||||||
pct start $CTID
|
pct start $CTID
|
||||||
msg_ok "Started LXC Container"
|
msg_ok "Started LXC Container"
|
||||||
lxc-attach -n $CTID -- bash -c "$(wget -qLO - https://raw.githubusercontent.com/tteck/Proxmox/main/setup/$var_install.sh)" || exit
|
lxc-attach -n $CTID -- bash -c "$(wget -qLO - https://raw.githubusercontent.com/tteck/Proxmox/main/install/$var_install.sh)" || exit
|
||||||
IP=$(pct exec $CTID ip a s dev eth0 | sed -n '/inet / s/\// /p' | awk '{print $2}')
|
IP=$(pct exec $CTID ip a s dev eth0 | sed -n '/inet / s/\// /p' | awk '{print $2}')
|
||||||
pct set $CTID -description "# ${APP} LXC
|
pct set $CTID -description "# ${APP} LXC
|
||||||
### https://tteck.github.io/Proxmox/
|
### https://tteck.github.io/Proxmox/
|
||||||
|
|
312
ct/docker-v2.sh
312
ct/docker-v2.sh
|
@ -1,312 +0,0 @@
|
||||||
#!/usr/bin/env bash
|
|
||||||
YW=`echo "\033[33m"`
|
|
||||||
BL=`echo "\033[36m"`
|
|
||||||
RD=`echo "\033[01;31m"`
|
|
||||||
CM='\xE2\x9C\x94\033'
|
|
||||||
GN=`echo "\033[1;92m"`
|
|
||||||
CL=`echo "\033[m"`
|
|
||||||
while true; do
|
|
||||||
read -p "This will create a New Docker LXC. Proceed(y/n)?" yn
|
|
||||||
case $yn in
|
|
||||||
[Yy]* ) break;;
|
|
||||||
[Nn]* ) exit;;
|
|
||||||
* ) echo "Please answer yes or no.";;
|
|
||||||
esac
|
|
||||||
done
|
|
||||||
clear
|
|
||||||
function header_info {
|
|
||||||
echo -e "${BL}
|
|
||||||
_____ _
|
|
||||||
| __ \ | |
|
|
||||||
| | | | ___ ___| | _____ _ __
|
|
||||||
| | | |/ _ \ / __| |/ / _ \ __|
|
|
||||||
| |__| | (_) | (__| < __/ |
|
|
||||||
|_____/ \___/ \___|_|\_\___|_|
|
|
||||||
${CL}"
|
|
||||||
}
|
|
||||||
|
|
||||||
header_info
|
|
||||||
show_menu(){
|
|
||||||
printf " ${YW} 1)${YW} Privileged ${CL}\n"
|
|
||||||
printf " ${YW} 2)${GN} Unprivileged ${CL}\n"
|
|
||||||
|
|
||||||
printf "Please choose a Install Method and hit enter or ${RD}x${CL} to exit."
|
|
||||||
read opt
|
|
||||||
}
|
|
||||||
|
|
||||||
option_picked(){
|
|
||||||
message1=${@:-"${CL}Error: No message passed"}
|
|
||||||
printf " ${YW}${message1}${CL}\n"
|
|
||||||
}
|
|
||||||
show_menu
|
|
||||||
while [ "$opt" != " " ]
|
|
||||||
do
|
|
||||||
case $opt in
|
|
||||||
1) clear;
|
|
||||||
header_info;
|
|
||||||
option_picked "Using Privileged Install";
|
|
||||||
IM=0
|
|
||||||
break;
|
|
||||||
;;
|
|
||||||
2) clear;
|
|
||||||
header_info;
|
|
||||||
option_picked "Using Unprivileged Install";
|
|
||||||
IM=1
|
|
||||||
break;
|
|
||||||
;;
|
|
||||||
|
|
||||||
x)exit;
|
|
||||||
;;
|
|
||||||
\n)exit;
|
|
||||||
;;
|
|
||||||
*)clear;
|
|
||||||
option_picked "Please choose a Install Method from the menu";
|
|
||||||
show_menu;
|
|
||||||
;;
|
|
||||||
esac
|
|
||||||
done
|
|
||||||
show_menu2(){
|
|
||||||
printf " ${YW} 1)${GN} Use Automatic Login ${CL}\n"
|
|
||||||
printf " ${YW} 2)${GN} Use Password (changeme) ${CL}\n"
|
|
||||||
|
|
||||||
printf "Please choose a Password Type and hit enter or ${RD}x${CL} to exit."
|
|
||||||
read opt
|
|
||||||
}
|
|
||||||
|
|
||||||
option_picked(){
|
|
||||||
message2=${@:-"${CL}Error: No message passed"}
|
|
||||||
printf " ${YW}${message1}${CL}\n"
|
|
||||||
printf " ${YW}${message2}${CL}\n"
|
|
||||||
}
|
|
||||||
show_menu2
|
|
||||||
while [ "$opt" != " " ]
|
|
||||||
do
|
|
||||||
case $opt in
|
|
||||||
1) clear;
|
|
||||||
header_info;
|
|
||||||
option_picked "Using Automatic Login";
|
|
||||||
PW=" "
|
|
||||||
break;
|
|
||||||
;;
|
|
||||||
2) clear;
|
|
||||||
header_info;
|
|
||||||
option_picked "Using Password (changeme)";
|
|
||||||
PW="-password changeme"
|
|
||||||
break;
|
|
||||||
;;
|
|
||||||
|
|
||||||
x)exit;
|
|
||||||
;;
|
|
||||||
\n)exit;
|
|
||||||
;;
|
|
||||||
*)clear;
|
|
||||||
option_picked "Please choose a Password Type from the menu";
|
|
||||||
show_menu2;
|
|
||||||
;;
|
|
||||||
esac
|
|
||||||
done
|
|
||||||
show_menu3(){
|
|
||||||
printf " ${RD} If Using ZFS, You Have Storage Driver Options${CL}\n"
|
|
||||||
printf " ${RD} Non ZFS, Select Standard overlay2 Storage Driver${CL}\n"
|
|
||||||
printf " ${YW} 1)${GN} Use fuse-overlayfs Storage Driver${CL}\n"
|
|
||||||
printf " ${YW} 2)${GN} Use Standard overlay2 Storage Driver${CL}\n"
|
|
||||||
|
|
||||||
printf "Please choose a Storage Driver and hit enter or ${RD}x${CL} to exit."
|
|
||||||
read opt
|
|
||||||
}
|
|
||||||
|
|
||||||
option_picked(){
|
|
||||||
message3=${@:-"${CL}Error: No message passed"}
|
|
||||||
printf " ${YW}${message1}${CL}\n"
|
|
||||||
printf " ${YW}${message2}${CL}\n"
|
|
||||||
printf " ${YW}${message3}${CL}\n"
|
|
||||||
}
|
|
||||||
show_menu3
|
|
||||||
while [ "$opt" != " " ]
|
|
||||||
do
|
|
||||||
case $opt in
|
|
||||||
1) clear;
|
|
||||||
header_info;
|
|
||||||
option_picked "Using fuse-overlayfs Storage Driver";
|
|
||||||
STORAGE_DRIVER="fuse"
|
|
||||||
break;
|
|
||||||
;;
|
|
||||||
2) clear;
|
|
||||||
header_info;
|
|
||||||
option_picked "Using overlay2 Storage Driver";
|
|
||||||
STORAGE_DRIVER=" "
|
|
||||||
break;
|
|
||||||
;;
|
|
||||||
|
|
||||||
x)exit;
|
|
||||||
;;
|
|
||||||
\n)exit;
|
|
||||||
;;
|
|
||||||
*)clear;
|
|
||||||
option_picked "Please choose a Storage Driver from the menu";
|
|
||||||
show_menu3;
|
|
||||||
;;
|
|
||||||
esac
|
|
||||||
done
|
|
||||||
show_menu4(){
|
|
||||||
printf " ${YW} 1)${GN} Automatic DHCP ${CL}\n"
|
|
||||||
printf " ${YW} 2)${GN} Manual DHCP ${CL}\n"
|
|
||||||
|
|
||||||
printf "Please choose a DHCP Type and hit enter or ${RD}x${CL} to exit."
|
|
||||||
read opt
|
|
||||||
}
|
|
||||||
|
|
||||||
option_picked(){
|
|
||||||
message4=${@:-"${CL}Error: No message passed"}
|
|
||||||
printf " ${YW}${message1}${CL}\n"
|
|
||||||
printf " ${YW}${message2}${CL}\n"
|
|
||||||
printf " ${YW}${message3}${CL}\n"
|
|
||||||
printf " ${YW}${message4}${CL}\n"
|
|
||||||
}
|
|
||||||
show_menu4
|
|
||||||
while [ "$opt" != " " ]
|
|
||||||
do
|
|
||||||
case $opt in
|
|
||||||
1) clear;
|
|
||||||
header_info;
|
|
||||||
option_picked "Using Automatic DHCP";
|
|
||||||
DHCP=" "
|
|
||||||
break;
|
|
||||||
;;
|
|
||||||
2) clear;
|
|
||||||
header_info;
|
|
||||||
option_picked "Using Manual DHCP";
|
|
||||||
DHCP="1"
|
|
||||||
break;
|
|
||||||
;;
|
|
||||||
|
|
||||||
x)exit;
|
|
||||||
;;
|
|
||||||
\n)exit;
|
|
||||||
;;
|
|
||||||
*)clear;
|
|
||||||
option_picked "Please choose a DHCP Type from the menu";
|
|
||||||
show_menu4;
|
|
||||||
;;
|
|
||||||
esac
|
|
||||||
done
|
|
||||||
|
|
||||||
set -o errexit
|
|
||||||
set -o errtrace
|
|
||||||
set -o nounset
|
|
||||||
set -o pipefail
|
|
||||||
shopt -s expand_aliases
|
|
||||||
alias die='EXIT=$? LINE=$LINENO error_exit'
|
|
||||||
trap die ERR
|
|
||||||
trap cleanup EXIT
|
|
||||||
|
|
||||||
function error_exit() {
|
|
||||||
trap - ERR
|
|
||||||
local DEFAULT='Unknown failure occured.'
|
|
||||||
local REASON="\e[97m${1:-$DEFAULT}\e[39m"
|
|
||||||
local FLAG="\e[91m[ERROR] \e[93m$EXIT@$LINE"
|
|
||||||
msg "$FLAG $REASON"
|
|
||||||
[ ! -z ${CTID-} ] && cleanup_ctid
|
|
||||||
exit $EXIT
|
|
||||||
}
|
|
||||||
function warn() {
|
|
||||||
local REASON="\e[97m$1\e[39m"
|
|
||||||
local FLAG="\e[93m[WARNING]\e[39m"
|
|
||||||
msg "$FLAG $REASON"
|
|
||||||
}
|
|
||||||
function info() {
|
|
||||||
local REASON="$1"
|
|
||||||
local FLAG="\e[36m[INFO]\e[39m"
|
|
||||||
msg "$FLAG $REASON"
|
|
||||||
}
|
|
||||||
function msg() {
|
|
||||||
local TEXT="$1"
|
|
||||||
echo -e "$TEXT"
|
|
||||||
}
|
|
||||||
function cleanup_ctid() {
|
|
||||||
if $(pct status $CTID &>/dev/null); then
|
|
||||||
if [ "$(pct status $CTID | awk '{print $2}')" == "running" ]; then
|
|
||||||
pct stop $CTID
|
|
||||||
fi
|
|
||||||
pct destroy $CTID
|
|
||||||
elif [ "$(pvesm list $STORAGE --vmid $CTID)" != "" ]; then
|
|
||||||
pvesm free $ROOTFS
|
|
||||||
fi
|
|
||||||
}
|
|
||||||
function cleanup() {
|
|
||||||
popd >/dev/null
|
|
||||||
rm -rf $TEMP_DIR
|
|
||||||
}
|
|
||||||
if [ "$IM" == "1" ] && [ "$STORAGE_DRIVER" == " " ]; then
|
|
||||||
FEATURES="nesting=1,keyctl=1"
|
|
||||||
elif
|
|
||||||
[ "$IM" == "1" ] && [ "$STORAGE_DRIVER" == "fuse" ]; then
|
|
||||||
FEATURES="nesting=1,keyctl=1,fuse=1"
|
|
||||||
elif
|
|
||||||
[ "$IM" == "0" ] && [ "$STORAGE_DRIVER" == "fuse" ]; then
|
|
||||||
FEATURES="nesting=1,fuse=1"
|
|
||||||
else
|
|
||||||
FEATURES="nesting=1"
|
|
||||||
fi
|
|
||||||
|
|
||||||
TEMP_DIR=$(mktemp -d)
|
|
||||||
pushd $TEMP_DIR >/dev/null
|
|
||||||
|
|
||||||
export CTID=$(pvesh get /cluster/nextid)
|
|
||||||
export PCT_OSTYPE=debian
|
|
||||||
export PCT_OSVERSION=11
|
|
||||||
export PCT_DISK_SIZE=4
|
|
||||||
export PCT_OPTIONS="
|
|
||||||
-features $FEATURES
|
|
||||||
-hostname docker
|
|
||||||
-net0 name=eth0,bridge=vmbr0,ip=dhcp
|
|
||||||
-onboot 1
|
|
||||||
-cores 2
|
|
||||||
-memory 2048
|
|
||||||
-unprivileged ${IM}
|
|
||||||
${PW}
|
|
||||||
"
|
|
||||||
bash -c "$(wget -qLO - https://raw.githubusercontent.com/tteck/Proxmox/main/ct/create_lxc.sh)" || exit
|
|
||||||
|
|
||||||
STORAGE_TYPE=$(pvesm status -storage $(pct config $CTID | grep rootfs | awk -F ":" '{print $2}') | awk 'NR>1 {print $2}')
|
|
||||||
if [ "$STORAGE_TYPE" == "zfspool" ]; then
|
|
||||||
wget -qL -O fuse-overlayfs https://github.com/containers/fuse-overlayfs/releases/download/v1.8.2/fuse-overlayfs-x86_64
|
|
||||||
warn "Some containers may not work properly due to ZFS not supporting 'fallocate'."
|
|
||||||
fi
|
|
||||||
LXC_CONFIG=/etc/pve/lxc/${CTID}.conf
|
|
||||||
cat <<EOF >> $LXC_CONFIG
|
|
||||||
lxc.cgroup2.devices.allow: a
|
|
||||||
lxc.cap.drop:
|
|
||||||
EOF
|
|
||||||
if [ "$DHCP" == "1" ]; then
|
|
||||||
MAC=$(pct config $CTID \
|
|
||||||
| grep -i hwaddr \
|
|
||||||
| awk '{print substr($2, 31, length($3) 17 ) }') \
|
|
||||||
|
|
||||||
echo -e "MAC Address ${BL}$MAC${CL}"
|
|
||||||
|
|
||||||
dhcp_reservation(){
|
|
||||||
printf "Please set DHCP reservation and press Enter."
|
|
||||||
read
|
|
||||||
}
|
|
||||||
dhcp_reservation
|
|
||||||
fi
|
|
||||||
|
|
||||||
echo -en "${GN} Starting LXC Container... "
|
|
||||||
pct start $CTID
|
|
||||||
echo -e "${CM}${CL} \r"
|
|
||||||
|
|
||||||
if [ "$STORAGE_TYPE" == "zfspool" ] && [ "$STORAGE_DRIVER" == "fuse" ]; then
|
|
||||||
pct push $CTID fuse-overlayfs /usr/local/bin/fuse-overlayfs -perms 755
|
|
||||||
info "Using ${BL}fuse-overlayfs${CL} Storage Driver."
|
|
||||||
else
|
|
||||||
info "Using ${BL}overlay2${CL} Storage Driver."
|
|
||||||
fi
|
|
||||||
|
|
||||||
alias lxc-cmd="lxc-attach -n $CTID --"
|
|
||||||
|
|
||||||
lxc-cmd bash -c "$(wget -qLO - https://raw.githubusercontent.com/tteck/Proxmox/main/setup/docker-install.sh)" || exit
|
|
||||||
|
|
||||||
IP=$(pct exec $CTID ip a s dev eth0 | sed -n '/inet / s/\// /p' | awk '{print $2}')
|
|
||||||
|
|
||||||
echo -e "${GN}Successfully created Docker LXC to${CL} ${BL}$CTID${CL}. \n"
|
|
361
ct/docker-v3.sh
361
ct/docker-v3.sh
|
@ -1,361 +0,0 @@
|
||||||
#!/usr/bin/env bash
|
|
||||||
echo -e "Loading..."
|
|
||||||
NEXTID=$(pvesh get /cluster/nextid)
|
|
||||||
INTEGER='^[0-9]+$'
|
|
||||||
YW=`echo "\033[33m"`
|
|
||||||
BL=`echo "\033[36m"`
|
|
||||||
RD=`echo "\033[01;31m"`
|
|
||||||
BGN=`echo "\033[4;92m"`
|
|
||||||
GN=`echo "\033[1;92m"`
|
|
||||||
DGN=`echo "\033[32m"`
|
|
||||||
CL=`echo "\033[m"`
|
|
||||||
BFR="\\r\\033[K"
|
|
||||||
HOLD="-"
|
|
||||||
CM="${GN}✓${CL}"
|
|
||||||
APP="Docker"
|
|
||||||
NSAPP=$(echo ${APP,,} | tr -d ' ')
|
|
||||||
set -o errexit
|
|
||||||
set -o errtrace
|
|
||||||
set -o nounset
|
|
||||||
set -o pipefail
|
|
||||||
shopt -s expand_aliases
|
|
||||||
alias die='EXIT=$? LINE=$LINENO error_exit'
|
|
||||||
trap die ERR
|
|
||||||
|
|
||||||
function error_exit() {
|
|
||||||
trap - ERR
|
|
||||||
local reason="Unknown failure occurred."
|
|
||||||
local msg="${1:-$reason}"
|
|
||||||
local flag="${RD}‼ ERROR ${CL}$EXIT@$LINE"
|
|
||||||
echo -e "$flag $msg" 1>&2
|
|
||||||
exit $EXIT
|
|
||||||
}
|
|
||||||
|
|
||||||
while true; do
|
|
||||||
clear
|
|
||||||
read -p "This will create a New ${APP} LXC. Proceed(y/n)?" yn
|
|
||||||
case $yn in
|
|
||||||
[Yy]* ) break;;
|
|
||||||
[Nn]* ) exit;;
|
|
||||||
* ) echo "Please answer yes or no.";;
|
|
||||||
esac
|
|
||||||
done
|
|
||||||
clear
|
|
||||||
function header_info {
|
|
||||||
echo -e "${BL}
|
|
||||||
_____ _
|
|
||||||
| __ \ | |
|
|
||||||
| | | | ___ ___| | _____ _ __
|
|
||||||
| |v3| |/ _ \ / __| |/ / _ \ __|
|
|
||||||
| |__| | (_) | (__| < __/ |
|
|
||||||
|_____/ \___/ \___|_|\_\___|_|
|
|
||||||
${CL}"
|
|
||||||
}
|
|
||||||
|
|
||||||
header_info
|
|
||||||
|
|
||||||
function msg_info() {
|
|
||||||
local msg="$1"
|
|
||||||
echo -ne " ${HOLD} ${YW}${msg}..."
|
|
||||||
}
|
|
||||||
|
|
||||||
function msg_ok() {
|
|
||||||
local msg="$1"
|
|
||||||
echo -e "${BFR} ${CM} ${GN}${msg}${CL}"
|
|
||||||
}
|
|
||||||
|
|
||||||
function PVE_CHECK() {
|
|
||||||
PVE=$(pveversion | grep "pve-manager/7" | wc -l)
|
|
||||||
|
|
||||||
if [[ $PVE != 1 ]]; then
|
|
||||||
echo -e "${RD}This script requires Proxmox Virtual Environment 7.0 or greater${CL}"
|
|
||||||
echo -e "Exiting..."
|
|
||||||
sleep 2
|
|
||||||
exit
|
|
||||||
fi
|
|
||||||
}
|
|
||||||
|
|
||||||
function default_settings() {
|
|
||||||
clear
|
|
||||||
header_info
|
|
||||||
echo -e "${BL}Using Default Settings${CL}"
|
|
||||||
echo -e "${DGN}Using CT Type ${BGN}Unprivileged${CL} ${RD}NO DEVICE PASSTHROUGH${CL}"
|
|
||||||
CT_TYPE="1"
|
|
||||||
echo -e "${DGN}Using CT Password ${BGN}Automatic Login${CL}"
|
|
||||||
PW=" "
|
|
||||||
echo -e "${DGN}Using CT ID ${BGN}$NEXTID${CL}"
|
|
||||||
CT_ID=$NEXTID
|
|
||||||
echo -e "${DGN}Using CT Name ${BGN}$NSAPP${CL}"
|
|
||||||
HN=$NSAPP
|
|
||||||
echo -e "${DGN}Using Disk Size ${BGN}4${CL}${DGN}GB${CL}"
|
|
||||||
DISK_SIZE="4"
|
|
||||||
echo -e "${DGN}Using ${BGN}2${CL}${DGN}vCPU${CL}"
|
|
||||||
CORE_COUNT="2"
|
|
||||||
echo -e "${DGN}Using ${BGN}2048${CL}${DGN}MiB RAM${CL}"
|
|
||||||
RAM_SIZE="2048"
|
|
||||||
echo -e "${DGN}Using Bridge ${BGN}vmbr0${CL}"
|
|
||||||
BRG="vmbr0"
|
|
||||||
echo -e "${DGN}Using Static IP Address ${BGN}DHCP${CL}"
|
|
||||||
NET=dhcp
|
|
||||||
echo -e "${DGN}Using Gateway Address ${BGN}NONE${CL}"
|
|
||||||
GATE=""
|
|
||||||
echo -e "${DGN}Using VLAN Tag ${BGN}NONE${CL}"
|
|
||||||
VLAN=""
|
|
||||||
}
|
|
||||||
|
|
||||||
function advanced_settings() {
|
|
||||||
clear
|
|
||||||
header_info
|
|
||||||
echo -e "${RD}Using Advanced Settings${CL}"
|
|
||||||
echo -e "${YW}Type Privileged, or Press [ENTER] for Default: Unprivileged (${RD}NO DEVICE PASSTHROUGH${CL}${YW})"
|
|
||||||
read CT_TYPE1
|
|
||||||
if [ -z $CT_TYPE1 ]; then CT_TYPE1="Unprivileged" CT_TYPE="1";
|
|
||||||
echo -en "${DGN}Set CT Type ${BL}$CT_TYPE1${CL}"
|
|
||||||
else
|
|
||||||
CT_TYPE1="Privileged"
|
|
||||||
CT_TYPE="0"
|
|
||||||
echo -en "${DGN}Set CT Type ${BL}Privileged${CL}"
|
|
||||||
fi;
|
|
||||||
echo -e " ${CM}${CL} \r"
|
|
||||||
sleep 1
|
|
||||||
clear
|
|
||||||
header_info
|
|
||||||
echo -e "${RD}Using Advanced Settings${CL}"
|
|
||||||
echo -e "${DGN}Using CT Type ${BGN}$CT_TYPE1${CL}"
|
|
||||||
echo -e "${YW}Set Password, or Press [ENTER] for Default: Automatic Login "
|
|
||||||
read PW1
|
|
||||||
if [ -z $PW1 ]; then PW1="Automatic Login" PW=" ";
|
|
||||||
echo -en "${DGN}Set CT ${BL}$PW1${CL}"
|
|
||||||
else
|
|
||||||
PW="-password $PW1"
|
|
||||||
echo -en "${DGN}Set CT Password ${BL}$PW1${CL}"
|
|
||||||
fi;
|
|
||||||
echo -e " ${CM}${CL} \r"
|
|
||||||
sleep 1
|
|
||||||
clear
|
|
||||||
header_info
|
|
||||||
echo -e "${RD}Using Advanced Settings${CL}"
|
|
||||||
echo -e "${DGN}Using CT Type ${BGN}$CT_TYPE1${CL}"
|
|
||||||
echo -e "${DGN}Using CT Password ${BGN}$PW1${CL}"
|
|
||||||
echo -e "${YW}Enter the CT ID, or Press [ENTER] to automatically generate (${NEXTID}) "
|
|
||||||
read CT_ID
|
|
||||||
if [ -z $CT_ID ]; then CT_ID=$NEXTID; fi;
|
|
||||||
echo -en "${DGN}Set CT ID To ${BL}$CT_ID${CL}"
|
|
||||||
echo -e " ${CM}${CL} \r"
|
|
||||||
sleep 1
|
|
||||||
clear
|
|
||||||
header_info
|
|
||||||
echo -e "${RD}Using Advanced Settings${CL}"
|
|
||||||
echo -e "${DGN}Using CT Type ${BGN}$CT_TYPE1${CL}"
|
|
||||||
echo -e "${DGN}Using CT Password ${BGN}$PW1${CL}"
|
|
||||||
echo -e "${DGN}Using CT ID ${BGN}$CT_ID${CL}"
|
|
||||||
echo -e "${YW}Enter CT Name (no-spaces), or Press [ENTER] for Default: $NSAPP "
|
|
||||||
read CT_NAME
|
|
||||||
if [ -z $CT_NAME ]; then
|
|
||||||
HN=$NSAPP
|
|
||||||
else
|
|
||||||
HN=$(echo ${CT_NAME,,} | tr -d ' ')
|
|
||||||
fi
|
|
||||||
echo -en "${DGN}Set CT Name To ${BL}$HN${CL}"
|
|
||||||
echo -e " ${CM}${CL} \r"
|
|
||||||
sleep 1
|
|
||||||
clear
|
|
||||||
header_info
|
|
||||||
echo -e "${RD}Using Advanced Settings${CL}"
|
|
||||||
echo -e "${DGN}Using CT Type ${BGN}$CT_TYPE1${CL}"
|
|
||||||
echo -e "${DGN}Using CT Password ${BGN}$PW1${CL}"
|
|
||||||
echo -e "${DGN}Using CT ID ${BGN}$CT_ID${CL}"
|
|
||||||
echo -e "${DGN}Using CT Name ${BGN}$HN${CL}"
|
|
||||||
echo -e "${YW}Enter a Disk Size, or Press [ENTER] for Default: 4 "
|
|
||||||
read DISK_SIZE
|
|
||||||
if [ -z $DISK_SIZE ]; then DISK_SIZE="4"; fi;
|
|
||||||
if ! [[ $DISK_SIZE =~ $INTEGER ]] ; then echo "ERROR! DISK SIZE MUST HAVE INTEGER NUMBER!"; exit; fi;
|
|
||||||
echo -en "${DGN}Set Disk Size To ${BL}$DISK_SIZE${CL}${DGN}GB${CL}"
|
|
||||||
echo -e " ${CM}${CL} \r"
|
|
||||||
sleep 1
|
|
||||||
clear
|
|
||||||
header_info
|
|
||||||
echo -e "${RD}Using Advanced Settings${CL}"
|
|
||||||
echo -e "${DGN}Using CT Type ${BGN}$CT_TYPE1${CL}"
|
|
||||||
echo -e "${DGN}Using CT Password ${BGN}$PW1${CL}"
|
|
||||||
echo -e "${DGN}Using CT ID ${BGN}$CT_ID${CL}"
|
|
||||||
echo -e "${DGN}Using CT Name ${BGN}$HN${CL}"
|
|
||||||
echo -e "${DGN}Using Disk Size ${BGN}$DISK_SIZE${CL}${DGN}GB${CL}"
|
|
||||||
echo -e "${YW}Allocate CPU cores, or Press [ENTER] for Default: 2 "
|
|
||||||
read CORE_COUNT
|
|
||||||
if [ -z $CORE_COUNT ]; then CORE_COUNT="2"; fi;
|
|
||||||
echo -en "${DGN}Set Cores To ${BL}$CORE_COUNT${CL}${DGN}vCPU${CL}"
|
|
||||||
echo -e " ${CM}${CL} \r"
|
|
||||||
sleep 1
|
|
||||||
clear
|
|
||||||
header_info
|
|
||||||
echo -e "${RD}Using Advanced Settings${CL}"
|
|
||||||
echo -e "${DGN}Using CT Type ${BGN}$CT_TYPE1${CL}"
|
|
||||||
echo -e "${DGN}Using CT Password ${BGN}$PW1${CL}"
|
|
||||||
echo -e "${DGN}Using CT ID ${BGN}$CT_ID${CL}"
|
|
||||||
echo -e "${DGN}Using CT Name ${BGN}$HN${CL}"
|
|
||||||
echo -e "${DGN}Using Disk Size ${BGN}$DISK_SIZE${CL}${DGN}GB${CL}"
|
|
||||||
echo -e "${DGN}Using ${BGN}${CORE_COUNT}${CL}${DGN}vCPU${CL}"
|
|
||||||
echo -e "${YW}Allocate RAM in MiB, or Press [ENTER] for Default: 2048 "
|
|
||||||
read RAM_SIZE
|
|
||||||
if [ -z $RAM_SIZE ]; then RAM_SIZE="2048"; fi;
|
|
||||||
echo -en "${DGN}Set RAM To ${BL}$RAM_SIZE${CL}${DGN}MiB RAM${CL}"
|
|
||||||
echo -e " ${CM}${CL} \n"
|
|
||||||
sleep 1
|
|
||||||
clear
|
|
||||||
header_info
|
|
||||||
echo -e "${RD}Using Advanced Settings${CL}"
|
|
||||||
echo -e "${DGN}Using CT Type ${BGN}$CT_TYPE1${CL}"
|
|
||||||
echo -e "${DGN}Using CT Password ${BGN}$PW1${CL}"
|
|
||||||
echo -e "${DGN}Using CT ID ${BGN}$CT_ID${CL}"
|
|
||||||
echo -e "${DGN}Using CT Name ${BGN}$HN${CL}"
|
|
||||||
echo -e "${DGN}Using Disk Size ${BGN}$DISK_SIZE${CL}${DGN}GB${CL}"
|
|
||||||
echo -e "${DGN}Using ${BGN}${CORE_COUNT}${CL}${DGN}vCPU${CL}"
|
|
||||||
echo -e "${DGN}Using ${BGN}${RAM_SIZE}${CL}${DGN}MiB RAM${CL}"
|
|
||||||
echo -e "${YW}Enter a Bridge, or Press [ENTER] for Default: vmbr0 "
|
|
||||||
read BRG
|
|
||||||
if [ -z $BRG ]; then BRG="vmbr0"; fi;
|
|
||||||
echo -en "${DGN}Set Bridge To ${BL}$BRG${CL}"
|
|
||||||
echo -e " ${CM}${CL} \n"
|
|
||||||
sleep 1
|
|
||||||
clear
|
|
||||||
header_info
|
|
||||||
echo -e "${RD}Using Advanced Settings${CL}"
|
|
||||||
echo -e "${DGN}Using CT Type ${BGN}$CT_TYPE1${CL}"
|
|
||||||
echo -e "${DGN}Using CT Password ${BGN}$PW1${CL}"
|
|
||||||
echo -e "${DGN}Using CT ID ${BGN}$CT_ID${CL}"
|
|
||||||
echo -e "${DGN}Using CT Name ${BGN}$HN${CL}"
|
|
||||||
echo -e "${DGN}Using Disk Size ${BGN}$DISK_SIZE${CL}${DGN}GB${CL}"
|
|
||||||
echo -e "${DGN}Using ${BGN}${CORE_COUNT}${CL}${DGN}vCPU${CL}"
|
|
||||||
echo -e "${DGN}Using ${BGN}${RAM_SIZE}${CL}${DGN}MiB RAM${CL}"
|
|
||||||
echo -e "${DGN}Using Bridge ${BGN}${BRG}${CL}"
|
|
||||||
echo -e "${YW}Enter a Static IPv4 CIDR Address, or Press [ENTER] for Default: DHCP "
|
|
||||||
read NET
|
|
||||||
if [ -z $NET ]; then NET="dhcp"; fi;
|
|
||||||
echo -en "${DGN}Set Static IP Address To ${BL}$NET${CL}"
|
|
||||||
echo -e " ${CM}${CL} \n"
|
|
||||||
sleep 1
|
|
||||||
clear
|
|
||||||
header_info
|
|
||||||
echo -e "${RD}Using Advanced Settings${CL}"
|
|
||||||
echo -e "${DGN}Using CT Type ${BGN}$CT_TYPE1${CL}"
|
|
||||||
echo -e "${DGN}Using CT Password ${BGN}$PW1${CL}"
|
|
||||||
echo -e "${DGN}Using CT ID ${BGN}$CT_ID${CL}"
|
|
||||||
echo -e "${DGN}Using CT Name ${BGN}$HN${CL}"
|
|
||||||
echo -e "${DGN}Using Disk Size ${BGN}$DISK_SIZE${CL}${DGN}GB${CL}"
|
|
||||||
echo -e "${DGN}Using ${BGN}${CORE_COUNT}${CL}${DGN}vCPU${CL}"
|
|
||||||
echo -e "${DGN}Using ${BGN}${RAM_SIZE}${CL}${DGN}MiB RAM${CL}"
|
|
||||||
echo -e "${DGN}Using Bridge ${BGN}${BRG}${CL}"
|
|
||||||
echo -e "${DGN}Using Static IP Address ${BGN}$NET${CL}"
|
|
||||||
echo -e "${YW}Enter a Gateway IP (mandatory if static IP is used), or Press [ENTER] for Default: NONE "
|
|
||||||
read GATE1
|
|
||||||
if [ -z $GATE1 ]; then GATE1="NONE" GATE="";
|
|
||||||
echo -en "${DGN}Set Gateway IP To ${BL}$GATE1${CL}"
|
|
||||||
else
|
|
||||||
GATE=",gw=$GATE1"
|
|
||||||
echo -en "${DGN}Set Gateway IP To ${BL}$GATE1${CL}"
|
|
||||||
fi;
|
|
||||||
echo -e " ${CM}${CL} \n"
|
|
||||||
sleep 1
|
|
||||||
clear
|
|
||||||
header_info
|
|
||||||
|
|
||||||
echo -e "${RD}Using Advanced Settings${CL}"
|
|
||||||
echo -e "${DGN}Using CT Type ${BGN}$CT_TYPE1${CL}"
|
|
||||||
echo -e "${DGN}Using CT Password ${BGN}$PW1${CL}"
|
|
||||||
echo -e "${DGN}Using CT ID ${BGN}$CT_ID${CL}"
|
|
||||||
echo -e "${DGN}Using CT Name ${BGN}$HN${CL}"
|
|
||||||
echo -e "${DGN}Using Disk Size ${BGN}$DISK_SIZE${CL}${DGN}GB${CL}"
|
|
||||||
echo -e "${DGN}Using ${BGN}${CORE_COUNT}${CL}${DGN}vCPU${CL}"
|
|
||||||
echo -e "${DGN}Using ${BGN}${RAM_SIZE}${CL}${DGN}MiB RAM${CL}"
|
|
||||||
echo -e "${DGN}Using Bridge ${BGN}${BRG}${CL}"
|
|
||||||
echo -e "${DGN}Using Static IP Address ${BGN}$NET${CL}"
|
|
||||||
echo -e "${DGN}Using Gateway IP Address ${BGN}$GATE1${CL}"
|
|
||||||
echo -e "${YW}Enter a VLAN Tag, or Press [ENTER] for Default: NONE "
|
|
||||||
read VLAN1
|
|
||||||
if [ -z $VLAN1 ]; then VLAN1="NONE" VLAN="";
|
|
||||||
echo -en "${DGN}Set VLAN Tag To ${BL}$VLAN1${CL}"
|
|
||||||
else
|
|
||||||
VLAN=",tag=$VLAN1"
|
|
||||||
echo -en "${DGN}Set VLAN Tag To ${BL}$VLAN1${CL}"
|
|
||||||
fi;
|
|
||||||
echo -e " ${CM}${CL} \n"
|
|
||||||
sleep 1
|
|
||||||
clear
|
|
||||||
header_info
|
|
||||||
echo -e "${RD}Using Advanced Settings${CL}"
|
|
||||||
echo -e "${DGN}Using CT Type ${BGN}$CT_TYPE1${CL}"
|
|
||||||
echo -e "${DGN}Using CT Password ${BGN}$PW1${CL}"
|
|
||||||
echo -e "${DGN}Using CT ID ${BGN}$CT_ID${CL}"
|
|
||||||
echo -e "${DGN}Using CT Name ${BGN}$HN${CL}"
|
|
||||||
echo -e "${DGN}Using Disk Size ${BGN}$DISK_SIZE${CL}${DGN}GB${CL}"
|
|
||||||
echo -e "${DGN}Using ${BGN}${CORE_COUNT}${CL}${DGN}vCPU${CL}"
|
|
||||||
echo -e "${DGN}Using ${BGN}${RAM_SIZE}${CL}${DGN}MiB RAM${CL}"
|
|
||||||
echo -e "${DGN}Using Bridge ${BGN}${BRG}${CL}"
|
|
||||||
echo -e "${DGN}Using Static IP Address ${BGN}$NET${CL}"
|
|
||||||
echo -e "${DGN}Using Gateway IP Address ${BGN}$GATE1${CL}"
|
|
||||||
echo -e "${DGN}Using VLAN Tag ${BGN}$VLAN1${CL}"
|
|
||||||
|
|
||||||
read -p "Are these settings correct(y/n)? " -n 1 -r
|
|
||||||
echo
|
|
||||||
if [[ ! $REPLY =~ ^[Yy]$ ]]
|
|
||||||
then
|
|
||||||
advanced_settings
|
|
||||||
fi
|
|
||||||
}
|
|
||||||
|
|
||||||
function start_script() {
|
|
||||||
echo -e "${YW}Type Advanced, or Press [ENTER] for Default Settings "
|
|
||||||
read SETTINGS
|
|
||||||
if [ -z $SETTINGS ]; then default_settings;
|
|
||||||
else
|
|
||||||
advanced_settings
|
|
||||||
fi;
|
|
||||||
}
|
|
||||||
|
|
||||||
PVE_CHECK
|
|
||||||
start_script
|
|
||||||
|
|
||||||
if [ "$CT_TYPE" == "1" ]; then
|
|
||||||
FEATURES="nesting=1,keyctl=1"
|
|
||||||
else
|
|
||||||
FEATURES="nesting=1"
|
|
||||||
fi
|
|
||||||
|
|
||||||
TEMP_DIR=$(mktemp -d)
|
|
||||||
pushd $TEMP_DIR >/dev/null
|
|
||||||
|
|
||||||
export CTID=$CT_ID
|
|
||||||
export PCT_OSTYPE=debian
|
|
||||||
export PCT_OSVERSION=11
|
|
||||||
export PCT_DISK_SIZE=$DISK_SIZE
|
|
||||||
export PCT_OPTIONS="
|
|
||||||
-features $FEATURES
|
|
||||||
-hostname $HN
|
|
||||||
-net0 name=eth0,bridge=$BRG,ip=$NET$GATE$VLAN
|
|
||||||
-onboot 1
|
|
||||||
-cores $CORE_COUNT
|
|
||||||
-memory $RAM_SIZE
|
|
||||||
-unprivileged $CT_TYPE
|
|
||||||
$PW
|
|
||||||
"
|
|
||||||
bash -c "$(wget -qLO - https://raw.githubusercontent.com/tteck/Proxmox/main/ct/create_lxc.sh)" || exit
|
|
||||||
|
|
||||||
LXC_CONFIG=/etc/pve/lxc/${CTID}.conf
|
|
||||||
cat <<EOF >> $LXC_CONFIG
|
|
||||||
lxc.cgroup2.devices.allow: a
|
|
||||||
lxc.cap.drop:
|
|
||||||
EOF
|
|
||||||
|
|
||||||
msg_info "Starting LXC Container"
|
|
||||||
pct start $CTID
|
|
||||||
msg_ok "Started LXC Container"
|
|
||||||
|
|
||||||
lxc-attach -n $CTID -- bash -c "$(wget -qLO - https://raw.githubusercontent.com/tteck/Proxmox/main/setup/docker-install.sh)" || exit
|
|
||||||
|
|
||||||
IP=$(pct exec $CTID ip a s dev eth0 | sed -n '/inet / s/\// /p' | awk '{print $2}')
|
|
||||||
|
|
||||||
pct set $CTID -description "# ${APP} LXC
|
|
||||||
### https://github.com/tteck/Proxmox"
|
|
||||||
|
|
||||||
msg_ok "Completed Successfully!\n"
|
|
|
@ -336,7 +336,7 @@ fi
|
||||||
msg_info "Starting LXC Container"
|
msg_info "Starting LXC Container"
|
||||||
pct start $CTID
|
pct start $CTID
|
||||||
msg_ok "Started LXC Container"
|
msg_ok "Started LXC Container"
|
||||||
lxc-attach -n $CTID -- bash -c "$(wget -qLO - https://raw.githubusercontent.com/tteck/Proxmox/main/setup/$var_install.sh)" || exit
|
lxc-attach -n $CTID -- bash -c "$(wget -qLO - https://raw.githubusercontent.com/tteck/Proxmox/main/install/$var_install.sh)" || exit
|
||||||
IP=$(pct exec $CTID ip a s dev eth0 | sed -n '/inet / s/\// /p' | awk '{print $2}')
|
IP=$(pct exec $CTID ip a s dev eth0 | sed -n '/inet / s/\// /p' | awk '{print $2}')
|
||||||
pct set $CTID -description "# ${APP} LXC
|
pct set $CTID -description "# ${APP} LXC
|
||||||
### https://tteck.github.io/Proxmox/
|
### https://tteck.github.io/Proxmox/
|
||||||
|
|
|
@ -331,7 +331,7 @@ fi
|
||||||
msg_info "Starting LXC Container"
|
msg_info "Starting LXC Container"
|
||||||
pct start $CTID
|
pct start $CTID
|
||||||
msg_ok "Started LXC Container"
|
msg_ok "Started LXC Container"
|
||||||
lxc-attach -n $CTID -- bash -c "$(wget -qLO - https://raw.githubusercontent.com/tteck/Proxmox/main/setup/$var_install.sh)" || exit
|
lxc-attach -n $CTID -- bash -c "$(wget -qLO - https://raw.githubusercontent.com/tteck/Proxmox/main/install/$var_install.sh)" || exit
|
||||||
IP=$(pct exec $CTID ip a s dev eth0 | sed -n '/inet / s/\// /p' | awk '{print $2}')
|
IP=$(pct exec $CTID ip a s dev eth0 | sed -n '/inet / s/\// /p' | awk '{print $2}')
|
||||||
pct set $CTID -description "# ${APP} LXC
|
pct set $CTID -description "# ${APP} LXC
|
||||||
### https://tteck.github.io/Proxmox/
|
### https://tteck.github.io/Proxmox/
|
||||||
|
|
|
@ -310,7 +310,7 @@ bash -c "$(wget -qLO - https://raw.githubusercontent.com/tteck/Proxmox/main/ct/c
|
||||||
msg_info "Starting LXC Container"
|
msg_info "Starting LXC Container"
|
||||||
pct start $CTID
|
pct start $CTID
|
||||||
msg_ok "Started LXC Container"
|
msg_ok "Started LXC Container"
|
||||||
lxc-attach -n $CTID -- bash -c "$(wget -qLO - https://raw.githubusercontent.com/tteck/Proxmox/main/setup/$var_install.sh)" || exit
|
lxc-attach -n $CTID -- bash -c "$(wget -qLO - https://raw.githubusercontent.com/tteck/Proxmox/main/install/$var_install.sh)" || exit
|
||||||
IP=$(pct exec $CTID ip a s dev eth0 | sed -n '/inet / s/\// /p' | awk '{print $2}')
|
IP=$(pct exec $CTID ip a s dev eth0 | sed -n '/inet / s/\// /p' | awk '{print $2}')
|
||||||
pct set $CTID -description "# ${APP} LXC
|
pct set $CTID -description "# ${APP} LXC
|
||||||
### https://tteck.github.io/Proxmox/
|
### https://tteck.github.io/Proxmox/
|
||||||
|
|
188
ct/esphome-v1.sh
188
ct/esphome-v1.sh
|
@ -1,188 +0,0 @@
|
||||||
#!/usr/bin/env bash
|
|
||||||
|
|
||||||
YW=`echo "\033[33m"`
|
|
||||||
BL=`echo "\033[36m"`
|
|
||||||
RD=`echo "\033[01;31m"`
|
|
||||||
CM='\xE2\x9C\x94\033'
|
|
||||||
GN=`echo "\033[1;92m"`
|
|
||||||
CL=`echo "\033[m"`
|
|
||||||
|
|
||||||
while true; do
|
|
||||||
read -p "This will create a New ESPHome LXC Container. Proceed(y/n)?" yn
|
|
||||||
case $yn in
|
|
||||||
[Yy]* ) break;;
|
|
||||||
[Nn]* ) exit;;
|
|
||||||
* ) echo "Please answer yes or no.";;
|
|
||||||
esac
|
|
||||||
done
|
|
||||||
clear
|
|
||||||
function header_info {
|
|
||||||
echo -e "${CL}
|
|
||||||
______ _____ _____ _ _ ____ __ __ ______
|
|
||||||
| ____|/ ____| __ \| | | |/ __ \| \/ | ____|
|
|
||||||
| |__ | (___ | |__) | |__| | | | | \ / | |__
|
|
||||||
| __| \___ \| ___/| __ | | | | |\/| | __|
|
|
||||||
| |____ ____) | | | | | | |__| | | | | |____
|
|
||||||
|______|_____/|_| |_| |_|\____/|_| |_|______|
|
|
||||||
|
|
||||||
${CL}"
|
|
||||||
}
|
|
||||||
|
|
||||||
header_info
|
|
||||||
|
|
||||||
set -o errexit
|
|
||||||
set -o errtrace
|
|
||||||
set -o nounset
|
|
||||||
set -o pipefail
|
|
||||||
shopt -s expand_aliases
|
|
||||||
alias die='EXIT=$? LINE=$LINENO error_exit'
|
|
||||||
CHECKMARK='\033[0;32m\xE2\x9C\x94\033[0m'
|
|
||||||
trap die ERR
|
|
||||||
trap cleanup EXIT
|
|
||||||
|
|
||||||
function error_exit() {
|
|
||||||
trap - ERR
|
|
||||||
local DEFAULT='Unknown failure occured.'
|
|
||||||
local REASON="\e[97m${1:-$DEFAULT}\e[39m"
|
|
||||||
local FLAG="\e[91m[ERROR] \e[93m$EXIT@$LINE"
|
|
||||||
msg "$FLAG $REASON"
|
|
||||||
[ ! -z ${CTID-} ] && cleanup_ctid
|
|
||||||
exit $EXIT
|
|
||||||
}
|
|
||||||
function warn() {
|
|
||||||
local REASON="\e[97m$1\e[39m"
|
|
||||||
local FLAG="\e[93m[WARNING]\e[39m"
|
|
||||||
msg "$FLAG $REASON"
|
|
||||||
}
|
|
||||||
function info() {
|
|
||||||
local REASON="$1"
|
|
||||||
local FLAG="\e[36m[INFO]\e[39m"
|
|
||||||
msg "$FLAG $REASON"
|
|
||||||
}
|
|
||||||
function msg() {
|
|
||||||
local TEXT="$1"
|
|
||||||
echo -e "$TEXT"
|
|
||||||
}
|
|
||||||
function cleanup_ctid() {
|
|
||||||
if [ ! -z ${MOUNT+x} ]; then
|
|
||||||
pct unmount $CTID
|
|
||||||
fi
|
|
||||||
if $(pct status $CTID &>/dev/null); then
|
|
||||||
if [ "$(pct status $CTID | awk '{print $2}')" == "running" ]; then
|
|
||||||
pct stop $CTID
|
|
||||||
fi
|
|
||||||
pct destroy $CTID
|
|
||||||
elif [ "$(pvesm list $STORAGE --vmid $CTID)" != "" ]; then
|
|
||||||
pvesm free $ROOTFS
|
|
||||||
fi
|
|
||||||
}
|
|
||||||
function cleanup() {
|
|
||||||
popd >/dev/null
|
|
||||||
rm -rf $TEMP_DIR
|
|
||||||
}
|
|
||||||
function load_module() {
|
|
||||||
if ! $(lsmod | grep -Fq $1); then
|
|
||||||
modprobe $1 &>/dev/null || \
|
|
||||||
die "Failed to load '$1' module."
|
|
||||||
fi
|
|
||||||
MODULES_PATH=/etc/modules
|
|
||||||
if ! $(grep -Fxq "$1" $MODULES_PATH); then
|
|
||||||
echo "$1" >> $MODULES_PATH || \
|
|
||||||
die "Failed to add '$1' module to load at boot."
|
|
||||||
fi
|
|
||||||
}
|
|
||||||
TEMP_DIR=$(mktemp -d)
|
|
||||||
pushd $TEMP_DIR >/dev/null
|
|
||||||
|
|
||||||
wget -qL https://raw.githubusercontent.com/tteck/Proxmox/main/setup/esphome_setup.sh
|
|
||||||
|
|
||||||
load_module overlay
|
|
||||||
|
|
||||||
while read -r line; do
|
|
||||||
TAG=$(echo $line | awk '{print $1}')
|
|
||||||
TYPE=$(echo $line | awk '{printf "%-10s", $2}')
|
|
||||||
FREE=$(echo $line | numfmt --field 4-6 --from-unit=K --to=iec --format %.2f | awk '{printf( "%9sB", $6)}')
|
|
||||||
ITEM=" Type: $TYPE Free: $FREE "
|
|
||||||
OFFSET=2
|
|
||||||
if [[ $((${#ITEM} + $OFFSET)) -gt ${MSG_MAX_LENGTH:-} ]]; then
|
|
||||||
MSG_MAX_LENGTH=$((${#ITEM} + $OFFSET))
|
|
||||||
fi
|
|
||||||
STORAGE_MENU+=( "$TAG" "$ITEM" "OFF" )
|
|
||||||
done < <(pvesm status -content rootdir | awk 'NR>1')
|
|
||||||
if [ $((${#STORAGE_MENU[@]}/3)) -eq 0 ]; then
|
|
||||||
warn "'Container' needs to be selected for at least one storage location."
|
|
||||||
die "Unable to detect valid storage location."
|
|
||||||
elif [ $((${#STORAGE_MENU[@]}/3)) -eq 1 ]; then
|
|
||||||
STORAGE=${STORAGE_MENU[0]}
|
|
||||||
else
|
|
||||||
while [ -z "${STORAGE:+x}" ]; do
|
|
||||||
STORAGE=$(whiptail --title "Storage Pools" --radiolist \
|
|
||||||
"Which storage pool you would like to use for the container?\n\n" \
|
|
||||||
16 $(($MSG_MAX_LENGTH + 23)) 6 \
|
|
||||||
"${STORAGE_MENU[@]}" 3>&1 1>&2 2>&3) || exit
|
|
||||||
done
|
|
||||||
fi
|
|
||||||
info "Using ${BL}$STORAGE${CL} for storage location."
|
|
||||||
|
|
||||||
CTID=$(pvesh get /cluster/nextid)
|
|
||||||
info "Container ID is ${BL}$CTID.${CL}"
|
|
||||||
|
|
||||||
echo -en "${GN} Updating LXC Template List... "
|
|
||||||
pveam update >/dev/null
|
|
||||||
echo -e "${CM}${CL} \r"
|
|
||||||
|
|
||||||
echo -en "${GN} Downloading LXC Template... "
|
|
||||||
OSTYPE=debian
|
|
||||||
OSVERSION=${OSTYPE}-11
|
|
||||||
mapfile -t TEMPLATES < <(pveam available -section system | sed -n "s/.*\($OSVERSION.*\)/\1/p" | sort -t - -k 2 -V)
|
|
||||||
TEMPLATE="${TEMPLATES[-1]}"
|
|
||||||
pveam download local $TEMPLATE >/dev/null ||
|
|
||||||
die "A problem occured while downloading the LXC template."
|
|
||||||
|
|
||||||
STORAGE_TYPE=$(pvesm status -storage $STORAGE | awk 'NR>1 {print $2}')
|
|
||||||
case $STORAGE_TYPE in
|
|
||||||
dir|nfs)
|
|
||||||
DISK_EXT=".raw"
|
|
||||||
DISK_REF="$CTID/"
|
|
||||||
;;
|
|
||||||
zfspool)
|
|
||||||
DISK_PREFIX="subvol"
|
|
||||||
DISK_FORMAT="subvol"
|
|
||||||
;;
|
|
||||||
esac
|
|
||||||
DISK=${DISK_PREFIX:-vm}-${CTID}-disk-0${DISK_EXT-}
|
|
||||||
ROOTFS=${STORAGE}:${DISK_REF-}${DISK}
|
|
||||||
echo -e "${CM}${CL} \r"
|
|
||||||
|
|
||||||
echo -en "${GN} Creating LXC Container... "
|
|
||||||
DISK_SIZE=4G
|
|
||||||
pvesm alloc $STORAGE $CTID $DISK $DISK_SIZE --format ${DISK_FORMAT:-raw} >/dev/null
|
|
||||||
if [ "$STORAGE_TYPE" == "zfspool" ]; then
|
|
||||||
warn "Some containers may not work properly due to ZFS not supporting 'fallocate'."
|
|
||||||
else
|
|
||||||
mkfs.ext4 $(pvesm path $ROOTFS) &>/dev/null
|
|
||||||
fi
|
|
||||||
ARCH=$(dpkg --print-architecture)
|
|
||||||
HOSTNAME=esphome
|
|
||||||
TEMPLATE_STRING="local:vztmpl/${TEMPLATE}"
|
|
||||||
pct create $CTID $TEMPLATE_STRING -arch $ARCH -features nesting=1 \
|
|
||||||
-hostname $HOSTNAME -net0 name=eth0,bridge=vmbr0,ip=dhcp -onboot 1 -cores 2 -memory 1024 \
|
|
||||||
-ostype $OSTYPE -rootfs $ROOTFS,size=$DISK_SIZE -storage $STORAGE >/dev/null
|
|
||||||
|
|
||||||
MOUNT=$(pct mount $CTID | cut -d"'" -f 2)
|
|
||||||
ln -fs $(readlink /etc/localtime) ${MOUNT}/etc/localtime
|
|
||||||
pct unmount $CTID && unset MOUNT
|
|
||||||
echo -e "${CM}${CL} \r"
|
|
||||||
|
|
||||||
echo -en "${GN} Starting LXC Container... "
|
|
||||||
pct start $CTID
|
|
||||||
pct push $CTID esphome_setup.sh /esphome_setup.sh -perms 755
|
|
||||||
echo -e "${CM}${CL} \r"
|
|
||||||
pct exec $CTID /esphome_setup.sh
|
|
||||||
|
|
||||||
|
|
||||||
IP=$(pct exec $CTID ip a s dev eth0 | sed -n '/inet / s/\// /p' | awk '{print $2}')
|
|
||||||
info "Successfully created ESPHome LXC Container to ${BL}$CTID${CL}"
|
|
||||||
echo -e "${CL} ESPHome should be reachable by going to the following URL.
|
|
||||||
${BL}http://${IP}:6052${CL}
|
|
||||||
\n"
|
|
259
ct/esphome-v2.sh
259
ct/esphome-v2.sh
|
@ -1,259 +0,0 @@
|
||||||
#!/usr/bin/env bash
|
|
||||||
YW=`echo "\033[33m"`
|
|
||||||
BL=`echo "\033[36m"`
|
|
||||||
RD=`echo "\033[01;31m"`
|
|
||||||
CM='\xE2\x9C\x94\033'
|
|
||||||
GN=`echo "\033[1;92m"`
|
|
||||||
CL=`echo "\033[m"`
|
|
||||||
APP="ESPHome"
|
|
||||||
HN=$(echo ${APP,,} | tr -d ' ')
|
|
||||||
while true; do
|
|
||||||
read -p "This will create a New ${APP} LXC. Proceed(y/n)?" yn
|
|
||||||
case $yn in
|
|
||||||
[Yy]* ) break;;
|
|
||||||
[Nn]* ) exit;;
|
|
||||||
* ) echo "Please answer yes or no.";;
|
|
||||||
esac
|
|
||||||
done
|
|
||||||
clear
|
|
||||||
function header_info {
|
|
||||||
echo -e "${RD}
|
|
||||||
______ _____ _____ _ _ ____ __ __ ______
|
|
||||||
| ____|/ ____| __ \| | | |/ __ \| \/ | ____|
|
|
||||||
| |__ | (___ | |__) | |__| | | | | \ / | |__
|
|
||||||
| __| \___ \| ___/| __ | | | | |\/| | __|
|
|
||||||
| |____ ____) | | | | | | |__| | | | | |____
|
|
||||||
|______|_____/|_| |_| |_|\____/|_| |_|______|
|
|
||||||
|
|
||||||
${CL}"
|
|
||||||
}
|
|
||||||
|
|
||||||
header_info
|
|
||||||
show_menu(){
|
|
||||||
printf " ${YW} 1)${YW} Privileged ${CL}\n"
|
|
||||||
printf " ${YW} 2)${GN} Unprivileged ${CL}\n"
|
|
||||||
|
|
||||||
printf "Please choose a Install Method and hit enter or ${RD}x${CL} to exit."
|
|
||||||
read opt
|
|
||||||
}
|
|
||||||
|
|
||||||
option_picked(){
|
|
||||||
message1=${@:-"${CL}Error: No message passed"}
|
|
||||||
printf " ${YW}${message1}${CL}\n"
|
|
||||||
}
|
|
||||||
show_menu
|
|
||||||
while [ "$opt" != " " ]
|
|
||||||
do
|
|
||||||
case $opt in
|
|
||||||
1) clear;
|
|
||||||
header_info;
|
|
||||||
option_picked "Using Privileged Install";
|
|
||||||
IM=0
|
|
||||||
break;
|
|
||||||
;;
|
|
||||||
2) clear;
|
|
||||||
header_info;
|
|
||||||
option_picked "Using Unprivileged Install";
|
|
||||||
IM=1
|
|
||||||
break;
|
|
||||||
;;
|
|
||||||
|
|
||||||
x)exit;
|
|
||||||
;;
|
|
||||||
\n)exit;
|
|
||||||
;;
|
|
||||||
*)clear;
|
|
||||||
option_picked "Please choose a Install Method from the menu";
|
|
||||||
show_menu;
|
|
||||||
;;
|
|
||||||
esac
|
|
||||||
done
|
|
||||||
show_menu2(){
|
|
||||||
printf " ${YW} 1)${GN} Use Automatic Login ${CL}\n"
|
|
||||||
printf " ${YW} 2)${GN} Use Password (changeme) ${CL}\n"
|
|
||||||
|
|
||||||
printf "Please choose a Password Type and hit enter or ${RD}x${CL} to exit."
|
|
||||||
read opt
|
|
||||||
}
|
|
||||||
|
|
||||||
option_picked(){
|
|
||||||
message2=${@:-"${CL}Error: No message passed"}
|
|
||||||
printf " ${YW}${message1}${CL}\n"
|
|
||||||
printf " ${YW}${message2}${CL}\n"
|
|
||||||
}
|
|
||||||
show_menu2
|
|
||||||
while [ "$opt" != " " ]
|
|
||||||
do
|
|
||||||
case $opt in
|
|
||||||
1) clear;
|
|
||||||
header_info;
|
|
||||||
option_picked "Using Automatic Login";
|
|
||||||
PW=" "
|
|
||||||
break;
|
|
||||||
;;
|
|
||||||
2) clear;
|
|
||||||
header_info;
|
|
||||||
option_picked "Using Password (changeme)";
|
|
||||||
PW="-password changeme"
|
|
||||||
break;
|
|
||||||
;;
|
|
||||||
|
|
||||||
x)exit;
|
|
||||||
;;
|
|
||||||
\n)exit;
|
|
||||||
;;
|
|
||||||
*)clear;
|
|
||||||
option_picked "Please choose a Password Type from the menu";
|
|
||||||
show_menu2;
|
|
||||||
;;
|
|
||||||
esac
|
|
||||||
done
|
|
||||||
show_menu3(){
|
|
||||||
printf " ${YW} 1)${GN} Automatic DHCP ${CL}\n"
|
|
||||||
printf " ${YW} 2)${GN} Manual DHCP ${CL}\n"
|
|
||||||
|
|
||||||
printf "Please choose a DHCP Type and hit enter or ${RD}x${CL} to exit."
|
|
||||||
read opt
|
|
||||||
}
|
|
||||||
|
|
||||||
option_picked(){
|
|
||||||
message3=${@:-"${CL}Error: No message passed"}
|
|
||||||
printf " ${YW}${message1}${CL}\n"
|
|
||||||
printf " ${YW}${message2}${CL}\n"
|
|
||||||
printf " ${YW}${message3}${CL}\n"
|
|
||||||
}
|
|
||||||
show_menu3
|
|
||||||
while [ "$opt" != " " ]
|
|
||||||
do
|
|
||||||
case $opt in
|
|
||||||
1) clear;
|
|
||||||
header_info;
|
|
||||||
option_picked "Using Automatic DHCP";
|
|
||||||
DHCP=" "
|
|
||||||
break;
|
|
||||||
;;
|
|
||||||
2) clear;
|
|
||||||
header_info;
|
|
||||||
option_picked "Using Manual DHCP";
|
|
||||||
DHCP="1"
|
|
||||||
break;
|
|
||||||
;;
|
|
||||||
|
|
||||||
x)exit;
|
|
||||||
;;
|
|
||||||
\n)exit;
|
|
||||||
;;
|
|
||||||
*)clear;
|
|
||||||
option_picked "Please choose a DHCP Type from the menu";
|
|
||||||
show_menu3;
|
|
||||||
;;
|
|
||||||
esac
|
|
||||||
done
|
|
||||||
|
|
||||||
set -o errexit
|
|
||||||
set -o errtrace
|
|
||||||
set -o nounset
|
|
||||||
set -o pipefail
|
|
||||||
shopt -s expand_aliases
|
|
||||||
alias die='EXIT=$? LINE=$LINENO error_exit'
|
|
||||||
trap die ERR
|
|
||||||
trap cleanup EXIT
|
|
||||||
|
|
||||||
function error_exit() {
|
|
||||||
trap - ERR
|
|
||||||
local DEFAULT='Unknown failure occured.'
|
|
||||||
local REASON="\e[97m${1:-$DEFAULT}\e[39m"
|
|
||||||
local FLAG="\e[91m[ERROR] \e[93m$EXIT@$LINE"
|
|
||||||
msg "$FLAG $REASON"
|
|
||||||
[ ! -z ${CTID-} ] && cleanup_ctid
|
|
||||||
exit $EXIT
|
|
||||||
}
|
|
||||||
function warn() {
|
|
||||||
local REASON="\e[97m$1\e[39m"
|
|
||||||
local FLAG="\e[93m[WARNING]\e[39m"
|
|
||||||
msg "$FLAG $REASON"
|
|
||||||
}
|
|
||||||
function info() {
|
|
||||||
local REASON="$1"
|
|
||||||
local FLAG="\e[36m[INFO]\e[39m"
|
|
||||||
msg "$FLAG $REASON"
|
|
||||||
}
|
|
||||||
function msg() {
|
|
||||||
local TEXT="$1"
|
|
||||||
echo -e "$TEXT"
|
|
||||||
}
|
|
||||||
function cleanup_ctid() {
|
|
||||||
if $(pct status $CTID &>/dev/null); then
|
|
||||||
if [ "$(pct status $CTID | awk '{print $2}')" == "running" ]; then
|
|
||||||
pct stop $CTID
|
|
||||||
fi
|
|
||||||
pct destroy $CTID
|
|
||||||
elif [ "$(pvesm list $STORAGE --vmid $CTID)" != "" ]; then
|
|
||||||
pvesm free $ROOTFS
|
|
||||||
fi
|
|
||||||
}
|
|
||||||
function cleanup() {
|
|
||||||
popd >/dev/null
|
|
||||||
rm -rf $TEMP_DIR
|
|
||||||
}
|
|
||||||
if [ "$IM" == "1" ]; then
|
|
||||||
FEATURES="nesting=1,keyctl=1"
|
|
||||||
else
|
|
||||||
FEATURES="nesting=1"
|
|
||||||
fi
|
|
||||||
|
|
||||||
TEMP_DIR=$(mktemp -d)
|
|
||||||
pushd $TEMP_DIR >/dev/null
|
|
||||||
|
|
||||||
export CTID=$(pvesh get /cluster/nextid)
|
|
||||||
export PCT_OSTYPE=debian
|
|
||||||
export PCT_OSVERSION=11
|
|
||||||
export PCT_DISK_SIZE=4
|
|
||||||
export PCT_OPTIONS="
|
|
||||||
-features $FEATURES
|
|
||||||
-hostname $HN
|
|
||||||
-net0 name=eth0,bridge=vmbr0,ip=dhcp
|
|
||||||
-onboot 1
|
|
||||||
-cores 2
|
|
||||||
-memory 1024
|
|
||||||
-unprivileged ${IM}
|
|
||||||
${PW}
|
|
||||||
"
|
|
||||||
bash -c "$(wget -qLO - https://raw.githubusercontent.com/tteck/Proxmox/main/ct/create_lxc.sh)" || exit
|
|
||||||
|
|
||||||
STORAGE_TYPE=$(pvesm status -storage $(pct config $CTID | grep rootfs | awk -F ":" '{print $2}') | awk 'NR>1 {print $2}')
|
|
||||||
if [ "$STORAGE_TYPE" == "zfspool" ]; then
|
|
||||||
warn "Some addons may not work due to ZFS not supporting 'fallocate'."
|
|
||||||
fi
|
|
||||||
LXC_CONFIG=/etc/pve/lxc/${CTID}.conf
|
|
||||||
cat <<EOF >> $LXC_CONFIG
|
|
||||||
lxc.cgroup2.devices.allow: a
|
|
||||||
lxc.cap.drop:
|
|
||||||
EOF
|
|
||||||
if [ "$DHCP" == "1" ]; then
|
|
||||||
MAC=$(pct config $CTID \
|
|
||||||
| grep -i hwaddr \
|
|
||||||
| awk '{print substr($2, 31, length($3) 17 ) }') \
|
|
||||||
|
|
||||||
echo -e "MAC Address ${BL}$MAC${CL}"
|
|
||||||
|
|
||||||
dhcp_reservation(){
|
|
||||||
printf "Please set DHCP reservation and press Enter."
|
|
||||||
read
|
|
||||||
}
|
|
||||||
dhcp_reservation
|
|
||||||
fi
|
|
||||||
|
|
||||||
echo -en "${GN} Starting LXC Container... "
|
|
||||||
pct start $CTID
|
|
||||||
echo -e "${CM}${CL} \r"
|
|
||||||
|
|
||||||
alias lxc-cmd="lxc-attach -n $CTID --"
|
|
||||||
|
|
||||||
lxc-cmd bash -c "$(wget -qLO - https://raw.githubusercontent.com/tteck/Proxmox/main/setup/$HN-install.sh)" || exit
|
|
||||||
|
|
||||||
IP=$(pct exec $CTID ip a s dev eth0 | sed -n '/inet / s/\// /p' | awk '{print $2}')
|
|
||||||
|
|
||||||
echo -e "${GN}Successfully created ${APP} LXC to${CL} ${BL}$CTID${CL}.
|
|
||||||
${BL}${APP}${CL} should be reachable by going to the following URL.
|
|
||||||
${BL}http://${IP}:6052${CL} \n"
|
|
357
ct/esphome-v3.sh
357
ct/esphome-v3.sh
|
@ -1,357 +0,0 @@
|
||||||
#!/usr/bin/env bash
|
|
||||||
echo -e "Loading..."
|
|
||||||
NEXTID=$(pvesh get /cluster/nextid)
|
|
||||||
INTEGER='^[0-9]+$'
|
|
||||||
YW=`echo "\033[33m"`
|
|
||||||
BL=`echo "\033[36m"`
|
|
||||||
RD=`echo "\033[01;31m"`
|
|
||||||
BGN=`echo "\033[4;92m"`
|
|
||||||
GN=`echo "\033[1;92m"`
|
|
||||||
DGN=`echo "\033[32m"`
|
|
||||||
CL=`echo "\033[m"`
|
|
||||||
BFR="\\r\\033[K"
|
|
||||||
HOLD="-"
|
|
||||||
CM="${GN}✓${CL}"
|
|
||||||
APP="ESPHome"
|
|
||||||
NSAPP=$(echo ${APP,,} | tr -d ' ')
|
|
||||||
set -o errexit
|
|
||||||
set -o errtrace
|
|
||||||
set -o nounset
|
|
||||||
set -o pipefail
|
|
||||||
shopt -s expand_aliases
|
|
||||||
alias die='EXIT=$? LINE=$LINENO error_exit'
|
|
||||||
trap die ERR
|
|
||||||
|
|
||||||
function error_exit() {
|
|
||||||
trap - ERR
|
|
||||||
local reason="Unknown failure occurred."
|
|
||||||
local msg="${1:-$reason}"
|
|
||||||
local flag="${RD}‼ ERROR ${CL}$EXIT@$LINE"
|
|
||||||
echo -e "$flag $msg" 1>&2
|
|
||||||
exit $EXIT
|
|
||||||
}
|
|
||||||
|
|
||||||
while true; do
|
|
||||||
clear
|
|
||||||
read -p "This will create a New ${APP} LXC. Proceed(y/n)?" yn
|
|
||||||
case $yn in
|
|
||||||
[Yy]* ) break;;
|
|
||||||
[Nn]* ) exit;;
|
|
||||||
* ) echo "Please answer yes or no.";;
|
|
||||||
esac
|
|
||||||
done
|
|
||||||
clear
|
|
||||||
function header_info {
|
|
||||||
echo -e "${RD}
|
|
||||||
______ _____ _____ _ _ ____ __ __ ______
|
|
||||||
| ____|/ ____| __ \| | | |/ __ \| \/ | ____|
|
|
||||||
| |__ | (___ | |__) | |__| | | | | \ / | |__
|
|
||||||
| __| \___ \| ___/| __ | | | | |\/| | __|
|
|
||||||
| |____ ____) | | | | | | |__| | | | | |____
|
|
||||||
|______|_____/|_| v3 |_| |_|\____/|_| |_|______|
|
|
||||||
|
|
||||||
${CL}"
|
|
||||||
}
|
|
||||||
|
|
||||||
header_info
|
|
||||||
|
|
||||||
function msg_info() {
|
|
||||||
local msg="$1"
|
|
||||||
echo -ne " ${HOLD} ${YW}${msg}..."
|
|
||||||
}
|
|
||||||
|
|
||||||
function msg_ok() {
|
|
||||||
local msg="$1"
|
|
||||||
echo -e "${BFR} ${CM} ${GN}${msg}${CL}"
|
|
||||||
}
|
|
||||||
|
|
||||||
function PVE_CHECK() {
|
|
||||||
PVE=$(pveversion | grep "pve-manager/7" | wc -l)
|
|
||||||
|
|
||||||
if [[ $PVE != 1 ]]; then
|
|
||||||
echo -e "${RD}This script requires Proxmox Virtual Environment 7.0 or greater${CL}"
|
|
||||||
echo -e "Exiting..."
|
|
||||||
sleep 2
|
|
||||||
exit
|
|
||||||
fi
|
|
||||||
}
|
|
||||||
|
|
||||||
function default_settings() {
|
|
||||||
clear
|
|
||||||
header_info
|
|
||||||
echo -e "${BL}Using Default Settings${CL}"
|
|
||||||
echo -e "${DGN}Using CT Type ${BGN}Unprivileged${CL} ${RD}NO DEVICE PASSTHROUGH${CL}"
|
|
||||||
CT_TYPE="1"
|
|
||||||
echo -e "${DGN}Using CT Password ${BGN}Automatic Login${CL}"
|
|
||||||
PW=" "
|
|
||||||
echo -e "${DGN}Using CT ID ${BGN}$NEXTID${CL}"
|
|
||||||
CT_ID=$NEXTID
|
|
||||||
echo -e "${DGN}Using CT Name ${BGN}$NSAPP${CL}"
|
|
||||||
HN=$NSAPP
|
|
||||||
echo -e "${DGN}Using Disk Size ${BGN}4${CL}${DGN}GB${CL}"
|
|
||||||
DISK_SIZE="4"
|
|
||||||
echo -e "${DGN}Using ${BGN}2${CL}${DGN}vCPU${CL}"
|
|
||||||
CORE_COUNT="2"
|
|
||||||
echo -e "${DGN}Using ${BGN}1024${CL}${DGN}MiB RAM${CL}"
|
|
||||||
RAM_SIZE="1024"
|
|
||||||
echo -e "${DGN}Using Bridge ${BGN}vmbr0${CL}"
|
|
||||||
BRG="vmbr0"
|
|
||||||
echo -e "${DGN}Using Static IP Address ${BGN}DHCP${CL}"
|
|
||||||
NET=dhcp
|
|
||||||
echo -e "${DGN}Using Gateway Address ${BGN}NONE${CL}"
|
|
||||||
GATE=""
|
|
||||||
echo -e "${DGN}Using VLAN Tag ${BGN}NONE${CL}"
|
|
||||||
VLAN=""
|
|
||||||
}
|
|
||||||
|
|
||||||
function advanced_settings() {
|
|
||||||
clear
|
|
||||||
header_info
|
|
||||||
echo -e "${RD}Using Advanced Settings${CL}"
|
|
||||||
echo -e "${YW}Type Privileged, or Press [ENTER] for Default: Unprivileged (${RD}NO DEVICE PASSTHROUGH${CL}${YW})"
|
|
||||||
read CT_TYPE1
|
|
||||||
if [ -z $CT_TYPE1 ]; then CT_TYPE1="Unprivileged" CT_TYPE="1";
|
|
||||||
echo -en "${DGN}Set CT Type ${BL}$CT_TYPE1${CL}"
|
|
||||||
else
|
|
||||||
CT_TYPE1="Privileged"
|
|
||||||
CT_TYPE="0"
|
|
||||||
echo -en "${DGN}Set CT Type ${BL}Privileged${CL}"
|
|
||||||
fi;
|
|
||||||
echo -e " ${CM}${CL} \r"
|
|
||||||
sleep 1
|
|
||||||
clear
|
|
||||||
header_info
|
|
||||||
echo -e "${RD}Using Advanced Settings${CL}"
|
|
||||||
echo -e "${DGN}Using CT Type ${BGN}$CT_TYPE1${CL}"
|
|
||||||
echo -e "${YW}Set Password, or Press [ENTER] for Default: Automatic Login "
|
|
||||||
read PW1
|
|
||||||
if [ -z $PW1 ]; then PW1="Automatic Login" PW=" ";
|
|
||||||
echo -en "${DGN}Set CT ${BL}$PW1${CL}"
|
|
||||||
else
|
|
||||||
PW="-password $PW1"
|
|
||||||
echo -en "${DGN}Set CT Password ${BL}$PW1${CL}"
|
|
||||||
fi;
|
|
||||||
echo -e " ${CM}${CL} \r"
|
|
||||||
sleep 1
|
|
||||||
clear
|
|
||||||
header_info
|
|
||||||
echo -e "${RD}Using Advanced Settings${CL}"
|
|
||||||
echo -e "${DGN}Using CT Type ${BGN}$CT_TYPE1${CL}"
|
|
||||||
echo -e "${DGN}Using CT Password ${BGN}$PW1${CL}"
|
|
||||||
echo -e "${YW}Enter the CT ID, or Press [ENTER] to automatically generate (${NEXTID}) "
|
|
||||||
read CT_ID
|
|
||||||
if [ -z $CT_ID ]; then CT_ID=$NEXTID; fi;
|
|
||||||
echo -en "${DGN}Set CT ID To ${BL}$CT_ID${CL}"
|
|
||||||
echo -e " ${CM}${CL} \r"
|
|
||||||
sleep 1
|
|
||||||
clear
|
|
||||||
header_info
|
|
||||||
echo -e "${RD}Using Advanced Settings${CL}"
|
|
||||||
echo -e "${DGN}Using CT Type ${BGN}$CT_TYPE1${CL}"
|
|
||||||
echo -e "${DGN}Using CT Password ${BGN}$PW1${CL}"
|
|
||||||
echo -e "${DGN}Using CT ID ${BGN}$CT_ID${CL}"
|
|
||||||
echo -e "${YW}Enter CT Name (no-spaces), or Press [ENTER] for Default: $NSAPP "
|
|
||||||
read CT_NAME
|
|
||||||
if [ -z $CT_NAME ]; then
|
|
||||||
HN=$NSAPP
|
|
||||||
else
|
|
||||||
HN=$(echo ${CT_NAME,,} | tr -d ' ')
|
|
||||||
fi
|
|
||||||
echo -en "${DGN}Set CT Name To ${BL}$HN${CL}"
|
|
||||||
echo -e " ${CM}${CL} \r"
|
|
||||||
sleep 1
|
|
||||||
clear
|
|
||||||
header_info
|
|
||||||
echo -e "${RD}Using Advanced Settings${CL}"
|
|
||||||
echo -e "${DGN}Using CT Type ${BGN}$CT_TYPE1${CL}"
|
|
||||||
echo -e "${DGN}Using CT Password ${BGN}$PW1${CL}"
|
|
||||||
echo -e "${DGN}Using CT ID ${BGN}$CT_ID${CL}"
|
|
||||||
echo -e "${DGN}Using CT Name ${BGN}$HN${CL}"
|
|
||||||
echo -e "${YW}Enter a Disk Size, or Press [ENTER] for Default: 4 "
|
|
||||||
read DISK_SIZE
|
|
||||||
if [ -z $DISK_SIZE ]; then DISK_SIZE="4"; fi;
|
|
||||||
if ! [[ $DISK_SIZE =~ $INTEGER ]] ; then echo "ERROR! DISK SIZE MUST HAVE INTEGER NUMBER!"; exit; fi;
|
|
||||||
echo -en "${DGN}Set Disk Size To ${BL}$DISK_SIZE${CL}${DGN}GB${CL}"
|
|
||||||
echo -e " ${CM}${CL} \r"
|
|
||||||
sleep 1
|
|
||||||
clear
|
|
||||||
header_info
|
|
||||||
echo -e "${RD}Using Advanced Settings${CL}"
|
|
||||||
echo -e "${DGN}Using CT Type ${BGN}$CT_TYPE1${CL}"
|
|
||||||
echo -e "${DGN}Using CT Password ${BGN}$PW1${CL}"
|
|
||||||
echo -e "${DGN}Using CT ID ${BGN}$CT_ID${CL}"
|
|
||||||
echo -e "${DGN}Using CT Name ${BGN}$HN${CL}"
|
|
||||||
echo -e "${DGN}Using Disk Size ${BGN}$DISK_SIZE${CL}${DGN}GB${CL}"
|
|
||||||
echo -e "${YW}Allocate CPU cores, or Press [ENTER] for Default: 2 "
|
|
||||||
read CORE_COUNT
|
|
||||||
if [ -z $CORE_COUNT ]; then CORE_COUNT="2"; fi;
|
|
||||||
echo -en "${DGN}Set Cores To ${BL}$CORE_COUNT${CL}${DGN}vCPU${CL}"
|
|
||||||
echo -e " ${CM}${CL} \r"
|
|
||||||
sleep 1
|
|
||||||
clear
|
|
||||||
header_info
|
|
||||||
echo -e "${RD}Using Advanced Settings${CL}"
|
|
||||||
echo -e "${DGN}Using CT Type ${BGN}$CT_TYPE1${CL}"
|
|
||||||
echo -e "${DGN}Using CT Password ${BGN}$PW1${CL}"
|
|
||||||
echo -e "${DGN}Using CT ID ${BGN}$CT_ID${CL}"
|
|
||||||
echo -e "${DGN}Using CT Name ${BGN}$HN${CL}"
|
|
||||||
echo -e "${DGN}Using Disk Size ${BGN}$DISK_SIZE${CL}${DGN}GB${CL}"
|
|
||||||
echo -e "${DGN}Using ${BGN}${CORE_COUNT}${CL}${DGN}vCPU${CL}"
|
|
||||||
echo -e "${YW}Allocate RAM in MiB, or Press [ENTER] for Default: 1024 "
|
|
||||||
read RAM_SIZE
|
|
||||||
if [ -z $RAM_SIZE ]; then RAM_SIZE="1024"; fi;
|
|
||||||
echo -en "${DGN}Set RAM To ${BL}$RAM_SIZE${CL}${DGN}MiB RAM${CL}"
|
|
||||||
echo -e " ${CM}${CL} \n"
|
|
||||||
sleep 1
|
|
||||||
clear
|
|
||||||
header_info
|
|
||||||
echo -e "${RD}Using Advanced Settings${CL}"
|
|
||||||
echo -e "${DGN}Using CT Type ${BGN}$CT_TYPE1${CL}"
|
|
||||||
echo -e "${DGN}Using CT Password ${BGN}$PW1${CL}"
|
|
||||||
echo -e "${DGN}Using CT ID ${BGN}$CT_ID${CL}"
|
|
||||||
echo -e "${DGN}Using CT Name ${BGN}$HN${CL}"
|
|
||||||
echo -e "${DGN}Using Disk Size ${BGN}$DISK_SIZE${CL}${DGN}GB${CL}"
|
|
||||||
echo -e "${DGN}Using ${BGN}${CORE_COUNT}${CL}${DGN}vCPU${CL}"
|
|
||||||
echo -e "${DGN}Using ${BGN}${RAM_SIZE}${CL}${DGN}MiB RAM${CL}"
|
|
||||||
echo -e "${YW}Enter a Bridge, or Press [ENTER] for Default: vmbr0 "
|
|
||||||
read BRG
|
|
||||||
if [ -z $BRG ]; then BRG="vmbr0"; fi;
|
|
||||||
echo -en "${DGN}Set Bridge To ${BL}$BRG${CL}"
|
|
||||||
echo -e " ${CM}${CL} \n"
|
|
||||||
sleep 1
|
|
||||||
clear
|
|
||||||
header_info
|
|
||||||
echo -e "${RD}Using Advanced Settings${CL}"
|
|
||||||
echo -e "${DGN}Using CT Type ${BGN}$CT_TYPE1${CL}"
|
|
||||||
echo -e "${DGN}Using CT Password ${BGN}$PW1${CL}"
|
|
||||||
echo -e "${DGN}Using CT ID ${BGN}$CT_ID${CL}"
|
|
||||||
echo -e "${DGN}Using CT Name ${BGN}$HN${CL}"
|
|
||||||
echo -e "${DGN}Using Disk Size ${BGN}$DISK_SIZE${CL}${DGN}GB${CL}"
|
|
||||||
echo -e "${DGN}Using ${BGN}${CORE_COUNT}${CL}${DGN}vCPU${CL}"
|
|
||||||
echo -e "${DGN}Using ${BGN}${RAM_SIZE}${CL}${DGN}MiB RAM${CL}"
|
|
||||||
echo -e "${DGN}Using Bridge ${BGN}${BRG}${CL}"
|
|
||||||
echo -e "${YW}Enter a Static IPv4 CIDR Address, or Press [ENTER] for Default: DHCP "
|
|
||||||
read NET
|
|
||||||
if [ -z $NET ]; then NET="dhcp"; fi;
|
|
||||||
echo -en "${DGN}Set Static IP Address To ${BL}$NET${CL}"
|
|
||||||
echo -e " ${CM}${CL} \n"
|
|
||||||
sleep 1
|
|
||||||
clear
|
|
||||||
header_info
|
|
||||||
echo -e "${RD}Using Advanced Settings${CL}"
|
|
||||||
echo -e "${DGN}Using CT Type ${BGN}$CT_TYPE1${CL}"
|
|
||||||
echo -e "${DGN}Using CT Password ${BGN}$PW1${CL}"
|
|
||||||
echo -e "${DGN}Using CT ID ${BGN}$CT_ID${CL}"
|
|
||||||
echo -e "${DGN}Using CT Name ${BGN}$HN${CL}"
|
|
||||||
echo -e "${DGN}Using Disk Size ${BGN}$DISK_SIZE${CL}${DGN}GB${CL}"
|
|
||||||
echo -e "${DGN}Using ${BGN}${CORE_COUNT}${CL}${DGN}vCPU${CL}"
|
|
||||||
echo -e "${DGN}Using ${BGN}${RAM_SIZE}${CL}${DGN}MiB RAM${CL}"
|
|
||||||
echo -e "${DGN}Using Bridge ${BGN}${BRG}${CL}"
|
|
||||||
echo -e "${DGN}Using Static IP Address ${BGN}$NET${CL}"
|
|
||||||
echo -e "${YW}Enter a Gateway IP (mandatory if static IP is used), or Press [ENTER] for Default: NONE "
|
|
||||||
read GATE1
|
|
||||||
if [ -z $GATE1 ]; then GATE1="NONE" GATE="";
|
|
||||||
echo -en "${DGN}Set Gateway IP To ${BL}$GATE1${CL}"
|
|
||||||
else
|
|
||||||
GATE=",gw=$GATE1"
|
|
||||||
echo -en "${DGN}Set Gateway IP To ${BL}$GATE1${CL}"
|
|
||||||
fi;
|
|
||||||
echo -e " ${CM}${CL} \n"
|
|
||||||
sleep 1
|
|
||||||
clear
|
|
||||||
header_info
|
|
||||||
|
|
||||||
echo -e "${RD}Using Advanced Settings${CL}"
|
|
||||||
echo -e "${DGN}Using CT Type ${BGN}$CT_TYPE1${CL}"
|
|
||||||
echo -e "${DGN}Using CT Password ${BGN}$PW1${CL}"
|
|
||||||
echo -e "${DGN}Using CT ID ${BGN}$CT_ID${CL}"
|
|
||||||
echo -e "${DGN}Using CT Name ${BGN}$HN${CL}"
|
|
||||||
echo -e "${DGN}Using Disk Size ${BGN}$DISK_SIZE${CL}${DGN}GB${CL}"
|
|
||||||
echo -e "${DGN}Using ${BGN}${CORE_COUNT}${CL}${DGN}vCPU${CL}"
|
|
||||||
echo -e "${DGN}Using ${BGN}${RAM_SIZE}${CL}${DGN}MiB RAM${CL}"
|
|
||||||
echo -e "${DGN}Using Bridge ${BGN}${BRG}${CL}"
|
|
||||||
echo -e "${DGN}Using Static IP Address ${BGN}$NET${CL}"
|
|
||||||
echo -e "${DGN}Using Gateway IP Address ${BGN}$GATE1${CL}"
|
|
||||||
echo -e "${YW}Enter a VLAN Tag, or Press [ENTER] for Default: NONE "
|
|
||||||
read VLAN1
|
|
||||||
if [ -z $VLAN1 ]; then VLAN1="NONE" VLAN="";
|
|
||||||
echo -en "${DGN}Set VLAN Tag To ${BL}$VLAN1${CL}"
|
|
||||||
else
|
|
||||||
VLAN=",tag=$VLAN1"
|
|
||||||
echo -en "${DGN}Set VLAN Tag To ${BL}$VLAN1${CL}"
|
|
||||||
fi;
|
|
||||||
echo -e " ${CM}${CL} \n"
|
|
||||||
sleep 1
|
|
||||||
clear
|
|
||||||
header_info
|
|
||||||
echo -e "${RD}Using Advanced Settings${CL}"
|
|
||||||
echo -e "${DGN}Using CT Type ${BGN}$CT_TYPE1${CL}"
|
|
||||||
echo -e "${DGN}Using CT Password ${BGN}$PW1${CL}"
|
|
||||||
echo -e "${DGN}Using CT ID ${BGN}$CT_ID${CL}"
|
|
||||||
echo -e "${DGN}Using CT Name ${BGN}$HN${CL}"
|
|
||||||
echo -e "${DGN}Using Disk Size ${BGN}$DISK_SIZE${CL}${DGN}GB${CL}"
|
|
||||||
echo -e "${DGN}Using ${BGN}${CORE_COUNT}${CL}${DGN}vCPU${CL}"
|
|
||||||
echo -e "${DGN}Using ${BGN}${RAM_SIZE}${CL}${DGN}MiB RAM${CL}"
|
|
||||||
echo -e "${DGN}Using Bridge ${BGN}${BRG}${CL}"
|
|
||||||
echo -e "${DGN}Using Static IP Address ${BGN}$NET${CL}"
|
|
||||||
echo -e "${DGN}Using Gateway IP Address ${BGN}$GATE1${CL}"
|
|
||||||
echo -e "${DGN}Using VLAN Tag ${BGN}$VLAN1${CL}"
|
|
||||||
|
|
||||||
read -p "Are these settings correct(y/n)? " -n 1 -r
|
|
||||||
echo
|
|
||||||
if [[ ! $REPLY =~ ^[Yy]$ ]]
|
|
||||||
then
|
|
||||||
advanced_settings
|
|
||||||
fi
|
|
||||||
}
|
|
||||||
|
|
||||||
function start_script() {
|
|
||||||
echo -e "${YW}Type Advanced, or Press [ENTER] for Default Settings "
|
|
||||||
read SETTINGS
|
|
||||||
if [ -z $SETTINGS ]; then default_settings;
|
|
||||||
else
|
|
||||||
advanced_settings
|
|
||||||
fi;
|
|
||||||
}
|
|
||||||
|
|
||||||
start_script
|
|
||||||
|
|
||||||
if [ "$CT_TYPE" == "1" ]; then
|
|
||||||
FEATURES="nesting=1,keyctl=1"
|
|
||||||
else
|
|
||||||
FEATURES="nesting=1"
|
|
||||||
fi
|
|
||||||
|
|
||||||
TEMP_DIR=$(mktemp -d)
|
|
||||||
pushd $TEMP_DIR >/dev/null
|
|
||||||
|
|
||||||
export CTID=$CT_ID
|
|
||||||
export PCT_OSTYPE=debian
|
|
||||||
export PCT_OSVERSION=11
|
|
||||||
export PCT_DISK_SIZE=$DISK_SIZE
|
|
||||||
export PCT_OPTIONS="
|
|
||||||
-features $FEATURES
|
|
||||||
-hostname $HN
|
|
||||||
-net0 name=eth0,bridge=$BRG,ip=$NET$GATE$VLAN
|
|
||||||
-onboot 1
|
|
||||||
-cores $CORE_COUNT
|
|
||||||
-memory $RAM_SIZE
|
|
||||||
-unprivileged $CT_TYPE
|
|
||||||
$PW
|
|
||||||
"
|
|
||||||
bash -c "$(wget -qLO - https://raw.githubusercontent.com/tteck/Proxmox/main/ct/create_lxc.sh)" || exit
|
|
||||||
|
|
||||||
msg_info "Starting LXC Container"
|
|
||||||
pct start $CTID
|
|
||||||
msg_ok "Started LXC Container"
|
|
||||||
|
|
||||||
lxc-attach -n $CTID -- bash -c "$(wget -qLO - https://raw.githubusercontent.com/tteck/Proxmox/main/setup/esphome-install.sh)" || exit
|
|
||||||
|
|
||||||
IP=$(pct exec $CTID ip a s dev eth0 | sed -n '/inet / s/\// /p' | awk '{print $2}')
|
|
||||||
|
|
||||||
pct set $CTID -description "# ${APP} LXC
|
|
||||||
### https://github.com/tteck/Proxmox"
|
|
||||||
|
|
||||||
msg_ok "Completed Successfully!\n"
|
|
||||||
echo -e "${APP} should be reachable by going to the following URL.
|
|
||||||
${BL}http://${IP}:6052${CL} \n"
|
|
|
@ -309,7 +309,7 @@ bash -c "$(wget -qLO - https://raw.githubusercontent.com/tteck/Proxmox/main/ct/c
|
||||||
msg_info "Starting LXC Container"
|
msg_info "Starting LXC Container"
|
||||||
pct start $CTID
|
pct start $CTID
|
||||||
msg_ok "Started LXC Container"
|
msg_ok "Started LXC Container"
|
||||||
lxc-attach -n $CTID -- bash -c "$(wget -qLO - https://raw.githubusercontent.com/tteck/Proxmox/main/setup/$var_install.sh)" || exit
|
lxc-attach -n $CTID -- bash -c "$(wget -qLO - https://raw.githubusercontent.com/tteck/Proxmox/main/install/$var_install.sh)" || exit
|
||||||
IP=$(pct exec $CTID ip a s dev eth0 | sed -n '/inet / s/\// /p' | awk '{print $2}')
|
IP=$(pct exec $CTID ip a s dev eth0 | sed -n '/inet / s/\// /p' | awk '{print $2}')
|
||||||
pct set $CTID -description "# ${APP} LXC
|
pct set $CTID -description "# ${APP} LXC
|
||||||
### https://tteck.github.io/Proxmox/
|
### https://tteck.github.io/Proxmox/
|
||||||
|
|
252
ct/grafana-v2.sh
252
ct/grafana-v2.sh
|
@ -1,252 +0,0 @@
|
||||||
#!/usr/bin/env bash
|
|
||||||
YW=`echo "\033[33m"`
|
|
||||||
BL=`echo "\033[36m"`
|
|
||||||
RD=`echo "\033[01;31m"`
|
|
||||||
CM='\xE2\x9C\x94\033'
|
|
||||||
GN=`echo "\033[1;92m"`
|
|
||||||
CL=`echo "\033[m"`
|
|
||||||
while true; do
|
|
||||||
read -p "This will create a New Grafana LXC. Proceed(y/n)?" yn
|
|
||||||
case $yn in
|
|
||||||
[Yy]* ) break;;
|
|
||||||
[Nn]* ) exit;;
|
|
||||||
* ) echo "Please answer yes or no.";;
|
|
||||||
esac
|
|
||||||
done
|
|
||||||
clear
|
|
||||||
function header_info {
|
|
||||||
echo -e "${YW}
|
|
||||||
_____ __
|
|
||||||
/ ____| / _|
|
|
||||||
| | __ _ __ __ _| |_ __ _ _ __ __ _
|
|
||||||
| | |_ | __/ _ | _/ _ | _ \ / _ |
|
|
||||||
| |__| | | | (_| | || (_| | | | | (_| |
|
|
||||||
\_____|_| \__,_|_| \__,_|_| |_|\__,_|
|
|
||||||
|
|
||||||
${CL}"
|
|
||||||
}
|
|
||||||
|
|
||||||
header_info
|
|
||||||
show_menu(){
|
|
||||||
printf " ${YW} 1)${YW} Privileged ${CL}\n"
|
|
||||||
printf " ${YW} 2)${GN} Unprivileged ${CL}\n"
|
|
||||||
|
|
||||||
printf "Please choose a Install Method and hit enter or ${RD}x${CL} to exit."
|
|
||||||
read opt
|
|
||||||
}
|
|
||||||
|
|
||||||
option_picked(){
|
|
||||||
message1=${@:-"${CL}Error: No message passed"}
|
|
||||||
printf " ${YW}${message1}${CL}\n"
|
|
||||||
}
|
|
||||||
show_menu
|
|
||||||
while [ "$opt" != " " ]
|
|
||||||
do
|
|
||||||
case $opt in
|
|
||||||
1) clear;
|
|
||||||
header_info;
|
|
||||||
option_picked "Using Privileged Install";
|
|
||||||
IM=0
|
|
||||||
break;
|
|
||||||
;;
|
|
||||||
2) clear;
|
|
||||||
header_info;
|
|
||||||
option_picked "Using Unprivileged Install";
|
|
||||||
IM=1
|
|
||||||
break;
|
|
||||||
;;
|
|
||||||
|
|
||||||
x)exit;
|
|
||||||
;;
|
|
||||||
\n)exit;
|
|
||||||
;;
|
|
||||||
*)clear;
|
|
||||||
option_picked "Please choose a Install Method from the menu";
|
|
||||||
show_menu;
|
|
||||||
;;
|
|
||||||
esac
|
|
||||||
done
|
|
||||||
show_menu2(){
|
|
||||||
printf " ${YW} 1)${GN} Use Automatic Login ${CL}\n"
|
|
||||||
printf " ${YW} 2)${GN} Use Password (changeme) ${CL}\n"
|
|
||||||
|
|
||||||
printf "Please choose a Password Type and hit enter or ${RD}x${CL} to exit."
|
|
||||||
read opt
|
|
||||||
}
|
|
||||||
|
|
||||||
option_picked(){
|
|
||||||
message2=${@:-"${CL}Error: No message passed"}
|
|
||||||
printf " ${YW}${message1}${CL}\n"
|
|
||||||
printf " ${YW}${message2}${CL}\n"
|
|
||||||
}
|
|
||||||
show_menu2
|
|
||||||
while [ "$opt" != " " ]
|
|
||||||
do
|
|
||||||
case $opt in
|
|
||||||
1) clear;
|
|
||||||
header_info;
|
|
||||||
option_picked "Using Automatic Login";
|
|
||||||
PW=" "
|
|
||||||
break;
|
|
||||||
;;
|
|
||||||
2) clear;
|
|
||||||
header_info;
|
|
||||||
option_picked "Using Password (changeme)";
|
|
||||||
PW="-password changeme"
|
|
||||||
break;
|
|
||||||
;;
|
|
||||||
|
|
||||||
x)exit;
|
|
||||||
;;
|
|
||||||
\n)exit;
|
|
||||||
;;
|
|
||||||
*)clear;
|
|
||||||
option_picked "Please choose a Password Type from the menu";
|
|
||||||
show_menu2;
|
|
||||||
;;
|
|
||||||
esac
|
|
||||||
done
|
|
||||||
show_menu3(){
|
|
||||||
printf " ${YW} 1)${GN} Automatic DHCP ${CL}\n"
|
|
||||||
printf " ${YW} 2)${GN} Manual DHCP ${CL}\n"
|
|
||||||
|
|
||||||
printf "Please choose a DHCP Type and hit enter or ${RD}x${CL} to exit."
|
|
||||||
read opt
|
|
||||||
}
|
|
||||||
|
|
||||||
option_picked(){
|
|
||||||
message3=${@:-"${CL}Error: No message passed"}
|
|
||||||
printf " ${YW}${message1}${CL}\n"
|
|
||||||
printf " ${YW}${message2}${CL}\n"
|
|
||||||
printf " ${YW}${message3}${CL}\n"
|
|
||||||
}
|
|
||||||
show_menu3
|
|
||||||
while [ "$opt" != " " ]
|
|
||||||
do
|
|
||||||
case $opt in
|
|
||||||
1) clear;
|
|
||||||
header_info;
|
|
||||||
option_picked "Using Automatic DHCP";
|
|
||||||
DHCP=" "
|
|
||||||
break;
|
|
||||||
;;
|
|
||||||
2) clear;
|
|
||||||
header_info;
|
|
||||||
option_picked "Using Manual DHCP";
|
|
||||||
DHCP="1"
|
|
||||||
break;
|
|
||||||
;;
|
|
||||||
|
|
||||||
x)exit;
|
|
||||||
;;
|
|
||||||
\n)exit;
|
|
||||||
;;
|
|
||||||
*)clear;
|
|
||||||
option_picked "Please choose a DHCP Type from the menu";
|
|
||||||
show_menu3;
|
|
||||||
;;
|
|
||||||
esac
|
|
||||||
done
|
|
||||||
|
|
||||||
set -o errexit
|
|
||||||
set -o errtrace
|
|
||||||
set -o nounset
|
|
||||||
set -o pipefail
|
|
||||||
shopt -s expand_aliases
|
|
||||||
alias die='EXIT=$? LINE=$LINENO error_exit'
|
|
||||||
trap die ERR
|
|
||||||
trap cleanup EXIT
|
|
||||||
|
|
||||||
function error_exit() {
|
|
||||||
trap - ERR
|
|
||||||
local DEFAULT='Unknown failure occured.'
|
|
||||||
local REASON="\e[97m${1:-$DEFAULT}\e[39m"
|
|
||||||
local FLAG="\e[91m[ERROR] \e[93m$EXIT@$LINE"
|
|
||||||
msg "$FLAG $REASON"
|
|
||||||
[ ! -z ${CTID-} ] && cleanup_ctid
|
|
||||||
exit $EXIT
|
|
||||||
}
|
|
||||||
function warn() {
|
|
||||||
local REASON="\e[97m$1\e[39m"
|
|
||||||
local FLAG="\e[93m[WARNING]\e[39m"
|
|
||||||
msg "$FLAG $REASON"
|
|
||||||
}
|
|
||||||
function info() {
|
|
||||||
local REASON="$1"
|
|
||||||
local FLAG="\e[36m[INFO]\e[39m"
|
|
||||||
msg "$FLAG $REASON"
|
|
||||||
}
|
|
||||||
function msg() {
|
|
||||||
local TEXT="$1"
|
|
||||||
echo -e "$TEXT"
|
|
||||||
}
|
|
||||||
function cleanup_ctid() {
|
|
||||||
if $(pct status $CTID &>/dev/null); then
|
|
||||||
if [ "$(pct status $CTID | awk '{print $2}')" == "running" ]; then
|
|
||||||
pct stop $CTID
|
|
||||||
fi
|
|
||||||
pct destroy $CTID
|
|
||||||
elif [ "$(pvesm list $STORAGE --vmid $CTID)" != "" ]; then
|
|
||||||
pvesm free $ROOTFS
|
|
||||||
fi
|
|
||||||
}
|
|
||||||
function cleanup() {
|
|
||||||
popd >/dev/null
|
|
||||||
rm -rf $TEMP_DIR
|
|
||||||
}
|
|
||||||
if [ "$IM" == "1" ]; then
|
|
||||||
FEATURES="nesting=1,keyctl=1"
|
|
||||||
else
|
|
||||||
FEATURES="nesting=1"
|
|
||||||
fi
|
|
||||||
|
|
||||||
TEMP_DIR=$(mktemp -d)
|
|
||||||
pushd $TEMP_DIR >/dev/null
|
|
||||||
|
|
||||||
export CTID=$(pvesh get /cluster/nextid)
|
|
||||||
export PCT_OSTYPE=debian
|
|
||||||
export PCT_OSVERSION=11
|
|
||||||
export PCT_DISK_SIZE=2
|
|
||||||
export PCT_OPTIONS="
|
|
||||||
-features $FEATURES
|
|
||||||
-hostname grafana
|
|
||||||
-net0 name=eth0,bridge=vmbr0,ip=dhcp
|
|
||||||
-onboot 1
|
|
||||||
-cores 1
|
|
||||||
-memory 512
|
|
||||||
-unprivileged ${IM}
|
|
||||||
${PW}
|
|
||||||
"
|
|
||||||
bash -c "$(wget -qLO - https://raw.githubusercontent.com/tteck/Proxmox/main/ct/create_lxc.sh)" || exit
|
|
||||||
|
|
||||||
STORAGE_TYPE=$(pvesm status -storage $(pct config $CTID | grep rootfs | awk -F ":" '{print $2}') | awk 'NR>1 {print $2}')
|
|
||||||
if [ "$STORAGE_TYPE" == "zfspool" ]; then
|
|
||||||
warn "Some addons may not work due to ZFS not supporting 'fallocate'."
|
|
||||||
fi
|
|
||||||
if [ "$DHCP" == "1" ]; then
|
|
||||||
MAC=$(pct config $CTID \
|
|
||||||
| grep -i hwaddr \
|
|
||||||
| awk '{print substr($2, 31, length($3) 17 ) }') \
|
|
||||||
|
|
||||||
echo -e "MAC Address ${BL}$MAC${CL}"
|
|
||||||
|
|
||||||
dhcp_reservation(){
|
|
||||||
printf "Please set DHCP reservation and press Enter."
|
|
||||||
read
|
|
||||||
}
|
|
||||||
dhcp_reservation
|
|
||||||
fi
|
|
||||||
|
|
||||||
echo -en "${GN} Starting LXC Container... "
|
|
||||||
pct start $CTID
|
|
||||||
echo -e "${CM}${CL} \r"
|
|
||||||
|
|
||||||
alias lxc-cmd="lxc-attach -n $CTID --"
|
|
||||||
|
|
||||||
lxc-cmd bash -c "$(wget -qLO - https://raw.githubusercontent.com/tteck/Proxmox/main/setup/grafana-install.sh)" || exit
|
|
||||||
|
|
||||||
IP=$(pct exec $CTID ip a s dev eth0 | sed -n '/inet / s/\// /p' | awk '{print $2}')
|
|
||||||
|
|
||||||
echo -e "${GN}Successfully created Grafana LXC to${CL} ${BL}$CTID${CL}.
|
|
||||||
${BL}Grafana${CL} should be reachable by going to the following URL.
|
|
||||||
${BL}http://${IP}:3000${CL} \n"
|
|
356
ct/grafana-v3.sh
356
ct/grafana-v3.sh
|
@ -1,356 +0,0 @@
|
||||||
#!/usr/bin/env bash
|
|
||||||
echo -e "Loading..."
|
|
||||||
NEXTID=$(pvesh get /cluster/nextid)
|
|
||||||
INTEGER='^[0-9]+$'
|
|
||||||
YW=`echo "\033[33m"`
|
|
||||||
BL=`echo "\033[36m"`
|
|
||||||
RD=`echo "\033[01;31m"`
|
|
||||||
BGN=`echo "\033[4;92m"`
|
|
||||||
GN=`echo "\033[1;92m"`
|
|
||||||
DGN=`echo "\033[32m"`
|
|
||||||
CL=`echo "\033[m"`
|
|
||||||
BFR="\\r\\033[K"
|
|
||||||
HOLD="-"
|
|
||||||
CM="${GN}✓${CL}"
|
|
||||||
APP="Grafana"
|
|
||||||
NSAPP=$(echo ${APP,,} | tr -d ' ')
|
|
||||||
set -o errexit
|
|
||||||
set -o errtrace
|
|
||||||
set -o nounset
|
|
||||||
set -o pipefail
|
|
||||||
shopt -s expand_aliases
|
|
||||||
alias die='EXIT=$? LINE=$LINENO error_exit'
|
|
||||||
trap die ERR
|
|
||||||
|
|
||||||
function error_exit() {
|
|
||||||
trap - ERR
|
|
||||||
local reason="Unknown failure occurred."
|
|
||||||
local msg="${1:-$reason}"
|
|
||||||
local flag="${RD}‼ ERROR ${CL}$EXIT@$LINE"
|
|
||||||
echo -e "$flag $msg" 1>&2
|
|
||||||
exit $EXIT
|
|
||||||
}
|
|
||||||
|
|
||||||
while true; do
|
|
||||||
clear
|
|
||||||
read -p "This will create a New ${APP} LXC. Proceed(y/n)?" yn
|
|
||||||
case $yn in
|
|
||||||
[Yy]* ) break;;
|
|
||||||
[Nn]* ) exit;;
|
|
||||||
* ) echo "Please answer yes or no.";;
|
|
||||||
esac
|
|
||||||
done
|
|
||||||
clear
|
|
||||||
function header_info {
|
|
||||||
echo -e "${YW}
|
|
||||||
_____ __
|
|
||||||
/ ____| / _|
|
|
||||||
| | __ _ __ __ _| |_ __ _ _ __ __ _
|
|
||||||
| | |_ | __/ _ | _/ _ | _ \ / _ |
|
|
||||||
| |__| | | | (_| | || (_| | | | | (_| |
|
|
||||||
\_____|_|v3\__,_|_| \__,_|_| |_|\__,_|
|
|
||||||
${CL}"
|
|
||||||
}
|
|
||||||
|
|
||||||
header_info
|
|
||||||
|
|
||||||
function msg_info() {
|
|
||||||
local msg="$1"
|
|
||||||
echo -ne " ${HOLD} ${YW}${msg}..."
|
|
||||||
}
|
|
||||||
|
|
||||||
function msg_ok() {
|
|
||||||
local msg="$1"
|
|
||||||
echo -e "${BFR} ${CM} ${GN}${msg}${CL}"
|
|
||||||
}
|
|
||||||
|
|
||||||
function PVE_CHECK() {
|
|
||||||
PVE=$(pveversion | grep "pve-manager/7" | wc -l)
|
|
||||||
|
|
||||||
if [[ $PVE != 1 ]]; then
|
|
||||||
echo -e "${RD}This script requires Proxmox Virtual Environment 7.0 or greater${CL}"
|
|
||||||
echo -e "Exiting..."
|
|
||||||
sleep 2
|
|
||||||
exit
|
|
||||||
fi
|
|
||||||
}
|
|
||||||
|
|
||||||
function default_settings() {
|
|
||||||
clear
|
|
||||||
header_info
|
|
||||||
echo -e "${BL}Using Default Settings${CL}"
|
|
||||||
echo -e "${DGN}Using CT Type ${BGN}Unprivileged${CL} ${RD}NO DEVICE PASSTHROUGH${CL}"
|
|
||||||
CT_TYPE="1"
|
|
||||||
echo -e "${DGN}Using CT Password ${BGN}Automatic Login${CL}"
|
|
||||||
PW=" "
|
|
||||||
echo -e "${DGN}Using CT ID ${BGN}$NEXTID${CL}"
|
|
||||||
CT_ID=$NEXTID
|
|
||||||
echo -e "${DGN}Using CT Name ${BGN}$NSAPP${CL}"
|
|
||||||
HN=$NSAPP
|
|
||||||
echo -e "${DGN}Using Disk Size ${BGN}2${CL}${DGN}GB${CL}"
|
|
||||||
DISK_SIZE="2"
|
|
||||||
echo -e "${DGN}Using ${BGN}1${CL}${DGN}vCPU${CL}"
|
|
||||||
CORE_COUNT="1"
|
|
||||||
echo -e "${DGN}Using ${BGN}512${CL}${DGN}MiB RAM${CL}"
|
|
||||||
RAM_SIZE="512"
|
|
||||||
echo -e "${DGN}Using Bridge ${BGN}vmbr0${CL}"
|
|
||||||
BRG="vmbr0"
|
|
||||||
echo -e "${DGN}Using Static IP Address ${BGN}DHCP${CL}"
|
|
||||||
NET=dhcp
|
|
||||||
echo -e "${DGN}Using Gateway Address ${BGN}NONE${CL}"
|
|
||||||
GATE=""
|
|
||||||
echo -e "${DGN}Using VLAN Tag ${BGN}NONE${CL}"
|
|
||||||
VLAN=""
|
|
||||||
}
|
|
||||||
|
|
||||||
function advanced_settings() {
|
|
||||||
clear
|
|
||||||
header_info
|
|
||||||
echo -e "${RD}Using Advanced Settings${CL}"
|
|
||||||
echo -e "${YW}Type Privileged, or Press [ENTER] for Default: Unprivileged (${RD}NO DEVICE PASSTHROUGH${CL}${YW})"
|
|
||||||
read CT_TYPE1
|
|
||||||
if [ -z $CT_TYPE1 ]; then CT_TYPE1="Unprivileged" CT_TYPE="1";
|
|
||||||
echo -en "${DGN}Set CT Type ${BL}$CT_TYPE1${CL}"
|
|
||||||
else
|
|
||||||
CT_TYPE1="Privileged"
|
|
||||||
CT_TYPE="0"
|
|
||||||
echo -en "${DGN}Set CT Type ${BL}Privileged${CL}"
|
|
||||||
fi;
|
|
||||||
echo -e " ${CM}${CL} \r"
|
|
||||||
sleep 1
|
|
||||||
clear
|
|
||||||
header_info
|
|
||||||
echo -e "${RD}Using Advanced Settings${CL}"
|
|
||||||
echo -e "${DGN}Using CT Type ${BGN}$CT_TYPE1${CL}"
|
|
||||||
echo -e "${YW}Set Password, or Press [ENTER] for Default: Automatic Login "
|
|
||||||
read PW1
|
|
||||||
if [ -z $PW1 ]; then PW1="Automatic Login" PW=" ";
|
|
||||||
echo -en "${DGN}Set CT ${BL}$PW1${CL}"
|
|
||||||
else
|
|
||||||
PW="-password $PW1"
|
|
||||||
echo -en "${DGN}Set CT Password ${BL}$PW1${CL}"
|
|
||||||
fi;
|
|
||||||
echo -e " ${CM}${CL} \r"
|
|
||||||
sleep 1
|
|
||||||
clear
|
|
||||||
header_info
|
|
||||||
echo -e "${RD}Using Advanced Settings${CL}"
|
|
||||||
echo -e "${DGN}Using CT Type ${BGN}$CT_TYPE1${CL}"
|
|
||||||
echo -e "${DGN}Using CT Password ${BGN}$PW1${CL}"
|
|
||||||
echo -e "${YW}Enter the CT ID, or Press [ENTER] to automatically generate (${NEXTID}) "
|
|
||||||
read CT_ID
|
|
||||||
if [ -z $CT_ID ]; then CT_ID=$NEXTID; fi;
|
|
||||||
echo -en "${DGN}Set CT ID To ${BL}$CT_ID${CL}"
|
|
||||||
echo -e " ${CM}${CL} \r"
|
|
||||||
sleep 1
|
|
||||||
clear
|
|
||||||
header_info
|
|
||||||
echo -e "${RD}Using Advanced Settings${CL}"
|
|
||||||
echo -e "${DGN}Using CT Type ${BGN}$CT_TYPE1${CL}"
|
|
||||||
echo -e "${DGN}Using CT Password ${BGN}$PW1${CL}"
|
|
||||||
echo -e "${DGN}Using CT ID ${BGN}$CT_ID${CL}"
|
|
||||||
echo -e "${YW}Enter CT Name (no-spaces), or Press [ENTER] for Default: $NSAPP "
|
|
||||||
read CT_NAME
|
|
||||||
if [ -z $CT_NAME ]; then
|
|
||||||
HN=$NSAPP
|
|
||||||
else
|
|
||||||
HN=$(echo ${CT_NAME,,} | tr -d ' ')
|
|
||||||
fi
|
|
||||||
echo -en "${DGN}Set CT Name To ${BL}$HN${CL}"
|
|
||||||
echo -e " ${CM}${CL} \r"
|
|
||||||
sleep 1
|
|
||||||
clear
|
|
||||||
header_info
|
|
||||||
echo -e "${RD}Using Advanced Settings${CL}"
|
|
||||||
echo -e "${DGN}Using CT Type ${BGN}$CT_TYPE1${CL}"
|
|
||||||
echo -e "${DGN}Using CT Password ${BGN}$PW1${CL}"
|
|
||||||
echo -e "${DGN}Using CT ID ${BGN}$CT_ID${CL}"
|
|
||||||
echo -e "${DGN}Using CT Name ${BGN}$HN${CL}"
|
|
||||||
echo -e "${YW}Enter a Disk Size, or Press [ENTER] for Default: 2 "
|
|
||||||
read DISK_SIZE
|
|
||||||
if [ -z $DISK_SIZE ]; then DISK_SIZE="2"; fi;
|
|
||||||
if ! [[ $DISK_SIZE =~ $INTEGER ]] ; then echo "ERROR! DISK SIZE MUST HAVE INTEGER NUMBER!"; exit; fi;
|
|
||||||
echo -en "${DGN}Set Disk Size To ${BL}$DISK_SIZE${CL}${DGN}GB${CL}"
|
|
||||||
echo -e " ${CM}${CL} \r"
|
|
||||||
sleep 1
|
|
||||||
clear
|
|
||||||
header_info
|
|
||||||
echo -e "${RD}Using Advanced Settings${CL}"
|
|
||||||
echo -e "${DGN}Using CT Type ${BGN}$CT_TYPE1${CL}"
|
|
||||||
echo -e "${DGN}Using CT Password ${BGN}$PW1${CL}"
|
|
||||||
echo -e "${DGN}Using CT ID ${BGN}$CT_ID${CL}"
|
|
||||||
echo -e "${DGN}Using CT Name ${BGN}$HN${CL}"
|
|
||||||
echo -e "${DGN}Using Disk Size ${BGN}$DISK_SIZE${CL}${DGN}GB${CL}"
|
|
||||||
echo -e "${YW}Allocate CPU cores, or Press [ENTER] for Default: 1 "
|
|
||||||
read CORE_COUNT
|
|
||||||
if [ -z $CORE_COUNT ]; then CORE_COUNT="1"; fi;
|
|
||||||
echo -en "${DGN}Set Cores To ${BL}$CORE_COUNT${CL}${DGN}vCPU${CL}"
|
|
||||||
echo -e " ${CM}${CL} \r"
|
|
||||||
sleep 1
|
|
||||||
clear
|
|
||||||
header_info
|
|
||||||
echo -e "${RD}Using Advanced Settings${CL}"
|
|
||||||
echo -e "${DGN}Using CT Type ${BGN}$CT_TYPE1${CL}"
|
|
||||||
echo -e "${DGN}Using CT Password ${BGN}$PW1${CL}"
|
|
||||||
echo -e "${DGN}Using CT ID ${BGN}$CT_ID${CL}"
|
|
||||||
echo -e "${DGN}Using CT Name ${BGN}$HN${CL}"
|
|
||||||
echo -e "${DGN}Using Disk Size ${BGN}$DISK_SIZE${CL}${DGN}GB${CL}"
|
|
||||||
echo -e "${DGN}Using ${BGN}${CORE_COUNT}${CL}${DGN}vCPU${CL}"
|
|
||||||
echo -e "${YW}Allocate RAM in MiB, or Press [ENTER] for Default: 512 "
|
|
||||||
read RAM_SIZE
|
|
||||||
if [ -z $RAM_SIZE ]; then RAM_SIZE="512"; fi;
|
|
||||||
echo -en "${DGN}Set RAM To ${BL}$RAM_SIZE${CL}${DGN}MiB RAM${CL}"
|
|
||||||
echo -e " ${CM}${CL} \n"
|
|
||||||
sleep 1
|
|
||||||
clear
|
|
||||||
header_info
|
|
||||||
echo -e "${RD}Using Advanced Settings${CL}"
|
|
||||||
echo -e "${DGN}Using CT Type ${BGN}$CT_TYPE1${CL}"
|
|
||||||
echo -e "${DGN}Using CT Password ${BGN}$PW1${CL}"
|
|
||||||
echo -e "${DGN}Using CT ID ${BGN}$CT_ID${CL}"
|
|
||||||
echo -e "${DGN}Using CT Name ${BGN}$HN${CL}"
|
|
||||||
echo -e "${DGN}Using Disk Size ${BGN}$DISK_SIZE${CL}${DGN}GB${CL}"
|
|
||||||
echo -e "${DGN}Using ${BGN}${CORE_COUNT}${CL}${DGN}vCPU${CL}"
|
|
||||||
echo -e "${DGN}Using ${BGN}${RAM_SIZE}${CL}${DGN}MiB RAM${CL}"
|
|
||||||
echo -e "${YW}Enter a Bridge, or Press [ENTER] for Default: vmbr0 "
|
|
||||||
read BRG
|
|
||||||
if [ -z $BRG ]; then BRG="vmbr0"; fi;
|
|
||||||
echo -en "${DGN}Set Bridge To ${BL}$BRG${CL}"
|
|
||||||
echo -e " ${CM}${CL} \n"
|
|
||||||
sleep 1
|
|
||||||
clear
|
|
||||||
header_info
|
|
||||||
echo -e "${RD}Using Advanced Settings${CL}"
|
|
||||||
echo -e "${DGN}Using CT Type ${BGN}$CT_TYPE1${CL}"
|
|
||||||
echo -e "${DGN}Using CT Password ${BGN}$PW1${CL}"
|
|
||||||
echo -e "${DGN}Using CT ID ${BGN}$CT_ID${CL}"
|
|
||||||
echo -e "${DGN}Using CT Name ${BGN}$HN${CL}"
|
|
||||||
echo -e "${DGN}Using Disk Size ${BGN}$DISK_SIZE${CL}${DGN}GB${CL}"
|
|
||||||
echo -e "${DGN}Using ${BGN}${CORE_COUNT}${CL}${DGN}vCPU${CL}"
|
|
||||||
echo -e "${DGN}Using ${BGN}${RAM_SIZE}${CL}${DGN}MiB RAM${CL}"
|
|
||||||
echo -e "${DGN}Using Bridge ${BGN}${BRG}${CL}"
|
|
||||||
echo -e "${YW}Enter a Static IPv4 CIDR Address, or Press [ENTER] for Default: DHCP "
|
|
||||||
read NET
|
|
||||||
if [ -z $NET ]; then NET="dhcp"; fi;
|
|
||||||
echo -en "${DGN}Set Static IP Address To ${BL}$NET${CL}"
|
|
||||||
echo -e " ${CM}${CL} \n"
|
|
||||||
sleep 1
|
|
||||||
clear
|
|
||||||
header_info
|
|
||||||
echo -e "${RD}Using Advanced Settings${CL}"
|
|
||||||
echo -e "${DGN}Using CT Type ${BGN}$CT_TYPE1${CL}"
|
|
||||||
echo -e "${DGN}Using CT Password ${BGN}$PW1${CL}"
|
|
||||||
echo -e "${DGN}Using CT ID ${BGN}$CT_ID${CL}"
|
|
||||||
echo -e "${DGN}Using CT Name ${BGN}$HN${CL}"
|
|
||||||
echo -e "${DGN}Using Disk Size ${BGN}$DISK_SIZE${CL}${DGN}GB${CL}"
|
|
||||||
echo -e "${DGN}Using ${BGN}${CORE_COUNT}${CL}${DGN}vCPU${CL}"
|
|
||||||
echo -e "${DGN}Using ${BGN}${RAM_SIZE}${CL}${DGN}MiB RAM${CL}"
|
|
||||||
echo -e "${DGN}Using Bridge ${BGN}${BRG}${CL}"
|
|
||||||
echo -e "${DGN}Using Static IP Address ${BGN}$NET${CL}"
|
|
||||||
echo -e "${YW}Enter a Gateway IP (mandatory if static IP is used), or Press [ENTER] for Default: NONE "
|
|
||||||
read GATE1
|
|
||||||
if [ -z $GATE1 ]; then GATE1="NONE" GATE="";
|
|
||||||
echo -en "${DGN}Set Gateway IP To ${BL}$GATE1${CL}"
|
|
||||||
else
|
|
||||||
GATE=",gw=$GATE1"
|
|
||||||
echo -en "${DGN}Set Gateway IP To ${BL}$GATE1${CL}"
|
|
||||||
fi;
|
|
||||||
echo -e " ${CM}${CL} \n"
|
|
||||||
sleep 1
|
|
||||||
clear
|
|
||||||
header_info
|
|
||||||
|
|
||||||
echo -e "${RD}Using Advanced Settings${CL}"
|
|
||||||
echo -e "${DGN}Using CT Type ${BGN}$CT_TYPE1${CL}"
|
|
||||||
echo -e "${DGN}Using CT Password ${BGN}$PW1${CL}"
|
|
||||||
echo -e "${DGN}Using CT ID ${BGN}$CT_ID${CL}"
|
|
||||||
echo -e "${DGN}Using CT Name ${BGN}$HN${CL}"
|
|
||||||
echo -e "${DGN}Using Disk Size ${BGN}$DISK_SIZE${CL}${DGN}GB${CL}"
|
|
||||||
echo -e "${DGN}Using ${BGN}${CORE_COUNT}${CL}${DGN}vCPU${CL}"
|
|
||||||
echo -e "${DGN}Using ${BGN}${RAM_SIZE}${CL}${DGN}MiB RAM${CL}"
|
|
||||||
echo -e "${DGN}Using Bridge ${BGN}${BRG}${CL}"
|
|
||||||
echo -e "${DGN}Using Static IP Address ${BGN}$NET${CL}"
|
|
||||||
echo -e "${DGN}Using Gateway IP Address ${BGN}$GATE1${CL}"
|
|
||||||
echo -e "${YW}Enter a VLAN Tag, or Press [ENTER] for Default: NONE "
|
|
||||||
read VLAN1
|
|
||||||
if [ -z $VLAN1 ]; then VLAN1="NONE" VLAN="";
|
|
||||||
echo -en "${DGN}Set VLAN Tag To ${BL}$VLAN1${CL}"
|
|
||||||
else
|
|
||||||
VLAN=",tag=$VLAN1"
|
|
||||||
echo -en "${DGN}Set VLAN Tag To ${BL}$VLAN1${CL}"
|
|
||||||
fi;
|
|
||||||
echo -e " ${CM}${CL} \n"
|
|
||||||
sleep 1
|
|
||||||
clear
|
|
||||||
header_info
|
|
||||||
echo -e "${RD}Using Advanced Settings${CL}"
|
|
||||||
echo -e "${DGN}Using CT Type ${BGN}$CT_TYPE1${CL}"
|
|
||||||
echo -e "${DGN}Using CT Password ${BGN}$PW1${CL}"
|
|
||||||
echo -e "${DGN}Using CT ID ${BGN}$CT_ID${CL}"
|
|
||||||
echo -e "${DGN}Using CT Name ${BGN}$HN${CL}"
|
|
||||||
echo -e "${DGN}Using Disk Size ${BGN}$DISK_SIZE${CL}${DGN}GB${CL}"
|
|
||||||
echo -e "${DGN}Using ${BGN}${CORE_COUNT}${CL}${DGN}vCPU${CL}"
|
|
||||||
echo -e "${DGN}Using ${BGN}${RAM_SIZE}${CL}${DGN}MiB RAM${CL}"
|
|
||||||
echo -e "${DGN}Using Bridge ${BGN}${BRG}${CL}"
|
|
||||||
echo -e "${DGN}Using Static IP Address ${BGN}$NET${CL}"
|
|
||||||
echo -e "${DGN}Using Gateway IP Address ${BGN}$GATE1${CL}"
|
|
||||||
echo -e "${DGN}Using VLAN Tag ${BGN}$VLAN1${CL}"
|
|
||||||
|
|
||||||
read -p "Are these settings correct(y/n)? " -n 1 -r
|
|
||||||
echo
|
|
||||||
if [[ ! $REPLY =~ ^[Yy]$ ]]
|
|
||||||
then
|
|
||||||
advanced_settings
|
|
||||||
fi
|
|
||||||
}
|
|
||||||
|
|
||||||
function start_script() {
|
|
||||||
echo -e "${YW}Type Advanced, or Press [ENTER] for Default Settings "
|
|
||||||
read SETTINGS
|
|
||||||
if [ -z $SETTINGS ]; then default_settings;
|
|
||||||
else
|
|
||||||
advanced_settings
|
|
||||||
fi;
|
|
||||||
}
|
|
||||||
|
|
||||||
start_script
|
|
||||||
|
|
||||||
if [ "$CT_TYPE" == "1" ]; then
|
|
||||||
FEATURES="nesting=1,keyctl=1"
|
|
||||||
else
|
|
||||||
FEATURES="nesting=1"
|
|
||||||
fi
|
|
||||||
|
|
||||||
TEMP_DIR=$(mktemp -d)
|
|
||||||
pushd $TEMP_DIR >/dev/null
|
|
||||||
|
|
||||||
export CTID=$CT_ID
|
|
||||||
export PCT_OSTYPE=debian
|
|
||||||
export PCT_OSVERSION=11
|
|
||||||
export PCT_DISK_SIZE=$DISK_SIZE
|
|
||||||
export PCT_OPTIONS="
|
|
||||||
-features $FEATURES
|
|
||||||
-hostname $HN
|
|
||||||
-net0 name=eth0,bridge=$BRG,ip=$NET$GATE$VLAN
|
|
||||||
-onboot 1
|
|
||||||
-cores $CORE_COUNT
|
|
||||||
-memory $RAM_SIZE
|
|
||||||
-unprivileged $CT_TYPE
|
|
||||||
$PW
|
|
||||||
"
|
|
||||||
bash -c "$(wget -qLO - https://raw.githubusercontent.com/tteck/Proxmox/main/ct/create_lxc.sh)" || exit
|
|
||||||
|
|
||||||
msg_info "Starting LXC Container"
|
|
||||||
pct start $CTID
|
|
||||||
msg_ok "Started LXC Container"
|
|
||||||
|
|
||||||
lxc-attach -n $CTID -- bash -c "$(wget -qLO - https://raw.githubusercontent.com/tteck/Proxmox/main/setup/grafana-install.sh)" || exit
|
|
||||||
|
|
||||||
IP=$(pct exec $CTID ip a s dev eth0 | sed -n '/inet / s/\// /p' | awk '{print $2}')
|
|
||||||
|
|
||||||
pct set $CTID -description "# ${APP} LXC
|
|
||||||
### https://github.com/tteck/Proxmox"
|
|
||||||
|
|
||||||
msg_ok "Completed Successfully!\n"
|
|
||||||
echo -e "${APP} should be reachable by going to the following URL.
|
|
||||||
${BL}http://${IP}:3000${CL} \n"
|
|
|
@ -309,7 +309,7 @@ bash -c "$(wget -qLO - https://raw.githubusercontent.com/tteck/Proxmox/main/ct/c
|
||||||
msg_info "Starting LXC Container"
|
msg_info "Starting LXC Container"
|
||||||
pct start $CTID
|
pct start $CTID
|
||||||
msg_ok "Started LXC Container"
|
msg_ok "Started LXC Container"
|
||||||
lxc-attach -n $CTID -- bash -c "$(wget -qLO - https://raw.githubusercontent.com/tteck/Proxmox/main/setup/$var_install.sh)" || exit
|
lxc-attach -n $CTID -- bash -c "$(wget -qLO - https://raw.githubusercontent.com/tteck/Proxmox/main/install/$var_install.sh)" || exit
|
||||||
IP=$(pct exec $CTID ip a s dev eth0 | sed -n '/inet / s/\// /p' | awk '{print $2}')
|
IP=$(pct exec $CTID ip a s dev eth0 | sed -n '/inet / s/\// /p' | awk '{print $2}')
|
||||||
pct set $CTID -description "# ${APP} LXC
|
pct set $CTID -description "# ${APP} LXC
|
||||||
### https://tteck.github.io/Proxmox/
|
### https://tteck.github.io/Proxmox/
|
||||||
|
|
359
ct/grocy-v3.sh
359
ct/grocy-v3.sh
|
@ -1,359 +0,0 @@
|
||||||
#!/usr/bin/env bash
|
|
||||||
echo -e "Loading..."
|
|
||||||
APP="grocy"
|
|
||||||
var_disk="2"
|
|
||||||
var_cpu="1"
|
|
||||||
var_ram="512"
|
|
||||||
var_os="debian"
|
|
||||||
var_version="11"
|
|
||||||
NEXTID=$(pvesh get /cluster/nextid)
|
|
||||||
INTEGER='^[0-9]+$'
|
|
||||||
NSAPP=$(echo ${APP,,} | tr -d ' ')
|
|
||||||
var_install="${NSAPP}-install"
|
|
||||||
YW=`echo "\033[33m"`
|
|
||||||
BL=`echo "\033[36m"`
|
|
||||||
RD=`echo "\033[01;31m"`
|
|
||||||
BGN=`echo "\033[4;92m"`
|
|
||||||
GN=`echo "\033[1;92m"`
|
|
||||||
DGN=`echo "\033[32m"`
|
|
||||||
CL=`echo "\033[m"`
|
|
||||||
BFR="\\r\\033[K"
|
|
||||||
HOLD="-"
|
|
||||||
CM="${GN}✓${CL}"
|
|
||||||
set -o errexit
|
|
||||||
set -o errtrace
|
|
||||||
set -o nounset
|
|
||||||
set -o pipefail
|
|
||||||
shopt -s expand_aliases
|
|
||||||
alias die='EXIT=$? LINE=$LINENO error_exit'
|
|
||||||
trap die ERR
|
|
||||||
|
|
||||||
function error_exit() {
|
|
||||||
trap - ERR
|
|
||||||
local reason="Unknown failure occurred."
|
|
||||||
local msg="${1:-$reason}"
|
|
||||||
local flag="${RD}‼ ERROR ${CL}$EXIT@$LINE"
|
|
||||||
echo -e "$flag $msg" 1>&2
|
|
||||||
exit $EXIT
|
|
||||||
}
|
|
||||||
|
|
||||||
function msg_info() {
|
|
||||||
local msg="$1"
|
|
||||||
echo -ne " ${HOLD} ${YW}${msg}..."
|
|
||||||
}
|
|
||||||
|
|
||||||
function msg_ok() {
|
|
||||||
local msg="$1"
|
|
||||||
echo -e "${BFR} ${CM} ${GN}${msg}${CL}"
|
|
||||||
}
|
|
||||||
|
|
||||||
while true; do
|
|
||||||
clear
|
|
||||||
read -p "This will create a New ${APP} LXC. Proceed(y/n)?" yn
|
|
||||||
case $yn in
|
|
||||||
[Yy]* ) break;;
|
|
||||||
[Nn]* ) exit;;
|
|
||||||
* ) echo "Please answer yes or no.";;
|
|
||||||
esac
|
|
||||||
done
|
|
||||||
clear
|
|
||||||
function header_info {
|
|
||||||
echo -e "${YW}
|
|
||||||
__ _ _ __ ___ ___ _ _
|
|
||||||
/ _ | __/ _ \ / __| | | |
|
|
||||||
| (_| | | | (_) | (__| |_| |
|
|
||||||
\__, |_| \___/ \___|\__, |
|
|
||||||
__/ | v3 __/ |
|
|
||||||
|___/ |___/
|
|
||||||
${CL}"
|
|
||||||
}
|
|
||||||
|
|
||||||
header_info
|
|
||||||
|
|
||||||
function PVE_CHECK() {
|
|
||||||
PVE=$(pveversion | grep "pve-manager/7" | wc -l)
|
|
||||||
|
|
||||||
if [[ $PVE != 1 ]]; then
|
|
||||||
echo -e "${RD}This script requires Proxmox Virtual Environment 7.0 or greater${CL}"
|
|
||||||
echo -e "Exiting..."
|
|
||||||
sleep 2
|
|
||||||
exit
|
|
||||||
fi
|
|
||||||
}
|
|
||||||
|
|
||||||
function default_settings() {
|
|
||||||
clear
|
|
||||||
header_info
|
|
||||||
echo -e "${BL}Using Default Settings${CL}"
|
|
||||||
echo -e "${DGN}Using CT Type ${BGN}Unprivileged${CL} ${RD}NO DEVICE PASSTHROUGH${CL}"
|
|
||||||
CT_TYPE="1"
|
|
||||||
echo -e "${DGN}Using CT Password ${BGN}Automatic Login${CL}"
|
|
||||||
PW=" "
|
|
||||||
echo -e "${DGN}Using CT ID ${BGN}$NEXTID${CL}"
|
|
||||||
CT_ID=$NEXTID
|
|
||||||
echo -e "${DGN}Using CT Name ${BGN}$NSAPP${CL}"
|
|
||||||
HN=$NSAPP
|
|
||||||
echo -e "${DGN}Using Disk Size ${BGN}$var_disk${CL}${DGN}GB${CL}"
|
|
||||||
DISK_SIZE="$var_disk"
|
|
||||||
echo -e "${DGN}Using ${BGN}$var_cpu${CL}${DGN}vCPU${CL}"
|
|
||||||
CORE_COUNT="$var_cpu"
|
|
||||||
echo -e "${DGN}Using ${BGN}$var_ram${CL}${DGN}MiB RAM${CL}"
|
|
||||||
RAM_SIZE="$var_ram"
|
|
||||||
echo -e "${DGN}Using Bridge ${BGN}vmbr0${CL}"
|
|
||||||
BRG="vmbr0"
|
|
||||||
echo -e "${DGN}Using Static IP Address ${BGN}DHCP${CL}"
|
|
||||||
NET=dhcp
|
|
||||||
echo -e "${DGN}Using Gateway Address ${BGN}NONE${CL}"
|
|
||||||
GATE=""
|
|
||||||
echo -e "${DGN}Using VLAN Tag ${BGN}NONE${CL}"
|
|
||||||
VLAN=""
|
|
||||||
}
|
|
||||||
|
|
||||||
function advanced_settings() {
|
|
||||||
clear
|
|
||||||
header_info
|
|
||||||
echo -e "${RD}Using Advanced Settings${CL}"
|
|
||||||
echo -e "${YW}Type Privileged, or Press [ENTER] for Default: Unprivileged (${RD}NO DEVICE PASSTHROUGH${CL}${YW})"
|
|
||||||
read CT_TYPE1
|
|
||||||
if [ -z $CT_TYPE1 ]; then CT_TYPE1="Unprivileged" CT_TYPE="1";
|
|
||||||
echo -en "${DGN}Set CT Type ${BL}$CT_TYPE1${CL}"
|
|
||||||
else
|
|
||||||
CT_TYPE1="Privileged"
|
|
||||||
CT_TYPE="0"
|
|
||||||
echo -en "${DGN}Set CT Type ${BL}Privileged${CL}"
|
|
||||||
fi;
|
|
||||||
echo -e " ${CM}${CL} \r"
|
|
||||||
sleep 1
|
|
||||||
clear
|
|
||||||
header_info
|
|
||||||
echo -e "${RD}Using Advanced Settings${CL}"
|
|
||||||
echo -e "${DGN}Using CT Type ${BGN}$CT_TYPE1${CL}"
|
|
||||||
echo -e "${YW}Set Password, or Press [ENTER] for Default: Automatic Login "
|
|
||||||
read PW1
|
|
||||||
if [ -z $PW1 ]; then PW1="Automatic Login" PW=" ";
|
|
||||||
echo -en "${DGN}Set CT ${BL}$PW1${CL}"
|
|
||||||
else
|
|
||||||
PW="-password $PW1"
|
|
||||||
echo -en "${DGN}Set CT Password ${BL}$PW1${CL}"
|
|
||||||
fi;
|
|
||||||
echo -e " ${CM}${CL} \r"
|
|
||||||
sleep 1
|
|
||||||
clear
|
|
||||||
header_info
|
|
||||||
echo -e "${RD}Using Advanced Settings${CL}"
|
|
||||||
echo -e "${DGN}Using CT Type ${BGN}$CT_TYPE1${CL}"
|
|
||||||
echo -e "${DGN}Using CT Password ${BGN}$PW1${CL}"
|
|
||||||
echo -e "${YW}Enter the CT ID, or Press [ENTER] to automatically generate (${NEXTID}) "
|
|
||||||
read CT_ID
|
|
||||||
if [ -z $CT_ID ]; then CT_ID=$NEXTID; fi;
|
|
||||||
echo -en "${DGN}Set CT ID To ${BL}$CT_ID${CL}"
|
|
||||||
echo -e " ${CM}${CL} \r"
|
|
||||||
sleep 1
|
|
||||||
clear
|
|
||||||
header_info
|
|
||||||
echo -e "${RD}Using Advanced Settings${CL}"
|
|
||||||
echo -e "${DGN}Using CT Type ${BGN}$CT_TYPE1${CL}"
|
|
||||||
echo -e "${DGN}Using CT Password ${BGN}$PW1${CL}"
|
|
||||||
echo -e "${DGN}Using CT ID ${BGN}$CT_ID${CL}"
|
|
||||||
echo -e "${YW}Enter CT Name (no-spaces), or Press [ENTER] for Default: $NSAPP "
|
|
||||||
read CT_NAME
|
|
||||||
if [ -z $CT_NAME ]; then
|
|
||||||
HN=$NSAPP
|
|
||||||
else
|
|
||||||
HN=$(echo ${CT_NAME,,} | tr -d ' ')
|
|
||||||
fi
|
|
||||||
echo -en "${DGN}Set CT Name To ${BL}$HN${CL}"
|
|
||||||
echo -e " ${CM}${CL} \r"
|
|
||||||
sleep 1
|
|
||||||
clear
|
|
||||||
header_info
|
|
||||||
echo -e "${RD}Using Advanced Settings${CL}"
|
|
||||||
echo -e "${DGN}Using CT Type ${BGN}$CT_TYPE1${CL}"
|
|
||||||
echo -e "${DGN}Using CT Password ${BGN}$PW1${CL}"
|
|
||||||
echo -e "${DGN}Using CT ID ${BGN}$CT_ID${CL}"
|
|
||||||
echo -e "${DGN}Using CT Name ${BGN}$HN${CL}"
|
|
||||||
echo -e "${YW}Enter a Disk Size, or Press [ENTER] for Default: $var_disk "
|
|
||||||
read DISK_SIZE
|
|
||||||
if [ -z $DISK_SIZE ]; then DISK_SIZE="$var_disk"; fi;
|
|
||||||
if ! [[ $DISK_SIZE =~ $INTEGER ]] ; then echo "ERROR! DISK SIZE MUST HAVE INTEGER NUMBER!"; exit; fi;
|
|
||||||
echo -en "${DGN}Set Disk Size To ${BL}$DISK_SIZE${CL}${DGN}GB${CL}"
|
|
||||||
echo -e " ${CM}${CL} \r"
|
|
||||||
sleep 1
|
|
||||||
clear
|
|
||||||
header_info
|
|
||||||
echo -e "${RD}Using Advanced Settings${CL}"
|
|
||||||
echo -e "${DGN}Using CT Type ${BGN}$CT_TYPE1${CL}"
|
|
||||||
echo -e "${DGN}Using CT Password ${BGN}$PW1${CL}"
|
|
||||||
echo -e "${DGN}Using CT ID ${BGN}$CT_ID${CL}"
|
|
||||||
echo -e "${DGN}Using CT Name ${BGN}$HN${CL}"
|
|
||||||
echo -e "${DGN}Using Disk Size ${BGN}$DISK_SIZE${CL}${DGN}GB${CL}"
|
|
||||||
echo -e "${YW}Allocate CPU cores, or Press [ENTER] for Default: $var_cpu "
|
|
||||||
read CORE_COUNT
|
|
||||||
if [ -z $CORE_COUNT ]; then CORE_COUNT="$var_cpu"; fi;
|
|
||||||
echo -en "${DGN}Set Cores To ${BL}$CORE_COUNT${CL}${DGN}vCPU${CL}"
|
|
||||||
echo -e " ${CM}${CL} \r"
|
|
||||||
sleep 1
|
|
||||||
clear
|
|
||||||
header_info
|
|
||||||
echo -e "${RD}Using Advanced Settings${CL}"
|
|
||||||
echo -e "${DGN}Using CT Type ${BGN}$CT_TYPE1${CL}"
|
|
||||||
echo -e "${DGN}Using CT Password ${BGN}$PW1${CL}"
|
|
||||||
echo -e "${DGN}Using CT ID ${BGN}$CT_ID${CL}"
|
|
||||||
echo -e "${DGN}Using CT Name ${BGN}$HN${CL}"
|
|
||||||
echo -e "${DGN}Using Disk Size ${BGN}$DISK_SIZE${CL}${DGN}GB${CL}"
|
|
||||||
echo -e "${DGN}Using ${BGN}${CORE_COUNT}${CL}${DGN}vCPU${CL}"
|
|
||||||
echo -e "${YW}Allocate RAM in MiB, or Press [ENTER] for Default: $var_ram "
|
|
||||||
read RAM_SIZE
|
|
||||||
if [ -z $RAM_SIZE ]; then RAM_SIZE="$var_ram"; fi;
|
|
||||||
echo -en "${DGN}Set RAM To ${BL}$RAM_SIZE${CL}${DGN}MiB RAM${CL}"
|
|
||||||
echo -e " ${CM}${CL} \n"
|
|
||||||
sleep 1
|
|
||||||
clear
|
|
||||||
header_info
|
|
||||||
echo -e "${RD}Using Advanced Settings${CL}"
|
|
||||||
echo -e "${DGN}Using CT Type ${BGN}$CT_TYPE1${CL}"
|
|
||||||
echo -e "${DGN}Using CT Password ${BGN}$PW1${CL}"
|
|
||||||
echo -e "${DGN}Using CT ID ${BGN}$CT_ID${CL}"
|
|
||||||
echo -e "${DGN}Using CT Name ${BGN}$HN${CL}"
|
|
||||||
echo -e "${DGN}Using Disk Size ${BGN}$DISK_SIZE${CL}${DGN}GB${CL}"
|
|
||||||
echo -e "${DGN}Using ${BGN}${CORE_COUNT}${CL}${DGN}vCPU${CL}"
|
|
||||||
echo -e "${DGN}Using ${BGN}${RAM_SIZE}${CL}${DGN}MiB RAM${CL}"
|
|
||||||
echo -e "${YW}Enter a Bridge, or Press [ENTER] for Default: vmbr0 "
|
|
||||||
read BRG
|
|
||||||
if [ -z $BRG ]; then BRG="vmbr0"; fi;
|
|
||||||
echo -en "${DGN}Set Bridge To ${BL}$BRG${CL}"
|
|
||||||
echo -e " ${CM}${CL} \n"
|
|
||||||
sleep 1
|
|
||||||
clear
|
|
||||||
header_info
|
|
||||||
echo -e "${RD}Using Advanced Settings${CL}"
|
|
||||||
echo -e "${DGN}Using CT Type ${BGN}$CT_TYPE1${CL}"
|
|
||||||
echo -e "${DGN}Using CT Password ${BGN}$PW1${CL}"
|
|
||||||
echo -e "${DGN}Using CT ID ${BGN}$CT_ID${CL}"
|
|
||||||
echo -e "${DGN}Using CT Name ${BGN}$HN${CL}"
|
|
||||||
echo -e "${DGN}Using Disk Size ${BGN}$DISK_SIZE${CL}${DGN}GB${CL}"
|
|
||||||
echo -e "${DGN}Using ${BGN}${CORE_COUNT}${CL}${DGN}vCPU${CL}"
|
|
||||||
echo -e "${DGN}Using ${BGN}${RAM_SIZE}${CL}${DGN}MiB RAM${CL}"
|
|
||||||
echo -e "${DGN}Using Bridge ${BGN}${BRG}${CL}"
|
|
||||||
echo -e "${YW}Enter a Static IPv4 CIDR Address, or Press [ENTER] for Default: DHCP "
|
|
||||||
read NET
|
|
||||||
if [ -z $NET ]; then NET="dhcp"; fi;
|
|
||||||
echo -en "${DGN}Set Static IP Address To ${BL}$NET${CL}"
|
|
||||||
echo -e " ${CM}${CL} \n"
|
|
||||||
sleep 1
|
|
||||||
clear
|
|
||||||
header_info
|
|
||||||
echo -e "${RD}Using Advanced Settings${CL}"
|
|
||||||
echo -e "${DGN}Using CT Type ${BGN}$CT_TYPE1${CL}"
|
|
||||||
echo -e "${DGN}Using CT Password ${BGN}$PW1${CL}"
|
|
||||||
echo -e "${DGN}Using CT ID ${BGN}$CT_ID${CL}"
|
|
||||||
echo -e "${DGN}Using CT Name ${BGN}$HN${CL}"
|
|
||||||
echo -e "${DGN}Using Disk Size ${BGN}$DISK_SIZE${CL}${DGN}GB${CL}"
|
|
||||||
echo -e "${DGN}Using ${BGN}${CORE_COUNT}${CL}${DGN}vCPU${CL}"
|
|
||||||
echo -e "${DGN}Using ${BGN}${RAM_SIZE}${CL}${DGN}MiB RAM${CL}"
|
|
||||||
echo -e "${DGN}Using Bridge ${BGN}${BRG}${CL}"
|
|
||||||
echo -e "${DGN}Using Static IP Address ${BGN}$NET${CL}"
|
|
||||||
echo -e "${YW}Enter a Gateway IP (mandatory if static IP is used), or Press [ENTER] for Default: NONE "
|
|
||||||
read GATE1
|
|
||||||
if [ -z $GATE1 ]; then GATE1="NONE" GATE="";
|
|
||||||
echo -en "${DGN}Set Gateway IP To ${BL}$GATE1${CL}"
|
|
||||||
else
|
|
||||||
GATE=",gw=$GATE1"
|
|
||||||
echo -en "${DGN}Set Gateway IP To ${BL}$GATE1${CL}"
|
|
||||||
fi;
|
|
||||||
echo -e " ${CM}${CL} \n"
|
|
||||||
sleep 1
|
|
||||||
clear
|
|
||||||
header_info
|
|
||||||
|
|
||||||
echo -e "${RD}Using Advanced Settings${CL}"
|
|
||||||
echo -e "${DGN}Using CT Type ${BGN}$CT_TYPE1${CL}"
|
|
||||||
echo -e "${DGN}Using CT Password ${BGN}$PW1${CL}"
|
|
||||||
echo -e "${DGN}Using CT ID ${BGN}$CT_ID${CL}"
|
|
||||||
echo -e "${DGN}Using CT Name ${BGN}$HN${CL}"
|
|
||||||
echo -e "${DGN}Using Disk Size ${BGN}$DISK_SIZE${CL}${DGN}GB${CL}"
|
|
||||||
echo -e "${DGN}Using ${BGN}${CORE_COUNT}${CL}${DGN}vCPU${CL}"
|
|
||||||
echo -e "${DGN}Using ${BGN}${RAM_SIZE}${CL}${DGN}MiB RAM${CL}"
|
|
||||||
echo -e "${DGN}Using Bridge ${BGN}${BRG}${CL}"
|
|
||||||
echo -e "${DGN}Using Static IP Address ${BGN}$NET${CL}"
|
|
||||||
echo -e "${DGN}Using Gateway IP Address ${BGN}$GATE1${CL}"
|
|
||||||
echo -e "${YW}Enter a VLAN Tag, or Press [ENTER] for Default: NONE "
|
|
||||||
read VLAN1
|
|
||||||
if [ -z $VLAN1 ]; then VLAN1="NONE" VLAN="";
|
|
||||||
echo -en "${DGN}Set VLAN Tag To ${BL}$VLAN1${CL}"
|
|
||||||
else
|
|
||||||
VLAN=",tag=$VLAN1"
|
|
||||||
echo -en "${DGN}Set VLAN Tag To ${BL}$VLAN1${CL}"
|
|
||||||
fi;
|
|
||||||
echo -e " ${CM}${CL} \n"
|
|
||||||
sleep 1
|
|
||||||
clear
|
|
||||||
header_info
|
|
||||||
echo -e "${RD}Using Advanced Settings${CL}"
|
|
||||||
echo -e "${DGN}Using CT Type ${BGN}$CT_TYPE1${CL}"
|
|
||||||
echo -e "${DGN}Using CT Password ${BGN}$PW1${CL}"
|
|
||||||
echo -e "${DGN}Using CT ID ${BGN}$CT_ID${CL}"
|
|
||||||
echo -e "${DGN}Using CT Name ${BGN}$HN${CL}"
|
|
||||||
echo -e "${DGN}Using Disk Size ${BGN}$DISK_SIZE${CL}${DGN}GB${CL}"
|
|
||||||
echo -e "${DGN}Using ${BGN}${CORE_COUNT}${CL}${DGN}vCPU${CL}"
|
|
||||||
echo -e "${DGN}Using ${BGN}${RAM_SIZE}${CL}${DGN}MiB RAM${CL}"
|
|
||||||
echo -e "${DGN}Using Bridge ${BGN}${BRG}${CL}"
|
|
||||||
echo -e "${DGN}Using Static IP Address ${BGN}$NET${CL}"
|
|
||||||
echo -e "${DGN}Using Gateway IP Address ${BGN}$GATE1${CL}"
|
|
||||||
echo -e "${DGN}Using VLAN Tag ${BGN}$VLAN1${CL}"
|
|
||||||
|
|
||||||
read -p "Are these settings correct(y/n)? " -n 1 -r
|
|
||||||
echo
|
|
||||||
if [[ ! $REPLY =~ ^[Yy]$ ]]
|
|
||||||
then
|
|
||||||
advanced_settings
|
|
||||||
fi
|
|
||||||
}
|
|
||||||
|
|
||||||
function start_script() {
|
|
||||||
echo -e "${YW}Type Advanced, or Press [ENTER] for Default Settings "
|
|
||||||
read SETTINGS
|
|
||||||
if [ -z $SETTINGS ]; then default_settings;
|
|
||||||
else
|
|
||||||
advanced_settings
|
|
||||||
fi;
|
|
||||||
}
|
|
||||||
|
|
||||||
start_script
|
|
||||||
|
|
||||||
if [ "$CT_TYPE" == "1" ]; then
|
|
||||||
FEATURES="nesting=1,keyctl=1"
|
|
||||||
else
|
|
||||||
FEATURES="nesting=1"
|
|
||||||
fi
|
|
||||||
|
|
||||||
export CTID=$CT_ID
|
|
||||||
export PCT_OSTYPE=$var_os
|
|
||||||
export PCT_OSVERSION=$var_version
|
|
||||||
export PCT_DISK_SIZE=$DISK_SIZE
|
|
||||||
export PCT_OPTIONS="
|
|
||||||
-features $FEATURES
|
|
||||||
-hostname $HN
|
|
||||||
-net0 name=eth0,bridge=$BRG,ip=$NET$GATE$VLAN
|
|
||||||
-onboot 1
|
|
||||||
-cores $CORE_COUNT
|
|
||||||
-memory $RAM_SIZE
|
|
||||||
-unprivileged $CT_TYPE
|
|
||||||
$PW
|
|
||||||
"
|
|
||||||
bash -c "$(wget -qLO - https://raw.githubusercontent.com/tteck/Proxmox/main/ct/create_lxc.sh)" || exit
|
|
||||||
|
|
||||||
msg_info "Starting LXC Container"
|
|
||||||
pct start $CTID
|
|
||||||
msg_ok "Started LXC Container"
|
|
||||||
|
|
||||||
lxc-attach -n $CTID -- bash -c "$(wget -qLO - https://raw.githubusercontent.com/tteck/Proxmox/main/setup/$var_install.sh)" || exit
|
|
||||||
|
|
||||||
IP=$(pct exec $CTID ip a s dev eth0 | sed -n '/inet / s/\// /p' | awk '{print $2}')
|
|
||||||
|
|
||||||
pct set $CTID -description "# ${APP} LXC
|
|
||||||
### https://github.com/tteck/Proxmox"
|
|
||||||
|
|
||||||
msg_ok "Completed Successfully!\n"
|
|
||||||
echo -e "${APP} should be reachable by going to the following URL.
|
|
||||||
${BL}http://${IP}${CL} \n"
|
|
|
@ -309,7 +309,7 @@ bash -c "$(wget -qLO - https://raw.githubusercontent.com/tteck/Proxmox/main/ct/c
|
||||||
msg_info "Starting LXC Container"
|
msg_info "Starting LXC Container"
|
||||||
pct start $CTID
|
pct start $CTID
|
||||||
msg_ok "Started LXC Container"
|
msg_ok "Started LXC Container"
|
||||||
lxc-attach -n $CTID -- bash -c "$(wget -qLO - https://raw.githubusercontent.com/tteck/Proxmox/main/setup/$var_install.sh)" || exit
|
lxc-attach -n $CTID -- bash -c "$(wget -qLO - https://raw.githubusercontent.com/tteck/Proxmox/main/install/$var_install.sh)" || exit
|
||||||
IP=$(pct exec $CTID ip a s dev eth0 | sed -n '/inet / s/\// /p' | awk '{print $2}')
|
IP=$(pct exec $CTID ip a s dev eth0 | sed -n '/inet / s/\// /p' | awk '{print $2}')
|
||||||
pct set $CTID -description "# ${APP} LXC
|
pct set $CTID -description "# ${APP} LXC
|
||||||
### https://tteck.github.io/Proxmox/
|
### https://tteck.github.io/Proxmox/
|
||||||
|
|
|
@ -1,259 +0,0 @@
|
||||||
#!/usr/bin/env bash
|
|
||||||
PP=`echo "\e[1;35m"`
|
|
||||||
YW=`echo "\033[33m"`
|
|
||||||
BL=`echo "\033[36m"`
|
|
||||||
RD=`echo "\033[01;31m"`
|
|
||||||
CM='\xE2\x9C\x94\033'
|
|
||||||
GN=`echo "\033[1;92m"`
|
|
||||||
CL=`echo "\033[m"`
|
|
||||||
APP="Heimdall Dashboard"
|
|
||||||
HN=$(echo ${APP,,} | tr -d ' ')
|
|
||||||
while true; do
|
|
||||||
read -p "This will create a New ${APP} LXC. Proceed(y/n)?" yn
|
|
||||||
case $yn in
|
|
||||||
[Yy]* ) break;;
|
|
||||||
[Nn]* ) exit;;
|
|
||||||
* ) echo "Please answer yes or no.";;
|
|
||||||
esac
|
|
||||||
done
|
|
||||||
clear
|
|
||||||
function header_info {
|
|
||||||
echo -e "${PP}
|
|
||||||
_ _ _ _ _ _ _____ _ _ _
|
|
||||||
| | | | (_) | | | | | | __ \ | | | | | |
|
|
||||||
| |__| | ___ _ _ __ ___ __| | __ _| | | | | | | __ _ ___| |__ | |__ ___ __ _ _ __ __| |
|
|
||||||
| __ |/ _ \ | _ _ \ / _ |/ _ | | | | | | |/ _ / __| _ \| _ \ / _ \ / _ | __/ _ |
|
|
||||||
| | | | __/ | | | | | | (_| | (_| | | | | |__| | (_| \__ \ | | | |_) | (_) | (_| | | | (_| |
|
|
||||||
|_| |_|\___|_|_| |_| |_|\__,_|\__,_|_|_| |_____/ \__,_|___/_| |_|_.__/ \___/ \__,_|_| \__,_|
|
|
||||||
${CL}"
|
|
||||||
}
|
|
||||||
|
|
||||||
header_info
|
|
||||||
show_menu(){
|
|
||||||
printf " ${YW} 1)${YW} Privileged ${CL}\n"
|
|
||||||
printf " ${YW} 2)${GN} Unprivileged ${CL}\n"
|
|
||||||
|
|
||||||
printf "Please choose a Install Method and press [ENTER] or ${RD}x${CL} to exit."
|
|
||||||
read opt
|
|
||||||
}
|
|
||||||
|
|
||||||
option_picked(){
|
|
||||||
message1=${@:-"${CL}Error: No message passed"}
|
|
||||||
printf " ${YW}${message1}${CL}\n"
|
|
||||||
}
|
|
||||||
show_menu
|
|
||||||
while [ "$opt" != " " ]
|
|
||||||
do
|
|
||||||
case $opt in
|
|
||||||
1) clear;
|
|
||||||
header_info;
|
|
||||||
option_picked "Using Privileged Install";
|
|
||||||
IM=0
|
|
||||||
break;
|
|
||||||
;;
|
|
||||||
2) clear;
|
|
||||||
header_info;
|
|
||||||
option_picked "Using Unprivileged Install";
|
|
||||||
IM=1
|
|
||||||
break;
|
|
||||||
;;
|
|
||||||
|
|
||||||
x)exit;
|
|
||||||
;;
|
|
||||||
\n)exit;
|
|
||||||
;;
|
|
||||||
*)clear;
|
|
||||||
option_picked "Please choose a Install Method from the menu";
|
|
||||||
show_menu;
|
|
||||||
;;
|
|
||||||
esac
|
|
||||||
done
|
|
||||||
show_menu2(){
|
|
||||||
printf " ${YW} 1)${GN} Use Automatic Login ${CL}\n"
|
|
||||||
printf " ${YW} 2)${GN} Use Password (changeme) ${CL}\n"
|
|
||||||
|
|
||||||
printf "Please choose a Password Type and press [ENTER] or ${RD}x${CL} to exit."
|
|
||||||
read opt
|
|
||||||
}
|
|
||||||
|
|
||||||
option_picked(){
|
|
||||||
message2=${@:-"${CL}Error: No message passed"}
|
|
||||||
printf " ${YW}${message1}${CL}\n"
|
|
||||||
printf " ${YW}${message2}${CL}\n"
|
|
||||||
}
|
|
||||||
show_menu2
|
|
||||||
while [ "$opt" != " " ]
|
|
||||||
do
|
|
||||||
case $opt in
|
|
||||||
1) clear;
|
|
||||||
header_info;
|
|
||||||
option_picked "Using Automatic Login";
|
|
||||||
PW=" "
|
|
||||||
break;
|
|
||||||
;;
|
|
||||||
2) clear;
|
|
||||||
header_info;
|
|
||||||
option_picked "Using Password (changeme)";
|
|
||||||
PW="-password changeme"
|
|
||||||
break;
|
|
||||||
;;
|
|
||||||
|
|
||||||
x)exit;
|
|
||||||
;;
|
|
||||||
\n)exit;
|
|
||||||
;;
|
|
||||||
*)clear;
|
|
||||||
option_picked "Please choose a Password Type from the menu";
|
|
||||||
show_menu2;
|
|
||||||
;;
|
|
||||||
esac
|
|
||||||
done
|
|
||||||
show_menu3(){
|
|
||||||
printf " ${YW} 1)${GN} Automatic DHCP ${CL}\n"
|
|
||||||
printf " ${YW} 2)${GN} Manual DHCP ${CL}\n"
|
|
||||||
|
|
||||||
printf "Please choose a DHCP Type and press [ENTER] or ${RD}x${CL} to exit."
|
|
||||||
read opt
|
|
||||||
}
|
|
||||||
|
|
||||||
option_picked(){
|
|
||||||
message3=${@:-"${CL}Error: No message passed"}
|
|
||||||
printf " ${YW}${message1}${CL}\n"
|
|
||||||
printf " ${YW}${message2}${CL}\n"
|
|
||||||
printf " ${YW}${message3}${CL}\n"
|
|
||||||
}
|
|
||||||
show_menu3
|
|
||||||
while [ "$opt" != " " ]
|
|
||||||
do
|
|
||||||
case $opt in
|
|
||||||
1) clear;
|
|
||||||
header_info;
|
|
||||||
option_picked "Using Automatic DHCP";
|
|
||||||
DHCP=" "
|
|
||||||
break;
|
|
||||||
;;
|
|
||||||
2) clear;
|
|
||||||
header_info;
|
|
||||||
option_picked "Using Manual DHCP";
|
|
||||||
DHCP="1"
|
|
||||||
break;
|
|
||||||
;;
|
|
||||||
|
|
||||||
x)exit;
|
|
||||||
;;
|
|
||||||
\n)exit;
|
|
||||||
;;
|
|
||||||
*)clear;
|
|
||||||
option_picked "Please choose a DHCP Type from the menu";
|
|
||||||
show_menu3;
|
|
||||||
;;
|
|
||||||
esac
|
|
||||||
done
|
|
||||||
|
|
||||||
set -o errexit
|
|
||||||
set -o errtrace
|
|
||||||
set -o nounset
|
|
||||||
set -o pipefail
|
|
||||||
shopt -s expand_aliases
|
|
||||||
alias die='EXIT=$? LINE=$LINENO error_exit'
|
|
||||||
trap die ERR
|
|
||||||
trap cleanup EXIT
|
|
||||||
|
|
||||||
function error_exit() {
|
|
||||||
trap - ERR
|
|
||||||
local DEFAULT='Unknown failure occured.'
|
|
||||||
local REASON="\e[97m${1:-$DEFAULT}\e[39m"
|
|
||||||
local FLAG="\e[91m[ERROR] \e[93m$EXIT@$LINE"
|
|
||||||
msg "$FLAG $REASON"
|
|
||||||
[ ! -z ${CTID-} ] && cleanup_ctid
|
|
||||||
exit $EXIT
|
|
||||||
}
|
|
||||||
function warn() {
|
|
||||||
local REASON="\e[97m$1\e[39m"
|
|
||||||
local FLAG="\e[93m[WARNING]\e[39m"
|
|
||||||
msg "$FLAG $REASON"
|
|
||||||
}
|
|
||||||
function info() {
|
|
||||||
local REASON="$1"
|
|
||||||
local FLAG="\e[36m[INFO]\e[39m"
|
|
||||||
msg "$FLAG $REASON"
|
|
||||||
}
|
|
||||||
function msg() {
|
|
||||||
local TEXT="$1"
|
|
||||||
echo -e "$TEXT"
|
|
||||||
}
|
|
||||||
function cleanup_ctid() {
|
|
||||||
if $(pct status $CTID &>/dev/null); then
|
|
||||||
if [ "$(pct status $CTID | awk '{print $2}')" == "running" ]; then
|
|
||||||
pct stop $CTID
|
|
||||||
fi
|
|
||||||
pct destroy $CTID
|
|
||||||
elif [ "$(pvesm list $STORAGE --vmid $CTID)" != "" ]; then
|
|
||||||
pvesm free $ROOTFS
|
|
||||||
fi
|
|
||||||
}
|
|
||||||
function cleanup() {
|
|
||||||
popd >/dev/null
|
|
||||||
rm -rf $TEMP_DIR
|
|
||||||
}
|
|
||||||
if [ "$IM" == "1" ]; then
|
|
||||||
FEATURES="nesting=1,keyctl=1"
|
|
||||||
else
|
|
||||||
FEATURES="nesting=1"
|
|
||||||
fi
|
|
||||||
|
|
||||||
TEMP_DIR=$(mktemp -d)
|
|
||||||
pushd $TEMP_DIR >/dev/null
|
|
||||||
|
|
||||||
export CTID=$(pvesh get /cluster/nextid)
|
|
||||||
export PCT_OSTYPE=debian
|
|
||||||
export PCT_OSVERSION=11
|
|
||||||
export PCT_DISK_SIZE=2
|
|
||||||
export PCT_OPTIONS="
|
|
||||||
-features $FEATURES
|
|
||||||
-hostname $HN
|
|
||||||
-net0 name=eth0,bridge=vmbr0,ip=dhcp
|
|
||||||
-onboot 1
|
|
||||||
-cores 1
|
|
||||||
-memory 512
|
|
||||||
-unprivileged ${IM}
|
|
||||||
${PW}
|
|
||||||
"
|
|
||||||
bash -c "$(wget -qLO - https://raw.githubusercontent.com/tteck/Proxmox/main/ct/create_lxc.sh)" || exit
|
|
||||||
|
|
||||||
STORAGE_TYPE=$(pvesm status -storage $(pct config $CTID | grep rootfs | awk -F ":" '{print $2}') | awk 'NR>1 {print $2}')
|
|
||||||
if [ "$STORAGE_TYPE" == "zfspool" ]; then
|
|
||||||
warn "Some addons may not work due to ZFS not supporting 'fallocate'."
|
|
||||||
fi
|
|
||||||
LXC_CONFIG=/etc/pve/lxc/${CTID}.conf
|
|
||||||
cat <<EOF >> $LXC_CONFIG
|
|
||||||
lxc.cgroup2.devices.allow: a
|
|
||||||
lxc.cap.drop:
|
|
||||||
EOF
|
|
||||||
if [ "$DHCP" == "1" ]; then
|
|
||||||
MAC=$(pct config $CTID \
|
|
||||||
| grep -i hwaddr \
|
|
||||||
| awk '{print substr($2, 31, length($3) 17 ) }') \
|
|
||||||
|
|
||||||
echo -e "MAC Address ${BL}$MAC${CL}"
|
|
||||||
|
|
||||||
dhcp_reservation(){
|
|
||||||
printf "Please set DHCP reservation and press [ENTER]."
|
|
||||||
read
|
|
||||||
}
|
|
||||||
dhcp_reservation
|
|
||||||
fi
|
|
||||||
|
|
||||||
echo -en "${GN} Starting LXC Container... "
|
|
||||||
pct start $CTID
|
|
||||||
echo -e "${CM}${CL} \r"
|
|
||||||
|
|
||||||
alias lxc-cmd="lxc-attach -n $CTID --"
|
|
||||||
|
|
||||||
lxc-cmd bash -c "$(wget -qLO - https://raw.githubusercontent.com/tteck/Proxmox/main/setup/$HN-install.sh)" || exit
|
|
||||||
|
|
||||||
IP=$(pct exec $CTID ip a s dev eth0 | sed -n '/inet / s/\// /p' | awk '{print $2}')
|
|
||||||
|
|
||||||
echo -e "${GN}Successfully created ${APP} LXC to${CL} ${BL}$CTID${CL}.
|
|
||||||
${BL}${APP}${CL} should be reachable by going to the following URL.
|
|
||||||
${BL}http://${IP}:7990${CL} \n"
|
|
|
@ -1,357 +0,0 @@
|
||||||
#!/usr/bin/env bash
|
|
||||||
echo -e "Loading..."
|
|
||||||
NEXTID=$(pvesh get /cluster/nextid)
|
|
||||||
INTEGER='^[0-9]+$'
|
|
||||||
PP=`echo "\e[1;35m"`
|
|
||||||
YW=`echo "\033[33m"`
|
|
||||||
BL=`echo "\033[36m"`
|
|
||||||
RD=`echo "\033[01;31m"`
|
|
||||||
BGN=`echo "\033[4;92m"`
|
|
||||||
GN=`echo "\033[1;92m"`
|
|
||||||
DGN=`echo "\033[32m"`
|
|
||||||
CL=`echo "\033[m"`
|
|
||||||
BFR="\\r\\033[K"
|
|
||||||
HOLD="-"
|
|
||||||
CM="${GN}✓${CL}"
|
|
||||||
APP="Heimdall Dashboard"
|
|
||||||
NSAPP=$(echo ${APP,,} | tr -d ' ')
|
|
||||||
set -o errexit
|
|
||||||
set -o errtrace
|
|
||||||
set -o nounset
|
|
||||||
set -o pipefail
|
|
||||||
shopt -s expand_aliases
|
|
||||||
alias die='EXIT=$? LINE=$LINENO error_exit'
|
|
||||||
trap die ERR
|
|
||||||
|
|
||||||
function error_exit() {
|
|
||||||
trap - ERR
|
|
||||||
local reason="Unknown failure occurred."
|
|
||||||
local msg="${1:-$reason}"
|
|
||||||
local flag="${RD}‼ ERROR ${CL}$EXIT@$LINE"
|
|
||||||
echo -e "$flag $msg" 1>&2
|
|
||||||
exit $EXIT
|
|
||||||
}
|
|
||||||
|
|
||||||
while true; do
|
|
||||||
clear
|
|
||||||
read -p "This will create a New ${APP} LXC. Proceed(y/n)?" yn
|
|
||||||
case $yn in
|
|
||||||
[Yy]* ) break;;
|
|
||||||
[Nn]* ) exit;;
|
|
||||||
* ) echo "Please answer yes or no.";;
|
|
||||||
esac
|
|
||||||
done
|
|
||||||
clear
|
|
||||||
function header_info {
|
|
||||||
echo -e "${PP}
|
|
||||||
_ _ _ _ _ _ _____ _ _ _
|
|
||||||
| | | | (_) | | | | | | __ \ | | | | | |
|
|
||||||
| |__| | ___ _ _ __ ___ __| | __v3| | | | | | | __ _ ___| |__ | |__ ___ __ _ _ __ __| |
|
|
||||||
| __ |/ _ \ | _ _ \ / _ |/ _ | | | | | | |/ _ / __| _ \| _ \ / _ \ / _ | __/ _ |
|
|
||||||
| | | | __/ | | | | | | (_| | (_| | | | | |__| | (_| \__ \ | | | |_) | (_) | (_| | | | (_| |
|
|
||||||
|_| |_|\___|_|_| |_| |_|\__,_|\__,_|_|_| |_____/ \__,_|___/_| |_|_.__/ \___/ \__,_|_| \__,_|
|
|
||||||
${CL}"
|
|
||||||
}
|
|
||||||
|
|
||||||
header_info
|
|
||||||
|
|
||||||
function msg_info() {
|
|
||||||
local msg="$1"
|
|
||||||
echo -ne " ${HOLD} ${YW}${msg}..."
|
|
||||||
}
|
|
||||||
|
|
||||||
function msg_ok() {
|
|
||||||
local msg="$1"
|
|
||||||
echo -e "${BFR} ${CM} ${GN}${msg}${CL}"
|
|
||||||
}
|
|
||||||
|
|
||||||
function PVE_CHECK() {
|
|
||||||
PVE=$(pveversion | grep "pve-manager/7" | wc -l)
|
|
||||||
|
|
||||||
if [[ $PVE != 1 ]]; then
|
|
||||||
echo -e "${RD}This script requires Proxmox Virtual Environment 7.0 or greater${CL}"
|
|
||||||
echo -e "Exiting..."
|
|
||||||
sleep 2
|
|
||||||
exit
|
|
||||||
fi
|
|
||||||
}
|
|
||||||
|
|
||||||
function default_settings() {
|
|
||||||
clear
|
|
||||||
header_info
|
|
||||||
echo -e "${BL}Using Default Settings${CL}"
|
|
||||||
echo -e "${DGN}Using CT Type ${BGN}Unprivileged${CL} ${RD}NO DEVICE PASSTHROUGH${CL}"
|
|
||||||
CT_TYPE="1"
|
|
||||||
echo -e "${DGN}Using CT Password ${BGN}Automatic Login${CL}"
|
|
||||||
PW=" "
|
|
||||||
echo -e "${DGN}Using CT ID ${BGN}$NEXTID${CL}"
|
|
||||||
CT_ID=$NEXTID
|
|
||||||
echo -e "${DGN}Using CT Name ${BGN}$NSAPP${CL}"
|
|
||||||
HN=$NSAPP
|
|
||||||
echo -e "${DGN}Using Disk Size ${BGN}2${CL}${DGN}GB${CL}"
|
|
||||||
DISK_SIZE="2"
|
|
||||||
echo -e "${DGN}Using ${BGN}1${CL}${DGN}vCPU${CL}"
|
|
||||||
CORE_COUNT="1"
|
|
||||||
echo -e "${DGN}Using ${BGN}512${CL}${DGN}MiB RAM${CL}"
|
|
||||||
RAM_SIZE="512"
|
|
||||||
echo -e "${DGN}Using Bridge ${BGN}vmbr0${CL}"
|
|
||||||
BRG="vmbr0"
|
|
||||||
echo -e "${DGN}Using Static IP Address ${BGN}DHCP${CL}"
|
|
||||||
NET=dhcp
|
|
||||||
echo -e "${DGN}Using Gateway Address ${BGN}NONE${CL}"
|
|
||||||
GATE=""
|
|
||||||
echo -e "${DGN}Using VLAN Tag ${BGN}NONE${CL}"
|
|
||||||
VLAN=""
|
|
||||||
}
|
|
||||||
|
|
||||||
function advanced_settings() {
|
|
||||||
clear
|
|
||||||
header_info
|
|
||||||
echo -e "${RD}Using Advanced Settings${CL}"
|
|
||||||
echo -e "${YW}Type Privileged, or Press [ENTER] for Default: Unprivileged (${RD}NO DEVICE PASSTHROUGH${CL}${YW})"
|
|
||||||
read CT_TYPE1
|
|
||||||
if [ -z $CT_TYPE1 ]; then CT_TYPE1="Unprivileged" CT_TYPE="1";
|
|
||||||
echo -en "${DGN}Set CT Type ${BL}$CT_TYPE1${CL}"
|
|
||||||
else
|
|
||||||
CT_TYPE1="Privileged"
|
|
||||||
CT_TYPE="0"
|
|
||||||
echo -en "${DGN}Set CT Type ${BL}Privileged${CL}"
|
|
||||||
fi;
|
|
||||||
echo -e " ${CM}${CL} \r"
|
|
||||||
sleep 1
|
|
||||||
clear
|
|
||||||
header_info
|
|
||||||
echo -e "${RD}Using Advanced Settings${CL}"
|
|
||||||
echo -e "${DGN}Using CT Type ${BGN}$CT_TYPE1${CL}"
|
|
||||||
echo -e "${YW}Set Password, or Press [ENTER] for Default: Automatic Login "
|
|
||||||
read PW1
|
|
||||||
if [ -z $PW1 ]; then PW1="Automatic Login" PW=" ";
|
|
||||||
echo -en "${DGN}Set CT ${BL}$PW1${CL}"
|
|
||||||
else
|
|
||||||
PW="-password $PW1"
|
|
||||||
echo -en "${DGN}Set CT Password ${BL}$PW1${CL}"
|
|
||||||
fi;
|
|
||||||
echo -e " ${CM}${CL} \r"
|
|
||||||
sleep 1
|
|
||||||
clear
|
|
||||||
header_info
|
|
||||||
echo -e "${RD}Using Advanced Settings${CL}"
|
|
||||||
echo -e "${DGN}Using CT Type ${BGN}$CT_TYPE1${CL}"
|
|
||||||
echo -e "${DGN}Using CT Password ${BGN}$PW1${CL}"
|
|
||||||
echo -e "${YW}Enter the CT ID, or Press [ENTER] to automatically generate (${NEXTID}) "
|
|
||||||
read CT_ID
|
|
||||||
if [ -z $CT_ID ]; then CT_ID=$NEXTID; fi;
|
|
||||||
echo -en "${DGN}Set CT ID To ${BL}$CT_ID${CL}"
|
|
||||||
echo -e " ${CM}${CL} \r"
|
|
||||||
sleep 1
|
|
||||||
clear
|
|
||||||
header_info
|
|
||||||
echo -e "${RD}Using Advanced Settings${CL}"
|
|
||||||
echo -e "${DGN}Using CT Type ${BGN}$CT_TYPE1${CL}"
|
|
||||||
echo -e "${DGN}Using CT Password ${BGN}$PW1${CL}"
|
|
||||||
echo -e "${DGN}Using CT ID ${BGN}$CT_ID${CL}"
|
|
||||||
echo -e "${YW}Enter CT Name (no-spaces), or Press [ENTER] for Default: $NSAPP "
|
|
||||||
read CT_NAME
|
|
||||||
if [ -z $CT_NAME ]; then
|
|
||||||
HN=$NSAPP
|
|
||||||
else
|
|
||||||
HN=$(echo ${CT_NAME,,} | tr -d ' ')
|
|
||||||
fi
|
|
||||||
echo -en "${DGN}Set CT Name To ${BL}$HN${CL}"
|
|
||||||
echo -e " ${CM}${CL} \r"
|
|
||||||
sleep 1
|
|
||||||
clear
|
|
||||||
header_info
|
|
||||||
echo -e "${RD}Using Advanced Settings${CL}"
|
|
||||||
echo -e "${DGN}Using CT Type ${BGN}$CT_TYPE1${CL}"
|
|
||||||
echo -e "${DGN}Using CT Password ${BGN}$PW1${CL}"
|
|
||||||
echo -e "${DGN}Using CT ID ${BGN}$CT_ID${CL}"
|
|
||||||
echo -e "${DGN}Using CT Name ${BGN}$HN${CL}"
|
|
||||||
echo -e "${YW}Enter a Disk Size, or Press [ENTER] for Default: 2 "
|
|
||||||
read DISK_SIZE
|
|
||||||
if [ -z $DISK_SIZE ]; then DISK_SIZE="2"; fi;
|
|
||||||
if ! [[ $DISK_SIZE =~ $INTEGER ]] ; then echo "ERROR! DISK SIZE MUST HAVE INTEGER NUMBER!"; exit; fi;
|
|
||||||
echo -en "${DGN}Set Disk Size To ${BL}$DISK_SIZE${CL}${DGN}GB${CL}"
|
|
||||||
echo -e " ${CM}${CL} \r"
|
|
||||||
sleep 1
|
|
||||||
clear
|
|
||||||
header_info
|
|
||||||
echo -e "${RD}Using Advanced Settings${CL}"
|
|
||||||
echo -e "${DGN}Using CT Type ${BGN}$CT_TYPE1${CL}"
|
|
||||||
echo -e "${DGN}Using CT Password ${BGN}$PW1${CL}"
|
|
||||||
echo -e "${DGN}Using CT ID ${BGN}$CT_ID${CL}"
|
|
||||||
echo -e "${DGN}Using CT Name ${BGN}$HN${CL}"
|
|
||||||
echo -e "${DGN}Using Disk Size ${BGN}$DISK_SIZE${CL}${DGN}GB${CL}"
|
|
||||||
echo -e "${YW}Allocate CPU cores, or Press [ENTER] for Default: 1 "
|
|
||||||
read CORE_COUNT
|
|
||||||
if [ -z $CORE_COUNT ]; then CORE_COUNT="1"; fi;
|
|
||||||
echo -en "${DGN}Set Cores To ${BL}$CORE_COUNT${CL}${DGN}vCPU${CL}"
|
|
||||||
echo -e " ${CM}${CL} \r"
|
|
||||||
sleep 1
|
|
||||||
clear
|
|
||||||
header_info
|
|
||||||
echo -e "${RD}Using Advanced Settings${CL}"
|
|
||||||
echo -e "${DGN}Using CT Type ${BGN}$CT_TYPE1${CL}"
|
|
||||||
echo -e "${DGN}Using CT Password ${BGN}$PW1${CL}"
|
|
||||||
echo -e "${DGN}Using CT ID ${BGN}$CT_ID${CL}"
|
|
||||||
echo -e "${DGN}Using CT Name ${BGN}$HN${CL}"
|
|
||||||
echo -e "${DGN}Using Disk Size ${BGN}$DISK_SIZE${CL}${DGN}GB${CL}"
|
|
||||||
echo -e "${DGN}Using ${BGN}${CORE_COUNT}${CL}${DGN}vCPU${CL}"
|
|
||||||
echo -e "${YW}Allocate RAM in MiB, or Press [ENTER] for Default: 512 "
|
|
||||||
read RAM_SIZE
|
|
||||||
if [ -z $RAM_SIZE ]; then RAM_SIZE="512"; fi;
|
|
||||||
echo -en "${DGN}Set RAM To ${BL}$RAM_SIZE${CL}${DGN}MiB RAM${CL}"
|
|
||||||
echo -e " ${CM}${CL} \n"
|
|
||||||
sleep 1
|
|
||||||
clear
|
|
||||||
header_info
|
|
||||||
echo -e "${RD}Using Advanced Settings${CL}"
|
|
||||||
echo -e "${DGN}Using CT Type ${BGN}$CT_TYPE1${CL}"
|
|
||||||
echo -e "${DGN}Using CT Password ${BGN}$PW1${CL}"
|
|
||||||
echo -e "${DGN}Using CT ID ${BGN}$CT_ID${CL}"
|
|
||||||
echo -e "${DGN}Using CT Name ${BGN}$HN${CL}"
|
|
||||||
echo -e "${DGN}Using Disk Size ${BGN}$DISK_SIZE${CL}${DGN}GB${CL}"
|
|
||||||
echo -e "${DGN}Using ${BGN}${CORE_COUNT}${CL}${DGN}vCPU${CL}"
|
|
||||||
echo -e "${DGN}Using ${BGN}${RAM_SIZE}${CL}${DGN}MiB RAM${CL}"
|
|
||||||
echo -e "${YW}Enter a Bridge, or Press [ENTER] for Default: vmbr0 "
|
|
||||||
read BRG
|
|
||||||
if [ -z $BRG ]; then BRG="vmbr0"; fi;
|
|
||||||
echo -en "${DGN}Set Bridge To ${BL}$BRG${CL}"
|
|
||||||
echo -e " ${CM}${CL} \n"
|
|
||||||
sleep 1
|
|
||||||
clear
|
|
||||||
header_info
|
|
||||||
echo -e "${RD}Using Advanced Settings${CL}"
|
|
||||||
echo -e "${DGN}Using CT Type ${BGN}$CT_TYPE1${CL}"
|
|
||||||
echo -e "${DGN}Using CT Password ${BGN}$PW1${CL}"
|
|
||||||
echo -e "${DGN}Using CT ID ${BGN}$CT_ID${CL}"
|
|
||||||
echo -e "${DGN}Using CT Name ${BGN}$HN${CL}"
|
|
||||||
echo -e "${DGN}Using Disk Size ${BGN}$DISK_SIZE${CL}${DGN}GB${CL}"
|
|
||||||
echo -e "${DGN}Using ${BGN}${CORE_COUNT}${CL}${DGN}vCPU${CL}"
|
|
||||||
echo -e "${DGN}Using ${BGN}${RAM_SIZE}${CL}${DGN}MiB RAM${CL}"
|
|
||||||
echo -e "${DGN}Using Bridge ${BGN}${BRG}${CL}"
|
|
||||||
echo -e "${YW}Enter a Static IPv4 CIDR Address, or Press [ENTER] for Default: DHCP "
|
|
||||||
read NET
|
|
||||||
if [ -z $NET ]; then NET="dhcp"; fi;
|
|
||||||
echo -en "${DGN}Set Static IP Address To ${BL}$NET${CL}"
|
|
||||||
echo -e " ${CM}${CL} \n"
|
|
||||||
sleep 1
|
|
||||||
clear
|
|
||||||
header_info
|
|
||||||
echo -e "${RD}Using Advanced Settings${CL}"
|
|
||||||
echo -e "${DGN}Using CT Type ${BGN}$CT_TYPE1${CL}"
|
|
||||||
echo -e "${DGN}Using CT Password ${BGN}$PW1${CL}"
|
|
||||||
echo -e "${DGN}Using CT ID ${BGN}$CT_ID${CL}"
|
|
||||||
echo -e "${DGN}Using CT Name ${BGN}$HN${CL}"
|
|
||||||
echo -e "${DGN}Using Disk Size ${BGN}$DISK_SIZE${CL}${DGN}GB${CL}"
|
|
||||||
echo -e "${DGN}Using ${BGN}${CORE_COUNT}${CL}${DGN}vCPU${CL}"
|
|
||||||
echo -e "${DGN}Using ${BGN}${RAM_SIZE}${CL}${DGN}MiB RAM${CL}"
|
|
||||||
echo -e "${DGN}Using Bridge ${BGN}${BRG}${CL}"
|
|
||||||
echo -e "${DGN}Using Static IP Address ${BGN}$NET${CL}"
|
|
||||||
echo -e "${YW}Enter a Gateway IP (mandatory if static IP is used), or Press [ENTER] for Default: NONE "
|
|
||||||
read GATE1
|
|
||||||
if [ -z $GATE1 ]; then GATE1="NONE" GATE="";
|
|
||||||
echo -en "${DGN}Set Gateway IP To ${BL}$GATE1${CL}"
|
|
||||||
else
|
|
||||||
GATE=",gw=$GATE1"
|
|
||||||
echo -en "${DGN}Set Gateway IP To ${BL}$GATE1${CL}"
|
|
||||||
fi;
|
|
||||||
echo -e " ${CM}${CL} \n"
|
|
||||||
sleep 1
|
|
||||||
clear
|
|
||||||
header_info
|
|
||||||
|
|
||||||
echo -e "${RD}Using Advanced Settings${CL}"
|
|
||||||
echo -e "${DGN}Using CT Type ${BGN}$CT_TYPE1${CL}"
|
|
||||||
echo -e "${DGN}Using CT Password ${BGN}$PW1${CL}"
|
|
||||||
echo -e "${DGN}Using CT ID ${BGN}$CT_ID${CL}"
|
|
||||||
echo -e "${DGN}Using CT Name ${BGN}$HN${CL}"
|
|
||||||
echo -e "${DGN}Using Disk Size ${BGN}$DISK_SIZE${CL}${DGN}GB${CL}"
|
|
||||||
echo -e "${DGN}Using ${BGN}${CORE_COUNT}${CL}${DGN}vCPU${CL}"
|
|
||||||
echo -e "${DGN}Using ${BGN}${RAM_SIZE}${CL}${DGN}MiB RAM${CL}"
|
|
||||||
echo -e "${DGN}Using Bridge ${BGN}${BRG}${CL}"
|
|
||||||
echo -e "${DGN}Using Static IP Address ${BGN}$NET${CL}"
|
|
||||||
echo -e "${DGN}Using Gateway IP Address ${BGN}$GATE1${CL}"
|
|
||||||
echo -e "${YW}Enter a VLAN Tag, or Press [ENTER] for Default: NONE "
|
|
||||||
read VLAN1
|
|
||||||
if [ -z $VLAN1 ]; then VLAN1="NONE" VLAN="";
|
|
||||||
echo -en "${DGN}Set VLAN Tag To ${BL}$VLAN1${CL}"
|
|
||||||
else
|
|
||||||
VLAN=",tag=$VLAN1"
|
|
||||||
echo -en "${DGN}Set VLAN Tag To ${BL}$VLAN1${CL}"
|
|
||||||
fi;
|
|
||||||
echo -e " ${CM}${CL} \n"
|
|
||||||
sleep 1
|
|
||||||
clear
|
|
||||||
header_info
|
|
||||||
echo -e "${RD}Using Advanced Settings${CL}"
|
|
||||||
echo -e "${DGN}Using CT Type ${BGN}$CT_TYPE1${CL}"
|
|
||||||
echo -e "${DGN}Using CT Password ${BGN}$PW1${CL}"
|
|
||||||
echo -e "${DGN}Using CT ID ${BGN}$CT_ID${CL}"
|
|
||||||
echo -e "${DGN}Using CT Name ${BGN}$HN${CL}"
|
|
||||||
echo -e "${DGN}Using Disk Size ${BGN}$DISK_SIZE${CL}${DGN}GB${CL}"
|
|
||||||
echo -e "${DGN}Using ${BGN}${CORE_COUNT}${CL}${DGN}vCPU${CL}"
|
|
||||||
echo -e "${DGN}Using ${BGN}${RAM_SIZE}${CL}${DGN}MiB RAM${CL}"
|
|
||||||
echo -e "${DGN}Using Bridge ${BGN}${BRG}${CL}"
|
|
||||||
echo -e "${DGN}Using Static IP Address ${BGN}$NET${CL}"
|
|
||||||
echo -e "${DGN}Using Gateway IP Address ${BGN}$GATE1${CL}"
|
|
||||||
echo -e "${DGN}Using VLAN Tag ${BGN}$VLAN1${CL}"
|
|
||||||
|
|
||||||
read -p "Are these settings correct(y/n)? " -n 1 -r
|
|
||||||
echo
|
|
||||||
if [[ ! $REPLY =~ ^[Yy]$ ]]
|
|
||||||
then
|
|
||||||
advanced_settings
|
|
||||||
fi
|
|
||||||
}
|
|
||||||
|
|
||||||
function start_script() {
|
|
||||||
echo -e "${YW}Type Advanced, or Press [ENTER] for Default Settings "
|
|
||||||
read SETTINGS
|
|
||||||
if [ -z $SETTINGS ]; then default_settings;
|
|
||||||
else
|
|
||||||
advanced_settings
|
|
||||||
fi;
|
|
||||||
}
|
|
||||||
|
|
||||||
start_script
|
|
||||||
|
|
||||||
if [ "$CT_TYPE" == "1" ]; then
|
|
||||||
FEATURES="nesting=1,keyctl=1"
|
|
||||||
else
|
|
||||||
FEATURES="nesting=1"
|
|
||||||
fi
|
|
||||||
|
|
||||||
TEMP_DIR=$(mktemp -d)
|
|
||||||
pushd $TEMP_DIR >/dev/null
|
|
||||||
|
|
||||||
export CTID=$CT_ID
|
|
||||||
export PCT_OSTYPE=debian
|
|
||||||
export PCT_OSVERSION=11
|
|
||||||
export PCT_DISK_SIZE=$DISK_SIZE
|
|
||||||
export PCT_OPTIONS="
|
|
||||||
-features $FEATURES
|
|
||||||
-hostname $HN
|
|
||||||
-net0 name=eth0,bridge=$BRG,ip=$NET$GATE$VLAN
|
|
||||||
-onboot 1
|
|
||||||
-cores $CORE_COUNT
|
|
||||||
-memory $RAM_SIZE
|
|
||||||
-unprivileged $CT_TYPE
|
|
||||||
$PW
|
|
||||||
"
|
|
||||||
bash -c "$(wget -qLO - https://raw.githubusercontent.com/tteck/Proxmox/main/ct/create_lxc.sh)" || exit
|
|
||||||
|
|
||||||
msg_info "Starting LXC Container"
|
|
||||||
pct start $CTID
|
|
||||||
msg_ok "Started LXC Container"
|
|
||||||
|
|
||||||
lxc-attach -n $CTID -- bash -c "$(wget -qLO - https://raw.githubusercontent.com/tteck/Proxmox/main/setup/heimdalldashboard-install.sh)" || exit
|
|
||||||
|
|
||||||
IP=$(pct exec $CTID ip a s dev eth0 | sed -n '/inet / s/\// /p' | awk '{print $2}')
|
|
||||||
|
|
||||||
pct set $CTID -description "# ${APP} LXC
|
|
||||||
### https://github.com/tteck/Proxmox"
|
|
||||||
|
|
||||||
msg_ok "Completed Successfully!\n"
|
|
||||||
echo -e "${APP} should be reachable by going to the following URL.
|
|
||||||
${BL}http://${IP}:7990${CL} \n"
|
|
|
@ -309,7 +309,7 @@ bash -c "$(wget -qLO - https://raw.githubusercontent.com/tteck/Proxmox/main/ct/c
|
||||||
msg_info "Starting LXC Container"
|
msg_info "Starting LXC Container"
|
||||||
pct start $CTID
|
pct start $CTID
|
||||||
msg_ok "Started LXC Container"
|
msg_ok "Started LXC Container"
|
||||||
lxc-attach -n $CTID -- bash -c "$(wget -qLO - https://raw.githubusercontent.com/tteck/Proxmox/main/setup/$var_install.sh)" || exit
|
lxc-attach -n $CTID -- bash -c "$(wget -qLO - https://raw.githubusercontent.com/tteck/Proxmox/main/install/$var_install.sh)" || exit
|
||||||
IP=$(pct exec $CTID ip a s dev eth0 | sed -n '/inet / s/\// /p' | awk '{print $2}')
|
IP=$(pct exec $CTID ip a s dev eth0 | sed -n '/inet / s/\// /p' | awk '{print $2}')
|
||||||
pct set $CTID -description "# ${APP} LXC
|
pct set $CTID -description "# ${APP} LXC
|
||||||
### https://tteck.github.io/Proxmox/
|
### https://tteck.github.io/Proxmox/
|
||||||
|
|
|
@ -324,7 +324,7 @@ fi
|
||||||
msg_info "Starting LXC Container"
|
msg_info "Starting LXC Container"
|
||||||
pct start $CTID
|
pct start $CTID
|
||||||
msg_ok "Started LXC Container"
|
msg_ok "Started LXC Container"
|
||||||
lxc-attach -n $CTID -- bash -c "$(wget -qLO - https://raw.githubusercontent.com/tteck/Proxmox/main/setup/$var_install.sh)" || exit
|
lxc-attach -n $CTID -- bash -c "$(wget -qLO - https://raw.githubusercontent.com/tteck/Proxmox/main/install/$var_install.sh)" || exit
|
||||||
IP=$(pct exec $CTID ip a s dev eth0 | sed -n '/inet / s/\// /p' | awk '{print $2}')
|
IP=$(pct exec $CTID ip a s dev eth0 | sed -n '/inet / s/\// /p' | awk '{print $2}')
|
||||||
pct set $CTID -description "# ${APP} LXC
|
pct set $CTID -description "# ${APP} LXC
|
||||||
### https://tteck.github.io/Proxmox/
|
### https://tteck.github.io/Proxmox/
|
||||||
|
|
|
@ -1,176 +0,0 @@
|
||||||
#!/usr/bin/env bash
|
|
||||||
|
|
||||||
while true; do
|
|
||||||
read -p "This will create a New Home Assistant Container LXC. Proceed(y/n)?" yn
|
|
||||||
case $yn in
|
|
||||||
[Yy]* ) break;;
|
|
||||||
[Nn]* ) exit;;
|
|
||||||
* ) echo "Please answer yes or no.";;
|
|
||||||
esac
|
|
||||||
done
|
|
||||||
set -o errexit
|
|
||||||
set -o errtrace
|
|
||||||
set -o nounset
|
|
||||||
set -o pipefail
|
|
||||||
shopt -s expand_aliases
|
|
||||||
alias die='EXIT=$? LINE=$LINENO error_exit'
|
|
||||||
CHECKMARK='\033[0;32m\xE2\x9C\x94\033[0m'
|
|
||||||
trap die ERR
|
|
||||||
trap cleanup EXIT
|
|
||||||
|
|
||||||
function error_exit() {
|
|
||||||
trap - ERR
|
|
||||||
local DEFAULT='Unknown failure occured.'
|
|
||||||
local REASON="\e[97m${1:-$DEFAULT}\e[39m"
|
|
||||||
local FLAG="\e[91m[ERROR] \e[93m$EXIT@$LINE"
|
|
||||||
msg "$FLAG $REASON"
|
|
||||||
[ ! -z ${CTID-} ] && cleanup_ctid
|
|
||||||
exit $EXIT
|
|
||||||
}
|
|
||||||
function warn() {
|
|
||||||
local REASON="\e[97m$1\e[39m"
|
|
||||||
local FLAG="\e[93m[WARNING]\e[39m"
|
|
||||||
msg "$FLAG $REASON"
|
|
||||||
}
|
|
||||||
function info() {
|
|
||||||
local REASON="$1"
|
|
||||||
local FLAG="\e[36m[INFO]\e[39m"
|
|
||||||
msg "$FLAG $REASON"
|
|
||||||
}
|
|
||||||
function msg() {
|
|
||||||
local TEXT="$1"
|
|
||||||
echo -e "$TEXT"
|
|
||||||
}
|
|
||||||
function cleanup_ctid() {
|
|
||||||
if [ ! -z ${MOUNT+x} ]; then
|
|
||||||
pct unmount $CTID
|
|
||||||
fi
|
|
||||||
if $(pct status $CTID &>/dev/null); then
|
|
||||||
if [ "$(pct status $CTID | awk '{print $2}')" == "running" ]; then
|
|
||||||
pct stop $CTID
|
|
||||||
fi
|
|
||||||
pct destroy $CTID
|
|
||||||
elif [ "$(pvesm list $STORAGE --vmid $CTID)" != "" ]; then
|
|
||||||
pvesm free $ROOTFS
|
|
||||||
fi
|
|
||||||
}
|
|
||||||
function cleanup() {
|
|
||||||
popd >/dev/null
|
|
||||||
rm -rf $TEMP_DIR
|
|
||||||
}
|
|
||||||
function load_module() {
|
|
||||||
if ! $(lsmod | grep -Fq $1); then
|
|
||||||
modprobe $1 &>/dev/null || \
|
|
||||||
die "Failed to load '$1' module."
|
|
||||||
fi
|
|
||||||
MODULES_PATH=/etc/modules
|
|
||||||
if ! $(grep -Fxq "$1" $MODULES_PATH); then
|
|
||||||
echo "$1" >> $MODULES_PATH || \
|
|
||||||
die "Failed to add '$1' module to load at boot."
|
|
||||||
fi
|
|
||||||
}
|
|
||||||
TEMP_DIR=$(mktemp -d)
|
|
||||||
pushd $TEMP_DIR >/dev/null
|
|
||||||
|
|
||||||
wget -qL https://raw.githubusercontent.com/tteck/Proxmox/main/setup/ha_setup.sh
|
|
||||||
|
|
||||||
load_module overlay
|
|
||||||
|
|
||||||
while read -r line; do
|
|
||||||
TAG=$(echo $line | awk '{print $1}')
|
|
||||||
TYPE=$(echo $line | awk '{printf "%-10s", $2}')
|
|
||||||
FREE=$(echo $line | numfmt --field 4-6 --from-unit=K --to=iec --format %.2f | awk '{printf( "%9sB", $6)}')
|
|
||||||
ITEM=" Type: $TYPE Free: $FREE "
|
|
||||||
OFFSET=2
|
|
||||||
if [[ $((${#ITEM} + $OFFSET)) -gt ${MSG_MAX_LENGTH:-} ]]; then
|
|
||||||
MSG_MAX_LENGTH=$((${#ITEM} + $OFFSET))
|
|
||||||
fi
|
|
||||||
STORAGE_MENU+=( "$TAG" "$ITEM" "OFF" )
|
|
||||||
done < <(pvesm status -content rootdir | awk 'NR>1')
|
|
||||||
if [ $((${#STORAGE_MENU[@]}/3)) -eq 0 ]; then
|
|
||||||
warn "'Container' needs to be selected for at least one storage location."
|
|
||||||
die "Unable to detect valid storage location."
|
|
||||||
elif [ $((${#STORAGE_MENU[@]}/3)) -eq 1 ]; then
|
|
||||||
STORAGE=${STORAGE_MENU[0]}
|
|
||||||
else
|
|
||||||
while [ -z "${STORAGE:+x}" ]; do
|
|
||||||
STORAGE=$(whiptail --title "Storage Pools" --radiolist \
|
|
||||||
"Which storage pool you would like to use for the container?\n\n" \
|
|
||||||
16 $(($MSG_MAX_LENGTH + 23)) 6 \
|
|
||||||
"${STORAGE_MENU[@]}" 3>&1 1>&2 2>&3) || exit
|
|
||||||
done
|
|
||||||
fi
|
|
||||||
info "Using '$STORAGE' for storage location."
|
|
||||||
CTID=$(pvesh get /cluster/nextid)
|
|
||||||
info "Container ID is $CTID."
|
|
||||||
|
|
||||||
echo -e "${CHECKMARK} \e[1;92m Updating LXC Template List... \e[0m"
|
|
||||||
pveam update >/dev/null
|
|
||||||
echo -e "${CHECKMARK} \e[1;92m Downloading LXC Template... \e[0m"
|
|
||||||
OSTYPE=debian
|
|
||||||
OSVERSION=${OSTYPE}-11
|
|
||||||
mapfile -t TEMPLATES < <(pveam available -section system | sed -n "s/.*\($OSVERSION.*\)/\1/p" | sort -t - -k 2 -V)
|
|
||||||
TEMPLATE="${TEMPLATES[-1]}"
|
|
||||||
pveam download local $TEMPLATE >/dev/null ||
|
|
||||||
die "A problem occured while downloading the LXC template."
|
|
||||||
|
|
||||||
STORAGE_TYPE=$(pvesm status -storage $STORAGE | awk 'NR>1 {print $2}')
|
|
||||||
case $STORAGE_TYPE in
|
|
||||||
dir|nfs)
|
|
||||||
DISK_EXT=".raw"
|
|
||||||
DISK_REF="$CTID/"
|
|
||||||
;;
|
|
||||||
zfspool)
|
|
||||||
DISK_PREFIX="subvol"
|
|
||||||
DISK_FORMAT="subvol"
|
|
||||||
;;
|
|
||||||
esac
|
|
||||||
DISK=${DISK_PREFIX:-vm}-${CTID}-disk-0${DISK_EXT-}
|
|
||||||
ROOTFS=${STORAGE}:${DISK_REF-}${DISK}
|
|
||||||
|
|
||||||
echo -e "${CHECKMARK} \e[1;92m Creating LXC Container... \e[0m"
|
|
||||||
DISK_SIZE=8G
|
|
||||||
pvesm alloc $STORAGE $CTID $DISK $DISK_SIZE --format ${DISK_FORMAT:-raw} >/dev/null
|
|
||||||
if [ "$STORAGE_TYPE" == "zfspool" ]; then
|
|
||||||
wget -qL -O fuse-overlayfs https://github.com/containers/fuse-overlayfs/releases/download/v1.8.2/fuse-overlayfs-x86_64
|
|
||||||
warn "Some containers may not work properly due to ZFS not supporting 'fallocate'."
|
|
||||||
else
|
|
||||||
mkfs.ext4 $(pvesm path $ROOTFS) &>/dev/null
|
|
||||||
fi
|
|
||||||
ARCH=$(dpkg --print-architecture)
|
|
||||||
HOSTNAME=homeassistant
|
|
||||||
TEMPLATE_STRING="local:vztmpl/${TEMPLATE}"
|
|
||||||
if [ "$STORAGE_TYPE" == "zfspool" ]; then
|
|
||||||
CT_FEATURES="fuse=1,keyctl=1,mknod=1,nesting=1"
|
|
||||||
else
|
|
||||||
CT_FEATURES="nesting=1"
|
|
||||||
fi
|
|
||||||
pct create $CTID $TEMPLATE_STRING -arch $ARCH -features $CT_FEATURES \
|
|
||||||
-hostname $HOSTNAME -net0 name=eth0,bridge=vmbr0,ip=dhcp -onboot 1 -cores 2 -memory 2048 \
|
|
||||||
-ostype $OSTYPE -rootfs $ROOTFS,size=$DISK_SIZE -storage $STORAGE >/dev/null
|
|
||||||
LXC_CONFIG=/etc/pve/lxc/${CTID}.conf
|
|
||||||
cat <<EOF >> $LXC_CONFIG
|
|
||||||
lxc.cgroup2.devices.allow: a
|
|
||||||
lxc.cap.drop:
|
|
||||||
EOF
|
|
||||||
|
|
||||||
MOUNT=$(pct mount $CTID | cut -d"'" -f 2)
|
|
||||||
ln -fs $(readlink /etc/localtime) ${MOUNT}/etc/localtime
|
|
||||||
pct unmount $CTID && unset MOUNT
|
|
||||||
|
|
||||||
echo -e "${CHECKMARK} \e[1;92m Starting LXC Container... \e[0m"
|
|
||||||
pct start $CTID
|
|
||||||
if [ "$STORAGE_TYPE" == "zfspool" ]; then
|
|
||||||
pct push $CTID fuse-overlayfs /usr/local/bin/fuse-overlayfs -perms 755
|
|
||||||
info "Using fuse-overlayfs."
|
|
||||||
fi
|
|
||||||
pct push $CTID ha_setup.sh /ha_setup.sh -perms 755
|
|
||||||
pct exec $CTID /ha_setup.sh
|
|
||||||
IP=$(pct exec $CTID ip a s dev eth0 | sed -n '/inet / s/\// /p' | awk '{print $2}')
|
|
||||||
info "Successfully Created Home Assistant Container LXC to $CTID."
|
|
||||||
msg "
|
|
||||||
|
|
||||||
Home Assistant should be reachable by going to the following URL.
|
|
||||||
|
|
||||||
http://${IP}:8123
|
|
||||||
"
|
|
|
@ -1,316 +0,0 @@
|
||||||
#!/usr/bin/env bash
|
|
||||||
YW=`echo "\033[33m"`
|
|
||||||
BL=`echo "\033[94m"`
|
|
||||||
RD=`echo "\033[01;31m"`
|
|
||||||
CM='\xE2\x9C\x94\033'
|
|
||||||
GN=`echo "\033[1;92m"`
|
|
||||||
CL=`echo "\033[m"`
|
|
||||||
while true; do
|
|
||||||
read -p "This will create a New Home Assistant Container LXC. Proceed(y/n)?" yn
|
|
||||||
case $yn in
|
|
||||||
[Yy]* ) break;;
|
|
||||||
[Nn]* ) exit;;
|
|
||||||
* ) echo "Please answer yes or no.";;
|
|
||||||
esac
|
|
||||||
done
|
|
||||||
clear
|
|
||||||
function header_info {
|
|
||||||
echo -e "${BL}
|
|
||||||
_ _ _ _
|
|
||||||
| | (_) | | | |
|
|
||||||
| |__ ___ _ __ ___ ___ __ _ ___ ___ _ ___| |_ __ _ _ __ | |_
|
|
||||||
| _ \ / _ \| _ _ \ / _ \/ _ / __/ __| / __| __/ _ | _ \| __|
|
|
||||||
| | | | (_) | | | | | | __/ (_| \__ \__ \ \__ \ || (_| | | | | |_
|
|
||||||
|_| |_|\___/|_| |_| |_|\___|\__,_|___/___/_|___/\__\__,_|_| |_|\__|
|
|
||||||
|
|
||||||
${CL}"
|
|
||||||
}
|
|
||||||
|
|
||||||
header_info
|
|
||||||
show_menu(){
|
|
||||||
printf " ${YW} 1)${YW} Privileged ${CL}\n"
|
|
||||||
printf " ${YW} 2)${GN} Unprivileged ${CL}\n"
|
|
||||||
|
|
||||||
printf "Please choose a Install Method and hit enter or ${RD}x${CL} to exit."
|
|
||||||
read opt
|
|
||||||
}
|
|
||||||
|
|
||||||
option_picked(){
|
|
||||||
message1=${@:-"${CL}Error: No message passed"}
|
|
||||||
printf " ${YW}${message1}${CL}\n"
|
|
||||||
}
|
|
||||||
show_menu
|
|
||||||
while [ "$opt" != " " ]
|
|
||||||
do
|
|
||||||
case $opt in
|
|
||||||
1) clear;
|
|
||||||
header_info;
|
|
||||||
option_picked "Using Privileged Install";
|
|
||||||
IM=0
|
|
||||||
break;
|
|
||||||
;;
|
|
||||||
2) clear;
|
|
||||||
header_info;
|
|
||||||
option_picked "Using Unprivileged Install";
|
|
||||||
IM=1
|
|
||||||
break;
|
|
||||||
;;
|
|
||||||
|
|
||||||
x)exit;
|
|
||||||
;;
|
|
||||||
\n)exit;
|
|
||||||
;;
|
|
||||||
*)clear;
|
|
||||||
option_picked "Please choose a Install Method from the menu";
|
|
||||||
show_menu;
|
|
||||||
;;
|
|
||||||
esac
|
|
||||||
done
|
|
||||||
show_menu2(){
|
|
||||||
printf " ${YW} 1)${GN} Use Automatic Login ${CL}\n"
|
|
||||||
printf " ${YW} 2)${GN} Use Password (changeme) ${CL}\n"
|
|
||||||
|
|
||||||
printf "Please choose a Password Type and hit enter or ${RD}x${CL} to exit."
|
|
||||||
read opt
|
|
||||||
}
|
|
||||||
|
|
||||||
option_picked(){
|
|
||||||
message2=${@:-"${CL}Error: No message passed"}
|
|
||||||
printf " ${YW}${message1}${CL}\n"
|
|
||||||
printf " ${YW}${message2}${CL}\n"
|
|
||||||
}
|
|
||||||
show_menu2
|
|
||||||
while [ "$opt" != " " ]
|
|
||||||
do
|
|
||||||
case $opt in
|
|
||||||
1) clear;
|
|
||||||
header_info;
|
|
||||||
option_picked "Using Automatic Login";
|
|
||||||
PW=" "
|
|
||||||
break;
|
|
||||||
;;
|
|
||||||
2) clear;
|
|
||||||
header_info;
|
|
||||||
option_picked "Using Password (changeme)";
|
|
||||||
PW="-password changeme"
|
|
||||||
break;
|
|
||||||
;;
|
|
||||||
|
|
||||||
x)exit;
|
|
||||||
;;
|
|
||||||
\n)exit;
|
|
||||||
;;
|
|
||||||
*)clear;
|
|
||||||
option_picked "Please choose a Password Type from the menu";
|
|
||||||
show_menu2;
|
|
||||||
;;
|
|
||||||
esac
|
|
||||||
done
|
|
||||||
show_menu3(){
|
|
||||||
printf " ${RD} If Using ZFS, You Have Storage Driver Options${CL}\n"
|
|
||||||
printf " ${RD} Non ZFS, Select Standard overlay2 Storage Driver${CL}\n"
|
|
||||||
printf " ${YW} 1)${GN} Use fuse-overlayfs Storage Driver${CL}\n"
|
|
||||||
printf " ${YW} 2)${GN} Use Standard overlay2 Storage Driver${CL}\n"
|
|
||||||
|
|
||||||
printf "Please choose a Storage Driver and hit enter or ${RD}x${CL} to exit."
|
|
||||||
read opt
|
|
||||||
}
|
|
||||||
|
|
||||||
option_picked(){
|
|
||||||
message3=${@:-"${CL}Error: No message passed"}
|
|
||||||
printf " ${YW}${message1}${CL}\n"
|
|
||||||
printf " ${YW}${message2}${CL}\n"
|
|
||||||
printf " ${YW}${message3}${CL}\n"
|
|
||||||
}
|
|
||||||
show_menu3
|
|
||||||
while [ "$opt" != " " ]
|
|
||||||
do
|
|
||||||
case $opt in
|
|
||||||
1) clear;
|
|
||||||
header_info;
|
|
||||||
option_picked "Using fuse-overlayfs Storage Driver";
|
|
||||||
STORAGE_DRIVER="fuse"
|
|
||||||
break;
|
|
||||||
;;
|
|
||||||
2) clear;
|
|
||||||
header_info;
|
|
||||||
option_picked "Using overlay2 Storage Driver";
|
|
||||||
STORAGE_DRIVER=" "
|
|
||||||
break;
|
|
||||||
;;
|
|
||||||
|
|
||||||
x)exit;
|
|
||||||
;;
|
|
||||||
\n)exit;
|
|
||||||
;;
|
|
||||||
*)clear;
|
|
||||||
option_picked "Please choose a Storage Driver from the menu";
|
|
||||||
show_menu3;
|
|
||||||
;;
|
|
||||||
esac
|
|
||||||
done
|
|
||||||
show_menu4(){
|
|
||||||
printf " ${YW} 1)${GN} Automatic DHCP ${CL}\n"
|
|
||||||
printf " ${YW} 2)${GN} Manual DHCP ${CL}\n"
|
|
||||||
|
|
||||||
printf "Please choose a DHCP Type and hit enter or ${RD}x${CL} to exit."
|
|
||||||
read opt
|
|
||||||
}
|
|
||||||
|
|
||||||
option_picked(){
|
|
||||||
message4=${@:-"${CL}Error: No message passed"}
|
|
||||||
printf " ${YW}${message1}${CL}\n"
|
|
||||||
printf " ${YW}${message2}${CL}\n"
|
|
||||||
printf " ${YW}${message3}${CL}\n"
|
|
||||||
printf " ${YW}${message4}${CL}\n"
|
|
||||||
}
|
|
||||||
show_menu4
|
|
||||||
while [ "$opt" != " " ]
|
|
||||||
do
|
|
||||||
case $opt in
|
|
||||||
1) clear;
|
|
||||||
header_info;
|
|
||||||
option_picked "Using Automatic DHCP";
|
|
||||||
DHCP=" "
|
|
||||||
break;
|
|
||||||
;;
|
|
||||||
2) clear;
|
|
||||||
header_info;
|
|
||||||
option_picked "Using Manual DHCP";
|
|
||||||
DHCP="1"
|
|
||||||
break;
|
|
||||||
;;
|
|
||||||
|
|
||||||
x)exit;
|
|
||||||
;;
|
|
||||||
\n)exit;
|
|
||||||
;;
|
|
||||||
*)clear;
|
|
||||||
option_picked "Please choose a DHCP Type from the menu";
|
|
||||||
show_menu4;
|
|
||||||
;;
|
|
||||||
esac
|
|
||||||
done
|
|
||||||
|
|
||||||
set -o errexit
|
|
||||||
set -o errtrace
|
|
||||||
set -o nounset
|
|
||||||
set -o pipefail
|
|
||||||
shopt -s expand_aliases
|
|
||||||
alias die='EXIT=$? LINE=$LINENO error_exit'
|
|
||||||
trap die ERR
|
|
||||||
trap cleanup EXIT
|
|
||||||
|
|
||||||
function error_exit() {
|
|
||||||
trap - ERR
|
|
||||||
local DEFAULT='Unknown failure occured.'
|
|
||||||
local REASON="\e[97m${1:-$DEFAULT}\e[39m"
|
|
||||||
local FLAG="\e[91m[ERROR] \e[93m$EXIT@$LINE"
|
|
||||||
msg "$FLAG $REASON"
|
|
||||||
[ ! -z ${CTID-} ] && cleanup_ctid
|
|
||||||
exit $EXIT
|
|
||||||
}
|
|
||||||
function warn() {
|
|
||||||
local REASON="\e[97m$1\e[39m"
|
|
||||||
local FLAG="\e[93m[WARNING]\e[39m"
|
|
||||||
msg "$FLAG $REASON"
|
|
||||||
}
|
|
||||||
function info() {
|
|
||||||
local REASON="$1"
|
|
||||||
local FLAG="\e[36m[INFO]\e[39m"
|
|
||||||
msg "$FLAG $REASON"
|
|
||||||
}
|
|
||||||
function msg() {
|
|
||||||
local TEXT="$1"
|
|
||||||
echo -e "$TEXT"
|
|
||||||
}
|
|
||||||
function cleanup_ctid() {
|
|
||||||
if $(pct status $CTID &>/dev/null); then
|
|
||||||
if [ "$(pct status $CTID | awk '{print $2}')" == "running" ]; then
|
|
||||||
pct stop $CTID
|
|
||||||
fi
|
|
||||||
pct destroy $CTID
|
|
||||||
elif [ "$(pvesm list $STORAGE --vmid $CTID)" != "" ]; then
|
|
||||||
pvesm free $ROOTFS
|
|
||||||
fi
|
|
||||||
}
|
|
||||||
function cleanup() {
|
|
||||||
popd >/dev/null
|
|
||||||
rm -rf $TEMP_DIR
|
|
||||||
}
|
|
||||||
if [ "$IM" == "1" ] && [ "$STORAGE_DRIVER" == " " ]; then
|
|
||||||
FEATURES="nesting=1,keyctl=1"
|
|
||||||
elif
|
|
||||||
[ "$IM" == "1" ] && [ "$STORAGE_DRIVER" == "fuse" ]; then
|
|
||||||
FEATURES="nesting=1,keyctl=1,fuse=1"
|
|
||||||
elif
|
|
||||||
[ "$IM" == "0" ] && [ "$STORAGE_DRIVER" == "fuse" ]; then
|
|
||||||
FEATURES="nesting=1,fuse=1"
|
|
||||||
else
|
|
||||||
FEATURES="nesting=1"
|
|
||||||
fi
|
|
||||||
|
|
||||||
TEMP_DIR=$(mktemp -d)
|
|
||||||
pushd $TEMP_DIR >/dev/null
|
|
||||||
|
|
||||||
export CTID=$(pvesh get /cluster/nextid)
|
|
||||||
export PCT_OSTYPE=debian
|
|
||||||
export PCT_OSVERSION=11
|
|
||||||
export PCT_DISK_SIZE=16
|
|
||||||
export PCT_OPTIONS="
|
|
||||||
-features $FEATURES
|
|
||||||
-hostname homeassistant
|
|
||||||
-net0 name=eth0,bridge=vmbr0,ip=dhcp
|
|
||||||
-onboot 1
|
|
||||||
-cores 2
|
|
||||||
-memory 2048
|
|
||||||
-unprivileged ${IM}
|
|
||||||
${PW}
|
|
||||||
"
|
|
||||||
bash -c "$(wget -qLO - https://raw.githubusercontent.com/tteck/Proxmox/main/ct/create_lxc.sh)" || exit
|
|
||||||
|
|
||||||
STORAGE_TYPE=$(pvesm status -storage $(pct config $CTID | grep rootfs | awk -F ":" '{print $2}') | awk 'NR>1 {print $2}')
|
|
||||||
if [ "$STORAGE_TYPE" == "zfspool" ]; then
|
|
||||||
wget -qL -O fuse-overlayfs https://github.com/containers/fuse-overlayfs/releases/download/v1.8.2/fuse-overlayfs-x86_64
|
|
||||||
warn "Some containers may not work properly due to ZFS not supporting 'fallocate'."
|
|
||||||
fi
|
|
||||||
LXC_CONFIG=/etc/pve/lxc/${CTID}.conf
|
|
||||||
cat <<EOF >> $LXC_CONFIG
|
|
||||||
lxc.cgroup2.devices.allow: a
|
|
||||||
lxc.cap.drop:
|
|
||||||
EOF
|
|
||||||
if [ "$DHCP" == "1" ]; then
|
|
||||||
MAC=$(pct config $CTID \
|
|
||||||
| grep -i hwaddr \
|
|
||||||
| awk '{print substr($2, 31, length($3) 17 ) }') \
|
|
||||||
|
|
||||||
echo -e "MAC Address ${BL}$MAC${CL}"
|
|
||||||
|
|
||||||
dhcp_reservation(){
|
|
||||||
printf "Please set DHCP reservation and press Enter."
|
|
||||||
read
|
|
||||||
}
|
|
||||||
dhcp_reservation
|
|
||||||
fi
|
|
||||||
|
|
||||||
echo -en "${GN} Starting LXC Container... "
|
|
||||||
pct start $CTID
|
|
||||||
echo -e "${CM}${CL} \r"
|
|
||||||
|
|
||||||
if [ "$STORAGE_TYPE" == "zfspool" ] && [ "$STORAGE_DRIVER" == "fuse" ]; then
|
|
||||||
pct push $CTID fuse-overlayfs /usr/local/bin/fuse-overlayfs -perms 755
|
|
||||||
info "Using ${BL}fuse-overlayfs${CL} Storage Driver."
|
|
||||||
else
|
|
||||||
info "Using ${BL}overlay2${CL} Storage Driver."
|
|
||||||
fi
|
|
||||||
|
|
||||||
alias lxc-cmd="lxc-attach -n $CTID --"
|
|
||||||
|
|
||||||
lxc-cmd bash -c "$(wget -qLO - https://raw.githubusercontent.com/tteck/Proxmox/main/setup/homeassistant-install.sh)" || exit
|
|
||||||
|
|
||||||
IP=$(pct exec $CTID ip a s dev eth0 | sed -n '/inet / s/\// /p' | awk '{print $2}')
|
|
||||||
|
|
||||||
echo -e "${GN}Successfully created Home Assistant Container LXC to${CL} ${BL}$CTID${CL}.
|
|
||||||
${BL}Home Assistant${CL} should be reachable by going to the following URL.
|
|
||||||
|
|
||||||
${BL}http://${IP}:8123${CL} \n"
|
|
|
@ -1,365 +0,0 @@
|
||||||
#!/usr/bin/env bash
|
|
||||||
echo -e "Loading..."
|
|
||||||
NEXTID=$(pvesh get /cluster/nextid)
|
|
||||||
INTEGER='^[0-9]+$'
|
|
||||||
YW=`echo "\033[33m"`
|
|
||||||
BL=`echo "\033[36m"`
|
|
||||||
RD=`echo "\033[01;31m"`
|
|
||||||
BGN=`echo "\033[4;92m"`
|
|
||||||
GN=`echo "\033[1;92m"`
|
|
||||||
DGN=`echo "\033[32m"`
|
|
||||||
CL=`echo "\033[m"`
|
|
||||||
BFR="\\r\\033[K"
|
|
||||||
HOLD="-"
|
|
||||||
CM="${GN}✓${CL}"
|
|
||||||
APP="Home Assistant"
|
|
||||||
NSAPP=$(echo ${APP,,} | tr -d ' ')
|
|
||||||
set -o errexit
|
|
||||||
set -o errtrace
|
|
||||||
set -o nounset
|
|
||||||
set -o pipefail
|
|
||||||
shopt -s expand_aliases
|
|
||||||
alias die='EXIT=$? LINE=$LINENO error_exit'
|
|
||||||
trap die ERR
|
|
||||||
|
|
||||||
function error_exit() {
|
|
||||||
trap - ERR
|
|
||||||
local reason="Unknown failure occurred."
|
|
||||||
local msg="${1:-$reason}"
|
|
||||||
local flag="${RD}‼ ERROR ${CL}$EXIT@$LINE"
|
|
||||||
echo -e "$flag $msg" 1>&2
|
|
||||||
exit $EXIT
|
|
||||||
}
|
|
||||||
|
|
||||||
while true; do
|
|
||||||
clear
|
|
||||||
read -p "This will create a New ${APP} LXC. Proceed(y/n)?" yn
|
|
||||||
case $yn in
|
|
||||||
[Yy]* ) break;;
|
|
||||||
[Nn]* ) exit;;
|
|
||||||
* ) echo "Please answer yes or no.";;
|
|
||||||
esac
|
|
||||||
done
|
|
||||||
clear
|
|
||||||
function header_info {
|
|
||||||
echo -e "${BL}
|
|
||||||
_ _ _ _
|
|
||||||
| | ${YW}v3${CL}${BL} (_) | | | |
|
|
||||||
| |__ ___ _ __ ___ ___ __ _ ___ ___ _ ___| |_ __ _ _ __ | |_
|
|
||||||
| _ \ / _ \| _ _ \ / _ \/ _ / __/ __| / __| __/ _ | _ \| __|
|
|
||||||
| | | | (_) | | | | | | __/ (_| \__ \__ \ \__ \ || (_| | | | | |_
|
|
||||||
|_| |_|\___/|_| |_| |_|\___|\__,_|___/___/_|___/\__\__,_|_| |_|\__|
|
|
||||||
${CL}"
|
|
||||||
}
|
|
||||||
|
|
||||||
header_info
|
|
||||||
|
|
||||||
function msg_info() {
|
|
||||||
local msg="$1"
|
|
||||||
echo -ne " ${HOLD} ${YW}${msg}..."
|
|
||||||
}
|
|
||||||
|
|
||||||
function msg_ok() {
|
|
||||||
local msg="$1"
|
|
||||||
echo -e "${BFR} ${CM} ${GN}${msg}${CL}"
|
|
||||||
}
|
|
||||||
|
|
||||||
function PVE_CHECK() {
|
|
||||||
PVE=$(pveversion | grep "pve-manager/7" | wc -l)
|
|
||||||
|
|
||||||
if [[ $PVE != 1 ]]; then
|
|
||||||
echo -e "${RD}This script requires Proxmox Virtual Environment 7.0 or greater${CL}"
|
|
||||||
echo -e "Exiting..."
|
|
||||||
sleep 2
|
|
||||||
exit
|
|
||||||
fi
|
|
||||||
}
|
|
||||||
|
|
||||||
function default_settings() {
|
|
||||||
clear
|
|
||||||
header_info
|
|
||||||
echo -e "${BL}Using Default Settings${CL}"
|
|
||||||
echo -e "${DGN}Using CT Type ${BGN}Unprivileged${CL} ${RD}NO DEVICE PASSTHROUGH${CL}"
|
|
||||||
CT_TYPE="1"
|
|
||||||
echo -e "${DGN}Using CT Password ${BGN}Automatic Login${CL}"
|
|
||||||
PW=" "
|
|
||||||
echo -e "${DGN}Using CT ID ${BGN}$NEXTID${CL}"
|
|
||||||
CT_ID=$NEXTID
|
|
||||||
echo -e "${DGN}Using CT Name ${BGN}$NSAPP${CL}"
|
|
||||||
HN=$NSAPP
|
|
||||||
echo -e "${DGN}Using Disk Size ${BGN}16${CL}${DGN}GB${CL}"
|
|
||||||
DISK_SIZE="16"
|
|
||||||
echo -e "${DGN}Using ${BGN}2${CL}${DGN}vCPU${CL}"
|
|
||||||
CORE_COUNT="2"
|
|
||||||
echo -e "${DGN}Using ${BGN}2048${CL}${DGN}MiB RAM${CL}"
|
|
||||||
RAM_SIZE="2048"
|
|
||||||
echo -e "${DGN}Using Bridge ${BGN}vmbr0${CL}"
|
|
||||||
BRG="vmbr0"
|
|
||||||
echo -e "${DGN}Using Static IP Address ${BGN}DHCP${CL}"
|
|
||||||
NET=dhcp
|
|
||||||
echo -e "${DGN}Using Gateway Address ${BGN}NONE${CL}"
|
|
||||||
GATE=""
|
|
||||||
echo -e "${DGN}Using VLAN Tag ${BGN}NONE${CL}"
|
|
||||||
VLAN=""
|
|
||||||
}
|
|
||||||
|
|
||||||
function advanced_settings() {
|
|
||||||
clear
|
|
||||||
header_info
|
|
||||||
echo -e "${RD}Using Advanced Settings${CL}"
|
|
||||||
echo -e "${YW}Type Privileged, or Press [ENTER] for Default: Unprivileged (${RD}NO DEVICE PASSTHROUGH${CL}${YW})"
|
|
||||||
read CT_TYPE1
|
|
||||||
if [ -z $CT_TYPE1 ]; then CT_TYPE1="Unprivileged" CT_TYPE="1";
|
|
||||||
echo -en "${DGN}Set CT Type ${BL}$CT_TYPE1${CL}"
|
|
||||||
else
|
|
||||||
CT_TYPE1="Privileged"
|
|
||||||
CT_TYPE="0"
|
|
||||||
echo -en "${DGN}Set CT Type ${BL}Privileged${CL}"
|
|
||||||
fi;
|
|
||||||
echo -e " ${CM}${CL} \r"
|
|
||||||
sleep 1
|
|
||||||
clear
|
|
||||||
header_info
|
|
||||||
echo -e "${RD}Using Advanced Settings${CL}"
|
|
||||||
echo -e "${DGN}Using CT Type ${BGN}$CT_TYPE1${CL}"
|
|
||||||
echo -e "${YW}Set Password, or Press [ENTER] for Default: Automatic Login "
|
|
||||||
read PW1
|
|
||||||
if [ -z $PW1 ]; then PW1="Automatic Login" PW=" ";
|
|
||||||
echo -en "${DGN}Set CT ${BL}$PW1${CL}"
|
|
||||||
else
|
|
||||||
PW="-password $PW1"
|
|
||||||
echo -en "${DGN}Set CT Password ${BL}$PW1${CL}"
|
|
||||||
fi;
|
|
||||||
echo -e " ${CM}${CL} \r"
|
|
||||||
sleep 1
|
|
||||||
clear
|
|
||||||
header_info
|
|
||||||
echo -e "${RD}Using Advanced Settings${CL}"
|
|
||||||
echo -e "${DGN}Using CT Type ${BGN}$CT_TYPE1${CL}"
|
|
||||||
echo -e "${DGN}Using CT Password ${BGN}$PW1${CL}"
|
|
||||||
echo -e "${YW}Enter the CT ID, or Press [ENTER] to automatically generate (${NEXTID}) "
|
|
||||||
read CT_ID
|
|
||||||
if [ -z $CT_ID ]; then CT_ID=$NEXTID; fi;
|
|
||||||
echo -en "${DGN}Set CT ID To ${BL}$CT_ID${CL}"
|
|
||||||
echo -e " ${CM}${CL} \r"
|
|
||||||
sleep 1
|
|
||||||
clear
|
|
||||||
header_info
|
|
||||||
echo -e "${RD}Using Advanced Settings${CL}"
|
|
||||||
echo -e "${DGN}Using CT Type ${BGN}$CT_TYPE1${CL}"
|
|
||||||
echo -e "${DGN}Using CT Password ${BGN}$PW1${CL}"
|
|
||||||
echo -e "${DGN}Using CT ID ${BGN}$CT_ID${CL}"
|
|
||||||
echo -e "${YW}Enter CT Name (no-spaces), or Press [ENTER] for Default: $NSAPP "
|
|
||||||
read CT_NAME
|
|
||||||
if [ -z $CT_NAME ]; then
|
|
||||||
HN=$NSAPP
|
|
||||||
else
|
|
||||||
HN=$(echo ${CT_NAME,,} | tr -d ' ')
|
|
||||||
fi
|
|
||||||
echo -en "${DGN}Set CT Name To ${BL}$HN${CL}"
|
|
||||||
echo -e " ${CM}${CL} \r"
|
|
||||||
sleep 1
|
|
||||||
clear
|
|
||||||
header_info
|
|
||||||
echo -e "${RD}Using Advanced Settings${CL}"
|
|
||||||
echo -e "${DGN}Using CT Type ${BGN}$CT_TYPE1${CL}"
|
|
||||||
echo -e "${DGN}Using CT Password ${BGN}$PW1${CL}"
|
|
||||||
echo -e "${DGN}Using CT ID ${BGN}$CT_ID${CL}"
|
|
||||||
echo -e "${DGN}Using CT Name ${BGN}$HN${CL}"
|
|
||||||
echo -e "${YW}Enter a Disk Size, or Press [ENTER] for Default: 16 "
|
|
||||||
read DISK_SIZE
|
|
||||||
if [ -z $DISK_SIZE ]; then DISK_SIZE="16"; fi;
|
|
||||||
if ! [[ $DISK_SIZE =~ $INTEGER ]] ; then echo "ERROR! DISK SIZE MUST HAVE INTEGER NUMBER!"; exit; fi;
|
|
||||||
echo -en "${DGN}Set Disk Size To ${BL}$DISK_SIZE${CL}${DGN}GB${CL}"
|
|
||||||
echo -e " ${CM}${CL} \r"
|
|
||||||
sleep 1
|
|
||||||
clear
|
|
||||||
header_info
|
|
||||||
echo -e "${RD}Using Advanced Settings${CL}"
|
|
||||||
echo -e "${DGN}Using CT Type ${BGN}$CT_TYPE1${CL}"
|
|
||||||
echo -e "${DGN}Using CT Password ${BGN}$PW1${CL}"
|
|
||||||
echo -e "${DGN}Using CT ID ${BGN}$CT_ID${CL}"
|
|
||||||
echo -e "${DGN}Using CT Name ${BGN}$HN${CL}"
|
|
||||||
echo -e "${DGN}Using Disk Size ${BGN}$DISK_SIZE${CL}${DGN}GB${CL}"
|
|
||||||
echo -e "${YW}Allocate CPU cores, or Press [ENTER] for Default: 2 "
|
|
||||||
read CORE_COUNT
|
|
||||||
if [ -z $CORE_COUNT ]; then CORE_COUNT="2"; fi;
|
|
||||||
echo -en "${DGN}Set Cores To ${BL}$CORE_COUNT${CL}${DGN}vCPU${CL}"
|
|
||||||
echo -e " ${CM}${CL} \r"
|
|
||||||
sleep 1
|
|
||||||
clear
|
|
||||||
header_info
|
|
||||||
echo -e "${RD}Using Advanced Settings${CL}"
|
|
||||||
echo -e "${DGN}Using CT Type ${BGN}$CT_TYPE1${CL}"
|
|
||||||
echo -e "${DGN}Using CT Password ${BGN}$PW1${CL}"
|
|
||||||
echo -e "${DGN}Using CT ID ${BGN}$CT_ID${CL}"
|
|
||||||
echo -e "${DGN}Using CT Name ${BGN}$HN${CL}"
|
|
||||||
echo -e "${DGN}Using Disk Size ${BGN}$DISK_SIZE${CL}${DGN}GB${CL}"
|
|
||||||
echo -e "${DGN}Using ${BGN}${CORE_COUNT}${CL}${DGN}vCPU${CL}"
|
|
||||||
echo -e "${YW}Allocate RAM in MiB, or Press [ENTER] for Default: 2048 "
|
|
||||||
read RAM_SIZE
|
|
||||||
if [ -z $RAM_SIZE ]; then RAM_SIZE="2048"; fi;
|
|
||||||
echo -en "${DGN}Set RAM To ${BL}$RAM_SIZE${CL}${DGN}MiB RAM${CL}"
|
|
||||||
echo -e " ${CM}${CL} \n"
|
|
||||||
sleep 1
|
|
||||||
clear
|
|
||||||
header_info
|
|
||||||
echo -e "${RD}Using Advanced Settings${CL}"
|
|
||||||
echo -e "${DGN}Using CT Type ${BGN}$CT_TYPE1${CL}"
|
|
||||||
echo -e "${DGN}Using CT Password ${BGN}$PW1${CL}"
|
|
||||||
echo -e "${DGN}Using CT ID ${BGN}$CT_ID${CL}"
|
|
||||||
echo -e "${DGN}Using CT Name ${BGN}$HN${CL}"
|
|
||||||
echo -e "${DGN}Using Disk Size ${BGN}$DISK_SIZE${CL}${DGN}GB${CL}"
|
|
||||||
echo -e "${DGN}Using ${BGN}${CORE_COUNT}${CL}${DGN}vCPU${CL}"
|
|
||||||
echo -e "${DGN}Using ${BGN}${RAM_SIZE}${CL}${DGN}MiB RAM${CL}"
|
|
||||||
echo -e "${YW}Enter a Bridge, or Press [ENTER] for Default: vmbr0 "
|
|
||||||
read BRG
|
|
||||||
if [ -z $BRG ]; then BRG="vmbr0"; fi;
|
|
||||||
echo -en "${DGN}Set Bridge To ${BL}$BRG${CL}"
|
|
||||||
echo -e " ${CM}${CL} \n"
|
|
||||||
sleep 1
|
|
||||||
clear
|
|
||||||
header_info
|
|
||||||
echo -e "${RD}Using Advanced Settings${CL}"
|
|
||||||
echo -e "${DGN}Using CT Type ${BGN}$CT_TYPE1${CL}"
|
|
||||||
echo -e "${DGN}Using CT Password ${BGN}$PW1${CL}"
|
|
||||||
echo -e "${DGN}Using CT ID ${BGN}$CT_ID${CL}"
|
|
||||||
echo -e "${DGN}Using CT Name ${BGN}$HN${CL}"
|
|
||||||
echo -e "${DGN}Using Disk Size ${BGN}$DISK_SIZE${CL}${DGN}GB${CL}"
|
|
||||||
echo -e "${DGN}Using ${BGN}${CORE_COUNT}${CL}${DGN}vCPU${CL}"
|
|
||||||
echo -e "${DGN}Using ${BGN}${RAM_SIZE}${CL}${DGN}MiB RAM${CL}"
|
|
||||||
echo -e "${DGN}Using Bridge ${BGN}${BRG}${CL}"
|
|
||||||
echo -e "${YW}Enter a Static IPv4 CIDR Address, or Press [ENTER] for Default: DHCP "
|
|
||||||
read NET
|
|
||||||
if [ -z $NET ]; then NET="dhcp"; fi;
|
|
||||||
echo -en "${DGN}Set Static IP Address To ${BL}$NET${CL}"
|
|
||||||
echo -e " ${CM}${CL} \n"
|
|
||||||
sleep 1
|
|
||||||
clear
|
|
||||||
header_info
|
|
||||||
echo -e "${RD}Using Advanced Settings${CL}"
|
|
||||||
echo -e "${DGN}Using CT Type ${BGN}$CT_TYPE1${CL}"
|
|
||||||
echo -e "${DGN}Using CT Password ${BGN}$PW1${CL}"
|
|
||||||
echo -e "${DGN}Using CT ID ${BGN}$CT_ID${CL}"
|
|
||||||
echo -e "${DGN}Using CT Name ${BGN}$HN${CL}"
|
|
||||||
echo -e "${DGN}Using Disk Size ${BGN}$DISK_SIZE${CL}${DGN}GB${CL}"
|
|
||||||
echo -e "${DGN}Using ${BGN}${CORE_COUNT}${CL}${DGN}vCPU${CL}"
|
|
||||||
echo -e "${DGN}Using ${BGN}${RAM_SIZE}${CL}${DGN}MiB RAM${CL}"
|
|
||||||
echo -e "${DGN}Using Bridge ${BGN}${BRG}${CL}"
|
|
||||||
echo -e "${DGN}Using Static IP Address ${BGN}$NET${CL}"
|
|
||||||
echo -e "${YW}Enter a Gateway IP (mandatory if static IP is used), or Press [ENTER] for Default: NONE "
|
|
||||||
read GATE1
|
|
||||||
if [ -z $GATE1 ]; then GATE1="NONE" GATE="";
|
|
||||||
echo -en "${DGN}Set Gateway IP To ${BL}$GATE1${CL}"
|
|
||||||
else
|
|
||||||
GATE=",gw=$GATE1"
|
|
||||||
echo -en "${DGN}Set Gateway IP To ${BL}$GATE1${CL}"
|
|
||||||
fi;
|
|
||||||
echo -e " ${CM}${CL} \n"
|
|
||||||
sleep 1
|
|
||||||
clear
|
|
||||||
header_info
|
|
||||||
|
|
||||||
echo -e "${RD}Using Advanced Settings${CL}"
|
|
||||||
echo -e "${DGN}Using CT Type ${BGN}$CT_TYPE1${CL}"
|
|
||||||
echo -e "${DGN}Using CT Password ${BGN}$PW1${CL}"
|
|
||||||
echo -e "${DGN}Using CT ID ${BGN}$CT_ID${CL}"
|
|
||||||
echo -e "${DGN}Using CT Name ${BGN}$HN${CL}"
|
|
||||||
echo -e "${DGN}Using Disk Size ${BGN}$DISK_SIZE${CL}${DGN}GB${CL}"
|
|
||||||
echo -e "${DGN}Using ${BGN}${CORE_COUNT}${CL}${DGN}vCPU${CL}"
|
|
||||||
echo -e "${DGN}Using ${BGN}${RAM_SIZE}${CL}${DGN}MiB RAM${CL}"
|
|
||||||
echo -e "${DGN}Using Bridge ${BGN}${BRG}${CL}"
|
|
||||||
echo -e "${DGN}Using Static IP Address ${BGN}$NET${CL}"
|
|
||||||
echo -e "${DGN}Using Gateway IP Address ${BGN}$GATE1${CL}"
|
|
||||||
echo -e "${YW}Enter a VLAN Tag, or Press [ENTER] for Default: NONE "
|
|
||||||
read VLAN1
|
|
||||||
if [ -z $VLAN1 ]; then VLAN1="NONE" VLAN="";
|
|
||||||
echo -en "${DGN}Set VLAN Tag To ${BL}$VLAN1${CL}"
|
|
||||||
else
|
|
||||||
VLAN=",tag=$VLAN1"
|
|
||||||
echo -en "${DGN}Set VLAN Tag To ${BL}$VLAN1${CL}"
|
|
||||||
fi;
|
|
||||||
echo -e " ${CM}${CL} \n"
|
|
||||||
sleep 1
|
|
||||||
clear
|
|
||||||
header_info
|
|
||||||
echo -e "${RD}Using Advanced Settings${CL}"
|
|
||||||
echo -e "${DGN}Using CT Type ${BGN}$CT_TYPE1${CL}"
|
|
||||||
echo -e "${DGN}Using CT Password ${BGN}$PW1${CL}"
|
|
||||||
echo -e "${DGN}Using CT ID ${BGN}$CT_ID${CL}"
|
|
||||||
echo -e "${DGN}Using CT Name ${BGN}$HN${CL}"
|
|
||||||
echo -e "${DGN}Using Disk Size ${BGN}$DISK_SIZE${CL}${DGN}GB${CL}"
|
|
||||||
echo -e "${DGN}Using ${BGN}${CORE_COUNT}${CL}${DGN}vCPU${CL}"
|
|
||||||
echo -e "${DGN}Using ${BGN}${RAM_SIZE}${CL}${DGN}MiB RAM${CL}"
|
|
||||||
echo -e "${DGN}Using Bridge ${BGN}${BRG}${CL}"
|
|
||||||
echo -e "${DGN}Using Static IP Address ${BGN}$NET${CL}"
|
|
||||||
echo -e "${DGN}Using Gateway IP Address ${BGN}$GATE1${CL}"
|
|
||||||
echo -e "${DGN}Using VLAN Tag ${BGN}$VLAN1${CL}"
|
|
||||||
|
|
||||||
read -p "Are these settings correct(y/n)? " -n 1 -r
|
|
||||||
echo
|
|
||||||
if [[ ! $REPLY =~ ^[Yy]$ ]]
|
|
||||||
then
|
|
||||||
advanced_settings
|
|
||||||
fi
|
|
||||||
}
|
|
||||||
|
|
||||||
function start_script() {
|
|
||||||
echo -e "${YW}Type Advanced, or Press [ENTER] for Default Settings "
|
|
||||||
read SETTINGS
|
|
||||||
if [ -z $SETTINGS ]; then default_settings;
|
|
||||||
else
|
|
||||||
advanced_settings
|
|
||||||
fi;
|
|
||||||
}
|
|
||||||
|
|
||||||
PVE_CHECK
|
|
||||||
start_script
|
|
||||||
|
|
||||||
if [ "$CT_TYPE" == "1" ]; then
|
|
||||||
FEATURES="nesting=1,keyctl=1"
|
|
||||||
else
|
|
||||||
FEATURES="nesting=1"
|
|
||||||
fi
|
|
||||||
|
|
||||||
TEMP_DIR=$(mktemp -d)
|
|
||||||
pushd $TEMP_DIR >/dev/null
|
|
||||||
|
|
||||||
export CTID=$CT_ID
|
|
||||||
export PCT_OSTYPE=debian
|
|
||||||
export PCT_OSVERSION=11
|
|
||||||
export PCT_DISK_SIZE=$DISK_SIZE
|
|
||||||
export PCT_OPTIONS="
|
|
||||||
-features $FEATURES
|
|
||||||
-hostname $HN
|
|
||||||
-net0 name=eth0,bridge=$BRG,ip=$NET$GATE$VLAN
|
|
||||||
-onboot 1
|
|
||||||
-cores $CORE_COUNT
|
|
||||||
-memory $RAM_SIZE
|
|
||||||
-unprivileged $CT_TYPE
|
|
||||||
$PW
|
|
||||||
"
|
|
||||||
bash -c "$(wget -qLO - https://raw.githubusercontent.com/tteck/Proxmox/main/ct/create_lxc.sh)" || exit
|
|
||||||
|
|
||||||
LXC_CONFIG=/etc/pve/lxc/${CTID}.conf
|
|
||||||
cat <<EOF >> $LXC_CONFIG
|
|
||||||
lxc.cgroup2.devices.allow: a
|
|
||||||
lxc.cap.drop:
|
|
||||||
EOF
|
|
||||||
|
|
||||||
msg_info "Starting LXC Container"
|
|
||||||
pct start $CTID
|
|
||||||
msg_ok "Started LXC Container"
|
|
||||||
|
|
||||||
lxc-attach -n $CTID -- bash -c "$(wget -qLO - https://raw.githubusercontent.com/tteck/Proxmox/main/setup/homeassistant-install.sh)" || exit
|
|
||||||
|
|
||||||
IP=$(pct exec $CTID ip a s dev eth0 | sed -n '/inet / s/\// /p' | awk '{print $2}')
|
|
||||||
|
|
||||||
pct set $CTID -description "# ${APP} LXC
|
|
||||||
### https://github.com/tteck/Proxmox"
|
|
||||||
|
|
||||||
msg_ok "Completed Successfully!\n"
|
|
||||||
echo -e "${APP} should be reachable by going to the following URL.
|
|
||||||
${BL}http://${IP}:8123${CL}
|
|
||||||
Portainer should be reachable by going to the following URL.
|
|
||||||
${BL}http://${IP}:9000${CL}\n"
|
|
|
@ -336,7 +336,7 @@ fi
|
||||||
msg_info "Starting LXC Container"
|
msg_info "Starting LXC Container"
|
||||||
pct start $CTID
|
pct start $CTID
|
||||||
msg_ok "Started LXC Container"
|
msg_ok "Started LXC Container"
|
||||||
lxc-attach -n $CTID -- bash -c "$(wget -qLO - https://raw.githubusercontent.com/tteck/Proxmox/main/setup/$var_install.sh)" || exit
|
lxc-attach -n $CTID -- bash -c "$(wget -qLO - https://raw.githubusercontent.com/tteck/Proxmox/main/install/$var_install.sh)" || exit
|
||||||
IP=$(pct exec $CTID ip a s dev eth0 | sed -n '/inet / s/\// /p' | awk '{print $2}')
|
IP=$(pct exec $CTID ip a s dev eth0 | sed -n '/inet / s/\// /p' | awk '{print $2}')
|
||||||
pct set $CTID -description "# ${APP} LXC
|
pct set $CTID -description "# ${APP} LXC
|
||||||
### https://tteck.github.io/Proxmox/
|
### https://tteck.github.io/Proxmox/
|
||||||
|
|
|
@ -1,251 +0,0 @@
|
||||||
#!/usr/bin/env bash
|
|
||||||
YW=`echo "\033[33m"`
|
|
||||||
BL=`echo "\033[36m"`
|
|
||||||
RD=`echo "\033[01;31m"`
|
|
||||||
CM='\xE2\x9C\x94\033'
|
|
||||||
GN=`echo "\033[1;92m"`
|
|
||||||
CL=`echo "\033[m"`
|
|
||||||
while true; do
|
|
||||||
read -p "This will create a New Homebridge LXC. Proceed(y/n)?" yn
|
|
||||||
case $yn in
|
|
||||||
[Yy]* ) break;;
|
|
||||||
[Nn]* ) exit;;
|
|
||||||
* ) echo "Please answer yes or no.";;
|
|
||||||
esac
|
|
||||||
done
|
|
||||||
clear
|
|
||||||
function header_info {
|
|
||||||
echo -e "${YW}
|
|
||||||
_ _ ____ __ __ ______ ____ _____ _____ _____ _____ ______
|
|
||||||
| | | |/ __ \| \/ | ____| _ \| __ \|_ _| __ \ / ____| ____|
|
|
||||||
| |__| | | | | \ / | |__ | |_) | |__) | | | | | | | | __| |__
|
|
||||||
| __ | | | | |\/| | __| | _ <| _ / | | | | | | | |_ | __|
|
|
||||||
| | | | |__| | | | | |____| |_) | | \ \ _| |_| |__| | |__| | |____
|
|
||||||
|_| |_|\____/|_| |_|______|____/|_| \_\_____|_____/ \_____|______|
|
|
||||||
${CL}"
|
|
||||||
}
|
|
||||||
|
|
||||||
header_info
|
|
||||||
show_menu(){
|
|
||||||
printf " ${YW} 1)${YW} Privileged ${CL}\n"
|
|
||||||
printf " ${YW} 2)${GN} Unprivileged ${CL}\n"
|
|
||||||
|
|
||||||
printf "Please choose a Install Method and hit enter or ${RD}x${CL} to exit."
|
|
||||||
read opt
|
|
||||||
}
|
|
||||||
|
|
||||||
option_picked(){
|
|
||||||
message1=${@:-"${CL}Error: No message passed"}
|
|
||||||
printf " ${YW}${message1}${CL}\n"
|
|
||||||
}
|
|
||||||
show_menu
|
|
||||||
while [ "$opt" != " " ]
|
|
||||||
do
|
|
||||||
case $opt in
|
|
||||||
1) clear;
|
|
||||||
header_info;
|
|
||||||
option_picked "Using Privileged Install";
|
|
||||||
IM=0
|
|
||||||
break;
|
|
||||||
;;
|
|
||||||
2) clear;
|
|
||||||
header_info;
|
|
||||||
option_picked "Using Unprivileged Install";
|
|
||||||
IM=1
|
|
||||||
break;
|
|
||||||
;;
|
|
||||||
|
|
||||||
x)exit;
|
|
||||||
;;
|
|
||||||
\n)exit;
|
|
||||||
;;
|
|
||||||
*)clear;
|
|
||||||
option_picked "Please choose a Install Method from the menu";
|
|
||||||
show_menu;
|
|
||||||
;;
|
|
||||||
esac
|
|
||||||
done
|
|
||||||
show_menu2(){
|
|
||||||
printf " ${YW} 1)${GN} Use Automatic Login ${CL}\n"
|
|
||||||
printf " ${YW} 2)${GN} Use Password (changeme) ${CL}\n"
|
|
||||||
|
|
||||||
printf "Please choose a Password Type and hit enter or ${RD}x${CL} to exit."
|
|
||||||
read opt
|
|
||||||
}
|
|
||||||
|
|
||||||
option_picked(){
|
|
||||||
message2=${@:-"${CL}Error: No message passed"}
|
|
||||||
printf " ${YW}${message1}${CL}\n"
|
|
||||||
printf " ${YW}${message2}${CL}\n"
|
|
||||||
}
|
|
||||||
show_menu2
|
|
||||||
while [ "$opt" != " " ]
|
|
||||||
do
|
|
||||||
case $opt in
|
|
||||||
1) clear;
|
|
||||||
header_info;
|
|
||||||
option_picked "Using Automatic Login";
|
|
||||||
PW=" "
|
|
||||||
break;
|
|
||||||
;;
|
|
||||||
2) clear;
|
|
||||||
header_info;
|
|
||||||
option_picked "Using Password (changeme)";
|
|
||||||
PW="-password changeme"
|
|
||||||
break;
|
|
||||||
;;
|
|
||||||
|
|
||||||
x)exit;
|
|
||||||
;;
|
|
||||||
\n)exit;
|
|
||||||
;;
|
|
||||||
*)clear;
|
|
||||||
option_picked "Please choose a Password Type from the menu";
|
|
||||||
show_menu2;
|
|
||||||
;;
|
|
||||||
esac
|
|
||||||
done
|
|
||||||
show_menu3(){
|
|
||||||
printf " ${YW} 1)${GN} Automatic DHCP ${CL}\n"
|
|
||||||
printf " ${YW} 2)${GN} Manual DHCP ${CL}\n"
|
|
||||||
|
|
||||||
printf "Please choose a DHCP Type and hit enter or ${RD}x${CL} to exit."
|
|
||||||
read opt
|
|
||||||
}
|
|
||||||
|
|
||||||
option_picked(){
|
|
||||||
message3=${@:-"${CL}Error: No message passed"}
|
|
||||||
printf " ${YW}${message1}${CL}\n"
|
|
||||||
printf " ${YW}${message2}${CL}\n"
|
|
||||||
printf " ${YW}${message3}${CL}\n"
|
|
||||||
}
|
|
||||||
show_menu3
|
|
||||||
while [ "$opt" != " " ]
|
|
||||||
do
|
|
||||||
case $opt in
|
|
||||||
1) clear;
|
|
||||||
header_info;
|
|
||||||
option_picked "Using Automatic DHCP";
|
|
||||||
DHCP=" "
|
|
||||||
break;
|
|
||||||
;;
|
|
||||||
2) clear;
|
|
||||||
header_info;
|
|
||||||
option_picked "Using Manual DHCP";
|
|
||||||
DHCP="1"
|
|
||||||
break;
|
|
||||||
;;
|
|
||||||
|
|
||||||
x)exit;
|
|
||||||
;;
|
|
||||||
\n)exit;
|
|
||||||
;;
|
|
||||||
*)clear;
|
|
||||||
option_picked "Please choose a DHCP Type from the menu";
|
|
||||||
show_menu3;
|
|
||||||
;;
|
|
||||||
esac
|
|
||||||
done
|
|
||||||
|
|
||||||
set -o errexit
|
|
||||||
set -o errtrace
|
|
||||||
set -o nounset
|
|
||||||
set -o pipefail
|
|
||||||
shopt -s expand_aliases
|
|
||||||
alias die='EXIT=$? LINE=$LINENO error_exit'
|
|
||||||
trap die ERR
|
|
||||||
trap cleanup EXIT
|
|
||||||
|
|
||||||
function error_exit() {
|
|
||||||
trap - ERR
|
|
||||||
local DEFAULT='Unknown failure occured.'
|
|
||||||
local REASON="\e[97m${1:-$DEFAULT}\e[39m"
|
|
||||||
local FLAG="\e[91m[ERROR] \e[93m$EXIT@$LINE"
|
|
||||||
msg "$FLAG $REASON"
|
|
||||||
[ ! -z ${CTID-} ] && cleanup_ctid
|
|
||||||
exit $EXIT
|
|
||||||
}
|
|
||||||
function warn() {
|
|
||||||
local REASON="\e[97m$1\e[39m"
|
|
||||||
local FLAG="\e[93m[WARNING]\e[39m"
|
|
||||||
msg "$FLAG $REASON"
|
|
||||||
}
|
|
||||||
function info() {
|
|
||||||
local REASON="$1"
|
|
||||||
local FLAG="\e[36m[INFO]\e[39m"
|
|
||||||
msg "$FLAG $REASON"
|
|
||||||
}
|
|
||||||
function msg() {
|
|
||||||
local TEXT="$1"
|
|
||||||
echo -e "$TEXT"
|
|
||||||
}
|
|
||||||
function cleanup_ctid() {
|
|
||||||
if $(pct status $CTID &>/dev/null); then
|
|
||||||
if [ "$(pct status $CTID | awk '{print $2}')" == "running" ]; then
|
|
||||||
pct stop $CTID
|
|
||||||
fi
|
|
||||||
pct destroy $CTID
|
|
||||||
elif [ "$(pvesm list $STORAGE --vmid $CTID)" != "" ]; then
|
|
||||||
pvesm free $ROOTFS
|
|
||||||
fi
|
|
||||||
}
|
|
||||||
function cleanup() {
|
|
||||||
popd >/dev/null
|
|
||||||
rm -rf $TEMP_DIR
|
|
||||||
}
|
|
||||||
if [ "$IM" == "1" ]; then
|
|
||||||
FEATURES="nesting=1,keyctl=1"
|
|
||||||
else
|
|
||||||
FEATURES="nesting=1"
|
|
||||||
fi
|
|
||||||
|
|
||||||
TEMP_DIR=$(mktemp -d)
|
|
||||||
pushd $TEMP_DIR >/dev/null
|
|
||||||
|
|
||||||
export CTID=$(pvesh get /cluster/nextid)
|
|
||||||
export PCT_OSTYPE=debian
|
|
||||||
export PCT_OSVERSION=11
|
|
||||||
export PCT_DISK_SIZE=4
|
|
||||||
export PCT_OPTIONS="
|
|
||||||
-features $FEATURES
|
|
||||||
-hostname homebridge
|
|
||||||
-net0 name=eth0,bridge=vmbr0,ip=dhcp
|
|
||||||
-onboot 1
|
|
||||||
-cores 1
|
|
||||||
-memory 1024
|
|
||||||
-unprivileged ${IM}
|
|
||||||
${PW}
|
|
||||||
"
|
|
||||||
bash -c "$(wget -qLO - https://raw.githubusercontent.com/tteck/Proxmox/main/ct/create_lxc.sh)" || exit
|
|
||||||
|
|
||||||
STORAGE_TYPE=$(pvesm status -storage $(pct config $CTID | grep rootfs | awk -F ":" '{print $2}') | awk 'NR>1 {print $2}')
|
|
||||||
if [ "$STORAGE_TYPE" == "zfspool" ]; then
|
|
||||||
warn "Some addons may not work due to ZFS not supporting 'fallocate'."
|
|
||||||
fi
|
|
||||||
if [ "$DHCP" == "1" ]; then
|
|
||||||
MAC=$(pct config $CTID \
|
|
||||||
| grep -i hwaddr \
|
|
||||||
| awk '{print substr($2, 31, length($3) 17 ) }') \
|
|
||||||
|
|
||||||
echo -e "MAC Address ${BL}$MAC${CL}"
|
|
||||||
|
|
||||||
dhcp_reservation(){
|
|
||||||
printf "Please set DHCP reservation and press Enter."
|
|
||||||
read
|
|
||||||
}
|
|
||||||
dhcp_reservation
|
|
||||||
fi
|
|
||||||
|
|
||||||
echo -en "${GN} Starting LXC Container... "
|
|
||||||
pct start $CTID
|
|
||||||
echo -e "${CM}${CL} \r"
|
|
||||||
|
|
||||||
alias lxc-cmd="lxc-attach -n $CTID --"
|
|
||||||
|
|
||||||
lxc-cmd bash -c "$(wget -qLO - https://raw.githubusercontent.com/tteck/Proxmox/main/setup/homebridge-install.sh)" || exit
|
|
||||||
|
|
||||||
IP=$(pct exec $CTID ip a s dev eth0 | sed -n '/inet / s/\// /p' | awk '{print $2}')
|
|
||||||
|
|
||||||
echo -e "${GN}Successfully created Homebridge LXC to${CL} ${BL}$CTID${CL}.
|
|
||||||
${BL}Homebridge${CL} should be reachable by going to the following URL.
|
|
||||||
${BL}http://${IP}:8581${CL} \n"
|
|
|
@ -1,356 +0,0 @@
|
||||||
#!/usr/bin/env bash
|
|
||||||
echo -e "Loading..."
|
|
||||||
NEXTID=$(pvesh get /cluster/nextid)
|
|
||||||
INTEGER='^[0-9]+$'
|
|
||||||
YW=`echo "\033[33m"`
|
|
||||||
BL=`echo "\033[36m"`
|
|
||||||
RD=`echo "\033[01;31m"`
|
|
||||||
BGN=`echo "\033[4;92m"`
|
|
||||||
GN=`echo "\033[1;92m"`
|
|
||||||
DGN=`echo "\033[32m"`
|
|
||||||
CL=`echo "\033[m"`
|
|
||||||
BFR="\\r\\033[K"
|
|
||||||
HOLD="-"
|
|
||||||
CM="${GN}✓${CL}"
|
|
||||||
APP="Homebridge"
|
|
||||||
NSAPP=$(echo ${APP,,} | tr -d ' ')
|
|
||||||
set -o errexit
|
|
||||||
set -o errtrace
|
|
||||||
set -o nounset
|
|
||||||
set -o pipefail
|
|
||||||
shopt -s expand_aliases
|
|
||||||
alias die='EXIT=$? LINE=$LINENO error_exit'
|
|
||||||
trap die ERR
|
|
||||||
|
|
||||||
function error_exit() {
|
|
||||||
trap - ERR
|
|
||||||
local reason="Unknown failure occurred."
|
|
||||||
local msg="${1:-$reason}"
|
|
||||||
local flag="${RD}‼ ERROR ${CL}$EXIT@$LINE"
|
|
||||||
echo -e "$flag $msg" 1>&2
|
|
||||||
exit $EXIT
|
|
||||||
}
|
|
||||||
|
|
||||||
while true; do
|
|
||||||
clear
|
|
||||||
read -p "This will create a New ${APP} LXC. Proceed(y/n)?" yn
|
|
||||||
case $yn in
|
|
||||||
[Yy]* ) break;;
|
|
||||||
[Nn]* ) exit;;
|
|
||||||
* ) echo "Please answer yes or no.";;
|
|
||||||
esac
|
|
||||||
done
|
|
||||||
clear
|
|
||||||
function header_info {
|
|
||||||
echo -e "${YW}
|
|
||||||
_ _ ____ __ __ ______ ____ _____ _____ _____ _____ ______
|
|
||||||
| | | |/ __ \| \/ | ____| _ \| __ \|_ _| __ \ / ____| ____|
|
|
||||||
| |__| | | | | \ / | |__ | |_) | |__) | | | | | | | | __| |__
|
|
||||||
| __ | | | | |\/| | __| | _ <| _ / | | | | | | | |_ | __|
|
|
||||||
| | | | |__| | | | | |____| |_) | | \ \ _| |_| |__| | |__| | |____
|
|
||||||
|_|v3|_|\____/|_| |_|______|____/|_| \_\_____|_____/ \_____|______|
|
|
||||||
${CL}"
|
|
||||||
}
|
|
||||||
|
|
||||||
header_info
|
|
||||||
|
|
||||||
function msg_info() {
|
|
||||||
local msg="$1"
|
|
||||||
echo -ne " ${HOLD} ${YW}${msg}..."
|
|
||||||
}
|
|
||||||
|
|
||||||
function msg_ok() {
|
|
||||||
local msg="$1"
|
|
||||||
echo -e "${BFR} ${CM} ${GN}${msg}${CL}"
|
|
||||||
}
|
|
||||||
|
|
||||||
function PVE_CHECK() {
|
|
||||||
PVE=$(pveversion | grep "pve-manager/7" | wc -l)
|
|
||||||
|
|
||||||
if [[ $PVE != 1 ]]; then
|
|
||||||
echo -e "${RD}This script requires Proxmox Virtual Environment 7.0 or greater${CL}"
|
|
||||||
echo -e "Exiting..."
|
|
||||||
sleep 2
|
|
||||||
exit
|
|
||||||
fi
|
|
||||||
}
|
|
||||||
|
|
||||||
function default_settings() {
|
|
||||||
clear
|
|
||||||
header_info
|
|
||||||
echo -e "${BL}Using Default Settings${CL}"
|
|
||||||
echo -e "${DGN}Using CT Type ${BGN}Unprivileged${CL} ${RD}NO DEVICE PASSTHROUGH${CL}"
|
|
||||||
CT_TYPE="1"
|
|
||||||
echo -e "${DGN}Using CT Password ${BGN}Automatic Login${CL}"
|
|
||||||
PW=" "
|
|
||||||
echo -e "${DGN}Using CT ID ${BGN}$NEXTID${CL}"
|
|
||||||
CT_ID=$NEXTID
|
|
||||||
echo -e "${DGN}Using CT Name ${BGN}$NSAPP${CL}"
|
|
||||||
HN=$NSAPP
|
|
||||||
echo -e "${DGN}Using Disk Size ${BGN}4${CL}${DGN}GB${CL}"
|
|
||||||
DISK_SIZE="4"
|
|
||||||
echo -e "${DGN}Using ${BGN}1${CL}${DGN}vCPU${CL}"
|
|
||||||
CORE_COUNT="1"
|
|
||||||
echo -e "${DGN}Using ${BGN}1024${CL}${DGN}MiB RAM${CL}"
|
|
||||||
RAM_SIZE="1024"
|
|
||||||
echo -e "${DGN}Using Bridge ${BGN}vmbr0${CL}"
|
|
||||||
BRG="vmbr0"
|
|
||||||
echo -e "${DGN}Using Static IP Address ${BGN}DHCP${CL}"
|
|
||||||
NET=dhcp
|
|
||||||
echo -e "${DGN}Using Gateway Address ${BGN}NONE${CL}"
|
|
||||||
GATE=""
|
|
||||||
echo -e "${DGN}Using VLAN Tag ${BGN}NONE${CL}"
|
|
||||||
VLAN=""
|
|
||||||
}
|
|
||||||
|
|
||||||
function advanced_settings() {
|
|
||||||
clear
|
|
||||||
header_info
|
|
||||||
echo -e "${RD}Using Advanced Settings${CL}"
|
|
||||||
echo -e "${YW}Type Privileged, or Press [ENTER] for Default: Unprivileged (${RD}NO DEVICE PASSTHROUGH${CL}${YW})"
|
|
||||||
read CT_TYPE1
|
|
||||||
if [ -z $CT_TYPE1 ]; then CT_TYPE1="Unprivileged" CT_TYPE="1";
|
|
||||||
echo -en "${DGN}Set CT Type ${BL}$CT_TYPE1${CL}"
|
|
||||||
else
|
|
||||||
CT_TYPE1="Privileged"
|
|
||||||
CT_TYPE="0"
|
|
||||||
echo -en "${DGN}Set CT Type ${BL}Privileged${CL}"
|
|
||||||
fi;
|
|
||||||
echo -e " ${CM}${CL} \r"
|
|
||||||
sleep 1
|
|
||||||
clear
|
|
||||||
header_info
|
|
||||||
echo -e "${RD}Using Advanced Settings${CL}"
|
|
||||||
echo -e "${DGN}Using CT Type ${BGN}$CT_TYPE1${CL}"
|
|
||||||
echo -e "${YW}Set Password, or Press [ENTER] for Default: Automatic Login "
|
|
||||||
read PW1
|
|
||||||
if [ -z $PW1 ]; then PW1="Automatic Login" PW=" ";
|
|
||||||
echo -en "${DGN}Set CT ${BL}$PW1${CL}"
|
|
||||||
else
|
|
||||||
PW="-password $PW1"
|
|
||||||
echo -en "${DGN}Set CT Password ${BL}$PW1${CL}"
|
|
||||||
fi;
|
|
||||||
echo -e " ${CM}${CL} \r"
|
|
||||||
sleep 1
|
|
||||||
clear
|
|
||||||
header_info
|
|
||||||
echo -e "${RD}Using Advanced Settings${CL}"
|
|
||||||
echo -e "${DGN}Using CT Type ${BGN}$CT_TYPE1${CL}"
|
|
||||||
echo -e "${DGN}Using CT Password ${BGN}$PW1${CL}"
|
|
||||||
echo -e "${YW}Enter the CT ID, or Press [ENTER] to automatically generate (${NEXTID}) "
|
|
||||||
read CT_ID
|
|
||||||
if [ -z $CT_ID ]; then CT_ID=$NEXTID; fi;
|
|
||||||
echo -en "${DGN}Set CT ID To ${BL}$CT_ID${CL}"
|
|
||||||
echo -e " ${CM}${CL} \r"
|
|
||||||
sleep 1
|
|
||||||
clear
|
|
||||||
header_info
|
|
||||||
echo -e "${RD}Using Advanced Settings${CL}"
|
|
||||||
echo -e "${DGN}Using CT Type ${BGN}$CT_TYPE1${CL}"
|
|
||||||
echo -e "${DGN}Using CT Password ${BGN}$PW1${CL}"
|
|
||||||
echo -e "${DGN}Using CT ID ${BGN}$CT_ID${CL}"
|
|
||||||
echo -e "${YW}Enter CT Name (no-spaces), or Press [ENTER] for Default: $NSAPP "
|
|
||||||
read CT_NAME
|
|
||||||
if [ -z $CT_NAME ]; then
|
|
||||||
HN=$NSAPP
|
|
||||||
else
|
|
||||||
HN=$(echo ${CT_NAME,,} | tr -d ' ')
|
|
||||||
fi
|
|
||||||
echo -en "${DGN}Set CT Name To ${BL}$HN${CL}"
|
|
||||||
echo -e " ${CM}${CL} \r"
|
|
||||||
sleep 1
|
|
||||||
clear
|
|
||||||
header_info
|
|
||||||
echo -e "${RD}Using Advanced Settings${CL}"
|
|
||||||
echo -e "${DGN}Using CT Type ${BGN}$CT_TYPE1${CL}"
|
|
||||||
echo -e "${DGN}Using CT Password ${BGN}$PW1${CL}"
|
|
||||||
echo -e "${DGN}Using CT ID ${BGN}$CT_ID${CL}"
|
|
||||||
echo -e "${DGN}Using CT Name ${BGN}$HN${CL}"
|
|
||||||
echo -e "${YW}Enter a Disk Size, or Press [ENTER] for Default: 4 "
|
|
||||||
read DISK_SIZE
|
|
||||||
if [ -z $DISK_SIZE ]; then DISK_SIZE="4"; fi;
|
|
||||||
if ! [[ $DISK_SIZE =~ $INTEGER ]] ; then echo "ERROR! DISK SIZE MUST HAVE INTEGER NUMBER!"; exit; fi;
|
|
||||||
echo -en "${DGN}Set Disk Size To ${BL}$DISK_SIZE${CL}${DGN}GB${CL}"
|
|
||||||
echo -e " ${CM}${CL} \r"
|
|
||||||
sleep 1
|
|
||||||
clear
|
|
||||||
header_info
|
|
||||||
echo -e "${RD}Using Advanced Settings${CL}"
|
|
||||||
echo -e "${DGN}Using CT Type ${BGN}$CT_TYPE1${CL}"
|
|
||||||
echo -e "${DGN}Using CT Password ${BGN}$PW1${CL}"
|
|
||||||
echo -e "${DGN}Using CT ID ${BGN}$CT_ID${CL}"
|
|
||||||
echo -e "${DGN}Using CT Name ${BGN}$HN${CL}"
|
|
||||||
echo -e "${DGN}Using Disk Size ${BGN}$DISK_SIZE${CL}${DGN}GB${CL}"
|
|
||||||
echo -e "${YW}Allocate CPU cores, or Press [ENTER] for Default: 1 "
|
|
||||||
read CORE_COUNT
|
|
||||||
if [ -z $CORE_COUNT ]; then CORE_COUNT="1"; fi;
|
|
||||||
echo -en "${DGN}Set Cores To ${BL}$CORE_COUNT${CL}${DGN}vCPU${CL}"
|
|
||||||
echo -e " ${CM}${CL} \r"
|
|
||||||
sleep 1
|
|
||||||
clear
|
|
||||||
header_info
|
|
||||||
echo -e "${RD}Using Advanced Settings${CL}"
|
|
||||||
echo -e "${DGN}Using CT Type ${BGN}$CT_TYPE1${CL}"
|
|
||||||
echo -e "${DGN}Using CT Password ${BGN}$PW1${CL}"
|
|
||||||
echo -e "${DGN}Using CT ID ${BGN}$CT_ID${CL}"
|
|
||||||
echo -e "${DGN}Using CT Name ${BGN}$HN${CL}"
|
|
||||||
echo -e "${DGN}Using Disk Size ${BGN}$DISK_SIZE${CL}${DGN}GB${CL}"
|
|
||||||
echo -e "${DGN}Using ${BGN}${CORE_COUNT}${CL}${DGN}vCPU${CL}"
|
|
||||||
echo -e "${YW}Allocate RAM in MiB, or Press [ENTER] for Default: 1024 "
|
|
||||||
read RAM_SIZE
|
|
||||||
if [ -z $RAM_SIZE ]; then RAM_SIZE="1024"; fi;
|
|
||||||
echo -en "${DGN}Set RAM To ${BL}$RAM_SIZE${CL}${DGN}MiB RAM${CL}"
|
|
||||||
echo -e " ${CM}${CL} \n"
|
|
||||||
sleep 1
|
|
||||||
clear
|
|
||||||
header_info
|
|
||||||
echo -e "${RD}Using Advanced Settings${CL}"
|
|
||||||
echo -e "${DGN}Using CT Type ${BGN}$CT_TYPE1${CL}"
|
|
||||||
echo -e "${DGN}Using CT Password ${BGN}$PW1${CL}"
|
|
||||||
echo -e "${DGN}Using CT ID ${BGN}$CT_ID${CL}"
|
|
||||||
echo -e "${DGN}Using CT Name ${BGN}$HN${CL}"
|
|
||||||
echo -e "${DGN}Using Disk Size ${BGN}$DISK_SIZE${CL}${DGN}GB${CL}"
|
|
||||||
echo -e "${DGN}Using ${BGN}${CORE_COUNT}${CL}${DGN}vCPU${CL}"
|
|
||||||
echo -e "${DGN}Using ${BGN}${RAM_SIZE}${CL}${DGN}MiB RAM${CL}"
|
|
||||||
echo -e "${YW}Enter a Bridge, or Press [ENTER] for Default: vmbr0 "
|
|
||||||
read BRG
|
|
||||||
if [ -z $BRG ]; then BRG="vmbr0"; fi;
|
|
||||||
echo -en "${DGN}Set Bridge To ${BL}$BRG${CL}"
|
|
||||||
echo -e " ${CM}${CL} \n"
|
|
||||||
sleep 1
|
|
||||||
clear
|
|
||||||
header_info
|
|
||||||
echo -e "${RD}Using Advanced Settings${CL}"
|
|
||||||
echo -e "${DGN}Using CT Type ${BGN}$CT_TYPE1${CL}"
|
|
||||||
echo -e "${DGN}Using CT Password ${BGN}$PW1${CL}"
|
|
||||||
echo -e "${DGN}Using CT ID ${BGN}$CT_ID${CL}"
|
|
||||||
echo -e "${DGN}Using CT Name ${BGN}$HN${CL}"
|
|
||||||
echo -e "${DGN}Using Disk Size ${BGN}$DISK_SIZE${CL}${DGN}GB${CL}"
|
|
||||||
echo -e "${DGN}Using ${BGN}${CORE_COUNT}${CL}${DGN}vCPU${CL}"
|
|
||||||
echo -e "${DGN}Using ${BGN}${RAM_SIZE}${CL}${DGN}MiB RAM${CL}"
|
|
||||||
echo -e "${DGN}Using Bridge ${BGN}${BRG}${CL}"
|
|
||||||
echo -e "${YW}Enter a Static IPv4 CIDR Address, or Press [ENTER] for Default: DHCP "
|
|
||||||
read NET
|
|
||||||
if [ -z $NET ]; then NET="dhcp"; fi;
|
|
||||||
echo -en "${DGN}Set Static IP Address To ${BL}$NET${CL}"
|
|
||||||
echo -e " ${CM}${CL} \n"
|
|
||||||
sleep 1
|
|
||||||
clear
|
|
||||||
header_info
|
|
||||||
echo -e "${RD}Using Advanced Settings${CL}"
|
|
||||||
echo -e "${DGN}Using CT Type ${BGN}$CT_TYPE1${CL}"
|
|
||||||
echo -e "${DGN}Using CT Password ${BGN}$PW1${CL}"
|
|
||||||
echo -e "${DGN}Using CT ID ${BGN}$CT_ID${CL}"
|
|
||||||
echo -e "${DGN}Using CT Name ${BGN}$HN${CL}"
|
|
||||||
echo -e "${DGN}Using Disk Size ${BGN}$DISK_SIZE${CL}${DGN}GB${CL}"
|
|
||||||
echo -e "${DGN}Using ${BGN}${CORE_COUNT}${CL}${DGN}vCPU${CL}"
|
|
||||||
echo -e "${DGN}Using ${BGN}${RAM_SIZE}${CL}${DGN}MiB RAM${CL}"
|
|
||||||
echo -e "${DGN}Using Bridge ${BGN}${BRG}${CL}"
|
|
||||||
echo -e "${DGN}Using Static IP Address ${BGN}$NET${CL}"
|
|
||||||
echo -e "${YW}Enter a Gateway IP (mandatory if static IP is used), or Press [ENTER] for Default: NONE "
|
|
||||||
read GATE1
|
|
||||||
if [ -z $GATE1 ]; then GATE1="NONE" GATE="";
|
|
||||||
echo -en "${DGN}Set Gateway IP To ${BL}$GATE1${CL}"
|
|
||||||
else
|
|
||||||
GATE=",gw=$GATE1"
|
|
||||||
echo -en "${DGN}Set Gateway IP To ${BL}$GATE1${CL}"
|
|
||||||
fi;
|
|
||||||
echo -e " ${CM}${CL} \n"
|
|
||||||
sleep 1
|
|
||||||
clear
|
|
||||||
header_info
|
|
||||||
|
|
||||||
echo -e "${RD}Using Advanced Settings${CL}"
|
|
||||||
echo -e "${DGN}Using CT Type ${BGN}$CT_TYPE1${CL}"
|
|
||||||
echo -e "${DGN}Using CT Password ${BGN}$PW1${CL}"
|
|
||||||
echo -e "${DGN}Using CT ID ${BGN}$CT_ID${CL}"
|
|
||||||
echo -e "${DGN}Using CT Name ${BGN}$HN${CL}"
|
|
||||||
echo -e "${DGN}Using Disk Size ${BGN}$DISK_SIZE${CL}${DGN}GB${CL}"
|
|
||||||
echo -e "${DGN}Using ${BGN}${CORE_COUNT}${CL}${DGN}vCPU${CL}"
|
|
||||||
echo -e "${DGN}Using ${BGN}${RAM_SIZE}${CL}${DGN}MiB RAM${CL}"
|
|
||||||
echo -e "${DGN}Using Bridge ${BGN}${BRG}${CL}"
|
|
||||||
echo -e "${DGN}Using Static IP Address ${BGN}$NET${CL}"
|
|
||||||
echo -e "${DGN}Using Gateway IP Address ${BGN}$GATE1${CL}"
|
|
||||||
echo -e "${YW}Enter a VLAN Tag, or Press [ENTER] for Default: NONE "
|
|
||||||
read VLAN1
|
|
||||||
if [ -z $VLAN1 ]; then VLAN1="NONE" VLAN="";
|
|
||||||
echo -en "${DGN}Set VLAN Tag To ${BL}$VLAN1${CL}"
|
|
||||||
else
|
|
||||||
VLAN=",tag=$VLAN1"
|
|
||||||
echo -en "${DGN}Set VLAN Tag To ${BL}$VLAN1${CL}"
|
|
||||||
fi;
|
|
||||||
echo -e " ${CM}${CL} \n"
|
|
||||||
sleep 1
|
|
||||||
clear
|
|
||||||
header_info
|
|
||||||
echo -e "${RD}Using Advanced Settings${CL}"
|
|
||||||
echo -e "${DGN}Using CT Type ${BGN}$CT_TYPE1${CL}"
|
|
||||||
echo -e "${DGN}Using CT Password ${BGN}$PW1${CL}"
|
|
||||||
echo -e "${DGN}Using CT ID ${BGN}$CT_ID${CL}"
|
|
||||||
echo -e "${DGN}Using CT Name ${BGN}$HN${CL}"
|
|
||||||
echo -e "${DGN}Using Disk Size ${BGN}$DISK_SIZE${CL}${DGN}GB${CL}"
|
|
||||||
echo -e "${DGN}Using ${BGN}${CORE_COUNT}${CL}${DGN}vCPU${CL}"
|
|
||||||
echo -e "${DGN}Using ${BGN}${RAM_SIZE}${CL}${DGN}MiB RAM${CL}"
|
|
||||||
echo -e "${DGN}Using Bridge ${BGN}${BRG}${CL}"
|
|
||||||
echo -e "${DGN}Using Static IP Address ${BGN}$NET${CL}"
|
|
||||||
echo -e "${DGN}Using Gateway IP Address ${BGN}$GATE1${CL}"
|
|
||||||
echo -e "${DGN}Using VLAN Tag ${BGN}$VLAN1${CL}"
|
|
||||||
|
|
||||||
read -p "Are these settings correct(y/n)? " -n 1 -r
|
|
||||||
echo
|
|
||||||
if [[ ! $REPLY =~ ^[Yy]$ ]]
|
|
||||||
then
|
|
||||||
advanced_settings
|
|
||||||
fi
|
|
||||||
}
|
|
||||||
|
|
||||||
function start_script() {
|
|
||||||
echo -e "${YW}Type Advanced, or Press [ENTER] for Default Settings "
|
|
||||||
read SETTINGS
|
|
||||||
if [ -z $SETTINGS ]; then default_settings;
|
|
||||||
else
|
|
||||||
advanced_settings
|
|
||||||
fi;
|
|
||||||
}
|
|
||||||
|
|
||||||
start_script
|
|
||||||
|
|
||||||
if [ "$CT_TYPE" == "1" ]; then
|
|
||||||
FEATURES="nesting=1,keyctl=1"
|
|
||||||
else
|
|
||||||
FEATURES="nesting=1"
|
|
||||||
fi
|
|
||||||
|
|
||||||
TEMP_DIR=$(mktemp -d)
|
|
||||||
pushd $TEMP_DIR >/dev/null
|
|
||||||
|
|
||||||
export CTID=$CT_ID
|
|
||||||
export PCT_OSTYPE=debian
|
|
||||||
export PCT_OSVERSION=11
|
|
||||||
export PCT_DISK_SIZE=$DISK_SIZE
|
|
||||||
export PCT_OPTIONS="
|
|
||||||
-features $FEATURES
|
|
||||||
-hostname $HN
|
|
||||||
-net0 name=eth0,bridge=$BRG,ip=$NET$GATE$VLAN
|
|
||||||
-onboot 1
|
|
||||||
-cores $CORE_COUNT
|
|
||||||
-memory $RAM_SIZE
|
|
||||||
-unprivileged $CT_TYPE
|
|
||||||
$PW
|
|
||||||
"
|
|
||||||
bash -c "$(wget -qLO - https://raw.githubusercontent.com/tteck/Proxmox/main/ct/create_lxc.sh)" || exit
|
|
||||||
|
|
||||||
msg_info "Starting LXC Container"
|
|
||||||
pct start $CTID
|
|
||||||
msg_ok "Started LXC Container"
|
|
||||||
|
|
||||||
lxc-attach -n $CTID -- bash -c "$(wget -qLO - https://raw.githubusercontent.com/tteck/Proxmox/main/setup/homebridge-install.sh)" || exit
|
|
||||||
|
|
||||||
IP=$(pct exec $CTID ip a s dev eth0 | sed -n '/inet / s/\// /p' | awk '{print $2}')
|
|
||||||
|
|
||||||
pct set $CTID -description "# ${APP} LXC
|
|
||||||
### https://github.com/tteck/Proxmox"
|
|
||||||
|
|
||||||
msg_ok "Completed Successfully!\n"
|
|
||||||
echo -e "Homebridge should be reachable by going to the following URL.
|
|
||||||
${BL}http://${IP}:8581${CL} \n"
|
|
|
@ -309,7 +309,7 @@ bash -c "$(wget -qLO - https://raw.githubusercontent.com/tteck/Proxmox/main/ct/c
|
||||||
msg_info "Starting LXC Container"
|
msg_info "Starting LXC Container"
|
||||||
pct start $CTID
|
pct start $CTID
|
||||||
msg_ok "Started LXC Container"
|
msg_ok "Started LXC Container"
|
||||||
lxc-attach -n $CTID -- bash -c "$(wget -qLO - https://raw.githubusercontent.com/tteck/Proxmox/main/setup/$var_install.sh)" || exit
|
lxc-attach -n $CTID -- bash -c "$(wget -qLO - https://raw.githubusercontent.com/tteck/Proxmox/main/install/$var_install.sh)" || exit
|
||||||
IP=$(pct exec $CTID ip a s dev eth0 | sed -n '/inet / s/\// /p' | awk '{print $2}')
|
IP=$(pct exec $CTID ip a s dev eth0 | sed -n '/inet / s/\// /p' | awk '{print $2}')
|
||||||
pct set $CTID -description "# ${APP} LXC
|
pct set $CTID -description "# ${APP} LXC
|
||||||
### https://tteck.github.io/Proxmox/
|
### https://tteck.github.io/Proxmox/
|
||||||
|
|
|
@ -310,7 +310,7 @@ bash -c "$(wget -qLO - https://raw.githubusercontent.com/tteck/Proxmox/main/ct/c
|
||||||
msg_info "Starting LXC Container"
|
msg_info "Starting LXC Container"
|
||||||
pct start $CTID
|
pct start $CTID
|
||||||
msg_ok "Started LXC Container"
|
msg_ok "Started LXC Container"
|
||||||
lxc-attach -n $CTID -- bash -c "$(wget -qLO - https://raw.githubusercontent.com/tteck/Proxmox/main/setup/$var_install.sh)" || exit
|
lxc-attach -n $CTID -- bash -c "$(wget -qLO - https://raw.githubusercontent.com/tteck/Proxmox/main/install/$var_install.sh)" || exit
|
||||||
IP=$(pct exec $CTID ip a s dev eth0 | sed -n '/inet / s/\// /p' | awk '{print $2}')
|
IP=$(pct exec $CTID ip a s dev eth0 | sed -n '/inet / s/\// /p' | awk '{print $2}')
|
||||||
pct set $CTID -description "# ${APP} LXC
|
pct set $CTID -description "# ${APP} LXC
|
||||||
### https://tteck.github.io/Proxmox/
|
### https://tteck.github.io/Proxmox/
|
||||||
|
|
|
@ -325,7 +325,7 @@ fi
|
||||||
msg_info "Starting LXC Container"
|
msg_info "Starting LXC Container"
|
||||||
pct start $CTID
|
pct start $CTID
|
||||||
msg_ok "Started LXC Container"
|
msg_ok "Started LXC Container"
|
||||||
lxc-attach -n $CTID -- bash -c "$(wget -qLO - https://raw.githubusercontent.com/tteck/Proxmox/main/setup/$var_install.sh)" || exit
|
lxc-attach -n $CTID -- bash -c "$(wget -qLO - https://raw.githubusercontent.com/tteck/Proxmox/main/install/$var_install.sh)" || exit
|
||||||
IP=$(pct exec $CTID ip a s dev eth0 | sed -n '/inet / s/\// /p' | awk '{print $2}')
|
IP=$(pct exec $CTID ip a s dev eth0 | sed -n '/inet / s/\// /p' | awk '{print $2}')
|
||||||
pct set $CTID -description "# ${APP} LXC
|
pct set $CTID -description "# ${APP} LXC
|
||||||
### https://tteck.github.io/Proxmox/
|
### https://tteck.github.io/Proxmox/
|
||||||
|
|
|
@ -1,250 +0,0 @@
|
||||||
#!/usr/bin/env bash
|
|
||||||
YW=`echo "\033[33m"`
|
|
||||||
BL=`echo "\033[36m"`
|
|
||||||
RD=`echo "\033[01;31m"`
|
|
||||||
CM='\xE2\x9C\x94\033'
|
|
||||||
GN=`echo "\033[1;92m"`
|
|
||||||
CL=`echo "\033[m"`
|
|
||||||
while true; do
|
|
||||||
read -p "This will create a New InfluxDB LXC. Proceed(y/n)?" yn
|
|
||||||
case $yn in
|
|
||||||
[Yy]* ) break;;
|
|
||||||
[Nn]* ) exit;;
|
|
||||||
* ) echo "Please answer yes or no.";;
|
|
||||||
esac
|
|
||||||
done
|
|
||||||
clear
|
|
||||||
function header_info {
|
|
||||||
echo -e "${YW}
|
|
||||||
_____ __ _ _____ ____
|
|
||||||
|_ _| / _| | | __ \| _ \
|
|
||||||
| | _ __ | |_| |_ ___ _| | | | |_) |
|
|
||||||
| | | _ \| _| | | | \ \/ / | | | _ <
|
|
||||||
_| |_| | | | | | | |_| |> <| |__| | |_) |
|
|
||||||
|_____|_| |_|_| |_|\__,_/_/\_\_____/|____/
|
|
||||||
with Telegraf
|
|
||||||
${CL}"
|
|
||||||
}
|
|
||||||
|
|
||||||
header_info
|
|
||||||
show_menu(){
|
|
||||||
printf " ${YW} 1)${YW} Privileged ${CL}\n"
|
|
||||||
printf " ${YW} 2)${GN} Unprivileged ${CL}\n"
|
|
||||||
|
|
||||||
printf "Please choose a Install Method and hit enter or ${RD}x${CL} to exit."
|
|
||||||
read opt
|
|
||||||
}
|
|
||||||
|
|
||||||
option_picked(){
|
|
||||||
message1=${@:-"${CL}Error: No message passed"}
|
|
||||||
printf " ${YW}${message1}${CL}\n"
|
|
||||||
}
|
|
||||||
show_menu
|
|
||||||
while [ "$opt" != " " ]
|
|
||||||
do
|
|
||||||
case $opt in
|
|
||||||
1) clear;
|
|
||||||
header_info;
|
|
||||||
option_picked "Using Privileged Install";
|
|
||||||
IM=0
|
|
||||||
break;
|
|
||||||
;;
|
|
||||||
2) clear;
|
|
||||||
header_info;
|
|
||||||
option_picked "Using Unprivileged Install";
|
|
||||||
IM=1
|
|
||||||
break;
|
|
||||||
;;
|
|
||||||
|
|
||||||
x)exit;
|
|
||||||
;;
|
|
||||||
\n)exit;
|
|
||||||
;;
|
|
||||||
*)clear;
|
|
||||||
option_picked "Please choose a Install Method from the menu";
|
|
||||||
show_menu;
|
|
||||||
;;
|
|
||||||
esac
|
|
||||||
done
|
|
||||||
show_menu2(){
|
|
||||||
printf " ${YW} 1)${GN} Use Automatic Login ${CL}\n"
|
|
||||||
printf " ${YW} 2)${GN} Use Password (changeme) ${CL}\n"
|
|
||||||
|
|
||||||
printf "Please choose a Password Type and hit enter or ${RD}x${CL} to exit."
|
|
||||||
read opt
|
|
||||||
}
|
|
||||||
|
|
||||||
option_picked(){
|
|
||||||
message2=${@:-"${CL}Error: No message passed"}
|
|
||||||
printf " ${YW}${message1}${CL}\n"
|
|
||||||
printf " ${YW}${message2}${CL}\n"
|
|
||||||
}
|
|
||||||
show_menu2
|
|
||||||
while [ "$opt" != " " ]
|
|
||||||
do
|
|
||||||
case $opt in
|
|
||||||
1) clear;
|
|
||||||
header_info;
|
|
||||||
option_picked "Using Automatic Login";
|
|
||||||
PW=" "
|
|
||||||
break;
|
|
||||||
;;
|
|
||||||
2) clear;
|
|
||||||
header_info;
|
|
||||||
option_picked "Using Password (changeme)";
|
|
||||||
PW="-password changeme"
|
|
||||||
break;
|
|
||||||
;;
|
|
||||||
|
|
||||||
x)exit;
|
|
||||||
;;
|
|
||||||
\n)exit;
|
|
||||||
;;
|
|
||||||
*)clear;
|
|
||||||
option_picked "Please choose a Password Type from the menu";
|
|
||||||
show_menu2;
|
|
||||||
;;
|
|
||||||
esac
|
|
||||||
done
|
|
||||||
show_menu3(){
|
|
||||||
printf " ${YW} 1)${GN} Automatic DHCP ${CL}\n"
|
|
||||||
printf " ${YW} 2)${GN} Manual DHCP ${CL}\n"
|
|
||||||
|
|
||||||
printf "Please choose a DHCP Type and hit enter or ${RD}x${CL} to exit."
|
|
||||||
read opt
|
|
||||||
}
|
|
||||||
|
|
||||||
option_picked(){
|
|
||||||
message3=${@:-"${CL}Error: No message passed"}
|
|
||||||
printf " ${YW}${message1}${CL}\n"
|
|
||||||
printf " ${YW}${message2}${CL}\n"
|
|
||||||
printf " ${YW}${message3}${CL}\n"
|
|
||||||
}
|
|
||||||
show_menu3
|
|
||||||
while [ "$opt" != " " ]
|
|
||||||
do
|
|
||||||
case $opt in
|
|
||||||
1) clear;
|
|
||||||
header_info;
|
|
||||||
option_picked "Using Automatic DHCP";
|
|
||||||
DHCP=" "
|
|
||||||
break;
|
|
||||||
;;
|
|
||||||
2) clear;
|
|
||||||
header_info;
|
|
||||||
option_picked "Using Manual DHCP";
|
|
||||||
DHCP="1"
|
|
||||||
break;
|
|
||||||
;;
|
|
||||||
|
|
||||||
x)exit;
|
|
||||||
;;
|
|
||||||
\n)exit;
|
|
||||||
;;
|
|
||||||
*)clear;
|
|
||||||
option_picked "Please choose a DHCP Type from the menu";
|
|
||||||
show_menu3;
|
|
||||||
;;
|
|
||||||
esac
|
|
||||||
done
|
|
||||||
|
|
||||||
set -o errexit
|
|
||||||
set -o errtrace
|
|
||||||
set -o nounset
|
|
||||||
set -o pipefail
|
|
||||||
shopt -s expand_aliases
|
|
||||||
alias die='EXIT=$? LINE=$LINENO error_exit'
|
|
||||||
trap die ERR
|
|
||||||
trap cleanup EXIT
|
|
||||||
|
|
||||||
function error_exit() {
|
|
||||||
trap - ERR
|
|
||||||
local DEFAULT='Unknown failure occured.'
|
|
||||||
local REASON="\e[97m${1:-$DEFAULT}\e[39m"
|
|
||||||
local FLAG="\e[91m[ERROR] \e[93m$EXIT@$LINE"
|
|
||||||
msg "$FLAG $REASON"
|
|
||||||
[ ! -z ${CTID-} ] && cleanup_ctid
|
|
||||||
exit $EXIT
|
|
||||||
}
|
|
||||||
function warn() {
|
|
||||||
local REASON="\e[97m$1\e[39m"
|
|
||||||
local FLAG="\e[93m[WARNING]\e[39m"
|
|
||||||
msg "$FLAG $REASON"
|
|
||||||
}
|
|
||||||
function info() {
|
|
||||||
local REASON="$1"
|
|
||||||
local FLAG="\e[36m[INFO]\e[39m"
|
|
||||||
msg "$FLAG $REASON"
|
|
||||||
}
|
|
||||||
function msg() {
|
|
||||||
local TEXT="$1"
|
|
||||||
echo -e "$TEXT"
|
|
||||||
}
|
|
||||||
function cleanup_ctid() {
|
|
||||||
if $(pct status $CTID &>/dev/null); then
|
|
||||||
if [ "$(pct status $CTID | awk '{print $2}')" == "running" ]; then
|
|
||||||
pct stop $CTID
|
|
||||||
fi
|
|
||||||
pct destroy $CTID
|
|
||||||
elif [ "$(pvesm list $STORAGE --vmid $CTID)" != "" ]; then
|
|
||||||
pvesm free $ROOTFS
|
|
||||||
fi
|
|
||||||
}
|
|
||||||
function cleanup() {
|
|
||||||
popd >/dev/null
|
|
||||||
rm -rf $TEMP_DIR
|
|
||||||
}
|
|
||||||
if [ "$IM" == "1" ]; then
|
|
||||||
FEATURES="nesting=1,keyctl=1"
|
|
||||||
else
|
|
||||||
FEATURES="nesting=1"
|
|
||||||
fi
|
|
||||||
|
|
||||||
TEMP_DIR=$(mktemp -d)
|
|
||||||
pushd $TEMP_DIR >/dev/null
|
|
||||||
|
|
||||||
export CTID=$(pvesh get /cluster/nextid)
|
|
||||||
export PCT_OSTYPE=debian
|
|
||||||
export PCT_OSVERSION=11
|
|
||||||
export PCT_DISK_SIZE=8
|
|
||||||
export PCT_OPTIONS="
|
|
||||||
-features $FEATURES
|
|
||||||
-hostname influxdb
|
|
||||||
-net0 name=eth0,bridge=vmbr0,ip=dhcp
|
|
||||||
-onboot 1
|
|
||||||
-cores 2
|
|
||||||
-memory 2048
|
|
||||||
-unprivileged ${IM}
|
|
||||||
${PW}
|
|
||||||
"
|
|
||||||
bash -c "$(wget -qLO - https://raw.githubusercontent.com/tteck/Proxmox/main/ct/create_lxc.sh)" || exit
|
|
||||||
|
|
||||||
STORAGE_TYPE=$(pvesm status -storage $(pct config $CTID | grep rootfs | awk -F ":" '{print $2}') | awk 'NR>1 {print $2}')
|
|
||||||
if [ "$STORAGE_TYPE" == "zfspool" ]; then
|
|
||||||
warn "Some addons may not work due to ZFS not supporting 'fallocate'."
|
|
||||||
fi
|
|
||||||
if [ "$DHCP" == "1" ]; then
|
|
||||||
MAC=$(pct config $CTID \
|
|
||||||
| grep -i hwaddr \
|
|
||||||
| awk '{print substr($2, 31, length($3) 17 ) }') \
|
|
||||||
|
|
||||||
echo -e "MAC Address ${BL}$MAC${CL}"
|
|
||||||
|
|
||||||
dhcp_reservation(){
|
|
||||||
printf "Please set DHCP reservation and press Enter."
|
|
||||||
read
|
|
||||||
}
|
|
||||||
dhcp_reservation
|
|
||||||
fi
|
|
||||||
|
|
||||||
echo -en "${GN} Starting LXC Container... "
|
|
||||||
pct start $CTID
|
|
||||||
echo -e "${CM}${CL} \r"
|
|
||||||
|
|
||||||
alias lxc-cmd="lxc-attach -n $CTID --"
|
|
||||||
|
|
||||||
lxc-cmd bash -c "$(wget -qLO - https://raw.githubusercontent.com/tteck/Proxmox/main/setup/influxdb-install.sh)" || exit
|
|
||||||
|
|
||||||
IP=$(pct exec $CTID ip a s dev eth0 | sed -n '/inet / s/\// /p' | awk '{print $2}')
|
|
||||||
|
|
||||||
echo -e "${GN}Successfully created InfluxDB LXC to${CL} ${BL}$CTID${CL}. \n"
|
|
|
@ -1,355 +0,0 @@
|
||||||
#!/usr/bin/env bash
|
|
||||||
echo -e "Loading..."
|
|
||||||
NEXTID=$(pvesh get /cluster/nextid)
|
|
||||||
INTEGER='^[0-9]+$'
|
|
||||||
YW=`echo "\033[33m"`
|
|
||||||
BL=`echo "\033[36m"`
|
|
||||||
RD=`echo "\033[01;31m"`
|
|
||||||
BGN=`echo "\033[4;92m"`
|
|
||||||
GN=`echo "\033[1;92m"`
|
|
||||||
DGN=`echo "\033[32m"`
|
|
||||||
CL=`echo "\033[m"`
|
|
||||||
BFR="\\r\\033[K"
|
|
||||||
HOLD="-"
|
|
||||||
CM="${GN}✓${CL}"
|
|
||||||
APP="InfluxDB"
|
|
||||||
NSAPP=$(echo ${APP,,} | tr -d ' ')
|
|
||||||
set -o errexit
|
|
||||||
set -o errtrace
|
|
||||||
set -o nounset
|
|
||||||
set -o pipefail
|
|
||||||
shopt -s expand_aliases
|
|
||||||
alias die='EXIT=$? LINE=$LINENO error_exit'
|
|
||||||
trap die ERR
|
|
||||||
|
|
||||||
function error_exit() {
|
|
||||||
trap - ERR
|
|
||||||
local reason="Unknown failure occurred."
|
|
||||||
local msg="${1:-$reason}"
|
|
||||||
local flag="${RD}‼ ERROR ${CL}$EXIT@$LINE"
|
|
||||||
echo -e "$flag $msg" 1>&2
|
|
||||||
exit $EXIT
|
|
||||||
}
|
|
||||||
|
|
||||||
while true; do
|
|
||||||
clear
|
|
||||||
read -p "This will create a New ${APP} LXC. Proceed(y/n)?" yn
|
|
||||||
case $yn in
|
|
||||||
[Yy]* ) break;;
|
|
||||||
[Nn]* ) exit;;
|
|
||||||
* ) echo "Please answer yes or no.";;
|
|
||||||
esac
|
|
||||||
done
|
|
||||||
clear
|
|
||||||
function header_info {
|
|
||||||
echo -e "${YW}
|
|
||||||
_____ __ _ _____ ____
|
|
||||||
|_ _| / _| | | __ \| _ \
|
|
||||||
| | _ __ | |_| |_ v3___ _| | | | |_) |
|
|
||||||
| | | _ \| _| | | | \ \/ / | | | _ <
|
|
||||||
_| |_| | | | | | | |_| |> <| |__| | |_) |
|
|
||||||
|_____|_| |_|_| |_|\__,_/_/\_\_____/|____/
|
|
||||||
with Telegraf
|
|
||||||
${CL}"
|
|
||||||
}
|
|
||||||
|
|
||||||
header_info
|
|
||||||
|
|
||||||
function msg_info() {
|
|
||||||
local msg="$1"
|
|
||||||
echo -ne " ${HOLD} ${YW}${msg}..."
|
|
||||||
}
|
|
||||||
|
|
||||||
function msg_ok() {
|
|
||||||
local msg="$1"
|
|
||||||
echo -e "${BFR} ${CM} ${GN}${msg}${CL}"
|
|
||||||
}
|
|
||||||
|
|
||||||
function PVE_CHECK() {
|
|
||||||
PVE=$(pveversion | grep "pve-manager/7" | wc -l)
|
|
||||||
|
|
||||||
if [[ $PVE != 1 ]]; then
|
|
||||||
echo -e "${RD}This script requires Proxmox Virtual Environment 7.0 or greater${CL}"
|
|
||||||
echo -e "Exiting..."
|
|
||||||
sleep 2
|
|
||||||
exit
|
|
||||||
fi
|
|
||||||
}
|
|
||||||
|
|
||||||
function default_settings() {
|
|
||||||
clear
|
|
||||||
header_info
|
|
||||||
echo -e "${BL}Using Default Settings${CL}"
|
|
||||||
echo -e "${DGN}Using CT Type ${BGN}Unprivileged${CL} ${RD}NO DEVICE PASSTHROUGH${CL}"
|
|
||||||
CT_TYPE="1"
|
|
||||||
echo -e "${DGN}Using CT Password ${BGN}Automatic Login${CL}"
|
|
||||||
PW=" "
|
|
||||||
echo -e "${DGN}Using CT ID ${BGN}$NEXTID${CL}"
|
|
||||||
CT_ID=$NEXTID
|
|
||||||
echo -e "${DGN}Using CT Name ${BGN}$NSAPP${CL}"
|
|
||||||
HN=$NSAPP
|
|
||||||
echo -e "${DGN}Using Disk Size ${BGN}8${CL}${DGN}GB${CL}"
|
|
||||||
DISK_SIZE="8"
|
|
||||||
echo -e "${DGN}Using ${BGN}2${CL}${DGN}vCPU${CL}"
|
|
||||||
CORE_COUNT="2"
|
|
||||||
echo -e "${DGN}Using ${BGN}2048${CL}${DGN}MiB RAM${CL}"
|
|
||||||
RAM_SIZE="2048"
|
|
||||||
echo -e "${DGN}Using Bridge ${BGN}vmbr0${CL}"
|
|
||||||
BRG="vmbr0"
|
|
||||||
echo -e "${DGN}Using Static IP Address ${BGN}DHCP${CL}"
|
|
||||||
NET=dhcp
|
|
||||||
echo -e "${DGN}Using Gateway Address ${BGN}NONE${CL}"
|
|
||||||
GATE=""
|
|
||||||
echo -e "${DGN}Using VLAN Tag ${BGN}NONE${CL}"
|
|
||||||
VLAN=""
|
|
||||||
}
|
|
||||||
|
|
||||||
function advanced_settings() {
|
|
||||||
clear
|
|
||||||
header_info
|
|
||||||
echo -e "${RD}Using Advanced Settings${CL}"
|
|
||||||
echo -e "${YW}Type Privileged, or Press [ENTER] for Default: Unprivileged (${RD}NO DEVICE PASSTHROUGH${CL}${YW})"
|
|
||||||
read CT_TYPE1
|
|
||||||
if [ -z $CT_TYPE1 ]; then CT_TYPE1="Unprivileged" CT_TYPE="1";
|
|
||||||
echo -en "${DGN}Set CT Type ${BL}$CT_TYPE1${CL}"
|
|
||||||
else
|
|
||||||
CT_TYPE1="Privileged"
|
|
||||||
CT_TYPE="0"
|
|
||||||
echo -en "${DGN}Set CT Type ${BL}Privileged${CL}"
|
|
||||||
fi;
|
|
||||||
echo -e " ${CM}${CL} \r"
|
|
||||||
sleep 1
|
|
||||||
clear
|
|
||||||
header_info
|
|
||||||
echo -e "${RD}Using Advanced Settings${CL}"
|
|
||||||
echo -e "${DGN}Using CT Type ${BGN}$CT_TYPE1${CL}"
|
|
||||||
echo -e "${YW}Set Password, or Press [ENTER] for Default: Automatic Login "
|
|
||||||
read PW1
|
|
||||||
if [ -z $PW1 ]; then PW1="Automatic Login" PW=" ";
|
|
||||||
echo -en "${DGN}Set CT ${BL}$PW1${CL}"
|
|
||||||
else
|
|
||||||
PW="-password $PW1"
|
|
||||||
echo -en "${DGN}Set CT Password ${BL}$PW1${CL}"
|
|
||||||
fi;
|
|
||||||
echo -e " ${CM}${CL} \r"
|
|
||||||
sleep 1
|
|
||||||
clear
|
|
||||||
header_info
|
|
||||||
echo -e "${RD}Using Advanced Settings${CL}"
|
|
||||||
echo -e "${DGN}Using CT Type ${BGN}$CT_TYPE1${CL}"
|
|
||||||
echo -e "${DGN}Using CT Password ${BGN}$PW1${CL}"
|
|
||||||
echo -e "${YW}Enter the CT ID, or Press [ENTER] to automatically generate (${NEXTID}) "
|
|
||||||
read CT_ID
|
|
||||||
if [ -z $CT_ID ]; then CT_ID=$NEXTID; fi;
|
|
||||||
echo -en "${DGN}Set CT ID To ${BL}$CT_ID${CL}"
|
|
||||||
echo -e " ${CM}${CL} \r"
|
|
||||||
sleep 1
|
|
||||||
clear
|
|
||||||
header_info
|
|
||||||
echo -e "${RD}Using Advanced Settings${CL}"
|
|
||||||
echo -e "${DGN}Using CT Type ${BGN}$CT_TYPE1${CL}"
|
|
||||||
echo -e "${DGN}Using CT Password ${BGN}$PW1${CL}"
|
|
||||||
echo -e "${DGN}Using CT ID ${BGN}$CT_ID${CL}"
|
|
||||||
echo -e "${YW}Enter CT Name (no-spaces), or Press [ENTER] for Default: $NSAPP "
|
|
||||||
read CT_NAME
|
|
||||||
if [ -z $CT_NAME ]; then
|
|
||||||
HN=$NSAPP
|
|
||||||
else
|
|
||||||
HN=$(echo ${CT_NAME,,} | tr -d ' ')
|
|
||||||
fi
|
|
||||||
echo -en "${DGN}Set CT Name To ${BL}$HN${CL}"
|
|
||||||
echo -e " ${CM}${CL} \r"
|
|
||||||
sleep 1
|
|
||||||
clear
|
|
||||||
header_info
|
|
||||||
echo -e "${RD}Using Advanced Settings${CL}"
|
|
||||||
echo -e "${DGN}Using CT Type ${BGN}$CT_TYPE1${CL}"
|
|
||||||
echo -e "${DGN}Using CT Password ${BGN}$PW1${CL}"
|
|
||||||
echo -e "${DGN}Using CT ID ${BGN}$CT_ID${CL}"
|
|
||||||
echo -e "${DGN}Using CT Name ${BGN}$HN${CL}"
|
|
||||||
echo -e "${YW}Enter a Disk Size, or Press [ENTER] for Default: 8 "
|
|
||||||
read DISK_SIZE
|
|
||||||
if [ -z $DISK_SIZE ]; then DISK_SIZE="8"; fi;
|
|
||||||
if ! [[ $DISK_SIZE =~ $INTEGER ]] ; then echo "ERROR! DISK SIZE MUST HAVE INTEGER NUMBER!"; exit; fi;
|
|
||||||
echo -en "${DGN}Set Disk Size To ${BL}$DISK_SIZE${CL}${DGN}GB${CL}"
|
|
||||||
echo -e " ${CM}${CL} \r"
|
|
||||||
sleep 1
|
|
||||||
clear
|
|
||||||
header_info
|
|
||||||
echo -e "${RD}Using Advanced Settings${CL}"
|
|
||||||
echo -e "${DGN}Using CT Type ${BGN}$CT_TYPE1${CL}"
|
|
||||||
echo -e "${DGN}Using CT Password ${BGN}$PW1${CL}"
|
|
||||||
echo -e "${DGN}Using CT ID ${BGN}$CT_ID${CL}"
|
|
||||||
echo -e "${DGN}Using CT Name ${BGN}$HN${CL}"
|
|
||||||
echo -e "${DGN}Using Disk Size ${BGN}$DISK_SIZE${CL}${DGN}GB${CL}"
|
|
||||||
echo -e "${YW}Allocate CPU cores, or Press [ENTER] for Default: 2 "
|
|
||||||
read CORE_COUNT
|
|
||||||
if [ -z $CORE_COUNT ]; then CORE_COUNT="2"; fi;
|
|
||||||
echo -en "${DGN}Set Cores To ${BL}$CORE_COUNT${CL}${DGN}vCPU${CL}"
|
|
||||||
echo -e " ${CM}${CL} \r"
|
|
||||||
sleep 1
|
|
||||||
clear
|
|
||||||
header_info
|
|
||||||
echo -e "${RD}Using Advanced Settings${CL}"
|
|
||||||
echo -e "${DGN}Using CT Type ${BGN}$CT_TYPE1${CL}"
|
|
||||||
echo -e "${DGN}Using CT Password ${BGN}$PW1${CL}"
|
|
||||||
echo -e "${DGN}Using CT ID ${BGN}$CT_ID${CL}"
|
|
||||||
echo -e "${DGN}Using CT Name ${BGN}$HN${CL}"
|
|
||||||
echo -e "${DGN}Using Disk Size ${BGN}$DISK_SIZE${CL}${DGN}GB${CL}"
|
|
||||||
echo -e "${DGN}Using ${BGN}${CORE_COUNT}${CL}${DGN}vCPU${CL}"
|
|
||||||
echo -e "${YW}Allocate RAM in MiB, or Press [ENTER] for Default: 2048 "
|
|
||||||
read RAM_SIZE
|
|
||||||
if [ -z $RAM_SIZE ]; then RAM_SIZE="2048"; fi;
|
|
||||||
echo -en "${DGN}Set RAM To ${BL}$RAM_SIZE${CL}${DGN}MiB RAM${CL}"
|
|
||||||
echo -e " ${CM}${CL} \n"
|
|
||||||
sleep 1
|
|
||||||
clear
|
|
||||||
header_info
|
|
||||||
echo -e "${RD}Using Advanced Settings${CL}"
|
|
||||||
echo -e "${DGN}Using CT Type ${BGN}$CT_TYPE1${CL}"
|
|
||||||
echo -e "${DGN}Using CT Password ${BGN}$PW1${CL}"
|
|
||||||
echo -e "${DGN}Using CT ID ${BGN}$CT_ID${CL}"
|
|
||||||
echo -e "${DGN}Using CT Name ${BGN}$HN${CL}"
|
|
||||||
echo -e "${DGN}Using Disk Size ${BGN}$DISK_SIZE${CL}${DGN}GB${CL}"
|
|
||||||
echo -e "${DGN}Using ${BGN}${CORE_COUNT}${CL}${DGN}vCPU${CL}"
|
|
||||||
echo -e "${DGN}Using ${BGN}${RAM_SIZE}${CL}${DGN}MiB RAM${CL}"
|
|
||||||
echo -e "${YW}Enter a Bridge, or Press [ENTER] for Default: vmbr0 "
|
|
||||||
read BRG
|
|
||||||
if [ -z $BRG ]; then BRG="vmbr0"; fi;
|
|
||||||
echo -en "${DGN}Set Bridge To ${BL}$BRG${CL}"
|
|
||||||
echo -e " ${CM}${CL} \n"
|
|
||||||
sleep 1
|
|
||||||
clear
|
|
||||||
header_info
|
|
||||||
echo -e "${RD}Using Advanced Settings${CL}"
|
|
||||||
echo -e "${DGN}Using CT Type ${BGN}$CT_TYPE1${CL}"
|
|
||||||
echo -e "${DGN}Using CT Password ${BGN}$PW1${CL}"
|
|
||||||
echo -e "${DGN}Using CT ID ${BGN}$CT_ID${CL}"
|
|
||||||
echo -e "${DGN}Using CT Name ${BGN}$HN${CL}"
|
|
||||||
echo -e "${DGN}Using Disk Size ${BGN}$DISK_SIZE${CL}${DGN}GB${CL}"
|
|
||||||
echo -e "${DGN}Using ${BGN}${CORE_COUNT}${CL}${DGN}vCPU${CL}"
|
|
||||||
echo -e "${DGN}Using ${BGN}${RAM_SIZE}${CL}${DGN}MiB RAM${CL}"
|
|
||||||
echo -e "${DGN}Using Bridge ${BGN}${BRG}${CL}"
|
|
||||||
echo -e "${YW}Enter a Static IPv4 CIDR Address, or Press [ENTER] for Default: DHCP "
|
|
||||||
read NET
|
|
||||||
if [ -z $NET ]; then NET="dhcp"; fi;
|
|
||||||
echo -en "${DGN}Set Static IP Address To ${BL}$NET${CL}"
|
|
||||||
echo -e " ${CM}${CL} \n"
|
|
||||||
sleep 1
|
|
||||||
clear
|
|
||||||
header_info
|
|
||||||
echo -e "${RD}Using Advanced Settings${CL}"
|
|
||||||
echo -e "${DGN}Using CT Type ${BGN}$CT_TYPE1${CL}"
|
|
||||||
echo -e "${DGN}Using CT Password ${BGN}$PW1${CL}"
|
|
||||||
echo -e "${DGN}Using CT ID ${BGN}$CT_ID${CL}"
|
|
||||||
echo -e "${DGN}Using CT Name ${BGN}$HN${CL}"
|
|
||||||
echo -e "${DGN}Using Disk Size ${BGN}$DISK_SIZE${CL}${DGN}GB${CL}"
|
|
||||||
echo -e "${DGN}Using ${BGN}${CORE_COUNT}${CL}${DGN}vCPU${CL}"
|
|
||||||
echo -e "${DGN}Using ${BGN}${RAM_SIZE}${CL}${DGN}MiB RAM${CL}"
|
|
||||||
echo -e "${DGN}Using Bridge ${BGN}${BRG}${CL}"
|
|
||||||
echo -e "${DGN}Using Static IP Address ${BGN}$NET${CL}"
|
|
||||||
echo -e "${YW}Enter a Gateway IP (mandatory if static IP is used), or Press [ENTER] for Default: NONE "
|
|
||||||
read GATE1
|
|
||||||
if [ -z $GATE1 ]; then GATE1="NONE" GATE="";
|
|
||||||
echo -en "${DGN}Set Gateway IP To ${BL}$GATE1${CL}"
|
|
||||||
else
|
|
||||||
GATE=",gw=$GATE1"
|
|
||||||
echo -en "${DGN}Set Gateway IP To ${BL}$GATE1${CL}"
|
|
||||||
fi;
|
|
||||||
echo -e " ${CM}${CL} \n"
|
|
||||||
sleep 1
|
|
||||||
clear
|
|
||||||
header_info
|
|
||||||
|
|
||||||
echo -e "${RD}Using Advanced Settings${CL}"
|
|
||||||
echo -e "${DGN}Using CT Type ${BGN}$CT_TYPE1${CL}"
|
|
||||||
echo -e "${DGN}Using CT Password ${BGN}$PW1${CL}"
|
|
||||||
echo -e "${DGN}Using CT ID ${BGN}$CT_ID${CL}"
|
|
||||||
echo -e "${DGN}Using CT Name ${BGN}$HN${CL}"
|
|
||||||
echo -e "${DGN}Using Disk Size ${BGN}$DISK_SIZE${CL}${DGN}GB${CL}"
|
|
||||||
echo -e "${DGN}Using ${BGN}${CORE_COUNT}${CL}${DGN}vCPU${CL}"
|
|
||||||
echo -e "${DGN}Using ${BGN}${RAM_SIZE}${CL}${DGN}MiB RAM${CL}"
|
|
||||||
echo -e "${DGN}Using Bridge ${BGN}${BRG}${CL}"
|
|
||||||
echo -e "${DGN}Using Static IP Address ${BGN}$NET${CL}"
|
|
||||||
echo -e "${DGN}Using Gateway IP Address ${BGN}$GATE1${CL}"
|
|
||||||
echo -e "${YW}Enter a VLAN Tag, or Press [ENTER] for Default: NONE "
|
|
||||||
read VLAN1
|
|
||||||
if [ -z $VLAN1 ]; then VLAN1="NONE" VLAN="";
|
|
||||||
echo -en "${DGN}Set VLAN Tag To ${BL}$VLAN1${CL}"
|
|
||||||
else
|
|
||||||
VLAN=",tag=$VLAN1"
|
|
||||||
echo -en "${DGN}Set VLAN Tag To ${BL}$VLAN1${CL}"
|
|
||||||
fi;
|
|
||||||
echo -e " ${CM}${CL} \n"
|
|
||||||
sleep 1
|
|
||||||
clear
|
|
||||||
header_info
|
|
||||||
echo -e "${RD}Using Advanced Settings${CL}"
|
|
||||||
echo -e "${DGN}Using CT Type ${BGN}$CT_TYPE1${CL}"
|
|
||||||
echo -e "${DGN}Using CT Password ${BGN}$PW1${CL}"
|
|
||||||
echo -e "${DGN}Using CT ID ${BGN}$CT_ID${CL}"
|
|
||||||
echo -e "${DGN}Using CT Name ${BGN}$HN${CL}"
|
|
||||||
echo -e "${DGN}Using Disk Size ${BGN}$DISK_SIZE${CL}${DGN}GB${CL}"
|
|
||||||
echo -e "${DGN}Using ${BGN}${CORE_COUNT}${CL}${DGN}vCPU${CL}"
|
|
||||||
echo -e "${DGN}Using ${BGN}${RAM_SIZE}${CL}${DGN}MiB RAM${CL}"
|
|
||||||
echo -e "${DGN}Using Bridge ${BGN}${BRG}${CL}"
|
|
||||||
echo -e "${DGN}Using Static IP Address ${BGN}$NET${CL}"
|
|
||||||
echo -e "${DGN}Using Gateway IP Address ${BGN}$GATE1${CL}"
|
|
||||||
echo -e "${DGN}Using VLAN Tag ${BGN}$VLAN1${CL}"
|
|
||||||
|
|
||||||
read -p "Are these settings correct(y/n)? " -n 1 -r
|
|
||||||
echo
|
|
||||||
if [[ ! $REPLY =~ ^[Yy]$ ]]
|
|
||||||
then
|
|
||||||
advanced_settings
|
|
||||||
fi
|
|
||||||
}
|
|
||||||
|
|
||||||
function start_script() {
|
|
||||||
echo -e "${YW}Type Advanced, or Press [ENTER] for Default Settings "
|
|
||||||
read SETTINGS
|
|
||||||
if [ -z $SETTINGS ]; then default_settings;
|
|
||||||
else
|
|
||||||
advanced_settings
|
|
||||||
fi;
|
|
||||||
}
|
|
||||||
|
|
||||||
start_script
|
|
||||||
|
|
||||||
if [ "$CT_TYPE" == "1" ]; then
|
|
||||||
FEATURES="nesting=1,keyctl=1"
|
|
||||||
else
|
|
||||||
FEATURES="nesting=1"
|
|
||||||
fi
|
|
||||||
|
|
||||||
TEMP_DIR=$(mktemp -d)
|
|
||||||
pushd $TEMP_DIR >/dev/null
|
|
||||||
|
|
||||||
export CTID=$CT_ID
|
|
||||||
export PCT_OSTYPE=debian
|
|
||||||
export PCT_OSVERSION=11
|
|
||||||
export PCT_DISK_SIZE=$DISK_SIZE
|
|
||||||
export PCT_OPTIONS="
|
|
||||||
-features $FEATURES
|
|
||||||
-hostname $HN
|
|
||||||
-net0 name=eth0,bridge=$BRG,ip=$NET$GATE$VLAN
|
|
||||||
-onboot 1
|
|
||||||
-cores $CORE_COUNT
|
|
||||||
-memory $RAM_SIZE
|
|
||||||
-unprivileged $CT_TYPE
|
|
||||||
$PW
|
|
||||||
"
|
|
||||||
bash -c "$(wget -qLO - https://raw.githubusercontent.com/tteck/Proxmox/main/ct/create_lxc.sh)" || exit
|
|
||||||
|
|
||||||
msg_info "Starting LXC Container"
|
|
||||||
pct start $CTID
|
|
||||||
msg_ok "Started LXC Container"
|
|
||||||
|
|
||||||
lxc-attach -n $CTID -- bash -c "$(wget -qLO - https://raw.githubusercontent.com/tteck/Proxmox/main/setup/influxdb-install.sh)" || exit
|
|
||||||
|
|
||||||
IP=$(pct exec $CTID ip a s dev eth0 | sed -n '/inet / s/\// /p' | awk '{print $2}')
|
|
||||||
|
|
||||||
pct set $CTID -description "# ${APP} LXC
|
|
||||||
### https://github.com/tteck/Proxmox"
|
|
||||||
|
|
||||||
msg_ok "Completed Successfully!\n"
|
|
|
@ -309,7 +309,7 @@ bash -c "$(wget -qLO - https://raw.githubusercontent.com/tteck/Proxmox/main/ct/c
|
||||||
msg_info "Starting LXC Container"
|
msg_info "Starting LXC Container"
|
||||||
pct start $CTID
|
pct start $CTID
|
||||||
msg_ok "Started LXC Container"
|
msg_ok "Started LXC Container"
|
||||||
lxc-attach -n $CTID -- bash -c "$(wget -qLO - https://raw.githubusercontent.com/tteck/Proxmox/main/setup/$var_install.sh)" || exit
|
lxc-attach -n $CTID -- bash -c "$(wget -qLO - https://raw.githubusercontent.com/tteck/Proxmox/main/install/$var_install.sh)" || exit
|
||||||
IP=$(pct exec $CTID ip a s dev eth0 | sed -n '/inet / s/\// /p' | awk '{print $2}')
|
IP=$(pct exec $CTID ip a s dev eth0 | sed -n '/inet / s/\// /p' | awk '{print $2}')
|
||||||
pct set $CTID -description "# ${APP} LXC
|
pct set $CTID -description "# ${APP} LXC
|
||||||
### https://tteck.github.io/Proxmox/
|
### https://tteck.github.io/Proxmox/
|
||||||
|
|
|
@ -1,356 +0,0 @@
|
||||||
#!/usr/bin/env bash
|
|
||||||
echo -e "Loading..."
|
|
||||||
NEXTID=$(pvesh get /cluster/nextid)
|
|
||||||
INTEGER='^[0-9]+$'
|
|
||||||
YW=`echo "\033[33m"`
|
|
||||||
BL=`echo "\033[36m"`
|
|
||||||
RD=`echo "\033[01;31m"`
|
|
||||||
BGN=`echo "\033[4;92m"`
|
|
||||||
GN=`echo "\033[1;92m"`
|
|
||||||
DGN=`echo "\033[32m"`
|
|
||||||
CL=`echo "\033[m"`
|
|
||||||
BFR="\\r\\033[K"
|
|
||||||
HOLD="-"
|
|
||||||
CM="${GN}✓${CL}"
|
|
||||||
APP="ioBroker"
|
|
||||||
NSAPP=$(echo ${APP,,} | tr -d ' ')
|
|
||||||
set -o errexit
|
|
||||||
set -o errtrace
|
|
||||||
set -o nounset
|
|
||||||
set -o pipefail
|
|
||||||
shopt -s expand_aliases
|
|
||||||
alias die='EXIT=$? LINE=$LINENO error_exit'
|
|
||||||
trap die ERR
|
|
||||||
|
|
||||||
function error_exit() {
|
|
||||||
trap - ERR
|
|
||||||
local reason="Unknown failure occurred."
|
|
||||||
local msg="${1:-$reason}"
|
|
||||||
local flag="${RD}‼ ERROR ${CL}$EXIT@$LINE"
|
|
||||||
echo -e "$flag $msg" 1>&2
|
|
||||||
exit $EXIT
|
|
||||||
}
|
|
||||||
|
|
||||||
while true; do
|
|
||||||
clear
|
|
||||||
read -p "This will create a New ${APP} LXC. Proceed(y/n)?" yn
|
|
||||||
case $yn in
|
|
||||||
[Yy]* ) break;;
|
|
||||||
[Nn]* ) exit;;
|
|
||||||
* ) echo "Please answer yes or no.";;
|
|
||||||
esac
|
|
||||||
done
|
|
||||||
clear
|
|
||||||
function header_info {
|
|
||||||
echo -e "${BL}
|
|
||||||
_ ____ _
|
|
||||||
(_) | _ \ | |
|
|
||||||
_ ___ | |_) |_ __ ___ | | _____ _ __
|
|
||||||
| |/ _ \| _ <| __/ _ \| |/ / _ \ __|
|
|
||||||
| | (_) | |_) | | | (_) | < __/ |
|
|
||||||
|_|\___/|____/|_|v3\___/|_|\_\___|_|
|
|
||||||
${CL}"
|
|
||||||
}
|
|
||||||
|
|
||||||
header_info
|
|
||||||
|
|
||||||
function msg_info() {
|
|
||||||
local msg="$1"
|
|
||||||
echo -ne " ${HOLD} ${YW}${msg}..."
|
|
||||||
}
|
|
||||||
|
|
||||||
function msg_ok() {
|
|
||||||
local msg="$1"
|
|
||||||
echo -e "${BFR} ${CM} ${GN}${msg}${CL}"
|
|
||||||
}
|
|
||||||
|
|
||||||
function PVE_CHECK() {
|
|
||||||
PVE=$(pveversion | grep "pve-manager/7" | wc -l)
|
|
||||||
|
|
||||||
if [[ $PVE != 1 ]]; then
|
|
||||||
echo -e "${RD}This script requires Proxmox Virtual Environment 7.0 or greater${CL}"
|
|
||||||
echo -e "Exiting..."
|
|
||||||
sleep 2
|
|
||||||
exit
|
|
||||||
fi
|
|
||||||
}
|
|
||||||
|
|
||||||
function default_settings() {
|
|
||||||
clear
|
|
||||||
header_info
|
|
||||||
echo -e "${BL}Using Default Settings${CL}"
|
|
||||||
echo -e "${DGN}Using CT Type ${BGN}Unprivileged${CL} ${RD}NO DEVICE PASSTHROUGH${CL}"
|
|
||||||
CT_TYPE="1"
|
|
||||||
echo -e "${DGN}Using CT Password ${BGN}Automatic Login${CL}"
|
|
||||||
PW=" "
|
|
||||||
echo -e "${DGN}Using CT ID ${BGN}$NEXTID${CL}"
|
|
||||||
CT_ID=$NEXTID
|
|
||||||
echo -e "${DGN}Using CT Name ${BGN}$NSAPP${CL}"
|
|
||||||
HN=$NSAPP
|
|
||||||
echo -e "${DGN}Using Disk Size ${BGN}8${CL}${DGN}GB${CL}"
|
|
||||||
DISK_SIZE="8"
|
|
||||||
echo -e "${DGN}Using ${BGN}2${CL}${DGN}vCPU${CL}"
|
|
||||||
CORE_COUNT="2"
|
|
||||||
echo -e "${DGN}Using ${BGN}2048${CL}${DGN}MiB RAM${CL}"
|
|
||||||
RAM_SIZE="2048"
|
|
||||||
echo -e "${DGN}Using Bridge ${BGN}vmbr0${CL}"
|
|
||||||
BRG="vmbr0"
|
|
||||||
echo -e "${DGN}Using Static IP Address ${BGN}DHCP${CL}"
|
|
||||||
NET=dhcp
|
|
||||||
echo -e "${DGN}Using Gateway Address ${BGN}NONE${CL}"
|
|
||||||
GATE=""
|
|
||||||
echo -e "${DGN}Using VLAN Tag ${BGN}NONE${CL}"
|
|
||||||
VLAN=""
|
|
||||||
}
|
|
||||||
|
|
||||||
function advanced_settings() {
|
|
||||||
clear
|
|
||||||
header_info
|
|
||||||
echo -e "${RD}Using Advanced Settings${CL}"
|
|
||||||
echo -e "${YW}Type Privileged, or Press [ENTER] for Default: Unprivileged (${RD}NO DEVICE PASSTHROUGH${CL}${YW})"
|
|
||||||
read CT_TYPE1
|
|
||||||
if [ -z $CT_TYPE1 ]; then CT_TYPE1="Unprivileged" CT_TYPE="1";
|
|
||||||
echo -en "${DGN}Set CT Type ${BL}$CT_TYPE1${CL}"
|
|
||||||
else
|
|
||||||
CT_TYPE1="Privileged"
|
|
||||||
CT_TYPE="0"
|
|
||||||
echo -en "${DGN}Set CT Type ${BL}Privileged${CL}"
|
|
||||||
fi;
|
|
||||||
echo -e " ${CM}${CL} \r"
|
|
||||||
sleep 1
|
|
||||||
clear
|
|
||||||
header_info
|
|
||||||
echo -e "${RD}Using Advanced Settings${CL}"
|
|
||||||
echo -e "${DGN}Using CT Type ${BGN}$CT_TYPE1${CL}"
|
|
||||||
echo -e "${YW}Set Password, or Press [ENTER] for Default: Automatic Login "
|
|
||||||
read PW1
|
|
||||||
if [ -z $PW1 ]; then PW1="Automatic Login" PW=" ";
|
|
||||||
echo -en "${DGN}Set CT ${BL}$PW1${CL}"
|
|
||||||
else
|
|
||||||
PW="-password $PW1"
|
|
||||||
echo -en "${DGN}Set CT Password ${BL}$PW1${CL}"
|
|
||||||
fi;
|
|
||||||
echo -e " ${CM}${CL} \r"
|
|
||||||
sleep 1
|
|
||||||
clear
|
|
||||||
header_info
|
|
||||||
echo -e "${RD}Using Advanced Settings${CL}"
|
|
||||||
echo -e "${DGN}Using CT Type ${BGN}$CT_TYPE1${CL}"
|
|
||||||
echo -e "${DGN}Using CT Password ${BGN}$PW1${CL}"
|
|
||||||
echo -e "${YW}Enter the CT ID, or Press [ENTER] to automatically generate (${NEXTID}) "
|
|
||||||
read CT_ID
|
|
||||||
if [ -z $CT_ID ]; then CT_ID=$NEXTID; fi;
|
|
||||||
echo -en "${DGN}Set CT ID To ${BL}$CT_ID${CL}"
|
|
||||||
echo -e " ${CM}${CL} \r"
|
|
||||||
sleep 1
|
|
||||||
clear
|
|
||||||
header_info
|
|
||||||
echo -e "${RD}Using Advanced Settings${CL}"
|
|
||||||
echo -e "${DGN}Using CT Type ${BGN}$CT_TYPE1${CL}"
|
|
||||||
echo -e "${DGN}Using CT Password ${BGN}$PW1${CL}"
|
|
||||||
echo -e "${DGN}Using CT ID ${BGN}$CT_ID${CL}"
|
|
||||||
echo -e "${YW}Enter CT Name (no-spaces), or Press [ENTER] for Default: $NSAPP "
|
|
||||||
read CT_NAME
|
|
||||||
if [ -z $CT_NAME ]; then
|
|
||||||
HN=$NSAPP
|
|
||||||
else
|
|
||||||
HN=$(echo ${CT_NAME,,} | tr -d ' ')
|
|
||||||
fi
|
|
||||||
echo -en "${DGN}Set CT Name To ${BL}$HN${CL}"
|
|
||||||
echo -e " ${CM}${CL} \r"
|
|
||||||
sleep 1
|
|
||||||
clear
|
|
||||||
header_info
|
|
||||||
echo -e "${RD}Using Advanced Settings${CL}"
|
|
||||||
echo -e "${DGN}Using CT Type ${BGN}$CT_TYPE1${CL}"
|
|
||||||
echo -e "${DGN}Using CT Password ${BGN}$PW1${CL}"
|
|
||||||
echo -e "${DGN}Using CT ID ${BGN}$CT_ID${CL}"
|
|
||||||
echo -e "${DGN}Using CT Name ${BGN}$HN${CL}"
|
|
||||||
echo -e "${YW}Enter a Disk Size, or Press [ENTER] for Default: 8 "
|
|
||||||
read DISK_SIZE
|
|
||||||
if [ -z $DISK_SIZE ]; then DISK_SIZE="8"; fi;
|
|
||||||
if ! [[ $DISK_SIZE =~ $INTEGER ]] ; then echo "ERROR! DISK SIZE MUST HAVE INTEGER NUMBER!"; exit; fi;
|
|
||||||
echo -en "${DGN}Set Disk Size To ${BL}$DISK_SIZE${CL}${DGN}GB${CL}"
|
|
||||||
echo -e " ${CM}${CL} \r"
|
|
||||||
sleep 1
|
|
||||||
clear
|
|
||||||
header_info
|
|
||||||
echo -e "${RD}Using Advanced Settings${CL}"
|
|
||||||
echo -e "${DGN}Using CT Type ${BGN}$CT_TYPE1${CL}"
|
|
||||||
echo -e "${DGN}Using CT Password ${BGN}$PW1${CL}"
|
|
||||||
echo -e "${DGN}Using CT ID ${BGN}$CT_ID${CL}"
|
|
||||||
echo -e "${DGN}Using CT Name ${BGN}$HN${CL}"
|
|
||||||
echo -e "${DGN}Using Disk Size ${BGN}$DISK_SIZE${CL}${DGN}GB${CL}"
|
|
||||||
echo -e "${YW}Allocate CPU cores, or Press [ENTER] for Default: 2 "
|
|
||||||
read CORE_COUNT
|
|
||||||
if [ -z $CORE_COUNT ]; then CORE_COUNT="2"; fi;
|
|
||||||
echo -en "${DGN}Set Cores To ${BL}$CORE_COUNT${CL}${DGN}vCPU${CL}"
|
|
||||||
echo -e " ${CM}${CL} \r"
|
|
||||||
sleep 1
|
|
||||||
clear
|
|
||||||
header_info
|
|
||||||
echo -e "${RD}Using Advanced Settings${CL}"
|
|
||||||
echo -e "${DGN}Using CT Type ${BGN}$CT_TYPE1${CL}"
|
|
||||||
echo -e "${DGN}Using CT Password ${BGN}$PW1${CL}"
|
|
||||||
echo -e "${DGN}Using CT ID ${BGN}$CT_ID${CL}"
|
|
||||||
echo -e "${DGN}Using CT Name ${BGN}$HN${CL}"
|
|
||||||
echo -e "${DGN}Using Disk Size ${BGN}$DISK_SIZE${CL}${DGN}GB${CL}"
|
|
||||||
echo -e "${DGN}Using ${BGN}${CORE_COUNT}${CL}${DGN}vCPU${CL}"
|
|
||||||
echo -e "${YW}Allocate RAM in MiB, or Press [ENTER] for Default: 2048 "
|
|
||||||
read RAM_SIZE
|
|
||||||
if [ -z $RAM_SIZE ]; then RAM_SIZE="2048"; fi;
|
|
||||||
echo -en "${DGN}Set RAM To ${BL}$RAM_SIZE${CL}${DGN}MiB RAM${CL}"
|
|
||||||
echo -e " ${CM}${CL} \n"
|
|
||||||
sleep 1
|
|
||||||
clear
|
|
||||||
header_info
|
|
||||||
echo -e "${RD}Using Advanced Settings${CL}"
|
|
||||||
echo -e "${DGN}Using CT Type ${BGN}$CT_TYPE1${CL}"
|
|
||||||
echo -e "${DGN}Using CT Password ${BGN}$PW1${CL}"
|
|
||||||
echo -e "${DGN}Using CT ID ${BGN}$CT_ID${CL}"
|
|
||||||
echo -e "${DGN}Using CT Name ${BGN}$HN${CL}"
|
|
||||||
echo -e "${DGN}Using Disk Size ${BGN}$DISK_SIZE${CL}${DGN}GB${CL}"
|
|
||||||
echo -e "${DGN}Using ${BGN}${CORE_COUNT}${CL}${DGN}vCPU${CL}"
|
|
||||||
echo -e "${DGN}Using ${BGN}${RAM_SIZE}${CL}${DGN}MiB RAM${CL}"
|
|
||||||
echo -e "${YW}Enter a Bridge, or Press [ENTER] for Default: vmbr0 "
|
|
||||||
read BRG
|
|
||||||
if [ -z $BRG ]; then BRG="vmbr0"; fi;
|
|
||||||
echo -en "${DGN}Set Bridge To ${BL}$BRG${CL}"
|
|
||||||
echo -e " ${CM}${CL} \n"
|
|
||||||
sleep 1
|
|
||||||
clear
|
|
||||||
header_info
|
|
||||||
echo -e "${RD}Using Advanced Settings${CL}"
|
|
||||||
echo -e "${DGN}Using CT Type ${BGN}$CT_TYPE1${CL}"
|
|
||||||
echo -e "${DGN}Using CT Password ${BGN}$PW1${CL}"
|
|
||||||
echo -e "${DGN}Using CT ID ${BGN}$CT_ID${CL}"
|
|
||||||
echo -e "${DGN}Using CT Name ${BGN}$HN${CL}"
|
|
||||||
echo -e "${DGN}Using Disk Size ${BGN}$DISK_SIZE${CL}${DGN}GB${CL}"
|
|
||||||
echo -e "${DGN}Using ${BGN}${CORE_COUNT}${CL}${DGN}vCPU${CL}"
|
|
||||||
echo -e "${DGN}Using ${BGN}${RAM_SIZE}${CL}${DGN}MiB RAM${CL}"
|
|
||||||
echo -e "${DGN}Using Bridge ${BGN}${BRG}${CL}"
|
|
||||||
echo -e "${YW}Enter a Static IPv4 CIDR Address, or Press [ENTER] for Default: DHCP "
|
|
||||||
read NET
|
|
||||||
if [ -z $NET ]; then NET="dhcp"; fi;
|
|
||||||
echo -en "${DGN}Set Static IP Address To ${BL}$NET${CL}"
|
|
||||||
echo -e " ${CM}${CL} \n"
|
|
||||||
sleep 1
|
|
||||||
clear
|
|
||||||
header_info
|
|
||||||
echo -e "${RD}Using Advanced Settings${CL}"
|
|
||||||
echo -e "${DGN}Using CT Type ${BGN}$CT_TYPE1${CL}"
|
|
||||||
echo -e "${DGN}Using CT Password ${BGN}$PW1${CL}"
|
|
||||||
echo -e "${DGN}Using CT ID ${BGN}$CT_ID${CL}"
|
|
||||||
echo -e "${DGN}Using CT Name ${BGN}$HN${CL}"
|
|
||||||
echo -e "${DGN}Using Disk Size ${BGN}$DISK_SIZE${CL}${DGN}GB${CL}"
|
|
||||||
echo -e "${DGN}Using ${BGN}${CORE_COUNT}${CL}${DGN}vCPU${CL}"
|
|
||||||
echo -e "${DGN}Using ${BGN}${RAM_SIZE}${CL}${DGN}MiB RAM${CL}"
|
|
||||||
echo -e "${DGN}Using Bridge ${BGN}${BRG}${CL}"
|
|
||||||
echo -e "${DGN}Using Static IP Address ${BGN}$NET${CL}"
|
|
||||||
echo -e "${YW}Enter a Gateway IP (mandatory if static IP is used), or Press [ENTER] for Default: NONE "
|
|
||||||
read GATE1
|
|
||||||
if [ -z $GATE1 ]; then GATE1="NONE" GATE="";
|
|
||||||
echo -en "${DGN}Set Gateway IP To ${BL}$GATE1${CL}"
|
|
||||||
else
|
|
||||||
GATE=",gw=$GATE1"
|
|
||||||
echo -en "${DGN}Set Gateway IP To ${BL}$GATE1${CL}"
|
|
||||||
fi;
|
|
||||||
echo -e " ${CM}${CL} \n"
|
|
||||||
sleep 1
|
|
||||||
clear
|
|
||||||
header_info
|
|
||||||
|
|
||||||
echo -e "${RD}Using Advanced Settings${CL}"
|
|
||||||
echo -e "${DGN}Using CT Type ${BGN}$CT_TYPE1${CL}"
|
|
||||||
echo -e "${DGN}Using CT Password ${BGN}$PW1${CL}"
|
|
||||||
echo -e "${DGN}Using CT ID ${BGN}$CT_ID${CL}"
|
|
||||||
echo -e "${DGN}Using CT Name ${BGN}$HN${CL}"
|
|
||||||
echo -e "${DGN}Using Disk Size ${BGN}$DISK_SIZE${CL}${DGN}GB${CL}"
|
|
||||||
echo -e "${DGN}Using ${BGN}${CORE_COUNT}${CL}${DGN}vCPU${CL}"
|
|
||||||
echo -e "${DGN}Using ${BGN}${RAM_SIZE}${CL}${DGN}MiB RAM${CL}"
|
|
||||||
echo -e "${DGN}Using Bridge ${BGN}${BRG}${CL}"
|
|
||||||
echo -e "${DGN}Using Static IP Address ${BGN}$NET${CL}"
|
|
||||||
echo -e "${DGN}Using Gateway IP Address ${BGN}$GATE1${CL}"
|
|
||||||
echo -e "${YW}Enter a VLAN Tag, or Press [ENTER] for Default: NONE "
|
|
||||||
read VLAN1
|
|
||||||
if [ -z $VLAN1 ]; then VLAN1="NONE" VLAN="";
|
|
||||||
echo -en "${DGN}Set VLAN Tag To ${BL}$VLAN1${CL}"
|
|
||||||
else
|
|
||||||
VLAN=",tag=$VLAN1"
|
|
||||||
echo -en "${DGN}Set VLAN Tag To ${BL}$VLAN1${CL}"
|
|
||||||
fi;
|
|
||||||
echo -e " ${CM}${CL} \n"
|
|
||||||
sleep 1
|
|
||||||
clear
|
|
||||||
header_info
|
|
||||||
echo -e "${RD}Using Advanced Settings${CL}"
|
|
||||||
echo -e "${DGN}Using CT Type ${BGN}$CT_TYPE1${CL}"
|
|
||||||
echo -e "${DGN}Using CT Password ${BGN}$PW1${CL}"
|
|
||||||
echo -e "${DGN}Using CT ID ${BGN}$CT_ID${CL}"
|
|
||||||
echo -e "${DGN}Using CT Name ${BGN}$HN${CL}"
|
|
||||||
echo -e "${DGN}Using Disk Size ${BGN}$DISK_SIZE${CL}${DGN}GB${CL}"
|
|
||||||
echo -e "${DGN}Using ${BGN}${CORE_COUNT}${CL}${DGN}vCPU${CL}"
|
|
||||||
echo -e "${DGN}Using ${BGN}${RAM_SIZE}${CL}${DGN}MiB RAM${CL}"
|
|
||||||
echo -e "${DGN}Using Bridge ${BGN}${BRG}${CL}"
|
|
||||||
echo -e "${DGN}Using Static IP Address ${BGN}$NET${CL}"
|
|
||||||
echo -e "${DGN}Using Gateway IP Address ${BGN}$GATE1${CL}"
|
|
||||||
echo -e "${DGN}Using VLAN Tag ${BGN}$VLAN1${CL}"
|
|
||||||
|
|
||||||
read -p "Are these settings correct(y/n)? " -n 1 -r
|
|
||||||
echo
|
|
||||||
if [[ ! $REPLY =~ ^[Yy]$ ]]
|
|
||||||
then
|
|
||||||
advanced_settings
|
|
||||||
fi
|
|
||||||
}
|
|
||||||
|
|
||||||
function start_script() {
|
|
||||||
echo -e "${YW}Type Advanced, or Press [ENTER] for Default Settings "
|
|
||||||
read SETTINGS
|
|
||||||
if [ -z $SETTINGS ]; then default_settings;
|
|
||||||
else
|
|
||||||
advanced_settings
|
|
||||||
fi;
|
|
||||||
}
|
|
||||||
|
|
||||||
start_script
|
|
||||||
|
|
||||||
if [ "$CT_TYPE" == "1" ]; then
|
|
||||||
FEATURES="nesting=1,keyctl=1"
|
|
||||||
else
|
|
||||||
FEATURES="nesting=1"
|
|
||||||
fi
|
|
||||||
|
|
||||||
TEMP_DIR=$(mktemp -d)
|
|
||||||
pushd $TEMP_DIR >/dev/null
|
|
||||||
|
|
||||||
export CTID=$CT_ID
|
|
||||||
export PCT_OSTYPE=debian
|
|
||||||
export PCT_OSVERSION=11
|
|
||||||
export PCT_DISK_SIZE=$DISK_SIZE
|
|
||||||
export PCT_OPTIONS="
|
|
||||||
-features $FEATURES
|
|
||||||
-hostname $HN
|
|
||||||
-net0 name=eth0,bridge=$BRG,ip=$NET$GATE$VLAN
|
|
||||||
-onboot 1
|
|
||||||
-cores $CORE_COUNT
|
|
||||||
-memory $RAM_SIZE
|
|
||||||
-unprivileged $CT_TYPE
|
|
||||||
$PW
|
|
||||||
"
|
|
||||||
bash -c "$(wget -qLO - https://raw.githubusercontent.com/tteck/Proxmox/main/ct/create_lxc.sh)" || exit
|
|
||||||
|
|
||||||
msg_info "Starting LXC Container"
|
|
||||||
pct start $CTID
|
|
||||||
msg_ok "Started LXC Container"
|
|
||||||
|
|
||||||
lxc-attach -n $CTID -- bash -c "$(wget -qLO - https://raw.githubusercontent.com/tteck/Proxmox/main/setup/iobroker-install.sh)" || exit
|
|
||||||
|
|
||||||
IP=$(pct exec $CTID ip a s dev eth0 | sed -n '/inet / s/\// /p' | awk '{print $2}')
|
|
||||||
|
|
||||||
pct set $CTID -description "# ${APP} LXC
|
|
||||||
### https://github.com/tteck/Proxmox"
|
|
||||||
|
|
||||||
msg_ok "Completed Successfully!\n"
|
|
||||||
echo -e "${APP} should be reachable by going to the following URL.
|
|
||||||
${BL}http://${IP}:8081${CL} \n"
|
|
|
@ -309,7 +309,7 @@ bash -c "$(wget -qLO - https://raw.githubusercontent.com/tteck/Proxmox/main/ct/c
|
||||||
msg_info "Starting LXC Container"
|
msg_info "Starting LXC Container"
|
||||||
pct start $CTID
|
pct start $CTID
|
||||||
msg_ok "Started LXC Container"
|
msg_ok "Started LXC Container"
|
||||||
lxc-attach -n $CTID -- bash -c "$(wget -qLO - https://raw.githubusercontent.com/tteck/Proxmox/main/setup/$var_install.sh)" || exit
|
lxc-attach -n $CTID -- bash -c "$(wget -qLO - https://raw.githubusercontent.com/tteck/Proxmox/main/install/$var_install.sh)" || exit
|
||||||
IP=$(pct exec $CTID ip a s dev eth0 | sed -n '/inet / s/\// /p' | awk '{print $2}')
|
IP=$(pct exec $CTID ip a s dev eth0 | sed -n '/inet / s/\// /p' | awk '{print $2}')
|
||||||
pct set $CTID -description "# ${APP} LXC
|
pct set $CTID -description "# ${APP} LXC
|
||||||
### https://tteck.github.io/Proxmox/
|
### https://tteck.github.io/Proxmox/
|
||||||
|
|
|
@ -1,171 +0,0 @@
|
||||||
#!/usr/bin/env bash
|
|
||||||
|
|
||||||
while true; do
|
|
||||||
read -p "This will create a Jellyfin Media Server LXC Container. Proceed(y/n)?" yn
|
|
||||||
case $yn in
|
|
||||||
[Yy]* ) break;;
|
|
||||||
[Nn]* ) exit;;
|
|
||||||
* ) echo "Please answer yes or no.";;
|
|
||||||
esac
|
|
||||||
done
|
|
||||||
set -o errexit
|
|
||||||
set -o errtrace
|
|
||||||
set -o nounset
|
|
||||||
set -o pipefail
|
|
||||||
shopt -s expand_aliases
|
|
||||||
alias die='EXIT=$? LINE=$LINENO error_exit'
|
|
||||||
trap die ERR
|
|
||||||
CHECKMARK='\033[0;32m\xE2\x9C\x94\033[0m'
|
|
||||||
trap cleanup EXIT
|
|
||||||
|
|
||||||
function error_exit() {
|
|
||||||
trap - ERR
|
|
||||||
local DEFAULT='Unknown failure occured.'
|
|
||||||
local REASON="\e[97m${1:-$DEFAULT}\e[39m"
|
|
||||||
local FLAG="\e[91m[ERROR] \e[93m$EXIT@$LINE"
|
|
||||||
msg "$FLAG $REASON"
|
|
||||||
[ ! -z ${CTID-} ] && cleanup_ctid
|
|
||||||
exit $EXIT
|
|
||||||
}
|
|
||||||
function warn() {
|
|
||||||
local REASON="\e[97m$1\e[39m"
|
|
||||||
local FLAG="\e[93m[WARNING]\e[39m"
|
|
||||||
msg "$FLAG $REASON"
|
|
||||||
}
|
|
||||||
function info() {
|
|
||||||
local REASON="$1"
|
|
||||||
local FLAG="\e[36m[INFO]\e[39m"
|
|
||||||
msg "$FLAG $REASON"
|
|
||||||
}
|
|
||||||
function msg() {
|
|
||||||
local TEXT="$1"
|
|
||||||
echo -e "$TEXT"
|
|
||||||
}
|
|
||||||
function cleanup_ctid() {
|
|
||||||
if [ ! -z ${MOUNT+x} ]; then
|
|
||||||
pct unmount $CTID
|
|
||||||
fi
|
|
||||||
if $(pct status $CTID &>/dev/null); then
|
|
||||||
if [ "$(pct status $CTID | awk '{print $2}')" == "running" ]; then
|
|
||||||
pct stop $CTID
|
|
||||||
fi
|
|
||||||
pct destroy $CTID
|
|
||||||
elif [ "$(pvesm list $STORAGE --vmid $CTID)" != "" ]; then
|
|
||||||
pvesm free $ROOTFS
|
|
||||||
fi
|
|
||||||
}
|
|
||||||
function cleanup() {
|
|
||||||
popd >/dev/null
|
|
||||||
rm -rf $TEMP_DIR
|
|
||||||
}
|
|
||||||
function load_module() {
|
|
||||||
if ! $(lsmod | grep -Fq $1); then
|
|
||||||
modprobe $1 &>/dev/null || \
|
|
||||||
die "Failed to load '$1' module."
|
|
||||||
fi
|
|
||||||
MODULES_PATH=/etc/modules
|
|
||||||
if ! $(grep -Fxq "$1" $MODULES_PATH); then
|
|
||||||
echo "$1" >> $MODULES_PATH || \
|
|
||||||
die "Failed to add '$1' module to load at boot."
|
|
||||||
fi
|
|
||||||
}
|
|
||||||
TEMP_DIR=$(mktemp -d)
|
|
||||||
pushd $TEMP_DIR >/dev/null
|
|
||||||
|
|
||||||
wget -qL https://raw.githubusercontent.com/tteck/Proxmox/main/setup/jellyfin_setup.sh
|
|
||||||
|
|
||||||
load_module overlay
|
|
||||||
|
|
||||||
while read -r line; do
|
|
||||||
TAG=$(echo $line | awk '{print $1}')
|
|
||||||
TYPE=$(echo $line | awk '{printf "%-10s", $2}')
|
|
||||||
FREE=$(echo $line | numfmt --field 4-6 --from-unit=K --to=iec --format %.2f | awk '{printf( "%9sB", $6)}')
|
|
||||||
ITEM=" Type: $TYPE Free: $FREE "
|
|
||||||
OFFSET=2
|
|
||||||
if [[ $((${#ITEM} + $OFFSET)) -gt ${MSG_MAX_LENGTH:-} ]]; then
|
|
||||||
MSG_MAX_LENGTH=$((${#ITEM} + $OFFSET))
|
|
||||||
fi
|
|
||||||
STORAGE_MENU+=( "$TAG" "$ITEM" "OFF" )
|
|
||||||
done < <(pvesm status -content rootdir | awk 'NR>1')
|
|
||||||
if [ $((${#STORAGE_MENU[@]}/3)) -eq 0 ]; then
|
|
||||||
warn "'Container' needs to be selected for at least one storage location."
|
|
||||||
die "Unable to detect valid storage location."
|
|
||||||
elif [ $((${#STORAGE_MENU[@]}/3)) -eq 1 ]; then
|
|
||||||
STORAGE=${STORAGE_MENU[0]}
|
|
||||||
else
|
|
||||||
while [ -z "${STORAGE:+x}" ]; do
|
|
||||||
STORAGE=$(whiptail --title "Storage Pools" --radiolist \
|
|
||||||
"Which storage pool you would like to use for the container?\n\n" \
|
|
||||||
16 $(($MSG_MAX_LENGTH + 23)) 6 \
|
|
||||||
"${STORAGE_MENU[@]}" 3>&1 1>&2 2>&3) || exit
|
|
||||||
done
|
|
||||||
fi
|
|
||||||
info "Using '$STORAGE' for Storage Location."
|
|
||||||
|
|
||||||
CTID=$(pvesh get /cluster/nextid)
|
|
||||||
info "Container ID is $CTID."
|
|
||||||
|
|
||||||
echo -e "${CHECKMARK} \e[1;92m Updating LXC Template List... \e[0m"
|
|
||||||
pveam update >/dev/null
|
|
||||||
echo -e "${CHECKMARK} \e[1;92m Downloading LXC Template... \e[0m"
|
|
||||||
OSTYPE=ubuntu
|
|
||||||
OSVERSION=${OSTYPE}-20.04
|
|
||||||
mapfile -t TEMPLATES < <(pveam available -section system | sed -n "s/.*\($OSVERSION.*\)/\1/p" | sort -t - -k 2 -V)
|
|
||||||
TEMPLATE="${TEMPLATES[-1]}"
|
|
||||||
pveam download local $TEMPLATE >/dev/null ||
|
|
||||||
die "A problem occured while downloading the LXC template."
|
|
||||||
|
|
||||||
STORAGE_TYPE=$(pvesm status -storage $STORAGE | awk 'NR>1 {print $2}')
|
|
||||||
case $STORAGE_TYPE in
|
|
||||||
dir|nfs)
|
|
||||||
DISK_EXT=".raw"
|
|
||||||
DISK_REF="$CTID/"
|
|
||||||
;;
|
|
||||||
zfspool)
|
|
||||||
DISK_PREFIX="subvol"
|
|
||||||
DISK_FORMAT="subvol"
|
|
||||||
;;
|
|
||||||
esac
|
|
||||||
DISK=${DISK_PREFIX:-vm}-${CTID}-disk-0${DISK_EXT-}
|
|
||||||
ROOTFS=${STORAGE}:${DISK_REF-}${DISK}
|
|
||||||
|
|
||||||
echo -e "${CHECKMARK} \e[1;92m Creating LXC Container... \e[0m"
|
|
||||||
DISK_SIZE=8G
|
|
||||||
pvesm alloc $STORAGE $CTID $DISK $DISK_SIZE --format ${DISK_FORMAT:-raw} >/dev/null
|
|
||||||
if [ "$STORAGE_TYPE" == "zfspool" ]; then
|
|
||||||
warn "Some containers may not work properly due to ZFS not supporting 'fallocate'."
|
|
||||||
else
|
|
||||||
mkfs.ext4 $(pvesm path $ROOTFS) &>/dev/null
|
|
||||||
fi
|
|
||||||
ARCH=$(dpkg --print-architecture)
|
|
||||||
HOSTNAME=jellyfin
|
|
||||||
TEMPLATE_STRING="local:vztmpl/${TEMPLATE}"
|
|
||||||
pct create $CTID $TEMPLATE_STRING -arch $ARCH -features nesting=1 \
|
|
||||||
-hostname $HOSTNAME -net0 name=eth0,bridge=vmbr0,ip=dhcp -onboot 1 -cores 2 -memory 2048\
|
|
||||||
-ostype $OSTYPE -rootfs $ROOTFS,size=$DISK_SIZE -storage $STORAGE >/dev/null
|
|
||||||
|
|
||||||
LXC_CONFIG=/etc/pve/lxc/${CTID}.conf
|
|
||||||
cat <<EOF >> $LXC_CONFIG
|
|
||||||
lxc.cgroup2.devices.allow: a
|
|
||||||
lxc.cap.drop:
|
|
||||||
lxc.cgroup2.devices.allow: c 226:0 rwm
|
|
||||||
lxc.cgroup2.devices.allow: c 226:128 rwm
|
|
||||||
lxc.mount.entry: /dev/dri dev/dri none bind,optional,create=dir
|
|
||||||
lxc.mount.entry: /dev/dri/card0 dev/dri/card0 none bind,optional,create=file
|
|
||||||
lxc.mount.entry: /dev/dri/renderD128 dev/renderD128 none bind,optional,create=file
|
|
||||||
EOF
|
|
||||||
|
|
||||||
MOUNT=$(pct mount $CTID | cut -d"'" -f 2)
|
|
||||||
ln -fs $(readlink /etc/localtime) ${MOUNT}/etc/localtime
|
|
||||||
pct unmount $CTID && unset MOUNT
|
|
||||||
|
|
||||||
echo -e "${CHECKMARK} \e[1;92m Starting LXC Container... \e[0m"
|
|
||||||
pct start $CTID
|
|
||||||
pct push $CTID jellyfin_setup.sh /jellyfin_setup.sh -perms 755
|
|
||||||
pct exec $CTID /jellyfin_setup.sh
|
|
||||||
|
|
||||||
IP=$(pct exec $CTID ip a s dev eth0 | sed -n '/inet / s/\// /p' | awk '{print $2}')
|
|
||||||
info "Successfully Created Jellyfin Media Server LXC to $CTID."
|
|
||||||
echo -e "\e[1;92m Jellyfin Media Server should be reachable by going to the following URL.
|
|
||||||
http://${IP}:8096
|
|
||||||
\e[0m"
|
|
|
@ -1,370 +0,0 @@
|
||||||
#!/usr/bin/env bash
|
|
||||||
echo -e "Loading..."
|
|
||||||
NEXTID=$(pvesh get /cluster/nextid)
|
|
||||||
INTEGER='^[0-9]+$'
|
|
||||||
YW=`echo "\033[33m"`
|
|
||||||
BL=`echo "\033[36m"`
|
|
||||||
RD=`echo "\033[01;31m"`
|
|
||||||
BGN=`echo "\033[4;92m"`
|
|
||||||
GN=`echo "\033[1;92m"`
|
|
||||||
DGN=`echo "\033[32m"`
|
|
||||||
CL=`echo "\033[m"`
|
|
||||||
BFR="\\r\\033[K"
|
|
||||||
HOLD="-"
|
|
||||||
CM="${GN}✓${CL}"
|
|
||||||
CROSS="${RD}✗${CL}"
|
|
||||||
APP="Jellyfin"
|
|
||||||
NSAPP=$(echo ${APP,,} | tr -d ' ')
|
|
||||||
set -o errexit
|
|
||||||
set -o errtrace
|
|
||||||
set -o nounset
|
|
||||||
set -o pipefail
|
|
||||||
shopt -s expand_aliases
|
|
||||||
alias die='EXIT=$? LINE=$LINENO error_exit'
|
|
||||||
trap die ERR
|
|
||||||
|
|
||||||
function error_exit() {
|
|
||||||
trap - ERR
|
|
||||||
local reason="Unknown failure occurred."
|
|
||||||
local msg="${1:-$reason}"
|
|
||||||
local flag="${RD}‼ ERROR ${CL}$EXIT@$LINE"
|
|
||||||
echo -e "$flag $msg" 1>&2
|
|
||||||
exit $EXIT
|
|
||||||
}
|
|
||||||
|
|
||||||
while true; do
|
|
||||||
clear
|
|
||||||
read -p "This will create a New ${APP} LXC. Proceed(y/n)?" yn
|
|
||||||
case $yn in
|
|
||||||
[Yy]* ) break;;
|
|
||||||
[Nn]* ) exit;;
|
|
||||||
* ) echo "Please answer yes or no.";;
|
|
||||||
esac
|
|
||||||
done
|
|
||||||
clear
|
|
||||||
function header_info {
|
|
||||||
echo -e "${DGN}
|
|
||||||
_ _ _ __ _
|
|
||||||
| | | | | / _(_)
|
|
||||||
| | ___| | |_v3 _| |_ _ _ __
|
|
||||||
_ | |/ _ \ | | | | | _| | _ \
|
|
||||||
| |__| | __/ | | |_| | | | | | | |
|
|
||||||
\____/ \___|_|_|\__, |_| |_|_| |_|
|
|
||||||
__/ |
|
|
||||||
|___/
|
|
||||||
${CL}"
|
|
||||||
}
|
|
||||||
|
|
||||||
header_info
|
|
||||||
|
|
||||||
function msg_info() {
|
|
||||||
local msg="$1"
|
|
||||||
echo -ne " ${HOLD} ${YW}${msg}..."
|
|
||||||
}
|
|
||||||
|
|
||||||
function msg_ok() {
|
|
||||||
local msg="$1"
|
|
||||||
echo -e "${BFR} ${CM} ${GN}${msg}${CL}"
|
|
||||||
}
|
|
||||||
|
|
||||||
function PVE_CHECK() {
|
|
||||||
PVE=$(pveversion | grep "pve-manager/7" | wc -l)
|
|
||||||
|
|
||||||
if [[ $PVE != 1 ]]; then
|
|
||||||
echo -e "${RD}This script requires Proxmox Virtual Environment 7.0 or greater${CL}"
|
|
||||||
echo -e "Exiting..."
|
|
||||||
sleep 2
|
|
||||||
exit
|
|
||||||
fi
|
|
||||||
}
|
|
||||||
|
|
||||||
function default_settings() {
|
|
||||||
clear
|
|
||||||
header_info
|
|
||||||
echo -e "${BL}Using Default Settings${CL}"
|
|
||||||
echo -e "${DGN}Using CT Type ${BGN}Privileged${CL}"
|
|
||||||
CT_TYPE="0"
|
|
||||||
echo -e "${DGN}Using CT Password ${BGN}Automatic Login${CL}"
|
|
||||||
PW=" "
|
|
||||||
echo -e "${DGN}Using CT ID ${BGN}$NEXTID${CL}"
|
|
||||||
CT_ID=$NEXTID
|
|
||||||
echo -e "${DGN}Using CT Name ${BGN}$NSAPP${CL}"
|
|
||||||
HN=$NSAPP
|
|
||||||
echo -e "${DGN}Using Disk Size ${BGN}8${CL}${DGN}GB${CL}"
|
|
||||||
DISK_SIZE="8"
|
|
||||||
echo -e "${DGN}Using ${BGN}2${CL}${DGN}vCPU${CL}"
|
|
||||||
CORE_COUNT="2"
|
|
||||||
echo -e "${DGN}Using ${BGN}2048${CL}${DGN}MiB RAM${CL}"
|
|
||||||
RAM_SIZE="2048"
|
|
||||||
echo -e "${DGN}Using Bridge ${BGN}vmbr0${CL}"
|
|
||||||
BRG="vmbr0"
|
|
||||||
echo -e "${DGN}Using Static IP Address ${BGN}DHCP${CL}"
|
|
||||||
NET=dhcp
|
|
||||||
echo -e "${DGN}Using Gateway Address ${BGN}NONE${CL}"
|
|
||||||
GATE=""
|
|
||||||
echo -e "${DGN}Using VLAN Tag ${BGN}NONE${CL}"
|
|
||||||
VLAN=""
|
|
||||||
}
|
|
||||||
|
|
||||||
function advanced_settings() {
|
|
||||||
clear
|
|
||||||
header_info
|
|
||||||
echo -e "${RD}Using Advanced Settings${CL}"
|
|
||||||
echo -e "${YW}Type ${CROSS}${YW}Unprivileged, or Press [ENTER] for Default: Privileged"
|
|
||||||
read CT_TYPE1
|
|
||||||
if [ -z $CT_TYPE1 ]; then CT_TYPE1="Privileged" CT_TYPE="0";
|
|
||||||
echo -en "${DGN}Set CT Type ${BL}$CT_TYPE1${CL}"
|
|
||||||
else
|
|
||||||
CT_TYPE1="Unprivileged"
|
|
||||||
CT_TYPE="1"
|
|
||||||
echo -en "${DGN}Set CT Type ${BL}Unprivileged${CL}"
|
|
||||||
fi;
|
|
||||||
echo -e " ${CM}${CL} \r"
|
|
||||||
sleep 1
|
|
||||||
clear
|
|
||||||
header_info
|
|
||||||
echo -e "${RD}Using Advanced Settings${CL}"
|
|
||||||
echo -e "${DGN}Using CT Type ${BGN}$CT_TYPE1${CL}"
|
|
||||||
echo -e "${YW}Set Password, or Press [ENTER] for Default: Automatic Login "
|
|
||||||
read PW1
|
|
||||||
if [ -z $PW1 ]; then PW1="Automatic Login" PW=" ";
|
|
||||||
echo -en "${DGN}Set CT ${BL}$PW1${CL}"
|
|
||||||
else
|
|
||||||
PW="-password $PW1"
|
|
||||||
echo -en "${DGN}Set CT Password ${BL}$PW1${CL}"
|
|
||||||
fi;
|
|
||||||
echo -e " ${CM}${CL} \r"
|
|
||||||
sleep 1
|
|
||||||
clear
|
|
||||||
header_info
|
|
||||||
echo -e "${RD}Using Advanced Settings${CL}"
|
|
||||||
echo -e "${DGN}Using CT Type ${BGN}$CT_TYPE1${CL}"
|
|
||||||
echo -e "${DGN}Using CT Password ${BGN}$PW1${CL}"
|
|
||||||
echo -e "${YW}Enter the CT ID, or Press [ENTER] to automatically generate (${NEXTID}) "
|
|
||||||
read CT_ID
|
|
||||||
if [ -z $CT_ID ]; then CT_ID=$NEXTID; fi;
|
|
||||||
echo -en "${DGN}Set CT ID To ${BL}$CT_ID${CL}"
|
|
||||||
echo -e " ${CM}${CL} \r"
|
|
||||||
sleep 1
|
|
||||||
clear
|
|
||||||
header_info
|
|
||||||
echo -e "${RD}Using Advanced Settings${CL}"
|
|
||||||
echo -e "${DGN}Using CT Type ${BGN}$CT_TYPE1${CL}"
|
|
||||||
echo -e "${DGN}Using CT Password ${BGN}$PW1${CL}"
|
|
||||||
echo -e "${DGN}Using CT ID ${BGN}$CT_ID${CL}"
|
|
||||||
echo -e "${YW}Enter CT Name (no-spaces), or Press [ENTER] for Default: $NSAPP "
|
|
||||||
read CT_NAME
|
|
||||||
if [ -z $CT_NAME ]; then
|
|
||||||
HN=$NSAPP
|
|
||||||
else
|
|
||||||
HN=$(echo ${CT_NAME,,} | tr -d ' ')
|
|
||||||
fi
|
|
||||||
echo -en "${DGN}Set CT Name To ${BL}$HN${CL}"
|
|
||||||
echo -e " ${CM}${CL} \r"
|
|
||||||
sleep 1
|
|
||||||
clear
|
|
||||||
header_info
|
|
||||||
echo -e "${RD}Using Advanced Settings${CL}"
|
|
||||||
echo -e "${DGN}Using CT Type ${BGN}$CT_TYPE1${CL}"
|
|
||||||
echo -e "${DGN}Using CT Password ${BGN}$PW1${CL}"
|
|
||||||
echo -e "${DGN}Using CT ID ${BGN}$CT_ID${CL}"
|
|
||||||
echo -e "${DGN}Using CT Name ${BGN}$HN${CL}"
|
|
||||||
echo -e "${YW}Enter a Disk Size, or Press [ENTER] for Default: 8 "
|
|
||||||
read DISK_SIZE
|
|
||||||
if [ -z $DISK_SIZE ]; then DISK_SIZE="8"; fi;
|
|
||||||
if ! [[ $DISK_SIZE =~ $INTEGER ]] ; then echo "ERROR! DISK SIZE MUST HAVE INTEGER NUMBER!"; exit; fi;
|
|
||||||
echo -en "${DGN}Set Disk Size To ${BL}$DISK_SIZE${CL}${DGN}GB${CL}"
|
|
||||||
echo -e " ${CM}${CL} \r"
|
|
||||||
sleep 1
|
|
||||||
clear
|
|
||||||
header_info
|
|
||||||
echo -e "${RD}Using Advanced Settings${CL}"
|
|
||||||
echo -e "${DGN}Using CT Type ${BGN}$CT_TYPE1${CL}"
|
|
||||||
echo -e "${DGN}Using CT Password ${BGN}$PW1${CL}"
|
|
||||||
echo -e "${DGN}Using CT ID ${BGN}$CT_ID${CL}"
|
|
||||||
echo -e "${DGN}Using CT Name ${BGN}$HN${CL}"
|
|
||||||
echo -e "${DGN}Using Disk Size ${BGN}$DISK_SIZE${CL}${DGN}GB${CL}"
|
|
||||||
echo -e "${YW}Allocate CPU cores, or Press [ENTER] for Default: 2 "
|
|
||||||
read CORE_COUNT
|
|
||||||
if [ -z $CORE_COUNT ]; then CORE_COUNT="2"; fi;
|
|
||||||
echo -en "${DGN}Set Cores To ${BL}$CORE_COUNT${CL}${DGN}vCPU${CL}"
|
|
||||||
echo -e " ${CM}${CL} \r"
|
|
||||||
sleep 1
|
|
||||||
clear
|
|
||||||
header_info
|
|
||||||
echo -e "${RD}Using Advanced Settings${CL}"
|
|
||||||
echo -e "${DGN}Using CT Type ${BGN}$CT_TYPE1${CL}"
|
|
||||||
echo -e "${DGN}Using CT Password ${BGN}$PW1${CL}"
|
|
||||||
echo -e "${DGN}Using CT ID ${BGN}$CT_ID${CL}"
|
|
||||||
echo -e "${DGN}Using CT Name ${BGN}$HN${CL}"
|
|
||||||
echo -e "${DGN}Using Disk Size ${BGN}$DISK_SIZE${CL}${DGN}GB${CL}"
|
|
||||||
echo -e "${DGN}Using ${BGN}${CORE_COUNT}${CL}${DGN}vCPU${CL}"
|
|
||||||
echo -e "${YW}Allocate RAM in MiB, or Press [ENTER] for Default: 2048 "
|
|
||||||
read RAM_SIZE
|
|
||||||
if [ -z $RAM_SIZE ]; then RAM_SIZE="2048"; fi;
|
|
||||||
echo -en "${DGN}Set RAM To ${BL}$RAM_SIZE${CL}${DGN}MiB RAM${CL}"
|
|
||||||
echo -e " ${CM}${CL} \n"
|
|
||||||
sleep 1
|
|
||||||
clear
|
|
||||||
header_info
|
|
||||||
echo -e "${RD}Using Advanced Settings${CL}"
|
|
||||||
echo -e "${DGN}Using CT Type ${BGN}$CT_TYPE1${CL}"
|
|
||||||
echo -e "${DGN}Using CT Password ${BGN}$PW1${CL}"
|
|
||||||
echo -e "${DGN}Using CT ID ${BGN}$CT_ID${CL}"
|
|
||||||
echo -e "${DGN}Using CT Name ${BGN}$HN${CL}"
|
|
||||||
echo -e "${DGN}Using Disk Size ${BGN}$DISK_SIZE${CL}${DGN}GB${CL}"
|
|
||||||
echo -e "${DGN}Using ${BGN}${CORE_COUNT}${CL}${DGN}vCPU${CL}"
|
|
||||||
echo -e "${DGN}Using ${BGN}${RAM_SIZE}${CL}${DGN}MiB RAM${CL}"
|
|
||||||
echo -e "${YW}Enter a Bridge, or Press [ENTER] for Default: vmbr0 "
|
|
||||||
read BRG
|
|
||||||
if [ -z $BRG ]; then BRG="vmbr0"; fi;
|
|
||||||
echo -en "${DGN}Set Bridge To ${BL}$BRG${CL}"
|
|
||||||
echo -e " ${CM}${CL} \n"
|
|
||||||
sleep 1
|
|
||||||
clear
|
|
||||||
header_info
|
|
||||||
echo -e "${RD}Using Advanced Settings${CL}"
|
|
||||||
echo -e "${DGN}Using CT Type ${BGN}$CT_TYPE1${CL}"
|
|
||||||
echo -e "${DGN}Using CT Password ${BGN}$PW1${CL}"
|
|
||||||
echo -e "${DGN}Using CT ID ${BGN}$CT_ID${CL}"
|
|
||||||
echo -e "${DGN}Using CT Name ${BGN}$HN${CL}"
|
|
||||||
echo -e "${DGN}Using Disk Size ${BGN}$DISK_SIZE${CL}${DGN}GB${CL}"
|
|
||||||
echo -e "${DGN}Using ${BGN}${CORE_COUNT}${CL}${DGN}vCPU${CL}"
|
|
||||||
echo -e "${DGN}Using ${BGN}${RAM_SIZE}${CL}${DGN}MiB RAM${CL}"
|
|
||||||
echo -e "${DGN}Using Bridge ${BGN}${BRG}${CL}"
|
|
||||||
echo -e "${YW}Enter a Static IPv4 CIDR Address, or Press [ENTER] for Default: DHCP "
|
|
||||||
read NET
|
|
||||||
if [ -z $NET ]; then NET="dhcp"; fi;
|
|
||||||
echo -en "${DGN}Set Static IP Address To ${BL}$NET${CL}"
|
|
||||||
echo -e " ${CM}${CL} \n"
|
|
||||||
sleep 1
|
|
||||||
clear
|
|
||||||
header_info
|
|
||||||
echo -e "${RD}Using Advanced Settings${CL}"
|
|
||||||
echo -e "${DGN}Using CT Type ${BGN}$CT_TYPE1${CL}"
|
|
||||||
echo -e "${DGN}Using CT Password ${BGN}$PW1${CL}"
|
|
||||||
echo -e "${DGN}Using CT ID ${BGN}$CT_ID${CL}"
|
|
||||||
echo -e "${DGN}Using CT Name ${BGN}$HN${CL}"
|
|
||||||
echo -e "${DGN}Using Disk Size ${BGN}$DISK_SIZE${CL}${DGN}GB${CL}"
|
|
||||||
echo -e "${DGN}Using ${BGN}${CORE_COUNT}${CL}${DGN}vCPU${CL}"
|
|
||||||
echo -e "${DGN}Using ${BGN}${RAM_SIZE}${CL}${DGN}MiB RAM${CL}"
|
|
||||||
echo -e "${DGN}Using Bridge ${BGN}${BRG}${CL}"
|
|
||||||
echo -e "${DGN}Using Static IP Address ${BGN}$NET${CL}"
|
|
||||||
echo -e "${YW}Enter a Gateway IP (mandatory if static IP is used), or Press [ENTER] for Default: NONE "
|
|
||||||
read GATE1
|
|
||||||
if [ -z $GATE1 ]; then GATE1="NONE" GATE="";
|
|
||||||
echo -en "${DGN}Set Gateway IP To ${BL}$GATE1${CL}"
|
|
||||||
else
|
|
||||||
GATE=",gw=$GATE1"
|
|
||||||
echo -en "${DGN}Set Gateway IP To ${BL}$GATE1${CL}"
|
|
||||||
fi;
|
|
||||||
echo -e " ${CM}${CL} \n"
|
|
||||||
sleep 1
|
|
||||||
clear
|
|
||||||
header_info
|
|
||||||
|
|
||||||
echo -e "${RD}Using Advanced Settings${CL}"
|
|
||||||
echo -e "${DGN}Using CT Type ${BGN}$CT_TYPE1${CL}"
|
|
||||||
echo -e "${DGN}Using CT Password ${BGN}$PW1${CL}"
|
|
||||||
echo -e "${DGN}Using CT ID ${BGN}$CT_ID${CL}"
|
|
||||||
echo -e "${DGN}Using CT Name ${BGN}$HN${CL}"
|
|
||||||
echo -e "${DGN}Using Disk Size ${BGN}$DISK_SIZE${CL}${DGN}GB${CL}"
|
|
||||||
echo -e "${DGN}Using ${BGN}${CORE_COUNT}${CL}${DGN}vCPU${CL}"
|
|
||||||
echo -e "${DGN}Using ${BGN}${RAM_SIZE}${CL}${DGN}MiB RAM${CL}"
|
|
||||||
echo -e "${DGN}Using Bridge ${BGN}${BRG}${CL}"
|
|
||||||
echo -e "${DGN}Using Static IP Address ${BGN}$NET${CL}"
|
|
||||||
echo -e "${DGN}Using Gateway IP Address ${BGN}$GATE1${CL}"
|
|
||||||
echo -e "${YW}Enter a VLAN Tag, or Press [ENTER] for Default: NONE "
|
|
||||||
read VLAN1
|
|
||||||
if [ -z $VLAN1 ]; then VLAN1="NONE" VLAN="";
|
|
||||||
echo -en "${DGN}Set VLAN Tag To ${BL}$VLAN1${CL}"
|
|
||||||
else
|
|
||||||
VLAN=",tag=$VLAN1"
|
|
||||||
echo -en "${DGN}Set VLAN Tag To ${BL}$VLAN1${CL}"
|
|
||||||
fi;
|
|
||||||
echo -e " ${CM}${CL} \n"
|
|
||||||
sleep 1
|
|
||||||
clear
|
|
||||||
header_info
|
|
||||||
echo -e "${RD}Using Advanced Settings${CL}"
|
|
||||||
echo -e "${DGN}Using CT Type ${BGN}$CT_TYPE1${CL}"
|
|
||||||
echo -e "${DGN}Using CT Password ${BGN}$PW1${CL}"
|
|
||||||
echo -e "${DGN}Using CT ID ${BGN}$CT_ID${CL}"
|
|
||||||
echo -e "${DGN}Using CT Name ${BGN}$HN${CL}"
|
|
||||||
echo -e "${DGN}Using Disk Size ${BGN}$DISK_SIZE${CL}${DGN}GB${CL}"
|
|
||||||
echo -e "${DGN}Using ${BGN}${CORE_COUNT}${CL}${DGN}vCPU${CL}"
|
|
||||||
echo -e "${DGN}Using ${BGN}${RAM_SIZE}${CL}${DGN}MiB RAM${CL}"
|
|
||||||
echo -e "${DGN}Using Bridge ${BGN}${BRG}${CL}"
|
|
||||||
echo -e "${DGN}Using Static IP Address ${BGN}$NET${CL}"
|
|
||||||
echo -e "${DGN}Using Gateway IP Address ${BGN}$GATE1${CL}"
|
|
||||||
echo -e "${DGN}Using VLAN Tag ${BGN}$VLAN1${CL}"
|
|
||||||
|
|
||||||
read -p "Are these settings correct(y/n)? " -n 1 -r
|
|
||||||
echo
|
|
||||||
if [[ ! $REPLY =~ ^[Yy]$ ]]
|
|
||||||
then
|
|
||||||
advanced_settings
|
|
||||||
fi
|
|
||||||
}
|
|
||||||
|
|
||||||
function start_script() {
|
|
||||||
echo -e "${YW}Type Advanced, or Press [ENTER] for Default Settings "
|
|
||||||
read SETTINGS
|
|
||||||
if [ -z $SETTINGS ]; then default_settings;
|
|
||||||
else
|
|
||||||
advanced_settings
|
|
||||||
fi;
|
|
||||||
}
|
|
||||||
|
|
||||||
PVE_CHECK
|
|
||||||
start_script
|
|
||||||
|
|
||||||
if [ "$CT_TYPE" == "1" ]; then
|
|
||||||
FEATURES="nesting=1,keyctl=1"
|
|
||||||
else
|
|
||||||
FEATURES="nesting=1"
|
|
||||||
fi
|
|
||||||
|
|
||||||
TEMP_DIR=$(mktemp -d)
|
|
||||||
pushd $TEMP_DIR >/dev/null
|
|
||||||
|
|
||||||
export CTID=$CT_ID
|
|
||||||
export PCT_OSTYPE=ubuntu
|
|
||||||
export PCT_OSVERSION=20.04
|
|
||||||
export PCT_DISK_SIZE=$DISK_SIZE
|
|
||||||
export PCT_OPTIONS="
|
|
||||||
-features $FEATURES
|
|
||||||
-hostname $HN
|
|
||||||
-net0 name=eth0,bridge=$BRG,ip=$NET$GATE$VLAN
|
|
||||||
-onboot 1
|
|
||||||
-cores $CORE_COUNT
|
|
||||||
-memory $RAM_SIZE
|
|
||||||
-unprivileged $CT_TYPE
|
|
||||||
$PW
|
|
||||||
"
|
|
||||||
bash -c "$(wget -qLO - https://raw.githubusercontent.com/tteck/Proxmox/main/ct/create_lxc.sh)" || exit
|
|
||||||
|
|
||||||
LXC_CONFIG=/etc/pve/lxc/${CTID}.conf
|
|
||||||
cat <<EOF >> $LXC_CONFIG
|
|
||||||
lxc.cgroup2.devices.allow: c 226:0 rwm
|
|
||||||
lxc.cgroup2.devices.allow: c 226:128 rwm
|
|
||||||
lxc.cgroup2.devices.allow: c 29:0 rwm
|
|
||||||
lxc.mount.entry: /dev/fb0 dev/fb0 none bind,optional,create=file
|
|
||||||
lxc.mount.entry: /dev/dri dev/dri none bind,optional,create=dir
|
|
||||||
lxc.mount.entry: /dev/dri/renderD128 dev/renderD128 none bind,optional,create=file
|
|
||||||
EOF
|
|
||||||
|
|
||||||
msg_info "Starting LXC Container"
|
|
||||||
pct start $CTID
|
|
||||||
msg_ok "Started LXC Container"
|
|
||||||
|
|
||||||
lxc-attach -n $CTID -- bash -c "$(wget -qLO - https://raw.githubusercontent.com/tteck/Proxmox/main/setup/jellyfin-install.sh)" || exit
|
|
||||||
|
|
||||||
IP=$(pct exec $CTID ip a s dev eth0 | sed -n '/inet / s/\// /p' | awk '{print $2}')
|
|
||||||
|
|
||||||
pct set $CTID -description "# ${APP} LXC
|
|
||||||
### https://github.com/tteck/Proxmox"
|
|
||||||
|
|
||||||
msg_ok "Completed Successfully!\n"
|
|
||||||
echo -e "Jellyfin Media Server should be reachable by going to the following URL.
|
|
||||||
${BL}http://${IP}:8096${CL}\n"
|
|
|
@ -331,7 +331,7 @@ fi
|
||||||
msg_info "Starting LXC Container"
|
msg_info "Starting LXC Container"
|
||||||
pct start $CTID
|
pct start $CTID
|
||||||
msg_ok "Started LXC Container"
|
msg_ok "Started LXC Container"
|
||||||
lxc-attach -n $CTID -- bash -c "$(wget -qLO - https://raw.githubusercontent.com/tteck/Proxmox/main/setup/$var_install.sh)" || exit
|
lxc-attach -n $CTID -- bash -c "$(wget -qLO - https://raw.githubusercontent.com/tteck/Proxmox/main/install/$var_install.sh)" || exit
|
||||||
IP=$(pct exec $CTID ip a s dev eth0 | sed -n '/inet / s/\// /p' | awk '{print $2}')
|
IP=$(pct exec $CTID ip a s dev eth0 | sed -n '/inet / s/\// /p' | awk '{print $2}')
|
||||||
pct set $CTID -description "# ${APP} LXC
|
pct set $CTID -description "# ${APP} LXC
|
||||||
### https://tteck.github.io/Proxmox/
|
### https://tteck.github.io/Proxmox/
|
||||||
|
|
|
@ -310,7 +310,7 @@ bash -c "$(wget -qLO - https://raw.githubusercontent.com/tteck/Proxmox/main/ct/c
|
||||||
msg_info "Starting LXC Container"
|
msg_info "Starting LXC Container"
|
||||||
pct start $CTID
|
pct start $CTID
|
||||||
msg_ok "Started LXC Container"
|
msg_ok "Started LXC Container"
|
||||||
lxc-attach -n $CTID -- bash -c "$(wget -qLO - https://raw.githubusercontent.com/tteck/Proxmox/main/setup/$var_install.sh)" || exit
|
lxc-attach -n $CTID -- bash -c "$(wget -qLO - https://raw.githubusercontent.com/tteck/Proxmox/main/install/$var_install.sh)" || exit
|
||||||
IP=$(pct exec $CTID ip a s dev eth0 | sed -n '/inet / s/\// /p' | awk '{print $2}')
|
IP=$(pct exec $CTID ip a s dev eth0 | sed -n '/inet / s/\// /p' | awk '{print $2}')
|
||||||
pct set $CTID -description "# ${APP} LXC
|
pct set $CTID -description "# ${APP} LXC
|
||||||
### https://tteck.github.io/Proxmox/
|
### https://tteck.github.io/Proxmox/
|
||||||
|
|
|
@ -1,360 +0,0 @@
|
||||||
#!/usr/bin/env bash
|
|
||||||
echo -e "Loading..."
|
|
||||||
APP="Keycloak"
|
|
||||||
var_disk="4"
|
|
||||||
var_cpu="2"
|
|
||||||
var_ram="2048"
|
|
||||||
var_os="debian"
|
|
||||||
var_version="11"
|
|
||||||
NEXTID=$(pvesh get /cluster/nextid)
|
|
||||||
INTEGER='^[0-9]+$'
|
|
||||||
NSAPP=$(echo ${APP,,} | tr -d ' ')
|
|
||||||
var_install="${NSAPP}-install"
|
|
||||||
YW=`echo "\033[33m"`
|
|
||||||
BL=`echo "\033[36m"`
|
|
||||||
RD=`echo "\033[01;31m"`
|
|
||||||
BGN=`echo "\033[4;92m"`
|
|
||||||
GN=`echo "\033[1;92m"`
|
|
||||||
DGN=`echo "\033[32m"`
|
|
||||||
CL=`echo "\033[m"`
|
|
||||||
BFR="\\r\\033[K"
|
|
||||||
HOLD="-"
|
|
||||||
CM="${GN}✓${CL}"
|
|
||||||
set -o errexit
|
|
||||||
set -o errtrace
|
|
||||||
set -o nounset
|
|
||||||
set -o pipefail
|
|
||||||
shopt -s expand_aliases
|
|
||||||
alias die='EXIT=$? LINE=$LINENO error_exit'
|
|
||||||
trap die ERR
|
|
||||||
|
|
||||||
function error_exit() {
|
|
||||||
trap - ERR
|
|
||||||
local reason="Unknown failure occurred."
|
|
||||||
local msg="${1:-$reason}"
|
|
||||||
local flag="${RD}‼ ERROR ${CL}$EXIT@$LINE"
|
|
||||||
echo -e "$flag $msg" 1>&2
|
|
||||||
exit $EXIT
|
|
||||||
}
|
|
||||||
|
|
||||||
function msg_info() {
|
|
||||||
local msg="$1"
|
|
||||||
echo -ne " ${HOLD} ${YW}${msg}..."
|
|
||||||
}
|
|
||||||
|
|
||||||
function msg_ok() {
|
|
||||||
local msg="$1"
|
|
||||||
echo -e "${BFR} ${CM} ${GN}${msg}${CL}"
|
|
||||||
}
|
|
||||||
|
|
||||||
while true; do
|
|
||||||
clear
|
|
||||||
read -p "This will create a New ${APP} LXC. Proceed(y/n)?" yn
|
|
||||||
case $yn in
|
|
||||||
[Yy]* ) break;;
|
|
||||||
[Nn]* ) exit;;
|
|
||||||
* ) echo "Please answer yes or no.";;
|
|
||||||
esac
|
|
||||||
done
|
|
||||||
clear
|
|
||||||
function header_info {
|
|
||||||
echo -e "${RD}
|
|
||||||
|
|
||||||
_ __________ _______ _ ____ _ __
|
|
||||||
| |/ / ____\ \ / / ____| | / __ \ /\ | |/ /
|
|
||||||
| ' /| |__ \ \_/ / | | | | | | | / \ | ' /
|
|
||||||
| < | __| \ /| | v3 | | | | | |/ /\ \ | <
|
|
||||||
| . \| |____ | | | |____| |___| |__| / ____ \| . \
|
|
||||||
|_|\_\______| |_| \_____|______\____/_/ \_\_|\_\
|
|
||||||
${CL}"
|
|
||||||
}
|
|
||||||
|
|
||||||
header_info
|
|
||||||
|
|
||||||
function PVE_CHECK() {
|
|
||||||
PVE=$(pveversion | grep "pve-manager/7" | wc -l)
|
|
||||||
|
|
||||||
if [[ $PVE != 1 ]]; then
|
|
||||||
echo -e "${RD}This script requires Proxmox Virtual Environment 7.0 or greater${CL}"
|
|
||||||
echo -e "Exiting..."
|
|
||||||
sleep 2
|
|
||||||
exit
|
|
||||||
fi
|
|
||||||
}
|
|
||||||
|
|
||||||
function default_settings() {
|
|
||||||
clear
|
|
||||||
header_info
|
|
||||||
echo -e "${BL}Using Default Settings${CL}"
|
|
||||||
echo -e "${DGN}Using CT Type ${BGN}Unprivileged${CL} ${RD}NO DEVICE PASSTHROUGH${CL}"
|
|
||||||
CT_TYPE="1"
|
|
||||||
echo -e "${DGN}Using CT Password ${BGN}Automatic Login${CL}"
|
|
||||||
PW=" "
|
|
||||||
echo -e "${DGN}Using CT ID ${BGN}$NEXTID${CL}"
|
|
||||||
CT_ID=$NEXTID
|
|
||||||
echo -e "${DGN}Using CT Name ${BGN}$NSAPP${CL}"
|
|
||||||
HN=$NSAPP
|
|
||||||
echo -e "${DGN}Using Disk Size ${BGN}$var_disk${CL}${DGN}GB${CL}"
|
|
||||||
DISK_SIZE="$var_disk"
|
|
||||||
echo -e "${DGN}Using ${BGN}$var_cpu${CL}${DGN}vCPU${CL}"
|
|
||||||
CORE_COUNT="$var_cpu"
|
|
||||||
echo -e "${DGN}Using ${BGN}$var_ram${CL}${DGN}MiB RAM${CL}"
|
|
||||||
RAM_SIZE="$var_ram"
|
|
||||||
echo -e "${DGN}Using Bridge ${BGN}vmbr0${CL}"
|
|
||||||
BRG="vmbr0"
|
|
||||||
echo -e "${DGN}Using Static IP Address ${BGN}DHCP${CL}"
|
|
||||||
NET=dhcp
|
|
||||||
echo -e "${DGN}Using Gateway Address ${BGN}NONE${CL}"
|
|
||||||
GATE=""
|
|
||||||
echo -e "${DGN}Using VLAN Tag ${BGN}NONE${CL}"
|
|
||||||
VLAN=""
|
|
||||||
}
|
|
||||||
|
|
||||||
function advanced_settings() {
|
|
||||||
clear
|
|
||||||
header_info
|
|
||||||
echo -e "${RD}Using Advanced Settings${CL}"
|
|
||||||
echo -e "${YW}Type Privileged, or Press [ENTER] for Default: Unprivileged (${RD}NO DEVICE PASSTHROUGH${CL}${YW})"
|
|
||||||
read CT_TYPE1
|
|
||||||
if [ -z $CT_TYPE1 ]; then CT_TYPE1="Unprivileged" CT_TYPE="1";
|
|
||||||
echo -en "${DGN}Set CT Type ${BL}$CT_TYPE1${CL}"
|
|
||||||
else
|
|
||||||
CT_TYPE1="Privileged"
|
|
||||||
CT_TYPE="0"
|
|
||||||
echo -en "${DGN}Set CT Type ${BL}Privileged${CL}"
|
|
||||||
fi;
|
|
||||||
echo -e " ${CM}${CL} \r"
|
|
||||||
sleep 1
|
|
||||||
clear
|
|
||||||
header_info
|
|
||||||
echo -e "${RD}Using Advanced Settings${CL}"
|
|
||||||
echo -e "${DGN}Using CT Type ${BGN}$CT_TYPE1${CL}"
|
|
||||||
echo -e "${YW}Set Password, or Press [ENTER] for Default: Automatic Login "
|
|
||||||
read PW1
|
|
||||||
if [ -z $PW1 ]; then PW1="Automatic Login" PW=" ";
|
|
||||||
echo -en "${DGN}Set CT ${BL}$PW1${CL}"
|
|
||||||
else
|
|
||||||
PW="-password $PW1"
|
|
||||||
echo -en "${DGN}Set CT Password ${BL}$PW1${CL}"
|
|
||||||
fi;
|
|
||||||
echo -e " ${CM}${CL} \r"
|
|
||||||
sleep 1
|
|
||||||
clear
|
|
||||||
header_info
|
|
||||||
echo -e "${RD}Using Advanced Settings${CL}"
|
|
||||||
echo -e "${DGN}Using CT Type ${BGN}$CT_TYPE1${CL}"
|
|
||||||
echo -e "${DGN}Using CT Password ${BGN}$PW1${CL}"
|
|
||||||
echo -e "${YW}Enter the CT ID, or Press [ENTER] to automatically generate (${NEXTID}) "
|
|
||||||
read CT_ID
|
|
||||||
if [ -z $CT_ID ]; then CT_ID=$NEXTID; fi;
|
|
||||||
echo -en "${DGN}Set CT ID To ${BL}$CT_ID${CL}"
|
|
||||||
echo -e " ${CM}${CL} \r"
|
|
||||||
sleep 1
|
|
||||||
clear
|
|
||||||
header_info
|
|
||||||
echo -e "${RD}Using Advanced Settings${CL}"
|
|
||||||
echo -e "${DGN}Using CT Type ${BGN}$CT_TYPE1${CL}"
|
|
||||||
echo -e "${DGN}Using CT Password ${BGN}$PW1${CL}"
|
|
||||||
echo -e "${DGN}Using CT ID ${BGN}$CT_ID${CL}"
|
|
||||||
echo -e "${YW}Enter CT Name (no-spaces), or Press [ENTER] for Default: $NSAPP "
|
|
||||||
read CT_NAME
|
|
||||||
if [ -z $CT_NAME ]; then
|
|
||||||
HN=$NSAPP
|
|
||||||
else
|
|
||||||
HN=$(echo ${CT_NAME,,} | tr -d ' ')
|
|
||||||
fi
|
|
||||||
echo -en "${DGN}Set CT Name To ${BL}$HN${CL}"
|
|
||||||
echo -e " ${CM}${CL} \r"
|
|
||||||
sleep 1
|
|
||||||
clear
|
|
||||||
header_info
|
|
||||||
echo -e "${RD}Using Advanced Settings${CL}"
|
|
||||||
echo -e "${DGN}Using CT Type ${BGN}$CT_TYPE1${CL}"
|
|
||||||
echo -e "${DGN}Using CT Password ${BGN}$PW1${CL}"
|
|
||||||
echo -e "${DGN}Using CT ID ${BGN}$CT_ID${CL}"
|
|
||||||
echo -e "${DGN}Using CT Name ${BGN}$HN${CL}"
|
|
||||||
echo -e "${YW}Enter a Disk Size, or Press [ENTER] for Default: $var_disk "
|
|
||||||
read DISK_SIZE
|
|
||||||
if [ -z $DISK_SIZE ]; then DISK_SIZE="$var_disk"; fi;
|
|
||||||
if ! [[ $DISK_SIZE =~ $INTEGER ]] ; then echo "ERROR! DISK SIZE MUST HAVE INTEGER NUMBER!"; exit; fi;
|
|
||||||
echo -en "${DGN}Set Disk Size To ${BL}$DISK_SIZE${CL}${DGN}GB${CL}"
|
|
||||||
echo -e " ${CM}${CL} \r"
|
|
||||||
sleep 1
|
|
||||||
clear
|
|
||||||
header_info
|
|
||||||
echo -e "${RD}Using Advanced Settings${CL}"
|
|
||||||
echo -e "${DGN}Using CT Type ${BGN}$CT_TYPE1${CL}"
|
|
||||||
echo -e "${DGN}Using CT Password ${BGN}$PW1${CL}"
|
|
||||||
echo -e "${DGN}Using CT ID ${BGN}$CT_ID${CL}"
|
|
||||||
echo -e "${DGN}Using CT Name ${BGN}$HN${CL}"
|
|
||||||
echo -e "${DGN}Using Disk Size ${BGN}$DISK_SIZE${CL}${DGN}GB${CL}"
|
|
||||||
echo -e "${YW}Allocate CPU cores, or Press [ENTER] for Default: $var_cpu "
|
|
||||||
read CORE_COUNT
|
|
||||||
if [ -z $CORE_COUNT ]; then CORE_COUNT="$var_cpu"; fi;
|
|
||||||
echo -en "${DGN}Set Cores To ${BL}$CORE_COUNT${CL}${DGN}vCPU${CL}"
|
|
||||||
echo -e " ${CM}${CL} \r"
|
|
||||||
sleep 1
|
|
||||||
clear
|
|
||||||
header_info
|
|
||||||
echo -e "${RD}Using Advanced Settings${CL}"
|
|
||||||
echo -e "${DGN}Using CT Type ${BGN}$CT_TYPE1${CL}"
|
|
||||||
echo -e "${DGN}Using CT Password ${BGN}$PW1${CL}"
|
|
||||||
echo -e "${DGN}Using CT ID ${BGN}$CT_ID${CL}"
|
|
||||||
echo -e "${DGN}Using CT Name ${BGN}$HN${CL}"
|
|
||||||
echo -e "${DGN}Using Disk Size ${BGN}$DISK_SIZE${CL}${DGN}GB${CL}"
|
|
||||||
echo -e "${DGN}Using ${BGN}${CORE_COUNT}${CL}${DGN}vCPU${CL}"
|
|
||||||
echo -e "${YW}Allocate RAM in MiB, or Press [ENTER] for Default: $var_ram "
|
|
||||||
read RAM_SIZE
|
|
||||||
if [ -z $RAM_SIZE ]; then RAM_SIZE="$var_ram"; fi;
|
|
||||||
echo -en "${DGN}Set RAM To ${BL}$RAM_SIZE${CL}${DGN}MiB RAM${CL}"
|
|
||||||
echo -e " ${CM}${CL} \n"
|
|
||||||
sleep 1
|
|
||||||
clear
|
|
||||||
header_info
|
|
||||||
echo -e "${RD}Using Advanced Settings${CL}"
|
|
||||||
echo -e "${DGN}Using CT Type ${BGN}$CT_TYPE1${CL}"
|
|
||||||
echo -e "${DGN}Using CT Password ${BGN}$PW1${CL}"
|
|
||||||
echo -e "${DGN}Using CT ID ${BGN}$CT_ID${CL}"
|
|
||||||
echo -e "${DGN}Using CT Name ${BGN}$HN${CL}"
|
|
||||||
echo -e "${DGN}Using Disk Size ${BGN}$DISK_SIZE${CL}${DGN}GB${CL}"
|
|
||||||
echo -e "${DGN}Using ${BGN}${CORE_COUNT}${CL}${DGN}vCPU${CL}"
|
|
||||||
echo -e "${DGN}Using ${BGN}${RAM_SIZE}${CL}${DGN}MiB RAM${CL}"
|
|
||||||
echo -e "${YW}Enter a Bridge, or Press [ENTER] for Default: vmbr0 "
|
|
||||||
read BRG
|
|
||||||
if [ -z $BRG ]; then BRG="vmbr0"; fi;
|
|
||||||
echo -en "${DGN}Set Bridge To ${BL}$BRG${CL}"
|
|
||||||
echo -e " ${CM}${CL} \n"
|
|
||||||
sleep 1
|
|
||||||
clear
|
|
||||||
header_info
|
|
||||||
echo -e "${RD}Using Advanced Settings${CL}"
|
|
||||||
echo -e "${DGN}Using CT Type ${BGN}$CT_TYPE1${CL}"
|
|
||||||
echo -e "${DGN}Using CT Password ${BGN}$PW1${CL}"
|
|
||||||
echo -e "${DGN}Using CT ID ${BGN}$CT_ID${CL}"
|
|
||||||
echo -e "${DGN}Using CT Name ${BGN}$HN${CL}"
|
|
||||||
echo -e "${DGN}Using Disk Size ${BGN}$DISK_SIZE${CL}${DGN}GB${CL}"
|
|
||||||
echo -e "${DGN}Using ${BGN}${CORE_COUNT}${CL}${DGN}vCPU${CL}"
|
|
||||||
echo -e "${DGN}Using ${BGN}${RAM_SIZE}${CL}${DGN}MiB RAM${CL}"
|
|
||||||
echo -e "${DGN}Using Bridge ${BGN}${BRG}${CL}"
|
|
||||||
echo -e "${YW}Enter a Static IPv4 CIDR Address, or Press [ENTER] for Default: DHCP "
|
|
||||||
read NET
|
|
||||||
if [ -z $NET ]; then NET="dhcp"; fi;
|
|
||||||
echo -en "${DGN}Set Static IP Address To ${BL}$NET${CL}"
|
|
||||||
echo -e " ${CM}${CL} \n"
|
|
||||||
sleep 1
|
|
||||||
clear
|
|
||||||
header_info
|
|
||||||
echo -e "${RD}Using Advanced Settings${CL}"
|
|
||||||
echo -e "${DGN}Using CT Type ${BGN}$CT_TYPE1${CL}"
|
|
||||||
echo -e "${DGN}Using CT Password ${BGN}$PW1${CL}"
|
|
||||||
echo -e "${DGN}Using CT ID ${BGN}$CT_ID${CL}"
|
|
||||||
echo -e "${DGN}Using CT Name ${BGN}$HN${CL}"
|
|
||||||
echo -e "${DGN}Using Disk Size ${BGN}$DISK_SIZE${CL}${DGN}GB${CL}"
|
|
||||||
echo -e "${DGN}Using ${BGN}${CORE_COUNT}${CL}${DGN}vCPU${CL}"
|
|
||||||
echo -e "${DGN}Using ${BGN}${RAM_SIZE}${CL}${DGN}MiB RAM${CL}"
|
|
||||||
echo -e "${DGN}Using Bridge ${BGN}${BRG}${CL}"
|
|
||||||
echo -e "${DGN}Using Static IP Address ${BGN}$NET${CL}"
|
|
||||||
echo -e "${YW}Enter a Gateway IP (mandatory if static IP is used), or Press [ENTER] for Default: NONE "
|
|
||||||
read GATE1
|
|
||||||
if [ -z $GATE1 ]; then GATE1="NONE" GATE="";
|
|
||||||
echo -en "${DGN}Set Gateway IP To ${BL}$GATE1${CL}"
|
|
||||||
else
|
|
||||||
GATE=",gw=$GATE1"
|
|
||||||
echo -en "${DGN}Set Gateway IP To ${BL}$GATE1${CL}"
|
|
||||||
fi;
|
|
||||||
echo -e " ${CM}${CL} \n"
|
|
||||||
sleep 1
|
|
||||||
clear
|
|
||||||
header_info
|
|
||||||
|
|
||||||
echo -e "${RD}Using Advanced Settings${CL}"
|
|
||||||
echo -e "${DGN}Using CT Type ${BGN}$CT_TYPE1${CL}"
|
|
||||||
echo -e "${DGN}Using CT Password ${BGN}$PW1${CL}"
|
|
||||||
echo -e "${DGN}Using CT ID ${BGN}$CT_ID${CL}"
|
|
||||||
echo -e "${DGN}Using CT Name ${BGN}$HN${CL}"
|
|
||||||
echo -e "${DGN}Using Disk Size ${BGN}$DISK_SIZE${CL}${DGN}GB${CL}"
|
|
||||||
echo -e "${DGN}Using ${BGN}${CORE_COUNT}${CL}${DGN}vCPU${CL}"
|
|
||||||
echo -e "${DGN}Using ${BGN}${RAM_SIZE}${CL}${DGN}MiB RAM${CL}"
|
|
||||||
echo -e "${DGN}Using Bridge ${BGN}${BRG}${CL}"
|
|
||||||
echo -e "${DGN}Using Static IP Address ${BGN}$NET${CL}"
|
|
||||||
echo -e "${DGN}Using Gateway IP Address ${BGN}$GATE1${CL}"
|
|
||||||
echo -e "${YW}Enter a VLAN Tag, or Press [ENTER] for Default: NONE "
|
|
||||||
read VLAN1
|
|
||||||
if [ -z $VLAN1 ]; then VLAN1="NONE" VLAN="";
|
|
||||||
echo -en "${DGN}Set VLAN Tag To ${BL}$VLAN1${CL}"
|
|
||||||
else
|
|
||||||
VLAN=",tag=$VLAN1"
|
|
||||||
echo -en "${DGN}Set VLAN Tag To ${BL}$VLAN1${CL}"
|
|
||||||
fi;
|
|
||||||
echo -e " ${CM}${CL} \n"
|
|
||||||
sleep 1
|
|
||||||
clear
|
|
||||||
header_info
|
|
||||||
echo -e "${RD}Using Advanced Settings${CL}"
|
|
||||||
echo -e "${DGN}Using CT Type ${BGN}$CT_TYPE1${CL}"
|
|
||||||
echo -e "${DGN}Using CT Password ${BGN}$PW1${CL}"
|
|
||||||
echo -e "${DGN}Using CT ID ${BGN}$CT_ID${CL}"
|
|
||||||
echo -e "${DGN}Using CT Name ${BGN}$HN${CL}"
|
|
||||||
echo -e "${DGN}Using Disk Size ${BGN}$DISK_SIZE${CL}${DGN}GB${CL}"
|
|
||||||
echo -e "${DGN}Using ${BGN}${CORE_COUNT}${CL}${DGN}vCPU${CL}"
|
|
||||||
echo -e "${DGN}Using ${BGN}${RAM_SIZE}${CL}${DGN}MiB RAM${CL}"
|
|
||||||
echo -e "${DGN}Using Bridge ${BGN}${BRG}${CL}"
|
|
||||||
echo -e "${DGN}Using Static IP Address ${BGN}$NET${CL}"
|
|
||||||
echo -e "${DGN}Using Gateway IP Address ${BGN}$GATE1${CL}"
|
|
||||||
echo -e "${DGN}Using VLAN Tag ${BGN}$VLAN1${CL}"
|
|
||||||
|
|
||||||
read -p "Are these settings correct(y/n)? " -n 1 -r
|
|
||||||
echo
|
|
||||||
if [[ ! $REPLY =~ ^[Yy]$ ]]
|
|
||||||
then
|
|
||||||
advanced_settings
|
|
||||||
fi
|
|
||||||
}
|
|
||||||
|
|
||||||
function start_script() {
|
|
||||||
echo -e "${YW}Type Advanced, or Press [ENTER] for Default Settings "
|
|
||||||
read SETTINGS
|
|
||||||
if [ -z $SETTINGS ]; then default_settings;
|
|
||||||
else
|
|
||||||
advanced_settings
|
|
||||||
fi;
|
|
||||||
}
|
|
||||||
|
|
||||||
start_script
|
|
||||||
|
|
||||||
if [ "$CT_TYPE" == "1" ]; then
|
|
||||||
FEATURES="nesting=1,keyctl=1"
|
|
||||||
else
|
|
||||||
FEATURES="nesting=1"
|
|
||||||
fi
|
|
||||||
|
|
||||||
export CTID=$CT_ID
|
|
||||||
export PCT_OSTYPE=$var_os
|
|
||||||
export PCT_OSVERSION=$var_version
|
|
||||||
export PCT_DISK_SIZE=$DISK_SIZE
|
|
||||||
export PCT_OPTIONS="
|
|
||||||
-features $FEATURES
|
|
||||||
-hostname $HN
|
|
||||||
-net0 name=eth0,bridge=$BRG,ip=$NET$GATE$VLAN
|
|
||||||
-onboot 1
|
|
||||||
-cores $CORE_COUNT
|
|
||||||
-memory $RAM_SIZE
|
|
||||||
-unprivileged $CT_TYPE
|
|
||||||
$PW
|
|
||||||
"
|
|
||||||
bash -c "$(wget -qLO - https://raw.githubusercontent.com/tteck/Proxmox/main/ct/create_lxc.sh)" || exit
|
|
||||||
|
|
||||||
msg_info "Starting LXC Container"
|
|
||||||
pct start $CTID
|
|
||||||
msg_ok "Started LXC Container"
|
|
||||||
|
|
||||||
lxc-attach -n $CTID -- bash -c "$(wget -qLO - https://raw.githubusercontent.com/tteck/Proxmox/main/setup/$var_install.sh)" || exit
|
|
||||||
|
|
||||||
IP=$(pct exec $CTID ip a s dev eth0 | sed -n '/inet / s/\// /p' | awk '{print $2}')
|
|
||||||
|
|
||||||
pct set $CTID -description "# ${APP} LXC
|
|
||||||
### https://github.com/tteck/Proxmox"
|
|
||||||
|
|
||||||
msg_ok "Completed Successfully!\n"
|
|
||||||
echo -e "${APP} should be reachable by going to the following URL.
|
|
||||||
${BL}http://${IP}:8080${CL} \n"
|
|
|
@ -310,7 +310,7 @@ bash -c "$(wget -qLO - https://raw.githubusercontent.com/tteck/Proxmox/main/ct/c
|
||||||
msg_info "Starting LXC Container"
|
msg_info "Starting LXC Container"
|
||||||
pct start $CTID
|
pct start $CTID
|
||||||
msg_ok "Started LXC Container"
|
msg_ok "Started LXC Container"
|
||||||
lxc-attach -n $CTID -- bash -c "$(wget -qLO - https://raw.githubusercontent.com/tteck/Proxmox/main/setup/$var_install.sh)" || exit
|
lxc-attach -n $CTID -- bash -c "$(wget -qLO - https://raw.githubusercontent.com/tteck/Proxmox/main/install/$var_install.sh)" || exit
|
||||||
IP=$(pct exec $CTID ip a s dev eth0 | sed -n '/inet / s/\// /p' | awk '{print $2}')
|
IP=$(pct exec $CTID ip a s dev eth0 | sed -n '/inet / s/\// /p' | awk '{print $2}')
|
||||||
pct set $CTID -description "# ${APP} LXC
|
pct set $CTID -description "# ${APP} LXC
|
||||||
### https://tteck.github.io/Proxmox/
|
### https://tteck.github.io/Proxmox/
|
||||||
|
|
|
@ -1,359 +0,0 @@
|
||||||
#!/usr/bin/env bash
|
|
||||||
echo -e "Loading..."
|
|
||||||
APP="MagicMirror"
|
|
||||||
var_disk="3"
|
|
||||||
var_cpu="1"
|
|
||||||
var_ram="512"
|
|
||||||
var_os="debian"
|
|
||||||
var_version="11"
|
|
||||||
NEXTID=$(pvesh get /cluster/nextid)
|
|
||||||
INTEGER='^[0-9]+$'
|
|
||||||
NSAPP=$(echo ${APP,,} | tr -d ' ')
|
|
||||||
var_install="${NSAPP}-install"
|
|
||||||
YW=`echo "\033[33m"`
|
|
||||||
BL=`echo "\033[36m"`
|
|
||||||
RD=`echo "\033[01;31m"`
|
|
||||||
BGN=`echo "\033[4;92m"`
|
|
||||||
GN=`echo "\033[1;92m"`
|
|
||||||
DGN=`echo "\033[32m"`
|
|
||||||
CL=`echo "\033[m"`
|
|
||||||
BFR="\\r\\033[K"
|
|
||||||
HOLD="-"
|
|
||||||
CM="${GN}✓${CL}"
|
|
||||||
set -o errexit
|
|
||||||
set -o errtrace
|
|
||||||
set -o nounset
|
|
||||||
set -o pipefail
|
|
||||||
shopt -s expand_aliases
|
|
||||||
alias die='EXIT=$? LINE=$LINENO error_exit'
|
|
||||||
trap die ERR
|
|
||||||
|
|
||||||
function error_exit() {
|
|
||||||
trap - ERR
|
|
||||||
local reason="Unknown failure occurred."
|
|
||||||
local msg="${1:-$reason}"
|
|
||||||
local flag="${RD}‼ ERROR ${CL}$EXIT@$LINE"
|
|
||||||
echo -e "$flag $msg" 1>&2
|
|
||||||
exit $EXIT
|
|
||||||
}
|
|
||||||
|
|
||||||
function msg_info() {
|
|
||||||
local msg="$1"
|
|
||||||
echo -ne " ${HOLD} ${YW}${msg}..."
|
|
||||||
}
|
|
||||||
|
|
||||||
function msg_ok() {
|
|
||||||
local msg="$1"
|
|
||||||
echo -e "${BFR} ${CM} ${GN}${msg}${CL}"
|
|
||||||
}
|
|
||||||
|
|
||||||
while true; do
|
|
||||||
clear
|
|
||||||
read -p "This will create a New ${APP} LXC. Proceed(y/n)?" yn
|
|
||||||
case $yn in
|
|
||||||
[Yy]* ) break;;
|
|
||||||
[Nn]* ) exit;;
|
|
||||||
* ) echo "Please answer yes or no.";;
|
|
||||||
esac
|
|
||||||
done
|
|
||||||
clear
|
|
||||||
function header_info {
|
|
||||||
echo -e "${BL}
|
|
||||||
__ __ _____ _____ _____ __ __ _____ _____ _____ ____ _____
|
|
||||||
| \/ | /\ / ____|_ _/ ____| \/ |_ _| __ \| __ \ / __ \| __ \
|
|
||||||
| \ / | / \ | | __ | || | | \ / | | | | |__) | |__) | | | | |__) |
|
|
||||||
| |\/| | / /\ \| | |_ | | || | v3 | |\/| | | | | _ /| _ /| | | | _ /
|
|
||||||
| | | |/ ____ \ |__| |_| || |____| | | |_| |_| | \ \| | \ \| |__| | | \ \
|
|
||||||
|_| |_/_/ \_\_____|_____\_____|_| |_|_____|_| \_\_| \_\ ____/|_| \_\
|
|
||||||
${CL}"
|
|
||||||
}
|
|
||||||
|
|
||||||
header_info
|
|
||||||
|
|
||||||
function PVE_CHECK() {
|
|
||||||
PVE=$(pveversion | grep "pve-manager/7" | wc -l)
|
|
||||||
|
|
||||||
if [[ $PVE != 1 ]]; then
|
|
||||||
echo -e "${RD}This script requires Proxmox Virtual Environment 7.0 or greater${CL}"
|
|
||||||
echo -e "Exiting..."
|
|
||||||
sleep 2
|
|
||||||
exit
|
|
||||||
fi
|
|
||||||
}
|
|
||||||
|
|
||||||
function default_settings() {
|
|
||||||
clear
|
|
||||||
header_info
|
|
||||||
echo -e "${BL}Using Default Settings${CL}"
|
|
||||||
echo -e "${DGN}Using CT Type ${BGN}Unprivileged${CL} ${RD}NO DEVICE PASSTHROUGH${CL}"
|
|
||||||
CT_TYPE="1"
|
|
||||||
echo -e "${DGN}Using CT Password ${BGN}Automatic Login${CL}"
|
|
||||||
PW=" "
|
|
||||||
echo -e "${DGN}Using CT ID ${BGN}$NEXTID${CL}"
|
|
||||||
CT_ID=$NEXTID
|
|
||||||
echo -e "${DGN}Using CT Name ${BGN}$NSAPP${CL}"
|
|
||||||
HN=$NSAPP
|
|
||||||
echo -e "${DGN}Using Disk Size ${BGN}$var_disk${CL}${DGN}GB${CL}"
|
|
||||||
DISK_SIZE="$var_disk"
|
|
||||||
echo -e "${DGN}Using ${BGN}$var_cpu${CL}${DGN}vCPU${CL}"
|
|
||||||
CORE_COUNT="$var_cpu"
|
|
||||||
echo -e "${DGN}Using ${BGN}$var_ram${CL}${DGN}MiB RAM${CL}"
|
|
||||||
RAM_SIZE="$var_ram"
|
|
||||||
echo -e "${DGN}Using Bridge ${BGN}vmbr0${CL}"
|
|
||||||
BRG="vmbr0"
|
|
||||||
echo -e "${DGN}Using Static IP Address ${BGN}DHCP${CL}"
|
|
||||||
NET=dhcp
|
|
||||||
echo -e "${DGN}Using Gateway Address ${BGN}NONE${CL}"
|
|
||||||
GATE=""
|
|
||||||
echo -e "${DGN}Using VLAN Tag ${BGN}NONE${CL}"
|
|
||||||
VLAN=""
|
|
||||||
}
|
|
||||||
|
|
||||||
function advanced_settings() {
|
|
||||||
clear
|
|
||||||
header_info
|
|
||||||
echo -e "${RD}Using Advanced Settings${CL}"
|
|
||||||
echo -e "${YW}Type Privileged, or Press [ENTER] for Default: Unprivileged (${RD}NO DEVICE PASSTHROUGH${CL}${YW})"
|
|
||||||
read CT_TYPE1
|
|
||||||
if [ -z $CT_TYPE1 ]; then CT_TYPE1="Unprivileged" CT_TYPE="1";
|
|
||||||
echo -en "${DGN}Set CT Type ${BL}$CT_TYPE1${CL}"
|
|
||||||
else
|
|
||||||
CT_TYPE1="Privileged"
|
|
||||||
CT_TYPE="0"
|
|
||||||
echo -en "${DGN}Set CT Type ${BL}Privileged${CL}"
|
|
||||||
fi;
|
|
||||||
echo -e " ${CM}${CL} \r"
|
|
||||||
sleep 1
|
|
||||||
clear
|
|
||||||
header_info
|
|
||||||
echo -e "${RD}Using Advanced Settings${CL}"
|
|
||||||
echo -e "${DGN}Using CT Type ${BGN}$CT_TYPE1${CL}"
|
|
||||||
echo -e "${YW}Set Password, or Press [ENTER] for Default: Automatic Login "
|
|
||||||
read PW1
|
|
||||||
if [ -z $PW1 ]; then PW1="Automatic Login" PW=" ";
|
|
||||||
echo -en "${DGN}Set CT ${BL}$PW1${CL}"
|
|
||||||
else
|
|
||||||
PW="-password $PW1"
|
|
||||||
echo -en "${DGN}Set CT Password ${BL}$PW1${CL}"
|
|
||||||
fi;
|
|
||||||
echo -e " ${CM}${CL} \r"
|
|
||||||
sleep 1
|
|
||||||
clear
|
|
||||||
header_info
|
|
||||||
echo -e "${RD}Using Advanced Settings${CL}"
|
|
||||||
echo -e "${DGN}Using CT Type ${BGN}$CT_TYPE1${CL}"
|
|
||||||
echo -e "${DGN}Using CT Password ${BGN}$PW1${CL}"
|
|
||||||
echo -e "${YW}Enter the CT ID, or Press [ENTER] to automatically generate (${NEXTID}) "
|
|
||||||
read CT_ID
|
|
||||||
if [ -z $CT_ID ]; then CT_ID=$NEXTID; fi;
|
|
||||||
echo -en "${DGN}Set CT ID To ${BL}$CT_ID${CL}"
|
|
||||||
echo -e " ${CM}${CL} \r"
|
|
||||||
sleep 1
|
|
||||||
clear
|
|
||||||
header_info
|
|
||||||
echo -e "${RD}Using Advanced Settings${CL}"
|
|
||||||
echo -e "${DGN}Using CT Type ${BGN}$CT_TYPE1${CL}"
|
|
||||||
echo -e "${DGN}Using CT Password ${BGN}$PW1${CL}"
|
|
||||||
echo -e "${DGN}Using CT ID ${BGN}$CT_ID${CL}"
|
|
||||||
echo -e "${YW}Enter CT Name (no-spaces), or Press [ENTER] for Default: $NSAPP "
|
|
||||||
read CT_NAME
|
|
||||||
if [ -z $CT_NAME ]; then
|
|
||||||
HN=$NSAPP
|
|
||||||
else
|
|
||||||
HN=$(echo ${CT_NAME,,} | tr -d ' ')
|
|
||||||
fi
|
|
||||||
echo -en "${DGN}Set CT Name To ${BL}$HN${CL}"
|
|
||||||
echo -e " ${CM}${CL} \r"
|
|
||||||
sleep 1
|
|
||||||
clear
|
|
||||||
header_info
|
|
||||||
echo -e "${RD}Using Advanced Settings${CL}"
|
|
||||||
echo -e "${DGN}Using CT Type ${BGN}$CT_TYPE1${CL}"
|
|
||||||
echo -e "${DGN}Using CT Password ${BGN}$PW1${CL}"
|
|
||||||
echo -e "${DGN}Using CT ID ${BGN}$CT_ID${CL}"
|
|
||||||
echo -e "${DGN}Using CT Name ${BGN}$HN${CL}"
|
|
||||||
echo -e "${YW}Enter a Disk Size, or Press [ENTER] for Default: $var_disk "
|
|
||||||
read DISK_SIZE
|
|
||||||
if [ -z $DISK_SIZE ]; then DISK_SIZE="$var_disk"; fi;
|
|
||||||
if ! [[ $DISK_SIZE =~ $INTEGER ]] ; then echo "ERROR! DISK SIZE MUST HAVE INTEGER NUMBER!"; exit; fi;
|
|
||||||
echo -en "${DGN}Set Disk Size To ${BL}$DISK_SIZE${CL}${DGN}GB${CL}"
|
|
||||||
echo -e " ${CM}${CL} \r"
|
|
||||||
sleep 1
|
|
||||||
clear
|
|
||||||
header_info
|
|
||||||
echo -e "${RD}Using Advanced Settings${CL}"
|
|
||||||
echo -e "${DGN}Using CT Type ${BGN}$CT_TYPE1${CL}"
|
|
||||||
echo -e "${DGN}Using CT Password ${BGN}$PW1${CL}"
|
|
||||||
echo -e "${DGN}Using CT ID ${BGN}$CT_ID${CL}"
|
|
||||||
echo -e "${DGN}Using CT Name ${BGN}$HN${CL}"
|
|
||||||
echo -e "${DGN}Using Disk Size ${BGN}$DISK_SIZE${CL}${DGN}GB${CL}"
|
|
||||||
echo -e "${YW}Allocate CPU cores, or Press [ENTER] for Default: $var_cpu "
|
|
||||||
read CORE_COUNT
|
|
||||||
if [ -z $CORE_COUNT ]; then CORE_COUNT="$var_cpu"; fi;
|
|
||||||
echo -en "${DGN}Set Cores To ${BL}$CORE_COUNT${CL}${DGN}vCPU${CL}"
|
|
||||||
echo -e " ${CM}${CL} \r"
|
|
||||||
sleep 1
|
|
||||||
clear
|
|
||||||
header_info
|
|
||||||
echo -e "${RD}Using Advanced Settings${CL}"
|
|
||||||
echo -e "${DGN}Using CT Type ${BGN}$CT_TYPE1${CL}"
|
|
||||||
echo -e "${DGN}Using CT Password ${BGN}$PW1${CL}"
|
|
||||||
echo -e "${DGN}Using CT ID ${BGN}$CT_ID${CL}"
|
|
||||||
echo -e "${DGN}Using CT Name ${BGN}$HN${CL}"
|
|
||||||
echo -e "${DGN}Using Disk Size ${BGN}$DISK_SIZE${CL}${DGN}GB${CL}"
|
|
||||||
echo -e "${DGN}Using ${BGN}${CORE_COUNT}${CL}${DGN}vCPU${CL}"
|
|
||||||
echo -e "${YW}Allocate RAM in MiB, or Press [ENTER] for Default: $var_ram "
|
|
||||||
read RAM_SIZE
|
|
||||||
if [ -z $RAM_SIZE ]; then RAM_SIZE="$var_ram"; fi;
|
|
||||||
echo -en "${DGN}Set RAM To ${BL}$RAM_SIZE${CL}${DGN}MiB RAM${CL}"
|
|
||||||
echo -e " ${CM}${CL} \n"
|
|
||||||
sleep 1
|
|
||||||
clear
|
|
||||||
header_info
|
|
||||||
echo -e "${RD}Using Advanced Settings${CL}"
|
|
||||||
echo -e "${DGN}Using CT Type ${BGN}$CT_TYPE1${CL}"
|
|
||||||
echo -e "${DGN}Using CT Password ${BGN}$PW1${CL}"
|
|
||||||
echo -e "${DGN}Using CT ID ${BGN}$CT_ID${CL}"
|
|
||||||
echo -e "${DGN}Using CT Name ${BGN}$HN${CL}"
|
|
||||||
echo -e "${DGN}Using Disk Size ${BGN}$DISK_SIZE${CL}${DGN}GB${CL}"
|
|
||||||
echo -e "${DGN}Using ${BGN}${CORE_COUNT}${CL}${DGN}vCPU${CL}"
|
|
||||||
echo -e "${DGN}Using ${BGN}${RAM_SIZE}${CL}${DGN}MiB RAM${CL}"
|
|
||||||
echo -e "${YW}Enter a Bridge, or Press [ENTER] for Default: vmbr0 "
|
|
||||||
read BRG
|
|
||||||
if [ -z $BRG ]; then BRG="vmbr0"; fi;
|
|
||||||
echo -en "${DGN}Set Bridge To ${BL}$BRG${CL}"
|
|
||||||
echo -e " ${CM}${CL} \n"
|
|
||||||
sleep 1
|
|
||||||
clear
|
|
||||||
header_info
|
|
||||||
echo -e "${RD}Using Advanced Settings${CL}"
|
|
||||||
echo -e "${DGN}Using CT Type ${BGN}$CT_TYPE1${CL}"
|
|
||||||
echo -e "${DGN}Using CT Password ${BGN}$PW1${CL}"
|
|
||||||
echo -e "${DGN}Using CT ID ${BGN}$CT_ID${CL}"
|
|
||||||
echo -e "${DGN}Using CT Name ${BGN}$HN${CL}"
|
|
||||||
echo -e "${DGN}Using Disk Size ${BGN}$DISK_SIZE${CL}${DGN}GB${CL}"
|
|
||||||
echo -e "${DGN}Using ${BGN}${CORE_COUNT}${CL}${DGN}vCPU${CL}"
|
|
||||||
echo -e "${DGN}Using ${BGN}${RAM_SIZE}${CL}${DGN}MiB RAM${CL}"
|
|
||||||
echo -e "${DGN}Using Bridge ${BGN}${BRG}${CL}"
|
|
||||||
echo -e "${YW}Enter a Static IPv4 CIDR Address, or Press [ENTER] for Default: DHCP "
|
|
||||||
read NET
|
|
||||||
if [ -z $NET ]; then NET="dhcp"; fi;
|
|
||||||
echo -en "${DGN}Set Static IP Address To ${BL}$NET${CL}"
|
|
||||||
echo -e " ${CM}${CL} \n"
|
|
||||||
sleep 1
|
|
||||||
clear
|
|
||||||
header_info
|
|
||||||
echo -e "${RD}Using Advanced Settings${CL}"
|
|
||||||
echo -e "${DGN}Using CT Type ${BGN}$CT_TYPE1${CL}"
|
|
||||||
echo -e "${DGN}Using CT Password ${BGN}$PW1${CL}"
|
|
||||||
echo -e "${DGN}Using CT ID ${BGN}$CT_ID${CL}"
|
|
||||||
echo -e "${DGN}Using CT Name ${BGN}$HN${CL}"
|
|
||||||
echo -e "${DGN}Using Disk Size ${BGN}$DISK_SIZE${CL}${DGN}GB${CL}"
|
|
||||||
echo -e "${DGN}Using ${BGN}${CORE_COUNT}${CL}${DGN}vCPU${CL}"
|
|
||||||
echo -e "${DGN}Using ${BGN}${RAM_SIZE}${CL}${DGN}MiB RAM${CL}"
|
|
||||||
echo -e "${DGN}Using Bridge ${BGN}${BRG}${CL}"
|
|
||||||
echo -e "${DGN}Using Static IP Address ${BGN}$NET${CL}"
|
|
||||||
echo -e "${YW}Enter a Gateway IP (mandatory if static IP is used), or Press [ENTER] for Default: NONE "
|
|
||||||
read GATE1
|
|
||||||
if [ -z $GATE1 ]; then GATE1="NONE" GATE="";
|
|
||||||
echo -en "${DGN}Set Gateway IP To ${BL}$GATE1${CL}"
|
|
||||||
else
|
|
||||||
GATE=",gw=$GATE1"
|
|
||||||
echo -en "${DGN}Set Gateway IP To ${BL}$GATE1${CL}"
|
|
||||||
fi;
|
|
||||||
echo -e " ${CM}${CL} \n"
|
|
||||||
sleep 1
|
|
||||||
clear
|
|
||||||
header_info
|
|
||||||
|
|
||||||
echo -e "${RD}Using Advanced Settings${CL}"
|
|
||||||
echo -e "${DGN}Using CT Type ${BGN}$CT_TYPE1${CL}"
|
|
||||||
echo -e "${DGN}Using CT Password ${BGN}$PW1${CL}"
|
|
||||||
echo -e "${DGN}Using CT ID ${BGN}$CT_ID${CL}"
|
|
||||||
echo -e "${DGN}Using CT Name ${BGN}$HN${CL}"
|
|
||||||
echo -e "${DGN}Using Disk Size ${BGN}$DISK_SIZE${CL}${DGN}GB${CL}"
|
|
||||||
echo -e "${DGN}Using ${BGN}${CORE_COUNT}${CL}${DGN}vCPU${CL}"
|
|
||||||
echo -e "${DGN}Using ${BGN}${RAM_SIZE}${CL}${DGN}MiB RAM${CL}"
|
|
||||||
echo -e "${DGN}Using Bridge ${BGN}${BRG}${CL}"
|
|
||||||
echo -e "${DGN}Using Static IP Address ${BGN}$NET${CL}"
|
|
||||||
echo -e "${DGN}Using Gateway IP Address ${BGN}$GATE1${CL}"
|
|
||||||
echo -e "${YW}Enter a VLAN Tag, or Press [ENTER] for Default: NONE "
|
|
||||||
read VLAN1
|
|
||||||
if [ -z $VLAN1 ]; then VLAN1="NONE" VLAN="";
|
|
||||||
echo -en "${DGN}Set VLAN Tag To ${BL}$VLAN1${CL}"
|
|
||||||
else
|
|
||||||
VLAN=",tag=$VLAN1"
|
|
||||||
echo -en "${DGN}Set VLAN Tag To ${BL}$VLAN1${CL}"
|
|
||||||
fi;
|
|
||||||
echo -e " ${CM}${CL} \n"
|
|
||||||
sleep 1
|
|
||||||
clear
|
|
||||||
header_info
|
|
||||||
echo -e "${RD}Using Advanced Settings${CL}"
|
|
||||||
echo -e "${DGN}Using CT Type ${BGN}$CT_TYPE1${CL}"
|
|
||||||
echo -e "${DGN}Using CT Password ${BGN}$PW1${CL}"
|
|
||||||
echo -e "${DGN}Using CT ID ${BGN}$CT_ID${CL}"
|
|
||||||
echo -e "${DGN}Using CT Name ${BGN}$HN${CL}"
|
|
||||||
echo -e "${DGN}Using Disk Size ${BGN}$DISK_SIZE${CL}${DGN}GB${CL}"
|
|
||||||
echo -e "${DGN}Using ${BGN}${CORE_COUNT}${CL}${DGN}vCPU${CL}"
|
|
||||||
echo -e "${DGN}Using ${BGN}${RAM_SIZE}${CL}${DGN}MiB RAM${CL}"
|
|
||||||
echo -e "${DGN}Using Bridge ${BGN}${BRG}${CL}"
|
|
||||||
echo -e "${DGN}Using Static IP Address ${BGN}$NET${CL}"
|
|
||||||
echo -e "${DGN}Using Gateway IP Address ${BGN}$GATE1${CL}"
|
|
||||||
echo -e "${DGN}Using VLAN Tag ${BGN}$VLAN1${CL}"
|
|
||||||
|
|
||||||
read -p "Are these settings correct(y/n)? " -n 1 -r
|
|
||||||
echo
|
|
||||||
if [[ ! $REPLY =~ ^[Yy]$ ]]
|
|
||||||
then
|
|
||||||
advanced_settings
|
|
||||||
fi
|
|
||||||
}
|
|
||||||
|
|
||||||
function start_script() {
|
|
||||||
echo -e "${YW}Type Advanced, or Press [ENTER] for Default Settings "
|
|
||||||
read SETTINGS
|
|
||||||
if [ -z $SETTINGS ]; then default_settings;
|
|
||||||
else
|
|
||||||
advanced_settings
|
|
||||||
fi;
|
|
||||||
}
|
|
||||||
|
|
||||||
start_script
|
|
||||||
|
|
||||||
if [ "$CT_TYPE" == "1" ]; then
|
|
||||||
FEATURES="nesting=1,keyctl=1"
|
|
||||||
else
|
|
||||||
FEATURES="nesting=1"
|
|
||||||
fi
|
|
||||||
|
|
||||||
export CTID=$CT_ID
|
|
||||||
export PCT_OSTYPE=$var_os
|
|
||||||
export PCT_OSVERSION=$var_version
|
|
||||||
export PCT_DISK_SIZE=$DISK_SIZE
|
|
||||||
export PCT_OPTIONS="
|
|
||||||
-features $FEATURES
|
|
||||||
-hostname $HN
|
|
||||||
-net0 name=eth0,bridge=$BRG,ip=$NET$GATE$VLAN
|
|
||||||
-onboot 1
|
|
||||||
-cores $CORE_COUNT
|
|
||||||
-memory $RAM_SIZE
|
|
||||||
-unprivileged $CT_TYPE
|
|
||||||
$PW
|
|
||||||
"
|
|
||||||
bash -c "$(wget -qLO - https://raw.githubusercontent.com/tteck/Proxmox/main/ct/create_lxc.sh)" || exit
|
|
||||||
|
|
||||||
msg_info "Starting LXC Container"
|
|
||||||
pct start $CTID
|
|
||||||
msg_ok "Started LXC Container"
|
|
||||||
|
|
||||||
lxc-attach -n $CTID -- bash -c "$(wget -qLO - https://raw.githubusercontent.com/tteck/Proxmox/main/setup/$var_install.sh)" || exit
|
|
||||||
|
|
||||||
IP=$(pct exec $CTID ip a s dev eth0 | sed -n '/inet / s/\// /p' | awk '{print $2}')
|
|
||||||
|
|
||||||
pct set $CTID -description "# ${APP} LXC
|
|
||||||
### https://github.com/tteck/Proxmox"
|
|
||||||
|
|
||||||
msg_ok "Completed Successfully!\n"
|
|
||||||
echo -e "${APP} should be reachable by going to the following URL.
|
|
||||||
${BL}http://${IP}:8080${CL} \n"
|
|
|
@ -310,7 +310,7 @@ bash -c "$(wget -qLO - https://raw.githubusercontent.com/tteck/Proxmox/main/ct/c
|
||||||
msg_info "Starting LXC Container"
|
msg_info "Starting LXC Container"
|
||||||
pct start $CTID
|
pct start $CTID
|
||||||
msg_ok "Started LXC Container"
|
msg_ok "Started LXC Container"
|
||||||
lxc-attach -n $CTID -- bash -c "$(wget -qLO - https://raw.githubusercontent.com/tteck/Proxmox/main/setup/$var_install.sh)" || exit
|
lxc-attach -n $CTID -- bash -c "$(wget -qLO - https://raw.githubusercontent.com/tteck/Proxmox/main/install/$var_install.sh)" || exit
|
||||||
IP=$(pct exec $CTID ip a s dev eth0 | sed -n '/inet / s/\// /p' | awk '{print $2}')
|
IP=$(pct exec $CTID ip a s dev eth0 | sed -n '/inet / s/\// /p' | awk '{print $2}')
|
||||||
pct set $CTID -description "# ${APP} LXC
|
pct set $CTID -description "# ${APP} LXC
|
||||||
### https://tteck.github.io/Proxmox/
|
### https://tteck.github.io/Proxmox/
|
||||||
|
|
168
ct/mariadb-v1.sh
168
ct/mariadb-v1.sh
|
@ -1,168 +0,0 @@
|
||||||
#!/usr/bin/env bash
|
|
||||||
|
|
||||||
while true; do
|
|
||||||
read -p "This will create a New Mariadb LXC Container. Proceed(y/n)?" yn
|
|
||||||
case $yn in
|
|
||||||
[Yy]* ) break;;
|
|
||||||
[Nn]* ) exit;;
|
|
||||||
* ) echo "Please answer yes or no.";;
|
|
||||||
esac
|
|
||||||
done
|
|
||||||
clear
|
|
||||||
set -o errexit
|
|
||||||
set -o errtrace
|
|
||||||
set -o nounset
|
|
||||||
set -o pipefail
|
|
||||||
shopt -s expand_aliases
|
|
||||||
alias die='EXIT=$? LINE=$LINENO error_exit'
|
|
||||||
BL=`echo "\033[36m"`
|
|
||||||
CM='\xE2\x9C\x94\033'
|
|
||||||
GN=`echo "\033[1;92m"`
|
|
||||||
CL=`echo "\033[m"`
|
|
||||||
trap die ERR
|
|
||||||
trap cleanup EXIT
|
|
||||||
|
|
||||||
function error_exit() {
|
|
||||||
trap - ERR
|
|
||||||
local DEFAULT='Unknown failure occured.'
|
|
||||||
local REASON="\e[97m${1:-$DEFAULT}\e[39m"
|
|
||||||
local FLAG="\e[91m[ERROR] \e[93m$EXIT@$LINE"
|
|
||||||
msg "$FLAG $REASON"
|
|
||||||
[ ! -z ${CTID-} ] && cleanup_ctid
|
|
||||||
exit $EXIT
|
|
||||||
}
|
|
||||||
function warn() {
|
|
||||||
local REASON="\e[97m$1\e[39m"
|
|
||||||
local FLAG="\e[93m[WARNING]\e[39m"
|
|
||||||
msg "$FLAG $REASON"
|
|
||||||
}
|
|
||||||
function info() {
|
|
||||||
local REASON="$1"
|
|
||||||
local FLAG="\e[36m[INFO]\e[39m"
|
|
||||||
msg "$FLAG $REASON"
|
|
||||||
}
|
|
||||||
function msg() {
|
|
||||||
local TEXT="$1"
|
|
||||||
echo -e "$TEXT"
|
|
||||||
}
|
|
||||||
function cleanup_ctid() {
|
|
||||||
if [ ! -z ${MOUNT+x} ]; then
|
|
||||||
pct unmount $CTID
|
|
||||||
fi
|
|
||||||
if $(pct status $CTID &>/dev/null); then
|
|
||||||
if [ "$(pct status $CTID | awk '{print $2}')" == "running" ]; then
|
|
||||||
pct stop $CTID
|
|
||||||
fi
|
|
||||||
pct destroy $CTID
|
|
||||||
elif [ "$(pvesm list $STORAGE --vmid $CTID)" != "" ]; then
|
|
||||||
pvesm free $ROOTFS
|
|
||||||
fi
|
|
||||||
}
|
|
||||||
function cleanup() {
|
|
||||||
popd >/dev/null
|
|
||||||
rm -rf $TEMP_DIR
|
|
||||||
}
|
|
||||||
function load_module() {
|
|
||||||
if ! $(lsmod | grep -Fq $1); then
|
|
||||||
modprobe $1 &>/dev/null || \
|
|
||||||
die "Failed to load '$1' module."
|
|
||||||
fi
|
|
||||||
MODULES_PATH=/etc/modules
|
|
||||||
if ! $(grep -Fxq "$1" $MODULES_PATH); then
|
|
||||||
echo "$1" >> $MODULES_PATH || \
|
|
||||||
die "Failed to add '$1' module to load at boot."
|
|
||||||
fi
|
|
||||||
}
|
|
||||||
TEMP_DIR=$(mktemp -d)
|
|
||||||
pushd $TEMP_DIR >/dev/null
|
|
||||||
|
|
||||||
wget -qL https://raw.githubusercontent.com/tteck/Proxmox/main/setup/mariadb_setup.sh
|
|
||||||
|
|
||||||
load_module overlay
|
|
||||||
|
|
||||||
while read -r line; do
|
|
||||||
TAG=$(echo $line | awk '{print $1}')
|
|
||||||
TYPE=$(echo $line | awk '{printf "%-10s", $2}')
|
|
||||||
FREE=$(echo $line | numfmt --field 4-6 --from-unit=K --to=iec --format %.2f | awk '{printf( "%9sB", $6)}')
|
|
||||||
ITEM=" Type: $TYPE Free: $FREE "
|
|
||||||
OFFSET=2
|
|
||||||
if [[ $((${#ITEM} + $OFFSET)) -gt ${MSG_MAX_LENGTH:-} ]]; then
|
|
||||||
MSG_MAX_LENGTH=$((${#ITEM} + $OFFSET))
|
|
||||||
fi
|
|
||||||
STORAGE_MENU+=( "$TAG" "$ITEM" "OFF" )
|
|
||||||
done < <(pvesm status -content rootdir | awk 'NR>1')
|
|
||||||
if [ $((${#STORAGE_MENU[@]}/3)) -eq 0 ]; then
|
|
||||||
warn "'Container' needs to be selected for at least one storage location."
|
|
||||||
die "Unable to detect valid storage location."
|
|
||||||
elif [ $((${#STORAGE_MENU[@]}/3)) -eq 1 ]; then
|
|
||||||
STORAGE=${STORAGE_MENU[0]}
|
|
||||||
else
|
|
||||||
while [ -z "${STORAGE:+x}" ]; do
|
|
||||||
STORAGE=$(whiptail --title "Storage Pools" --radiolist \
|
|
||||||
"Which storage pool you would like to use for the container?\n\n" \
|
|
||||||
16 $(($MSG_MAX_LENGTH + 23)) 6 \
|
|
||||||
"${STORAGE_MENU[@]}" 3>&1 1>&2 2>&3) || exit
|
|
||||||
done
|
|
||||||
fi
|
|
||||||
info "Using ${BL}${STORAGE}${CL} for Storage Location."
|
|
||||||
|
|
||||||
CTID=$(pvesh get /cluster/nextid)
|
|
||||||
info "Container ID is ${BL}${CTID}${CL}."
|
|
||||||
|
|
||||||
echo -en "${GN} Updating LXC Template List... "
|
|
||||||
pveam update >/dev/null
|
|
||||||
echo -e "${CM}${CL} \r"
|
|
||||||
|
|
||||||
echo -en "${GN} Downloading LXC Template... "
|
|
||||||
OSTYPE=debian
|
|
||||||
OSVERSION=${OSTYPE}-11
|
|
||||||
mapfile -t TEMPLATES < <(pveam available -section system | sed -n "s/.*\($OSVERSION.*\)/\1/p" | sort -t - -k 2 -V)
|
|
||||||
TEMPLATE="${TEMPLATES[-1]}"
|
|
||||||
pveam download local $TEMPLATE >/dev/null ||
|
|
||||||
die "A problem occured while downloading the LXC template."
|
|
||||||
|
|
||||||
STORAGE_TYPE=$(pvesm status -storage $STORAGE | awk 'NR>1 {print $2}')
|
|
||||||
case $STORAGE_TYPE in
|
|
||||||
dir|nfs)
|
|
||||||
DISK_EXT=".raw"
|
|
||||||
DISK_REF="$CTID/"
|
|
||||||
;;
|
|
||||||
zfspool)
|
|
||||||
DISK_PREFIX="subvol"
|
|
||||||
DISK_FORMAT="subvol"
|
|
||||||
;;
|
|
||||||
esac
|
|
||||||
DISK=${DISK_PREFIX:-vm}-${CTID}-disk-0${DISK_EXT-}
|
|
||||||
ROOTFS=${STORAGE}:${DISK_REF-}${DISK}
|
|
||||||
echo -e "${CM}${CL} \r"
|
|
||||||
|
|
||||||
echo -en "${GN} Creating LXC Container... "
|
|
||||||
DISK_SIZE=4G
|
|
||||||
pvesm alloc $STORAGE $CTID $DISK $DISK_SIZE --format ${DISK_FORMAT:-raw} >/dev/null
|
|
||||||
if [ "$STORAGE_TYPE" == "zfspool" ]; then
|
|
||||||
warn "Some containers may not work properly due to ZFS not supporting 'fallocate'."
|
|
||||||
else
|
|
||||||
mkfs.ext4 $(pvesm path $ROOTFS) &>/dev/null
|
|
||||||
fi
|
|
||||||
ARCH=$(dpkg --print-architecture)
|
|
||||||
HOSTNAME=mariadb
|
|
||||||
TEMPLATE_STRING="local:vztmpl/${TEMPLATE}"
|
|
||||||
pct create $CTID $TEMPLATE_STRING -arch $ARCH -features nesting=1 \
|
|
||||||
-hostname $HOSTNAME -net0 name=eth0,bridge=vmbr0,ip=dhcp -onboot 1 -cores 1 -memory 1024 \
|
|
||||||
-ostype $OSTYPE -rootfs $ROOTFS,size=$DISK_SIZE -storage $STORAGE >/dev/null
|
|
||||||
|
|
||||||
MOUNT=$(pct mount $CTID | cut -d"'" -f 2)
|
|
||||||
ln -fs $(readlink /etc/localtime) ${MOUNT}/etc/localtime
|
|
||||||
pct unmount $CTID && unset MOUNT
|
|
||||||
echo -e "${CM}${CL} \r"
|
|
||||||
|
|
||||||
echo -en "${GN} Starting LXC Container... "
|
|
||||||
pct start $CTID
|
|
||||||
pct push $CTID mariadb_setup.sh /mariadb_setup.sh -perms 755
|
|
||||||
echo -e "${CM}${CL} \r"
|
|
||||||
pct exec $CTID /mariadb_setup.sh
|
|
||||||
|
|
||||||
IP=$(pct exec $CTID ip a s dev eth0 | sed -n '/inet / s/\// /p' | awk '{print $2}')
|
|
||||||
info "${GN} Successfully created a MariaDB LXC Container to ${BL}${CTID}${CL}"
|
|
||||||
echo -e "${CL} Adminer should be reachable by going to the following URL.
|
|
||||||
${BL} http://${IP}/adminer/ ${CL}"
|
|
252
ct/mariadb-v2.sh
252
ct/mariadb-v2.sh
|
@ -1,252 +0,0 @@
|
||||||
#!/usr/bin/env bash
|
|
||||||
YW=`echo "\033[33m"`
|
|
||||||
BL=`echo "\033[36m"`
|
|
||||||
RD=`echo "\033[01;31m"`
|
|
||||||
CM='\xE2\x9C\x94\033'
|
|
||||||
GN=`echo "\033[1;92m"`
|
|
||||||
CL=`echo "\033[m"`
|
|
||||||
while true; do
|
|
||||||
read -p "This will create a New Mariadb LXC. Proceed(y/n)?" yn
|
|
||||||
case $yn in
|
|
||||||
[Yy]* ) break;;
|
|
||||||
[Nn]* ) exit;;
|
|
||||||
* ) echo "Please answer yes or no.";;
|
|
||||||
esac
|
|
||||||
done
|
|
||||||
clear
|
|
||||||
function header_info {
|
|
||||||
echo -e "${BL}
|
|
||||||
__ __ _ _ _
|
|
||||||
| \/ | (_) | | |
|
|
||||||
| \ / | __ _ _ __ _ __ _ __| | |__
|
|
||||||
| |\/| |/ _ | __| |/ _ |/ _ | _ \
|
|
||||||
| | | | (_| | | | | (_| | (_| | |_) |
|
|
||||||
|_| |_|\__,_|_| |_|\__,_|\__,_|_.__/
|
|
||||||
|
|
||||||
${CL}"
|
|
||||||
}
|
|
||||||
|
|
||||||
header_info
|
|
||||||
show_menu(){
|
|
||||||
printf " ${YW} 1)${YW} Privileged ${CL}\n"
|
|
||||||
printf " ${YW} 2)${GN} Unprivileged ${CL}\n"
|
|
||||||
|
|
||||||
printf "Please choose a Install Method and hit enter or ${RD}x${CL} to exit."
|
|
||||||
read opt
|
|
||||||
}
|
|
||||||
|
|
||||||
option_picked(){
|
|
||||||
message1=${@:-"${CL}Error: No message passed"}
|
|
||||||
printf " ${YW}${message1}${CL}\n"
|
|
||||||
}
|
|
||||||
show_menu
|
|
||||||
while [ "$opt" != " " ]
|
|
||||||
do
|
|
||||||
case $opt in
|
|
||||||
1) clear;
|
|
||||||
header_info;
|
|
||||||
option_picked "Using Privileged Install";
|
|
||||||
IM=0
|
|
||||||
break;
|
|
||||||
;;
|
|
||||||
2) clear;
|
|
||||||
header_info;
|
|
||||||
option_picked "Using Unprivileged Install";
|
|
||||||
IM=1
|
|
||||||
break;
|
|
||||||
;;
|
|
||||||
|
|
||||||
x)exit;
|
|
||||||
;;
|
|
||||||
\n)exit;
|
|
||||||
;;
|
|
||||||
*)clear;
|
|
||||||
option_picked "Please choose a Install Method from the menu";
|
|
||||||
show_menu;
|
|
||||||
;;
|
|
||||||
esac
|
|
||||||
done
|
|
||||||
show_menu2(){
|
|
||||||
printf " ${YW} 1)${GN} Use Automatic Login ${CL}\n"
|
|
||||||
printf " ${YW} 2)${GN} Use Password (changeme) ${CL}\n"
|
|
||||||
|
|
||||||
printf "Please choose a Password Type and hit enter or ${RD}x${CL} to exit."
|
|
||||||
read opt
|
|
||||||
}
|
|
||||||
|
|
||||||
option_picked(){
|
|
||||||
message2=${@:-"${CL}Error: No message passed"}
|
|
||||||
printf " ${YW}${message1}${CL}\n"
|
|
||||||
printf " ${YW}${message2}${CL}\n"
|
|
||||||
}
|
|
||||||
show_menu2
|
|
||||||
while [ "$opt" != " " ]
|
|
||||||
do
|
|
||||||
case $opt in
|
|
||||||
1) clear;
|
|
||||||
header_info;
|
|
||||||
option_picked "Using Automatic Login";
|
|
||||||
PW=" "
|
|
||||||
break;
|
|
||||||
;;
|
|
||||||
2) clear;
|
|
||||||
header_info;
|
|
||||||
option_picked "Using Password (changeme)";
|
|
||||||
PW="-password changeme"
|
|
||||||
break;
|
|
||||||
;;
|
|
||||||
|
|
||||||
x)exit;
|
|
||||||
;;
|
|
||||||
\n)exit;
|
|
||||||
;;
|
|
||||||
*)clear;
|
|
||||||
option_picked "Please choose a Password Type from the menu";
|
|
||||||
show_menu2;
|
|
||||||
;;
|
|
||||||
esac
|
|
||||||
done
|
|
||||||
show_menu3(){
|
|
||||||
printf " ${YW} 1)${GN} Automatic DHCP ${CL}\n"
|
|
||||||
printf " ${YW} 2)${GN} Manual DHCP ${CL}\n"
|
|
||||||
|
|
||||||
printf "Please choose a DHCP Type and hit enter or ${RD}x${CL} to exit."
|
|
||||||
read opt
|
|
||||||
}
|
|
||||||
|
|
||||||
option_picked(){
|
|
||||||
message3=${@:-"${CL}Error: No message passed"}
|
|
||||||
printf " ${YW}${message1}${CL}\n"
|
|
||||||
printf " ${YW}${message2}${CL}\n"
|
|
||||||
printf " ${YW}${message3}${CL}\n"
|
|
||||||
}
|
|
||||||
show_menu3
|
|
||||||
while [ "$opt" != " " ]
|
|
||||||
do
|
|
||||||
case $opt in
|
|
||||||
1) clear;
|
|
||||||
header_info;
|
|
||||||
option_picked "Using Automatic DHCP";
|
|
||||||
DHCP=" "
|
|
||||||
break;
|
|
||||||
;;
|
|
||||||
2) clear;
|
|
||||||
header_info;
|
|
||||||
option_picked "Using Manual DHCP";
|
|
||||||
DHCP="1"
|
|
||||||
break;
|
|
||||||
;;
|
|
||||||
|
|
||||||
x)exit;
|
|
||||||
;;
|
|
||||||
\n)exit;
|
|
||||||
;;
|
|
||||||
*)clear;
|
|
||||||
option_picked "Please choose a DHCP Type from the menu";
|
|
||||||
show_menu3;
|
|
||||||
;;
|
|
||||||
esac
|
|
||||||
done
|
|
||||||
|
|
||||||
set -o errexit
|
|
||||||
set -o errtrace
|
|
||||||
set -o nounset
|
|
||||||
set -o pipefail
|
|
||||||
shopt -s expand_aliases
|
|
||||||
alias die='EXIT=$? LINE=$LINENO error_exit'
|
|
||||||
trap die ERR
|
|
||||||
trap cleanup EXIT
|
|
||||||
|
|
||||||
function error_exit() {
|
|
||||||
trap - ERR
|
|
||||||
local DEFAULT='Unknown failure occured.'
|
|
||||||
local REASON="\e[97m${1:-$DEFAULT}\e[39m"
|
|
||||||
local FLAG="\e[91m[ERROR] \e[93m$EXIT@$LINE"
|
|
||||||
msg "$FLAG $REASON"
|
|
||||||
[ ! -z ${CTID-} ] && cleanup_ctid
|
|
||||||
exit $EXIT
|
|
||||||
}
|
|
||||||
function warn() {
|
|
||||||
local REASON="\e[97m$1\e[39m"
|
|
||||||
local FLAG="\e[93m[WARNING]\e[39m"
|
|
||||||
msg "$FLAG $REASON"
|
|
||||||
}
|
|
||||||
function info() {
|
|
||||||
local REASON="$1"
|
|
||||||
local FLAG="\e[36m[INFO]\e[39m"
|
|
||||||
msg "$FLAG $REASON"
|
|
||||||
}
|
|
||||||
function msg() {
|
|
||||||
local TEXT="$1"
|
|
||||||
echo -e "$TEXT"
|
|
||||||
}
|
|
||||||
function cleanup_ctid() {
|
|
||||||
if $(pct status $CTID &>/dev/null); then
|
|
||||||
if [ "$(pct status $CTID | awk '{print $2}')" == "running" ]; then
|
|
||||||
pct stop $CTID
|
|
||||||
fi
|
|
||||||
pct destroy $CTID
|
|
||||||
elif [ "$(pvesm list $STORAGE --vmid $CTID)" != "" ]; then
|
|
||||||
pvesm free $ROOTFS
|
|
||||||
fi
|
|
||||||
}
|
|
||||||
function cleanup() {
|
|
||||||
popd >/dev/null
|
|
||||||
rm -rf $TEMP_DIR
|
|
||||||
}
|
|
||||||
if [ "$IM" == "1" ]; then
|
|
||||||
FEATURES="nesting=1,keyctl=1"
|
|
||||||
else
|
|
||||||
FEATURES="nesting=1"
|
|
||||||
fi
|
|
||||||
|
|
||||||
TEMP_DIR=$(mktemp -d)
|
|
||||||
pushd $TEMP_DIR >/dev/null
|
|
||||||
|
|
||||||
export CTID=$(pvesh get /cluster/nextid)
|
|
||||||
export PCT_OSTYPE=debian
|
|
||||||
export PCT_OSVERSION=11
|
|
||||||
export PCT_DISK_SIZE=4
|
|
||||||
export PCT_OPTIONS="
|
|
||||||
-features $FEATURES
|
|
||||||
-hostname mariadb
|
|
||||||
-net0 name=eth0,bridge=vmbr0,ip=dhcp
|
|
||||||
-onboot 1
|
|
||||||
-cores 1
|
|
||||||
-memory 1024
|
|
||||||
-unprivileged ${IM}
|
|
||||||
${PW}
|
|
||||||
"
|
|
||||||
bash -c "$(wget -qLO - https://raw.githubusercontent.com/tteck/Proxmox/main/ct/create_lxc.sh)" || exit
|
|
||||||
|
|
||||||
STORAGE_TYPE=$(pvesm status -storage $(pct config $CTID | grep rootfs | awk -F ":" '{print $2}') | awk 'NR>1 {print $2}')
|
|
||||||
if [ "$STORAGE_TYPE" == "zfspool" ]; then
|
|
||||||
warn "Some addons may not work due to ZFS not supporting 'fallocate'."
|
|
||||||
fi
|
|
||||||
if [ "$DHCP" == "1" ]; then
|
|
||||||
MAC=$(pct config $CTID \
|
|
||||||
| grep -i hwaddr \
|
|
||||||
| awk '{print substr($2, 31, length($3) 17 ) }') \
|
|
||||||
|
|
||||||
echo -e "MAC Address ${BL}$MAC${CL}"
|
|
||||||
|
|
||||||
dhcp_reservation(){
|
|
||||||
printf "Please set DHCP reservation and press Enter."
|
|
||||||
read
|
|
||||||
}
|
|
||||||
dhcp_reservation
|
|
||||||
fi
|
|
||||||
|
|
||||||
echo -en "${GN} Starting LXC Container... "
|
|
||||||
pct start $CTID
|
|
||||||
echo -e "${CM}${CL} \r"
|
|
||||||
|
|
||||||
alias lxc-cmd="lxc-attach -n $CTID --"
|
|
||||||
|
|
||||||
lxc-cmd bash -c "$(wget -qLO - https://raw.githubusercontent.com/tteck/Proxmox/main/setup/mariadb-install.sh)" || exit
|
|
||||||
|
|
||||||
IP=$(pct exec $CTID ip a s dev eth0 | sed -n '/inet / s/\// /p' | awk '{print $2}')
|
|
||||||
|
|
||||||
echo -e "${GN}Successfully created Mariadb LXC to${CL} ${BL}$CTID${CL}.
|
|
||||||
${BL}Adminer${CL} should be reachable by going to the following URL.
|
|
||||||
${BL}http://${IP}/adminer/${CL} \n"
|
|
356
ct/mariadb-v3.sh
356
ct/mariadb-v3.sh
|
@ -1,356 +0,0 @@
|
||||||
#!/usr/bin/env bash
|
|
||||||
echo -e "Loading..."
|
|
||||||
NEXTID=$(pvesh get /cluster/nextid)
|
|
||||||
INTEGER='^[0-9]+$'
|
|
||||||
YW=`echo "\033[33m"`
|
|
||||||
BL=`echo "\033[36m"`
|
|
||||||
RD=`echo "\033[01;31m"`
|
|
||||||
BGN=`echo "\033[4;92m"`
|
|
||||||
GN=`echo "\033[1;92m"`
|
|
||||||
DGN=`echo "\033[32m"`
|
|
||||||
CL=`echo "\033[m"`
|
|
||||||
BFR="\\r\\033[K"
|
|
||||||
HOLD="-"
|
|
||||||
CM="${GN}✓${CL}"
|
|
||||||
APP="MariaDB"
|
|
||||||
NSAPP=$(echo ${APP,,} | tr -d ' ')
|
|
||||||
set -o errexit
|
|
||||||
set -o errtrace
|
|
||||||
set -o nounset
|
|
||||||
set -o pipefail
|
|
||||||
shopt -s expand_aliases
|
|
||||||
alias die='EXIT=$? LINE=$LINENO error_exit'
|
|
||||||
trap die ERR
|
|
||||||
|
|
||||||
function error_exit() {
|
|
||||||
trap - ERR
|
|
||||||
local reason="Unknown failure occurred."
|
|
||||||
local msg="${1:-$reason}"
|
|
||||||
local flag="${RD}‼ ERROR ${CL}$EXIT@$LINE"
|
|
||||||
echo -e "$flag $msg" 1>&2
|
|
||||||
exit $EXIT
|
|
||||||
}
|
|
||||||
|
|
||||||
while true; do
|
|
||||||
clear
|
|
||||||
read -p "This will create a New ${APP} LXC. Proceed(y/n)?" yn
|
|
||||||
case $yn in
|
|
||||||
[Yy]* ) break;;
|
|
||||||
[Nn]* ) exit;;
|
|
||||||
* ) echo "Please answer yes or no.";;
|
|
||||||
esac
|
|
||||||
done
|
|
||||||
clear
|
|
||||||
function header_info {
|
|
||||||
echo -e "${BL}
|
|
||||||
__ __ _ _ _
|
|
||||||
| \/ | (_) | | |
|
|
||||||
| \ / | __ _ _ __ _ __ _ __| | |__
|
|
||||||
| |\/| |/ _ | __| |/ _ |/ _ | _ \
|
|
||||||
| | | | (_| | | | | (_| | (_| | |_) |
|
|
||||||
|_| |_|\__,_|_|v3|_|\__,_|\__,_|_.__/
|
|
||||||
${CL}"
|
|
||||||
}
|
|
||||||
|
|
||||||
header_info
|
|
||||||
|
|
||||||
function msg_info() {
|
|
||||||
local msg="$1"
|
|
||||||
echo -ne " ${HOLD} ${YW}${msg}..."
|
|
||||||
}
|
|
||||||
|
|
||||||
function msg_ok() {
|
|
||||||
local msg="$1"
|
|
||||||
echo -e "${BFR} ${CM} ${GN}${msg}${CL}"
|
|
||||||
}
|
|
||||||
|
|
||||||
function PVE_CHECK() {
|
|
||||||
PVE=$(pveversion | grep "pve-manager/7" | wc -l)
|
|
||||||
|
|
||||||
if [[ $PVE != 1 ]]; then
|
|
||||||
echo -e "${RD}This script requires Proxmox Virtual Environment 7.0 or greater${CL}"
|
|
||||||
echo -e "Exiting..."
|
|
||||||
sleep 2
|
|
||||||
exit
|
|
||||||
fi
|
|
||||||
}
|
|
||||||
|
|
||||||
function default_settings() {
|
|
||||||
clear
|
|
||||||
header_info
|
|
||||||
echo -e "${BL}Using Default Settings${CL}"
|
|
||||||
echo -e "${DGN}Using CT Type ${BGN}Unprivileged${CL} ${RD}NO DEVICE PASSTHROUGH${CL}"
|
|
||||||
CT_TYPE="1"
|
|
||||||
echo -e "${DGN}Using CT Password ${BGN}Automatic Login${CL}"
|
|
||||||
PW=" "
|
|
||||||
echo -e "${DGN}Using CT ID ${BGN}$NEXTID${CL}"
|
|
||||||
CT_ID=$NEXTID
|
|
||||||
echo -e "${DGN}Using CT Name ${BGN}$NSAPP${CL}"
|
|
||||||
HN=$NSAPP
|
|
||||||
echo -e "${DGN}Using Disk Size ${BGN}4${CL}${DGN}GB${CL}"
|
|
||||||
DISK_SIZE="4"
|
|
||||||
echo -e "${DGN}Using ${BGN}1${CL}${DGN}vCPU${CL}"
|
|
||||||
CORE_COUNT="1"
|
|
||||||
echo -e "${DGN}Using ${BGN}1024${CL}${DGN}MiB RAM${CL}"
|
|
||||||
RAM_SIZE="1024"
|
|
||||||
echo -e "${DGN}Using Bridge ${BGN}vmbr0${CL}"
|
|
||||||
BRG="vmbr0"
|
|
||||||
echo -e "${DGN}Using Static IP Address ${BGN}DHCP${CL}"
|
|
||||||
NET=dhcp
|
|
||||||
echo -e "${DGN}Using Gateway Address ${BGN}NONE${CL}"
|
|
||||||
GATE=""
|
|
||||||
echo -e "${DGN}Using VLAN Tag ${BGN}NONE${CL}"
|
|
||||||
VLAN=""
|
|
||||||
}
|
|
||||||
|
|
||||||
function advanced_settings() {
|
|
||||||
clear
|
|
||||||
header_info
|
|
||||||
echo -e "${RD}Using Advanced Settings${CL}"
|
|
||||||
echo -e "${YW}Type Privileged, or Press [ENTER] for Default: Unprivileged (${RD}NO DEVICE PASSTHROUGH${CL}${YW})"
|
|
||||||
read CT_TYPE1
|
|
||||||
if [ -z $CT_TYPE1 ]; then CT_TYPE1="Unprivileged" CT_TYPE="1";
|
|
||||||
echo -en "${DGN}Set CT Type ${BL}$CT_TYPE1${CL}"
|
|
||||||
else
|
|
||||||
CT_TYPE1="Privileged"
|
|
||||||
CT_TYPE="0"
|
|
||||||
echo -en "${DGN}Set CT Type ${BL}Privileged${CL}"
|
|
||||||
fi;
|
|
||||||
echo -e " ${CM}${CL} \r"
|
|
||||||
sleep 1
|
|
||||||
clear
|
|
||||||
header_info
|
|
||||||
echo -e "${RD}Using Advanced Settings${CL}"
|
|
||||||
echo -e "${DGN}Using CT Type ${BGN}$CT_TYPE1${CL}"
|
|
||||||
echo -e "${YW}Set Password, or Press [ENTER] for Default: Automatic Login "
|
|
||||||
read PW1
|
|
||||||
if [ -z $PW1 ]; then PW1="Automatic Login" PW=" ";
|
|
||||||
echo -en "${DGN}Set CT ${BL}$PW1${CL}"
|
|
||||||
else
|
|
||||||
PW="-password $PW1"
|
|
||||||
echo -en "${DGN}Set CT Password ${BL}$PW1${CL}"
|
|
||||||
fi;
|
|
||||||
echo -e " ${CM}${CL} \r"
|
|
||||||
sleep 1
|
|
||||||
clear
|
|
||||||
header_info
|
|
||||||
echo -e "${RD}Using Advanced Settings${CL}"
|
|
||||||
echo -e "${DGN}Using CT Type ${BGN}$CT_TYPE1${CL}"
|
|
||||||
echo -e "${DGN}Using CT Password ${BGN}$PW1${CL}"
|
|
||||||
echo -e "${YW}Enter the CT ID, or Press [ENTER] to automatically generate (${NEXTID}) "
|
|
||||||
read CT_ID
|
|
||||||
if [ -z $CT_ID ]; then CT_ID=$NEXTID; fi;
|
|
||||||
echo -en "${DGN}Set CT ID To ${BL}$CT_ID${CL}"
|
|
||||||
echo -e " ${CM}${CL} \r"
|
|
||||||
sleep 1
|
|
||||||
clear
|
|
||||||
header_info
|
|
||||||
echo -e "${RD}Using Advanced Settings${CL}"
|
|
||||||
echo -e "${DGN}Using CT Type ${BGN}$CT_TYPE1${CL}"
|
|
||||||
echo -e "${DGN}Using CT Password ${BGN}$PW1${CL}"
|
|
||||||
echo -e "${DGN}Using CT ID ${BGN}$CT_ID${CL}"
|
|
||||||
echo -e "${YW}Enter CT Name (no-spaces), or Press [ENTER] for Default: $NSAPP "
|
|
||||||
read CT_NAME
|
|
||||||
if [ -z $CT_NAME ]; then
|
|
||||||
HN=$NSAPP
|
|
||||||
else
|
|
||||||
HN=$(echo ${CT_NAME,,} | tr -d ' ')
|
|
||||||
fi
|
|
||||||
echo -en "${DGN}Set CT Name To ${BL}$HN${CL}"
|
|
||||||
echo -e " ${CM}${CL} \r"
|
|
||||||
sleep 1
|
|
||||||
clear
|
|
||||||
header_info
|
|
||||||
echo -e "${RD}Using Advanced Settings${CL}"
|
|
||||||
echo -e "${DGN}Using CT Type ${BGN}$CT_TYPE1${CL}"
|
|
||||||
echo -e "${DGN}Using CT Password ${BGN}$PW1${CL}"
|
|
||||||
echo -e "${DGN}Using CT ID ${BGN}$CT_ID${CL}"
|
|
||||||
echo -e "${DGN}Using CT Name ${BGN}$HN${CL}"
|
|
||||||
echo -e "${YW}Enter a Disk Size, or Press [ENTER] for Default: 4 "
|
|
||||||
read DISK_SIZE
|
|
||||||
if [ -z $DISK_SIZE ]; then DISK_SIZE="4"; fi;
|
|
||||||
if ! [[ $DISK_SIZE =~ $INTEGER ]] ; then echo "ERROR! DISK SIZE MUST HAVE INTEGER NUMBER!"; exit; fi;
|
|
||||||
echo -en "${DGN}Set Disk Size To ${BL}$DISK_SIZE${CL}${DGN}GB${CL}"
|
|
||||||
echo -e " ${CM}${CL} \r"
|
|
||||||
sleep 1
|
|
||||||
clear
|
|
||||||
header_info
|
|
||||||
echo -e "${RD}Using Advanced Settings${CL}"
|
|
||||||
echo -e "${DGN}Using CT Type ${BGN}$CT_TYPE1${CL}"
|
|
||||||
echo -e "${DGN}Using CT Password ${BGN}$PW1${CL}"
|
|
||||||
echo -e "${DGN}Using CT ID ${BGN}$CT_ID${CL}"
|
|
||||||
echo -e "${DGN}Using CT Name ${BGN}$HN${CL}"
|
|
||||||
echo -e "${DGN}Using Disk Size ${BGN}$DISK_SIZE${CL}${DGN}GB${CL}"
|
|
||||||
echo -e "${YW}Allocate CPU cores, or Press [ENTER] for Default: 1 "
|
|
||||||
read CORE_COUNT
|
|
||||||
if [ -z $CORE_COUNT ]; then CORE_COUNT="1"; fi;
|
|
||||||
echo -en "${DGN}Set Cores To ${BL}$CORE_COUNT${CL}${DGN}vCPU${CL}"
|
|
||||||
echo -e " ${CM}${CL} \r"
|
|
||||||
sleep 1
|
|
||||||
clear
|
|
||||||
header_info
|
|
||||||
echo -e "${RD}Using Advanced Settings${CL}"
|
|
||||||
echo -e "${DGN}Using CT Type ${BGN}$CT_TYPE1${CL}"
|
|
||||||
echo -e "${DGN}Using CT Password ${BGN}$PW1${CL}"
|
|
||||||
echo -e "${DGN}Using CT ID ${BGN}$CT_ID${CL}"
|
|
||||||
echo -e "${DGN}Using CT Name ${BGN}$HN${CL}"
|
|
||||||
echo -e "${DGN}Using Disk Size ${BGN}$DISK_SIZE${CL}${DGN}GB${CL}"
|
|
||||||
echo -e "${DGN}Using ${BGN}${CORE_COUNT}${CL}${DGN}vCPU${CL}"
|
|
||||||
echo -e "${YW}Allocate RAM in MiB, or Press [ENTER] for Default: 1024 "
|
|
||||||
read RAM_SIZE
|
|
||||||
if [ -z $RAM_SIZE ]; then RAM_SIZE="1024"; fi;
|
|
||||||
echo -en "${DGN}Set RAM To ${BL}$RAM_SIZE${CL}${DGN}MiB RAM${CL}"
|
|
||||||
echo -e " ${CM}${CL} \n"
|
|
||||||
sleep 1
|
|
||||||
clear
|
|
||||||
header_info
|
|
||||||
echo -e "${RD}Using Advanced Settings${CL}"
|
|
||||||
echo -e "${DGN}Using CT Type ${BGN}$CT_TYPE1${CL}"
|
|
||||||
echo -e "${DGN}Using CT Password ${BGN}$PW1${CL}"
|
|
||||||
echo -e "${DGN}Using CT ID ${BGN}$CT_ID${CL}"
|
|
||||||
echo -e "${DGN}Using CT Name ${BGN}$HN${CL}"
|
|
||||||
echo -e "${DGN}Using Disk Size ${BGN}$DISK_SIZE${CL}${DGN}GB${CL}"
|
|
||||||
echo -e "${DGN}Using ${BGN}${CORE_COUNT}${CL}${DGN}vCPU${CL}"
|
|
||||||
echo -e "${DGN}Using ${BGN}${RAM_SIZE}${CL}${DGN}MiB RAM${CL}"
|
|
||||||
echo -e "${YW}Enter a Bridge, or Press [ENTER] for Default: vmbr0 "
|
|
||||||
read BRG
|
|
||||||
if [ -z $BRG ]; then BRG="vmbr0"; fi;
|
|
||||||
echo -en "${DGN}Set Bridge To ${BL}$BRG${CL}"
|
|
||||||
echo -e " ${CM}${CL} \n"
|
|
||||||
sleep 1
|
|
||||||
clear
|
|
||||||
header_info
|
|
||||||
echo -e "${RD}Using Advanced Settings${CL}"
|
|
||||||
echo -e "${DGN}Using CT Type ${BGN}$CT_TYPE1${CL}"
|
|
||||||
echo -e "${DGN}Using CT Password ${BGN}$PW1${CL}"
|
|
||||||
echo -e "${DGN}Using CT ID ${BGN}$CT_ID${CL}"
|
|
||||||
echo -e "${DGN}Using CT Name ${BGN}$HN${CL}"
|
|
||||||
echo -e "${DGN}Using Disk Size ${BGN}$DISK_SIZE${CL}${DGN}GB${CL}"
|
|
||||||
echo -e "${DGN}Using ${BGN}${CORE_COUNT}${CL}${DGN}vCPU${CL}"
|
|
||||||
echo -e "${DGN}Using ${BGN}${RAM_SIZE}${CL}${DGN}MiB RAM${CL}"
|
|
||||||
echo -e "${DGN}Using Bridge ${BGN}${BRG}${CL}"
|
|
||||||
echo -e "${YW}Enter a Static IPv4 CIDR Address, or Press [ENTER] for Default: DHCP "
|
|
||||||
read NET
|
|
||||||
if [ -z $NET ]; then NET="dhcp"; fi;
|
|
||||||
echo -en "${DGN}Set Static IP Address To ${BL}$NET${CL}"
|
|
||||||
echo -e " ${CM}${CL} \n"
|
|
||||||
sleep 1
|
|
||||||
clear
|
|
||||||
header_info
|
|
||||||
echo -e "${RD}Using Advanced Settings${CL}"
|
|
||||||
echo -e "${DGN}Using CT Type ${BGN}$CT_TYPE1${CL}"
|
|
||||||
echo -e "${DGN}Using CT Password ${BGN}$PW1${CL}"
|
|
||||||
echo -e "${DGN}Using CT ID ${BGN}$CT_ID${CL}"
|
|
||||||
echo -e "${DGN}Using CT Name ${BGN}$HN${CL}"
|
|
||||||
echo -e "${DGN}Using Disk Size ${BGN}$DISK_SIZE${CL}${DGN}GB${CL}"
|
|
||||||
echo -e "${DGN}Using ${BGN}${CORE_COUNT}${CL}${DGN}vCPU${CL}"
|
|
||||||
echo -e "${DGN}Using ${BGN}${RAM_SIZE}${CL}${DGN}MiB RAM${CL}"
|
|
||||||
echo -e "${DGN}Using Bridge ${BGN}${BRG}${CL}"
|
|
||||||
echo -e "${DGN}Using Static IP Address ${BGN}$NET${CL}"
|
|
||||||
echo -e "${YW}Enter a Gateway IP (mandatory if static IP is used), or Press [ENTER] for Default: NONE "
|
|
||||||
read GATE1
|
|
||||||
if [ -z $GATE1 ]; then GATE1="NONE" GATE="";
|
|
||||||
echo -en "${DGN}Set Gateway IP To ${BL}$GATE1${CL}"
|
|
||||||
else
|
|
||||||
GATE=",gw=$GATE1"
|
|
||||||
echo -en "${DGN}Set Gateway IP To ${BL}$GATE1${CL}"
|
|
||||||
fi;
|
|
||||||
echo -e " ${CM}${CL} \n"
|
|
||||||
sleep 1
|
|
||||||
clear
|
|
||||||
header_info
|
|
||||||
|
|
||||||
echo -e "${RD}Using Advanced Settings${CL}"
|
|
||||||
echo -e "${DGN}Using CT Type ${BGN}$CT_TYPE1${CL}"
|
|
||||||
echo -e "${DGN}Using CT Password ${BGN}$PW1${CL}"
|
|
||||||
echo -e "${DGN}Using CT ID ${BGN}$CT_ID${CL}"
|
|
||||||
echo -e "${DGN}Using CT Name ${BGN}$HN${CL}"
|
|
||||||
echo -e "${DGN}Using Disk Size ${BGN}$DISK_SIZE${CL}${DGN}GB${CL}"
|
|
||||||
echo -e "${DGN}Using ${BGN}${CORE_COUNT}${CL}${DGN}vCPU${CL}"
|
|
||||||
echo -e "${DGN}Using ${BGN}${RAM_SIZE}${CL}${DGN}MiB RAM${CL}"
|
|
||||||
echo -e "${DGN}Using Bridge ${BGN}${BRG}${CL}"
|
|
||||||
echo -e "${DGN}Using Static IP Address ${BGN}$NET${CL}"
|
|
||||||
echo -e "${DGN}Using Gateway IP Address ${BGN}$GATE1${CL}"
|
|
||||||
echo -e "${YW}Enter a VLAN Tag, or Press [ENTER] for Default: NONE "
|
|
||||||
read VLAN1
|
|
||||||
if [ -z $VLAN1 ]; then VLAN1="NONE" VLAN="";
|
|
||||||
echo -en "${DGN}Set VLAN Tag To ${BL}$VLAN1${CL}"
|
|
||||||
else
|
|
||||||
VLAN=",tag=$VLAN1"
|
|
||||||
echo -en "${DGN}Set VLAN Tag To ${BL}$VLAN1${CL}"
|
|
||||||
fi;
|
|
||||||
echo -e " ${CM}${CL} \n"
|
|
||||||
sleep 1
|
|
||||||
clear
|
|
||||||
header_info
|
|
||||||
echo -e "${RD}Using Advanced Settings${CL}"
|
|
||||||
echo -e "${DGN}Using CT Type ${BGN}$CT_TYPE1${CL}"
|
|
||||||
echo -e "${DGN}Using CT Password ${BGN}$PW1${CL}"
|
|
||||||
echo -e "${DGN}Using CT ID ${BGN}$CT_ID${CL}"
|
|
||||||
echo -e "${DGN}Using CT Name ${BGN}$HN${CL}"
|
|
||||||
echo -e "${DGN}Using Disk Size ${BGN}$DISK_SIZE${CL}${DGN}GB${CL}"
|
|
||||||
echo -e "${DGN}Using ${BGN}${CORE_COUNT}${CL}${DGN}vCPU${CL}"
|
|
||||||
echo -e "${DGN}Using ${BGN}${RAM_SIZE}${CL}${DGN}MiB RAM${CL}"
|
|
||||||
echo -e "${DGN}Using Bridge ${BGN}${BRG}${CL}"
|
|
||||||
echo -e "${DGN}Using Static IP Address ${BGN}$NET${CL}"
|
|
||||||
echo -e "${DGN}Using Gateway IP Address ${BGN}$GATE1${CL}"
|
|
||||||
echo -e "${DGN}Using VLAN Tag ${BGN}$VLAN1${CL}"
|
|
||||||
|
|
||||||
read -p "Are these settings correct(y/n)? " -n 1 -r
|
|
||||||
echo
|
|
||||||
if [[ ! $REPLY =~ ^[Yy]$ ]]
|
|
||||||
then
|
|
||||||
advanced_settings
|
|
||||||
fi
|
|
||||||
}
|
|
||||||
|
|
||||||
function start_script() {
|
|
||||||
echo -e "${YW}Type Advanced, or Press [ENTER] for Default Settings "
|
|
||||||
read SETTINGS
|
|
||||||
if [ -z $SETTINGS ]; then default_settings;
|
|
||||||
else
|
|
||||||
advanced_settings
|
|
||||||
fi;
|
|
||||||
}
|
|
||||||
|
|
||||||
start_script
|
|
||||||
|
|
||||||
if [ "$CT_TYPE" == "1" ]; then
|
|
||||||
FEATURES="nesting=1,keyctl=1"
|
|
||||||
else
|
|
||||||
FEATURES="nesting=1"
|
|
||||||
fi
|
|
||||||
|
|
||||||
TEMP_DIR=$(mktemp -d)
|
|
||||||
pushd $TEMP_DIR >/dev/null
|
|
||||||
|
|
||||||
export CTID=$CT_ID
|
|
||||||
export PCT_OSTYPE=debian
|
|
||||||
export PCT_OSVERSION=11
|
|
||||||
export PCT_DISK_SIZE=$DISK_SIZE
|
|
||||||
export PCT_OPTIONS="
|
|
||||||
-features $FEATURES
|
|
||||||
-hostname $HN
|
|
||||||
-net0 name=eth0,bridge=$BRG,ip=$NET$GATE$VLAN
|
|
||||||
-onboot 1
|
|
||||||
-cores $CORE_COUNT
|
|
||||||
-memory $RAM_SIZE
|
|
||||||
-unprivileged $CT_TYPE
|
|
||||||
$PW
|
|
||||||
"
|
|
||||||
bash -c "$(wget -qLO - https://raw.githubusercontent.com/tteck/Proxmox/main/ct/create_lxc.sh)" || exit
|
|
||||||
|
|
||||||
msg_info "Starting LXC Container"
|
|
||||||
pct start $CTID
|
|
||||||
msg_ok "Started LXC Container"
|
|
||||||
|
|
||||||
lxc-attach -n $CTID -- bash -c "$(wget -qLO - https://raw.githubusercontent.com/tteck/Proxmox/main/setup/mariadb-install.sh)" || exit
|
|
||||||
|
|
||||||
IP=$(pct exec $CTID ip a s dev eth0 | sed -n '/inet / s/\// /p' | awk '{print $2}')
|
|
||||||
|
|
||||||
pct set $CTID -description "# ${APP} LXC
|
|
||||||
### https://github.com/tteck/Proxmox"
|
|
||||||
|
|
||||||
msg_ok "Completed Successfully!\n"
|
|
||||||
echo -e "Adminer should be reachable by going to the following URL.
|
|
||||||
${BL}http://${IP}/adminer/${CL} \n"
|
|
|
@ -309,7 +309,7 @@ bash -c "$(wget -qLO - https://raw.githubusercontent.com/tteck/Proxmox/main/ct/c
|
||||||
msg_info "Starting LXC Container"
|
msg_info "Starting LXC Container"
|
||||||
pct start $CTID
|
pct start $CTID
|
||||||
msg_ok "Started LXC Container"
|
msg_ok "Started LXC Container"
|
||||||
lxc-attach -n $CTID -- bash -c "$(wget -qLO - https://raw.githubusercontent.com/tteck/Proxmox/main/setup/$var_install.sh)" || exit
|
lxc-attach -n $CTID -- bash -c "$(wget -qLO - https://raw.githubusercontent.com/tteck/Proxmox/main/install/$var_install.sh)" || exit
|
||||||
IP=$(pct exec $CTID ip a s dev eth0 | sed -n '/inet / s/\// /p' | awk '{print $2}')
|
IP=$(pct exec $CTID ip a s dev eth0 | sed -n '/inet / s/\// /p' | awk '{print $2}')
|
||||||
pct set $CTID -description "# ${APP} LXC
|
pct set $CTID -description "# ${APP} LXC
|
||||||
### https://tteck.github.io/Proxmox/
|
### https://tteck.github.io/Proxmox/
|
||||||
|
|
|
@ -1,258 +0,0 @@
|
||||||
#!/usr/bin/env bash
|
|
||||||
YW=`echo "\033[33m"`
|
|
||||||
BL=`echo "\033[36m"`
|
|
||||||
RD=`echo "\033[01;31m"`
|
|
||||||
CM='\xE2\x9C\x94\033'
|
|
||||||
GN=`echo "\033[1;92m"`
|
|
||||||
CL=`echo "\033[m"`
|
|
||||||
APP="MeshCentral"
|
|
||||||
HN=$(echo ${APP,,} | tr -d ' ')
|
|
||||||
while true; do
|
|
||||||
read -p "This will create a New ${APP} LXC. Proceed(y/n)?" yn
|
|
||||||
case $yn in
|
|
||||||
[Yy]* ) break;;
|
|
||||||
[Nn]* ) exit;;
|
|
||||||
* ) echo "Please answer yes or no.";;
|
|
||||||
esac
|
|
||||||
done
|
|
||||||
clear
|
|
||||||
function header_info {
|
|
||||||
echo -e "${BL}
|
|
||||||
__ __ _ _____ _ _
|
|
||||||
| \/ | | | / ____| | | | |
|
|
||||||
| \ / | ___ ___| |__ | | ___ _ __ | |_ _ __ __ _| |
|
|
||||||
| |\/| |/ _ \/ __| _ \| | / _ \ _ \| __| __/ _ | |
|
|
||||||
| | | | __/\__ \ | | | |___| __/ | | | |_| | | (_| | |
|
|
||||||
|_| |_|\___||___/_| |_|\_____\___|_| |_|\__|_| \__,_|_|
|
|
||||||
${CL}"
|
|
||||||
}
|
|
||||||
|
|
||||||
header_info
|
|
||||||
show_menu(){
|
|
||||||
printf " ${YW} 1)${YW} Privileged ${CL}\n"
|
|
||||||
printf " ${YW} 2)${GN} Unprivileged ${CL}\n"
|
|
||||||
|
|
||||||
printf "Please choose a Install Method and hit enter or ${RD}x${CL} to exit."
|
|
||||||
read opt
|
|
||||||
}
|
|
||||||
|
|
||||||
option_picked(){
|
|
||||||
message1=${@:-"${CL}Error: No message passed"}
|
|
||||||
printf " ${YW}${message1}${CL}\n"
|
|
||||||
}
|
|
||||||
show_menu
|
|
||||||
while [ "$opt" != " " ]
|
|
||||||
do
|
|
||||||
case $opt in
|
|
||||||
1) clear;
|
|
||||||
header_info;
|
|
||||||
option_picked "Using Privileged Install";
|
|
||||||
IM=0
|
|
||||||
break;
|
|
||||||
;;
|
|
||||||
2) clear;
|
|
||||||
header_info;
|
|
||||||
option_picked "Using Unprivileged Install";
|
|
||||||
IM=1
|
|
||||||
break;
|
|
||||||
;;
|
|
||||||
|
|
||||||
x)exit;
|
|
||||||
;;
|
|
||||||
\n)exit;
|
|
||||||
;;
|
|
||||||
*)clear;
|
|
||||||
option_picked "Please choose a Install Method from the menu";
|
|
||||||
show_menu;
|
|
||||||
;;
|
|
||||||
esac
|
|
||||||
done
|
|
||||||
show_menu2(){
|
|
||||||
printf " ${YW} 1)${GN} Use Automatic Login ${CL}\n"
|
|
||||||
printf " ${YW} 2)${GN} Use Password (changeme) ${CL}\n"
|
|
||||||
|
|
||||||
printf "Please choose a Password Type and hit enter or ${RD}x${CL} to exit."
|
|
||||||
read opt
|
|
||||||
}
|
|
||||||
|
|
||||||
option_picked(){
|
|
||||||
message2=${@:-"${CL}Error: No message passed"}
|
|
||||||
printf " ${YW}${message1}${CL}\n"
|
|
||||||
printf " ${YW}${message2}${CL}\n"
|
|
||||||
}
|
|
||||||
show_menu2
|
|
||||||
while [ "$opt" != " " ]
|
|
||||||
do
|
|
||||||
case $opt in
|
|
||||||
1) clear;
|
|
||||||
header_info;
|
|
||||||
option_picked "Using Automatic Login";
|
|
||||||
PW=" "
|
|
||||||
break;
|
|
||||||
;;
|
|
||||||
2) clear;
|
|
||||||
header_info;
|
|
||||||
option_picked "Using Password (changeme)";
|
|
||||||
PW="-password changeme"
|
|
||||||
break;
|
|
||||||
;;
|
|
||||||
|
|
||||||
x)exit;
|
|
||||||
;;
|
|
||||||
\n)exit;
|
|
||||||
;;
|
|
||||||
*)clear;
|
|
||||||
option_picked "Please choose a Password Type from the menu";
|
|
||||||
show_menu2;
|
|
||||||
;;
|
|
||||||
esac
|
|
||||||
done
|
|
||||||
show_menu3(){
|
|
||||||
printf " ${YW} 1)${GN} Automatic DHCP ${CL}\n"
|
|
||||||
printf " ${YW} 2)${GN} Manual DHCP ${CL}\n"
|
|
||||||
|
|
||||||
printf "Please choose a DHCP Type and hit enter or ${RD}x${CL} to exit."
|
|
||||||
read opt
|
|
||||||
}
|
|
||||||
|
|
||||||
option_picked(){
|
|
||||||
message3=${@:-"${CL}Error: No message passed"}
|
|
||||||
printf " ${YW}${message1}${CL}\n"
|
|
||||||
printf " ${YW}${message2}${CL}\n"
|
|
||||||
printf " ${YW}${message3}${CL}\n"
|
|
||||||
}
|
|
||||||
show_menu3
|
|
||||||
while [ "$opt" != " " ]
|
|
||||||
do
|
|
||||||
case $opt in
|
|
||||||
1) clear;
|
|
||||||
header_info;
|
|
||||||
option_picked "Using Automatic DHCP";
|
|
||||||
DHCP=" "
|
|
||||||
break;
|
|
||||||
;;
|
|
||||||
2) clear;
|
|
||||||
header_info;
|
|
||||||
option_picked "Using Manual DHCP";
|
|
||||||
DHCP="1"
|
|
||||||
break;
|
|
||||||
;;
|
|
||||||
|
|
||||||
x)exit;
|
|
||||||
;;
|
|
||||||
\n)exit;
|
|
||||||
;;
|
|
||||||
*)clear;
|
|
||||||
option_picked "Please choose a DHCP Type from the menu";
|
|
||||||
show_menu3;
|
|
||||||
;;
|
|
||||||
esac
|
|
||||||
done
|
|
||||||
|
|
||||||
set -o errexit
|
|
||||||
set -o errtrace
|
|
||||||
set -o nounset
|
|
||||||
set -o pipefail
|
|
||||||
shopt -s expand_aliases
|
|
||||||
alias die='EXIT=$? LINE=$LINENO error_exit'
|
|
||||||
trap die ERR
|
|
||||||
trap cleanup EXIT
|
|
||||||
|
|
||||||
function error_exit() {
|
|
||||||
trap - ERR
|
|
||||||
local DEFAULT='Unknown failure occured.'
|
|
||||||
local REASON="\e[97m${1:-$DEFAULT}\e[39m"
|
|
||||||
local FLAG="\e[91m[ERROR] \e[93m$EXIT@$LINE"
|
|
||||||
msg "$FLAG $REASON"
|
|
||||||
[ ! -z ${CTID-} ] && cleanup_ctid
|
|
||||||
exit $EXIT
|
|
||||||
}
|
|
||||||
function warn() {
|
|
||||||
local REASON="\e[97m$1\e[39m"
|
|
||||||
local FLAG="\e[93m[WARNING]\e[39m"
|
|
||||||
msg "$FLAG $REASON"
|
|
||||||
}
|
|
||||||
function info() {
|
|
||||||
local REASON="$1"
|
|
||||||
local FLAG="\e[36m[INFO]\e[39m"
|
|
||||||
msg "$FLAG $REASON"
|
|
||||||
}
|
|
||||||
function msg() {
|
|
||||||
local TEXT="$1"
|
|
||||||
echo -e "$TEXT"
|
|
||||||
}
|
|
||||||
function cleanup_ctid() {
|
|
||||||
if $(pct status $CTID &>/dev/null); then
|
|
||||||
if [ "$(pct status $CTID | awk '{print $2}')" == "running" ]; then
|
|
||||||
pct stop $CTID
|
|
||||||
fi
|
|
||||||
pct destroy $CTID
|
|
||||||
elif [ "$(pvesm list $STORAGE --vmid $CTID)" != "" ]; then
|
|
||||||
pvesm free $ROOTFS
|
|
||||||
fi
|
|
||||||
}
|
|
||||||
function cleanup() {
|
|
||||||
popd >/dev/null
|
|
||||||
rm -rf $TEMP_DIR
|
|
||||||
}
|
|
||||||
if [ "$IM" == "1" ]; then
|
|
||||||
FEATURES="nesting=1,keyctl=1"
|
|
||||||
else
|
|
||||||
FEATURES="nesting=1"
|
|
||||||
fi
|
|
||||||
|
|
||||||
TEMP_DIR=$(mktemp -d)
|
|
||||||
pushd $TEMP_DIR >/dev/null
|
|
||||||
|
|
||||||
export CTID=$(pvesh get /cluster/nextid)
|
|
||||||
export PCT_OSTYPE=debian
|
|
||||||
export PCT_OSVERSION=11
|
|
||||||
export PCT_DISK_SIZE=2
|
|
||||||
export PCT_OPTIONS="
|
|
||||||
-features $FEATURES
|
|
||||||
-hostname $HN
|
|
||||||
-net0 name=eth0,bridge=vmbr0,ip=dhcp
|
|
||||||
-onboot 1
|
|
||||||
-cores 1
|
|
||||||
-memory 512
|
|
||||||
-unprivileged ${IM}
|
|
||||||
${PW}
|
|
||||||
"
|
|
||||||
bash -c "$(wget -qLO - https://raw.githubusercontent.com/tteck/Proxmox/main/ct/create_lxc.sh)" || exit
|
|
||||||
|
|
||||||
STORAGE_TYPE=$(pvesm status -storage $(pct config $CTID | grep rootfs | awk -F ":" '{print $2}') | awk 'NR>1 {print $2}')
|
|
||||||
if [ "$STORAGE_TYPE" == "zfspool" ]; then
|
|
||||||
warn "Some applications may not work properly due to ZFS not supporting 'fallocate'."
|
|
||||||
fi
|
|
||||||
LXC_CONFIG=/etc/pve/lxc/${CTID}.conf
|
|
||||||
cat <<EOF >> $LXC_CONFIG
|
|
||||||
lxc.cgroup2.devices.allow: a
|
|
||||||
lxc.cap.drop:
|
|
||||||
EOF
|
|
||||||
if [ "$DHCP" == "1" ]; then
|
|
||||||
MAC=$(pct config $CTID \
|
|
||||||
| grep -i hwaddr \
|
|
||||||
| awk '{print substr($2, 31, length($3) 17 ) }') \
|
|
||||||
|
|
||||||
echo -e "MAC Address ${BL}$MAC${CL}"
|
|
||||||
|
|
||||||
dhcp_reservation(){
|
|
||||||
printf "Please set DHCP reservation and press Enter."
|
|
||||||
read
|
|
||||||
}
|
|
||||||
dhcp_reservation
|
|
||||||
fi
|
|
||||||
|
|
||||||
echo -en "${GN} Starting LXC Container... "
|
|
||||||
pct start $CTID
|
|
||||||
echo -e "${CM}${CL} \r"
|
|
||||||
|
|
||||||
alias lxc-cmd="lxc-attach -n $CTID --"
|
|
||||||
|
|
||||||
lxc-cmd bash -c "$(wget -qLO - https://raw.githubusercontent.com/tteck/Proxmox/main/setup/$HN-install.sh)" || exit
|
|
||||||
|
|
||||||
IP=$(pct exec $CTID ip a s dev eth0 | sed -n '/inet / s/\// /p' | awk '{print $2}')
|
|
||||||
|
|
||||||
echo -e "${GN}Successfully created ${APP} LXC to${CL} ${BL}$CTID${CL}.
|
|
||||||
${APP} should be reachable by going to the following URL.
|
|
||||||
${BL}http://${IP}${CL} \n"
|
|
|
@ -1,356 +0,0 @@
|
||||||
#!/usr/bin/env bash
|
|
||||||
echo -e "Loading..."
|
|
||||||
NEXTID=$(pvesh get /cluster/nextid)
|
|
||||||
INTEGER='^[0-9]+$'
|
|
||||||
YW=`echo "\033[33m"`
|
|
||||||
BL=`echo "\033[36m"`
|
|
||||||
RD=`echo "\033[01;31m"`
|
|
||||||
BGN=`echo "\033[4;92m"`
|
|
||||||
GN=`echo "\033[1;92m"`
|
|
||||||
DGN=`echo "\033[32m"`
|
|
||||||
CL=`echo "\033[m"`
|
|
||||||
BFR="\\r\\033[K"
|
|
||||||
HOLD="-"
|
|
||||||
CM="${GN}✓${CL}"
|
|
||||||
APP="MeshCentral"
|
|
||||||
NSAPP=$(echo ${APP,,} | tr -d ' ')
|
|
||||||
set -o errexit
|
|
||||||
set -o errtrace
|
|
||||||
set -o nounset
|
|
||||||
set -o pipefail
|
|
||||||
shopt -s expand_aliases
|
|
||||||
alias die='EXIT=$? LINE=$LINENO error_exit'
|
|
||||||
trap die ERR
|
|
||||||
|
|
||||||
function error_exit() {
|
|
||||||
trap - ERR
|
|
||||||
local reason="Unknown failure occurred."
|
|
||||||
local msg="${1:-$reason}"
|
|
||||||
local flag="${RD}‼ ERROR ${CL}$EXIT@$LINE"
|
|
||||||
echo -e "$flag $msg" 1>&2
|
|
||||||
exit $EXIT
|
|
||||||
}
|
|
||||||
|
|
||||||
while true; do
|
|
||||||
clear
|
|
||||||
read -p "This will create a New ${APP} LXC. Proceed(y/n)?" yn
|
|
||||||
case $yn in
|
|
||||||
[Yy]* ) break;;
|
|
||||||
[Nn]* ) exit;;
|
|
||||||
* ) echo "Please answer yes or no.";;
|
|
||||||
esac
|
|
||||||
done
|
|
||||||
clear
|
|
||||||
function header_info {
|
|
||||||
echo -e "${BL}
|
|
||||||
__ __ _ _____ _ _
|
|
||||||
| \/ | | | / ____| | | | |
|
|
||||||
| \ / | ___ ___| |__ | | ___ _ __ | |_ _ __ __ _| |
|
|
||||||
| |\/| |/ _ \/ __| _ \| | v3 / _ \ _ \| __| __/ _ | |
|
|
||||||
| | | | __/\__ \ | | | |___| __/ | | | |_| | | (_| | |
|
|
||||||
|_| |_|\___||___/_| |_|\_____\___|_| |_|\__|_| \__,_|_|
|
|
||||||
${CL}"
|
|
||||||
}
|
|
||||||
|
|
||||||
header_info
|
|
||||||
|
|
||||||
function msg_info() {
|
|
||||||
local msg="$1"
|
|
||||||
echo -ne " ${HOLD} ${YW}${msg}..."
|
|
||||||
}
|
|
||||||
|
|
||||||
function msg_ok() {
|
|
||||||
local msg="$1"
|
|
||||||
echo -e "${BFR} ${CM} ${GN}${msg}${CL}"
|
|
||||||
}
|
|
||||||
|
|
||||||
function PVE_CHECK() {
|
|
||||||
PVE=$(pveversion | grep "pve-manager/7" | wc -l)
|
|
||||||
|
|
||||||
if [[ $PVE != 1 ]]; then
|
|
||||||
echo -e "${RD}This script requires Proxmox Virtual Environment 7.0 or greater${CL}"
|
|
||||||
echo -e "Exiting..."
|
|
||||||
sleep 2
|
|
||||||
exit
|
|
||||||
fi
|
|
||||||
}
|
|
||||||
|
|
||||||
function default_settings() {
|
|
||||||
clear
|
|
||||||
header_info
|
|
||||||
echo -e "${BL}Using Default Settings${CL}"
|
|
||||||
echo -e "${DGN}Using CT Type ${BGN}Unprivileged${CL} ${RD}NO DEVICE PASSTHROUGH${CL}"
|
|
||||||
CT_TYPE="1"
|
|
||||||
echo -e "${DGN}Using CT Password ${BGN}Automatic Login${CL}"
|
|
||||||
PW=" "
|
|
||||||
echo -e "${DGN}Using CT ID ${BGN}$NEXTID${CL}"
|
|
||||||
CT_ID=$NEXTID
|
|
||||||
echo -e "${DGN}Using CT Name ${BGN}$NSAPP${CL}"
|
|
||||||
HN=$NSAPP
|
|
||||||
echo -e "${DGN}Using Disk Size ${BGN}2${CL}${DGN}GB${CL}"
|
|
||||||
DISK_SIZE="2"
|
|
||||||
echo -e "${DGN}Using ${BGN}1${CL}${DGN}vCPU${CL}"
|
|
||||||
CORE_COUNT="1"
|
|
||||||
echo -e "${DGN}Using ${BGN}512${CL}${DGN}MiB RAM${CL}"
|
|
||||||
RAM_SIZE="512"
|
|
||||||
echo -e "${DGN}Using Bridge ${BGN}vmbr0${CL}"
|
|
||||||
BRG="vmbr0"
|
|
||||||
echo -e "${DGN}Using Static IP Address ${BGN}DHCP${CL}"
|
|
||||||
NET=dhcp
|
|
||||||
echo -e "${DGN}Using Gateway Address ${BGN}NONE${CL}"
|
|
||||||
GATE=""
|
|
||||||
echo -e "${DGN}Using VLAN Tag ${BGN}NONE${CL}"
|
|
||||||
VLAN=""
|
|
||||||
}
|
|
||||||
|
|
||||||
function advanced_settings() {
|
|
||||||
clear
|
|
||||||
header_info
|
|
||||||
echo -e "${RD}Using Advanced Settings${CL}"
|
|
||||||
echo -e "${YW}Type Privileged, or Press [ENTER] for Default: Unprivileged (${RD}NO DEVICE PASSTHROUGH${CL}${YW})"
|
|
||||||
read CT_TYPE1
|
|
||||||
if [ -z $CT_TYPE1 ]; then CT_TYPE1="Unprivileged" CT_TYPE="1";
|
|
||||||
echo -en "${DGN}Set CT Type ${BL}$CT_TYPE1${CL}"
|
|
||||||
else
|
|
||||||
CT_TYPE1="Privileged"
|
|
||||||
CT_TYPE="0"
|
|
||||||
echo -en "${DGN}Set CT Type ${BL}Privileged${CL}"
|
|
||||||
fi;
|
|
||||||
echo -e " ${CM}${CL} \r"
|
|
||||||
sleep 1
|
|
||||||
clear
|
|
||||||
header_info
|
|
||||||
echo -e "${RD}Using Advanced Settings${CL}"
|
|
||||||
echo -e "${DGN}Using CT Type ${BGN}$CT_TYPE1${CL}"
|
|
||||||
echo -e "${YW}Set Password, or Press [ENTER] for Default: Automatic Login "
|
|
||||||
read PW1
|
|
||||||
if [ -z $PW1 ]; then PW1="Automatic Login" PW=" ";
|
|
||||||
echo -en "${DGN}Set CT ${BL}$PW1${CL}"
|
|
||||||
else
|
|
||||||
PW="-password $PW1"
|
|
||||||
echo -en "${DGN}Set CT Password ${BL}$PW1${CL}"
|
|
||||||
fi;
|
|
||||||
echo -e " ${CM}${CL} \r"
|
|
||||||
sleep 1
|
|
||||||
clear
|
|
||||||
header_info
|
|
||||||
echo -e "${RD}Using Advanced Settings${CL}"
|
|
||||||
echo -e "${DGN}Using CT Type ${BGN}$CT_TYPE1${CL}"
|
|
||||||
echo -e "${DGN}Using CT Password ${BGN}$PW1${CL}"
|
|
||||||
echo -e "${YW}Enter the CT ID, or Press [ENTER] to automatically generate (${NEXTID}) "
|
|
||||||
read CT_ID
|
|
||||||
if [ -z $CT_ID ]; then CT_ID=$NEXTID; fi;
|
|
||||||
echo -en "${DGN}Set CT ID To ${BL}$CT_ID${CL}"
|
|
||||||
echo -e " ${CM}${CL} \r"
|
|
||||||
sleep 1
|
|
||||||
clear
|
|
||||||
header_info
|
|
||||||
echo -e "${RD}Using Advanced Settings${CL}"
|
|
||||||
echo -e "${DGN}Using CT Type ${BGN}$CT_TYPE1${CL}"
|
|
||||||
echo -e "${DGN}Using CT Password ${BGN}$PW1${CL}"
|
|
||||||
echo -e "${DGN}Using CT ID ${BGN}$CT_ID${CL}"
|
|
||||||
echo -e "${YW}Enter CT Name (no-spaces), or Press [ENTER] for Default: $NSAPP "
|
|
||||||
read CT_NAME
|
|
||||||
if [ -z $CT_NAME ]; then
|
|
||||||
HN=$NSAPP
|
|
||||||
else
|
|
||||||
HN=$(echo ${CT_NAME,,} | tr -d ' ')
|
|
||||||
fi
|
|
||||||
echo -en "${DGN}Set CT Name To ${BL}$HN${CL}"
|
|
||||||
echo -e " ${CM}${CL} \r"
|
|
||||||
sleep 1
|
|
||||||
clear
|
|
||||||
header_info
|
|
||||||
echo -e "${RD}Using Advanced Settings${CL}"
|
|
||||||
echo -e "${DGN}Using CT Type ${BGN}$CT_TYPE1${CL}"
|
|
||||||
echo -e "${DGN}Using CT Password ${BGN}$PW1${CL}"
|
|
||||||
echo -e "${DGN}Using CT ID ${BGN}$CT_ID${CL}"
|
|
||||||
echo -e "${DGN}Using CT Name ${BGN}$HN${CL}"
|
|
||||||
echo -e "${YW}Enter a Disk Size, or Press [ENTER] for Default: 2 "
|
|
||||||
read DISK_SIZE
|
|
||||||
if [ -z $DISK_SIZE ]; then DISK_SIZE="2"; fi;
|
|
||||||
if ! [[ $DISK_SIZE =~ $INTEGER ]] ; then echo "ERROR! DISK SIZE MUST HAVE INTEGER NUMBER!"; exit; fi;
|
|
||||||
echo -en "${DGN}Set Disk Size To ${BL}$DISK_SIZE${CL}${DGN}GB${CL}"
|
|
||||||
echo -e " ${CM}${CL} \r"
|
|
||||||
sleep 1
|
|
||||||
clear
|
|
||||||
header_info
|
|
||||||
echo -e "${RD}Using Advanced Settings${CL}"
|
|
||||||
echo -e "${DGN}Using CT Type ${BGN}$CT_TYPE1${CL}"
|
|
||||||
echo -e "${DGN}Using CT Password ${BGN}$PW1${CL}"
|
|
||||||
echo -e "${DGN}Using CT ID ${BGN}$CT_ID${CL}"
|
|
||||||
echo -e "${DGN}Using CT Name ${BGN}$HN${CL}"
|
|
||||||
echo -e "${DGN}Using Disk Size ${BGN}$DISK_SIZE${CL}${DGN}GB${CL}"
|
|
||||||
echo -e "${YW}Allocate CPU cores, or Press [ENTER] for Default: 1 "
|
|
||||||
read CORE_COUNT
|
|
||||||
if [ -z $CORE_COUNT ]; then CORE_COUNT="1"; fi;
|
|
||||||
echo -en "${DGN}Set Cores To ${BL}$CORE_COUNT${CL}${DGN}vCPU${CL}"
|
|
||||||
echo -e " ${CM}${CL} \r"
|
|
||||||
sleep 1
|
|
||||||
clear
|
|
||||||
header_info
|
|
||||||
echo -e "${RD}Using Advanced Settings${CL}"
|
|
||||||
echo -e "${DGN}Using CT Type ${BGN}$CT_TYPE1${CL}"
|
|
||||||
echo -e "${DGN}Using CT Password ${BGN}$PW1${CL}"
|
|
||||||
echo -e "${DGN}Using CT ID ${BGN}$CT_ID${CL}"
|
|
||||||
echo -e "${DGN}Using CT Name ${BGN}$HN${CL}"
|
|
||||||
echo -e "${DGN}Using Disk Size ${BGN}$DISK_SIZE${CL}${DGN}GB${CL}"
|
|
||||||
echo -e "${DGN}Using ${BGN}${CORE_COUNT}${CL}${DGN}vCPU${CL}"
|
|
||||||
echo -e "${YW}Allocate RAM in MiB, or Press [ENTER] for Default: 512 "
|
|
||||||
read RAM_SIZE
|
|
||||||
if [ -z $RAM_SIZE ]; then RAM_SIZE="512"; fi;
|
|
||||||
echo -en "${DGN}Set RAM To ${BL}$RAM_SIZE${CL}${DGN}MiB RAM${CL}"
|
|
||||||
echo -e " ${CM}${CL} \n"
|
|
||||||
sleep 1
|
|
||||||
clear
|
|
||||||
header_info
|
|
||||||
echo -e "${RD}Using Advanced Settings${CL}"
|
|
||||||
echo -e "${DGN}Using CT Type ${BGN}$CT_TYPE1${CL}"
|
|
||||||
echo -e "${DGN}Using CT Password ${BGN}$PW1${CL}"
|
|
||||||
echo -e "${DGN}Using CT ID ${BGN}$CT_ID${CL}"
|
|
||||||
echo -e "${DGN}Using CT Name ${BGN}$HN${CL}"
|
|
||||||
echo -e "${DGN}Using Disk Size ${BGN}$DISK_SIZE${CL}${DGN}GB${CL}"
|
|
||||||
echo -e "${DGN}Using ${BGN}${CORE_COUNT}${CL}${DGN}vCPU${CL}"
|
|
||||||
echo -e "${DGN}Using ${BGN}${RAM_SIZE}${CL}${DGN}MiB RAM${CL}"
|
|
||||||
echo -e "${YW}Enter a Bridge, or Press [ENTER] for Default: vmbr0 "
|
|
||||||
read BRG
|
|
||||||
if [ -z $BRG ]; then BRG="vmbr0"; fi;
|
|
||||||
echo -en "${DGN}Set Bridge To ${BL}$BRG${CL}"
|
|
||||||
echo -e " ${CM}${CL} \n"
|
|
||||||
sleep 1
|
|
||||||
clear
|
|
||||||
header_info
|
|
||||||
echo -e "${RD}Using Advanced Settings${CL}"
|
|
||||||
echo -e "${DGN}Using CT Type ${BGN}$CT_TYPE1${CL}"
|
|
||||||
echo -e "${DGN}Using CT Password ${BGN}$PW1${CL}"
|
|
||||||
echo -e "${DGN}Using CT ID ${BGN}$CT_ID${CL}"
|
|
||||||
echo -e "${DGN}Using CT Name ${BGN}$HN${CL}"
|
|
||||||
echo -e "${DGN}Using Disk Size ${BGN}$DISK_SIZE${CL}${DGN}GB${CL}"
|
|
||||||
echo -e "${DGN}Using ${BGN}${CORE_COUNT}${CL}${DGN}vCPU${CL}"
|
|
||||||
echo -e "${DGN}Using ${BGN}${RAM_SIZE}${CL}${DGN}MiB RAM${CL}"
|
|
||||||
echo -e "${DGN}Using Bridge ${BGN}${BRG}${CL}"
|
|
||||||
echo -e "${YW}Enter a Static IPv4 CIDR Address, or Press [ENTER] for Default: DHCP "
|
|
||||||
read NET
|
|
||||||
if [ -z $NET ]; then NET="dhcp"; fi;
|
|
||||||
echo -en "${DGN}Set Static IP Address To ${BL}$NET${CL}"
|
|
||||||
echo -e " ${CM}${CL} \n"
|
|
||||||
sleep 1
|
|
||||||
clear
|
|
||||||
header_info
|
|
||||||
echo -e "${RD}Using Advanced Settings${CL}"
|
|
||||||
echo -e "${DGN}Using CT Type ${BGN}$CT_TYPE1${CL}"
|
|
||||||
echo -e "${DGN}Using CT Password ${BGN}$PW1${CL}"
|
|
||||||
echo -e "${DGN}Using CT ID ${BGN}$CT_ID${CL}"
|
|
||||||
echo -e "${DGN}Using CT Name ${BGN}$HN${CL}"
|
|
||||||
echo -e "${DGN}Using Disk Size ${BGN}$DISK_SIZE${CL}${DGN}GB${CL}"
|
|
||||||
echo -e "${DGN}Using ${BGN}${CORE_COUNT}${CL}${DGN}vCPU${CL}"
|
|
||||||
echo -e "${DGN}Using ${BGN}${RAM_SIZE}${CL}${DGN}MiB RAM${CL}"
|
|
||||||
echo -e "${DGN}Using Bridge ${BGN}${BRG}${CL}"
|
|
||||||
echo -e "${DGN}Using Static IP Address ${BGN}$NET${CL}"
|
|
||||||
echo -e "${YW}Enter a Gateway IP (mandatory if static IP is used), or Press [ENTER] for Default: NONE "
|
|
||||||
read GATE1
|
|
||||||
if [ -z $GATE1 ]; then GATE1="NONE" GATE="";
|
|
||||||
echo -en "${DGN}Set Gateway IP To ${BL}$GATE1${CL}"
|
|
||||||
else
|
|
||||||
GATE=",gw=$GATE1"
|
|
||||||
echo -en "${DGN}Set Gateway IP To ${BL}$GATE1${CL}"
|
|
||||||
fi;
|
|
||||||
echo -e " ${CM}${CL} \n"
|
|
||||||
sleep 1
|
|
||||||
clear
|
|
||||||
header_info
|
|
||||||
|
|
||||||
echo -e "${RD}Using Advanced Settings${CL}"
|
|
||||||
echo -e "${DGN}Using CT Type ${BGN}$CT_TYPE1${CL}"
|
|
||||||
echo -e "${DGN}Using CT Password ${BGN}$PW1${CL}"
|
|
||||||
echo -e "${DGN}Using CT ID ${BGN}$CT_ID${CL}"
|
|
||||||
echo -e "${DGN}Using CT Name ${BGN}$HN${CL}"
|
|
||||||
echo -e "${DGN}Using Disk Size ${BGN}$DISK_SIZE${CL}${DGN}GB${CL}"
|
|
||||||
echo -e "${DGN}Using ${BGN}${CORE_COUNT}${CL}${DGN}vCPU${CL}"
|
|
||||||
echo -e "${DGN}Using ${BGN}${RAM_SIZE}${CL}${DGN}MiB RAM${CL}"
|
|
||||||
echo -e "${DGN}Using Bridge ${BGN}${BRG}${CL}"
|
|
||||||
echo -e "${DGN}Using Static IP Address ${BGN}$NET${CL}"
|
|
||||||
echo -e "${DGN}Using Gateway IP Address ${BGN}$GATE1${CL}"
|
|
||||||
echo -e "${YW}Enter a VLAN Tag, or Press [ENTER] for Default: NONE "
|
|
||||||
read VLAN1
|
|
||||||
if [ -z $VLAN1 ]; then VLAN1="NONE" VLAN="";
|
|
||||||
echo -en "${DGN}Set VLAN Tag To ${BL}$VLAN1${CL}"
|
|
||||||
else
|
|
||||||
VLAN=",tag=$VLAN1"
|
|
||||||
echo -en "${DGN}Set VLAN Tag To ${BL}$VLAN1${CL}"
|
|
||||||
fi;
|
|
||||||
echo -e " ${CM}${CL} \n"
|
|
||||||
sleep 1
|
|
||||||
clear
|
|
||||||
header_info
|
|
||||||
echo -e "${RD}Using Advanced Settings${CL}"
|
|
||||||
echo -e "${DGN}Using CT Type ${BGN}$CT_TYPE1${CL}"
|
|
||||||
echo -e "${DGN}Using CT Password ${BGN}$PW1${CL}"
|
|
||||||
echo -e "${DGN}Using CT ID ${BGN}$CT_ID${CL}"
|
|
||||||
echo -e "${DGN}Using CT Name ${BGN}$HN${CL}"
|
|
||||||
echo -e "${DGN}Using Disk Size ${BGN}$DISK_SIZE${CL}${DGN}GB${CL}"
|
|
||||||
echo -e "${DGN}Using ${BGN}${CORE_COUNT}${CL}${DGN}vCPU${CL}"
|
|
||||||
echo -e "${DGN}Using ${BGN}${RAM_SIZE}${CL}${DGN}MiB RAM${CL}"
|
|
||||||
echo -e "${DGN}Using Bridge ${BGN}${BRG}${CL}"
|
|
||||||
echo -e "${DGN}Using Static IP Address ${BGN}$NET${CL}"
|
|
||||||
echo -e "${DGN}Using Gateway IP Address ${BGN}$GATE1${CL}"
|
|
||||||
echo -e "${DGN}Using VLAN Tag ${BGN}$VLAN1${CL}"
|
|
||||||
|
|
||||||
read -p "Are these settings correct(y/n)? " -n 1 -r
|
|
||||||
echo
|
|
||||||
if [[ ! $REPLY =~ ^[Yy]$ ]]
|
|
||||||
then
|
|
||||||
advanced_settings
|
|
||||||
fi
|
|
||||||
}
|
|
||||||
|
|
||||||
function start_script() {
|
|
||||||
echo -e "${YW}Type Advanced, or Press [ENTER] for Default Settings "
|
|
||||||
read SETTINGS
|
|
||||||
if [ -z $SETTINGS ]; then default_settings;
|
|
||||||
else
|
|
||||||
advanced_settings
|
|
||||||
fi;
|
|
||||||
}
|
|
||||||
|
|
||||||
start_script
|
|
||||||
|
|
||||||
if [ "$CT_TYPE" == "1" ]; then
|
|
||||||
FEATURES="nesting=1,keyctl=1"
|
|
||||||
else
|
|
||||||
FEATURES="nesting=1"
|
|
||||||
fi
|
|
||||||
|
|
||||||
TEMP_DIR=$(mktemp -d)
|
|
||||||
pushd $TEMP_DIR >/dev/null
|
|
||||||
|
|
||||||
export CTID=$CT_ID
|
|
||||||
export PCT_OSTYPE=debian
|
|
||||||
export PCT_OSVERSION=11
|
|
||||||
export PCT_DISK_SIZE=$DISK_SIZE
|
|
||||||
export PCT_OPTIONS="
|
|
||||||
-features $FEATURES
|
|
||||||
-hostname $HN
|
|
||||||
-net0 name=eth0,bridge=$BRG,ip=$NET$GATE$VLAN
|
|
||||||
-onboot 1
|
|
||||||
-cores $CORE_COUNT
|
|
||||||
-memory $RAM_SIZE
|
|
||||||
-unprivileged $CT_TYPE
|
|
||||||
$PW
|
|
||||||
"
|
|
||||||
bash -c "$(wget -qLO - https://raw.githubusercontent.com/tteck/Proxmox/main/ct/create_lxc.sh)" || exit
|
|
||||||
|
|
||||||
msg_info "Starting LXC Container"
|
|
||||||
pct start $CTID
|
|
||||||
msg_ok "Started LXC Container"
|
|
||||||
|
|
||||||
lxc-attach -n $CTID -- bash -c "$(wget -qLO - https://raw.githubusercontent.com/tteck/Proxmox/main/setup/meshcentral-install.sh)" || exit
|
|
||||||
|
|
||||||
IP=$(pct exec $CTID ip a s dev eth0 | sed -n '/inet / s/\// /p' | awk '{print $2}')
|
|
||||||
|
|
||||||
pct set $CTID -description "# ${APP} LXC
|
|
||||||
### https://github.com/tteck/Proxmox"
|
|
||||||
|
|
||||||
msg_ok "Completed Successfully!\n"
|
|
||||||
echo -e "${APP} should be reachable by going to the following URL.
|
|
||||||
${BL}http://${IP}${CL} \n"
|
|
|
@ -309,7 +309,7 @@ bash -c "$(wget -qLO - https://raw.githubusercontent.com/tteck/Proxmox/main/ct/c
|
||||||
msg_info "Starting LXC Container"
|
msg_info "Starting LXC Container"
|
||||||
pct start $CTID
|
pct start $CTID
|
||||||
msg_ok "Started LXC Container"
|
msg_ok "Started LXC Container"
|
||||||
lxc-attach -n $CTID -- bash -c "$(wget -qLO - https://raw.githubusercontent.com/tteck/Proxmox/main/setup/$var_install.sh)" || exit
|
lxc-attach -n $CTID -- bash -c "$(wget -qLO - https://raw.githubusercontent.com/tteck/Proxmox/main/install/$var_install.sh)" || exit
|
||||||
IP=$(pct exec $CTID ip a s dev eth0 | sed -n '/inet / s/\// /p' | awk '{print $2}')
|
IP=$(pct exec $CTID ip a s dev eth0 | sed -n '/inet / s/\// /p' | awk '{print $2}')
|
||||||
pct set $CTID -description "# ${APP} LXC
|
pct set $CTID -description "# ${APP} LXC
|
||||||
### https://tteck.github.io/Proxmox/
|
### https://tteck.github.io/Proxmox/
|
||||||
|
|
|
@ -1,168 +0,0 @@
|
||||||
#!/usr/bin/env bash
|
|
||||||
|
|
||||||
while true; do
|
|
||||||
read -p "This will create a New MotionEye NVR LXC Container. Proceed(y/n)?" yn
|
|
||||||
case $yn in
|
|
||||||
[Yy]* ) break;;
|
|
||||||
[Nn]* ) exit;;
|
|
||||||
* ) echo "Please answer yes or no.";;
|
|
||||||
esac
|
|
||||||
done
|
|
||||||
|
|
||||||
set -o errexit
|
|
||||||
set -o errtrace
|
|
||||||
set -o nounset
|
|
||||||
set -o pipefail
|
|
||||||
shopt -s expand_aliases
|
|
||||||
alias die='EXIT=$? LINE=$LINENO error_exit'
|
|
||||||
CHECKMARK='\033[0;32m\xE2\x9C\x94\033[0m'
|
|
||||||
trap die ERR
|
|
||||||
trap cleanup EXIT
|
|
||||||
|
|
||||||
function error_exit() {
|
|
||||||
trap - ERR
|
|
||||||
local DEFAULT='Unknown failure occured.'
|
|
||||||
local REASON="\e[97m${1:-$DEFAULT}\e[39m"
|
|
||||||
local FLAG="\e[91m[ERROR] \e[93m$EXIT@$LINE"
|
|
||||||
msg "$FLAG $REASON"
|
|
||||||
[ ! -z ${CTID-} ] && cleanup_ctid
|
|
||||||
exit $EXIT
|
|
||||||
}
|
|
||||||
function warn() {
|
|
||||||
local REASON="\e[97m$1\e[39m"
|
|
||||||
local FLAG="\e[93m[WARNING]\e[39m"
|
|
||||||
msg "$FLAG $REASON"
|
|
||||||
}
|
|
||||||
function info() {
|
|
||||||
local REASON="$1"
|
|
||||||
local FLAG="\e[36m[INFO]\e[39m"
|
|
||||||
msg "$FLAG $REASON"
|
|
||||||
}
|
|
||||||
function msg() {
|
|
||||||
local TEXT="$1"
|
|
||||||
echo -e "$TEXT"
|
|
||||||
}
|
|
||||||
function cleanup_ctid() {
|
|
||||||
if [ ! -z ${MOUNT+x} ]; then
|
|
||||||
pct unmount $CTID
|
|
||||||
fi
|
|
||||||
if $(pct status $CTID &>/dev/null); then
|
|
||||||
if [ "$(pct status $CTID | awk '{print $2}')" == "running" ]; then
|
|
||||||
pct stop $CTID
|
|
||||||
fi
|
|
||||||
pct destroy $CTID
|
|
||||||
elif [ "$(pvesm list $STORAGE --vmid $CTID)" != "" ]; then
|
|
||||||
pvesm free $ROOTFS
|
|
||||||
fi
|
|
||||||
}
|
|
||||||
function cleanup() {
|
|
||||||
popd >/dev/null
|
|
||||||
rm -rf $TEMP_DIR
|
|
||||||
}
|
|
||||||
function load_module() {
|
|
||||||
if ! $(lsmod | grep -Fq $1); then
|
|
||||||
modprobe $1 &>/dev/null || \
|
|
||||||
die "Failed to load '$1' module."
|
|
||||||
fi
|
|
||||||
MODULES_PATH=/etc/modules
|
|
||||||
if ! $(grep -Fxq "$1" $MODULES_PATH); then
|
|
||||||
echo "$1" >> $MODULES_PATH || \
|
|
||||||
die "Failed to add '$1' module to load at boot."
|
|
||||||
fi
|
|
||||||
}
|
|
||||||
TEMP_DIR=$(mktemp -d)
|
|
||||||
pushd $TEMP_DIR >/dev/null
|
|
||||||
|
|
||||||
wget -qL https://raw.githubusercontent.com/tteck/Proxmox/main/setup/motioneye_setup.sh
|
|
||||||
|
|
||||||
load_module overlay
|
|
||||||
|
|
||||||
while read -r line; do
|
|
||||||
TAG=$(echo $line | awk '{print $1}')
|
|
||||||
TYPE=$(echo $line | awk '{printf "%-10s", $2}')
|
|
||||||
FREE=$(echo $line | numfmt --field 4-6 --from-unit=K --to=iec --format %.2f | awk '{printf( "%9sB", $6)}')
|
|
||||||
ITEM=" Type: $TYPE Free: $FREE "
|
|
||||||
OFFSET=2
|
|
||||||
if [[ $((${#ITEM} + $OFFSET)) -gt ${MSG_MAX_LENGTH:-} ]]; then
|
|
||||||
MSG_MAX_LENGTH=$((${#ITEM} + $OFFSET))
|
|
||||||
fi
|
|
||||||
STORAGE_MENU+=( "$TAG" "$ITEM" "OFF" )
|
|
||||||
done < <(pvesm status -content rootdir | awk 'NR>1')
|
|
||||||
if [ $((${#STORAGE_MENU[@]}/3)) -eq 0 ]; then
|
|
||||||
warn "'Container' needs to be selected for at least one storage location."
|
|
||||||
die "Unable to detect valid storage location."
|
|
||||||
elif [ $((${#STORAGE_MENU[@]}/3)) -eq 1 ]; then
|
|
||||||
STORAGE=${STORAGE_MENU[0]}
|
|
||||||
else
|
|
||||||
while [ -z "${STORAGE:+x}" ]; do
|
|
||||||
STORAGE=$(whiptail --title "Storage Pools" --radiolist \
|
|
||||||
"Which storage pool you would like to use for the container?\n\n" \
|
|
||||||
16 $(($MSG_MAX_LENGTH + 23)) 6 \
|
|
||||||
"${STORAGE_MENU[@]}" 3>&1 1>&2 2>&3) || exit
|
|
||||||
done
|
|
||||||
fi
|
|
||||||
info "Using '$STORAGE' for storage location."
|
|
||||||
|
|
||||||
CTID=$(pvesh get /cluster/nextid)
|
|
||||||
info "Container ID is $CTID."
|
|
||||||
|
|
||||||
echo -e "${CHECKMARK} \e[1;92m Updating LXC Template List... \e[0m"
|
|
||||||
pveam update >/dev/null
|
|
||||||
|
|
||||||
echo -e "${CHECKMARK} \e[1;92m Downloading LXC Template... \e[0m"
|
|
||||||
OSTYPE=debian
|
|
||||||
OSVERSION=${OSTYPE}-11
|
|
||||||
mapfile -t TEMPLATES < <(pveam available -section system | sed -n "s/.*\($OSVERSION.*\)/\1/p" | sort -t - -k 2 -V)
|
|
||||||
TEMPLATE="${TEMPLATES[-1]}"
|
|
||||||
pveam download local $TEMPLATE >/dev/null ||
|
|
||||||
die "A problem occured while downloading the LXC template."
|
|
||||||
|
|
||||||
STORAGE_TYPE=$(pvesm status -storage $STORAGE | awk 'NR>1 {print $2}')
|
|
||||||
case $STORAGE_TYPE in
|
|
||||||
dir|nfs)
|
|
||||||
DISK_EXT=".raw"
|
|
||||||
DISK_REF="$CTID/"
|
|
||||||
;;
|
|
||||||
zfspool)
|
|
||||||
DISK_PREFIX="subvol"
|
|
||||||
DISK_FORMAT="subvol"
|
|
||||||
;;
|
|
||||||
esac
|
|
||||||
DISK=${DISK_PREFIX:-vm}-${CTID}-disk-0${DISK_EXT-}
|
|
||||||
ROOTFS=${STORAGE}:${DISK_REF-}${DISK}
|
|
||||||
|
|
||||||
echo -e "${CHECKMARK} \e[1;92m Creating LXC Container... \e[0m"
|
|
||||||
DISK_SIZE=8G
|
|
||||||
pvesm alloc $STORAGE $CTID $DISK $DISK_SIZE --format ${DISK_FORMAT:-raw} >/dev/null
|
|
||||||
if [ "$STORAGE_TYPE" == "zfspool" ]; then
|
|
||||||
warn "Some containers may not work properly due to ZFS not supporting 'fallocate'."
|
|
||||||
else
|
|
||||||
mkfs.ext4 $(pvesm path $ROOTFS) &>/dev/null
|
|
||||||
fi
|
|
||||||
ARCH=$(dpkg --print-architecture)
|
|
||||||
HOSTNAME=motioneye
|
|
||||||
TEMPLATE_STRING="local:vztmpl/${TEMPLATE}"
|
|
||||||
pct create $CTID $TEMPLATE_STRING -arch $ARCH -features nesting=1 \
|
|
||||||
-hostname $HOSTNAME -net0 name=eth0,bridge=vmbr0,ip=dhcp -onboot 1 -cores 2 -memory 2048\
|
|
||||||
-ostype $OSTYPE -rootfs $ROOTFS,size=$DISK_SIZE -storage $STORAGE >/dev/null
|
|
||||||
|
|
||||||
LXC_CONFIG=/etc/pve/lxc/${CTID}.conf
|
|
||||||
cat <<EOF >> $LXC_CONFIG
|
|
||||||
lxc.cgroup2.devices.allow: a
|
|
||||||
lxc.cap.drop:
|
|
||||||
EOF
|
|
||||||
|
|
||||||
MOUNT=$(pct mount $CTID | cut -d"'" -f 2)
|
|
||||||
ln -fs $(readlink /etc/localtime) ${MOUNT}/etc/localtime
|
|
||||||
pct unmount $CTID && unset MOUNT
|
|
||||||
|
|
||||||
echo -e "${CHECKMARK} \e[1;92m Starting LXC Container... \e[0m"
|
|
||||||
pct start $CTID
|
|
||||||
pct push $CTID motioneye_setup.sh /motioneye_setup.sh -perms 755
|
|
||||||
pct exec $CTID /motioneye_setup.sh
|
|
||||||
|
|
||||||
IP=$(pct exec $CTID ip a s dev eth0 | sed -n '/inet / s/\// /p' | awk '{print $2}')
|
|
||||||
info "Successfully Created MotionEye LXC to $CTID."
|
|
||||||
echo -e "\e[1;92m MotionEye NVR should be reachable by going to the following URL.
|
|
||||||
http://${IP}:8765
|
|
||||||
\e[0m"
|
|
|
@ -1,258 +0,0 @@
|
||||||
#!/usr/bin/env bash
|
|
||||||
YW=`echo "\033[33m"`
|
|
||||||
BL=`echo "\033[36m"`
|
|
||||||
RD=`echo "\033[01;31m"`
|
|
||||||
CM='\xE2\x9C\x94\033'
|
|
||||||
GN=`echo "\033[1;92m"`
|
|
||||||
CL=`echo "\033[m"`
|
|
||||||
APP="Motioneye"
|
|
||||||
HN=$(echo ${APP,,} | tr -d ' ')
|
|
||||||
while true; do
|
|
||||||
read -p "This will create a New ${APP} LXC. Proceed(y/n)?" yn
|
|
||||||
case $yn in
|
|
||||||
[Yy]* ) break;;
|
|
||||||
[Nn]* ) exit;;
|
|
||||||
* ) echo "Please answer yes or no.";;
|
|
||||||
esac
|
|
||||||
done
|
|
||||||
clear
|
|
||||||
function header_info {
|
|
||||||
echo -e "${BL}
|
|
||||||
__ __ ____ _______ _____ ____ _ _ ________ ________
|
|
||||||
| \/ |/ __ \__ __|_ _/ __ \| \ | | ____\ \ / / ____|
|
|
||||||
| \ / | | | | | | | || | | | \| | |__ \ \_/ /| |__
|
|
||||||
| |\/| | | | | | | | || | | | | __| \ / | __|
|
|
||||||
| | | | |__| | | | _| || |__| | |\ | |____ | | | |____
|
|
||||||
|_| |_|\____/ |_| |_____\____/|_| \_|______| |_| |______|
|
|
||||||
${CL}"
|
|
||||||
}
|
|
||||||
|
|
||||||
header_info
|
|
||||||
show_menu(){
|
|
||||||
printf " ${YW} 1)${YW} Privileged ${CL}\n"
|
|
||||||
printf " ${YW} 2)${GN} Unprivileged ${CL}\n"
|
|
||||||
|
|
||||||
printf "Please choose a Install Method and hit enter or ${RD}x${CL} to exit."
|
|
||||||
read opt
|
|
||||||
}
|
|
||||||
|
|
||||||
option_picked(){
|
|
||||||
message1=${@:-"${CL}Error: No message passed"}
|
|
||||||
printf " ${YW}${message1}${CL}\n"
|
|
||||||
}
|
|
||||||
show_menu
|
|
||||||
while [ "$opt" != " " ]
|
|
||||||
do
|
|
||||||
case $opt in
|
|
||||||
1) clear;
|
|
||||||
header_info;
|
|
||||||
option_picked "Using Privileged Install";
|
|
||||||
IM=0
|
|
||||||
break;
|
|
||||||
;;
|
|
||||||
2) clear;
|
|
||||||
header_info;
|
|
||||||
option_picked "Using Unprivileged Install";
|
|
||||||
IM=1
|
|
||||||
break;
|
|
||||||
;;
|
|
||||||
|
|
||||||
x)exit;
|
|
||||||
;;
|
|
||||||
\n)exit;
|
|
||||||
;;
|
|
||||||
*)clear;
|
|
||||||
option_picked "Please choose a Install Method from the menu";
|
|
||||||
show_menu;
|
|
||||||
;;
|
|
||||||
esac
|
|
||||||
done
|
|
||||||
show_menu2(){
|
|
||||||
printf " ${YW} 1)${GN} Use Automatic Login ${CL}\n"
|
|
||||||
printf " ${YW} 2)${GN} Use Password (changeme) ${CL}\n"
|
|
||||||
|
|
||||||
printf "Please choose a Password Type and hit enter or ${RD}x${CL} to exit."
|
|
||||||
read opt
|
|
||||||
}
|
|
||||||
|
|
||||||
option_picked(){
|
|
||||||
message2=${@:-"${CL}Error: No message passed"}
|
|
||||||
printf " ${YW}${message1}${CL}\n"
|
|
||||||
printf " ${YW}${message2}${CL}\n"
|
|
||||||
}
|
|
||||||
show_menu2
|
|
||||||
while [ "$opt" != " " ]
|
|
||||||
do
|
|
||||||
case $opt in
|
|
||||||
1) clear;
|
|
||||||
header_info;
|
|
||||||
option_picked "Using Automatic Login";
|
|
||||||
PW=" "
|
|
||||||
break;
|
|
||||||
;;
|
|
||||||
2) clear;
|
|
||||||
header_info;
|
|
||||||
option_picked "Using Password (changeme)";
|
|
||||||
PW="-password changeme"
|
|
||||||
break;
|
|
||||||
;;
|
|
||||||
|
|
||||||
x)exit;
|
|
||||||
;;
|
|
||||||
\n)exit;
|
|
||||||
;;
|
|
||||||
*)clear;
|
|
||||||
option_picked "Please choose a Password Type from the menu";
|
|
||||||
show_menu2;
|
|
||||||
;;
|
|
||||||
esac
|
|
||||||
done
|
|
||||||
show_menu3(){
|
|
||||||
printf " ${YW} 1)${GN} Automatic DHCP ${CL}\n"
|
|
||||||
printf " ${YW} 2)${GN} Manual DHCP ${CL}\n"
|
|
||||||
|
|
||||||
printf "Please choose a DHCP Type and hit enter or ${RD}x${CL} to exit."
|
|
||||||
read opt
|
|
||||||
}
|
|
||||||
|
|
||||||
option_picked(){
|
|
||||||
message3=${@:-"${CL}Error: No message passed"}
|
|
||||||
printf " ${YW}${message1}${CL}\n"
|
|
||||||
printf " ${YW}${message2}${CL}\n"
|
|
||||||
printf " ${YW}${message3}${CL}\n"
|
|
||||||
}
|
|
||||||
show_menu3
|
|
||||||
while [ "$opt" != " " ]
|
|
||||||
do
|
|
||||||
case $opt in
|
|
||||||
1) clear;
|
|
||||||
header_info;
|
|
||||||
option_picked "Using Automatic DHCP";
|
|
||||||
DHCP=" "
|
|
||||||
break;
|
|
||||||
;;
|
|
||||||
2) clear;
|
|
||||||
header_info;
|
|
||||||
option_picked "Using Manual DHCP";
|
|
||||||
DHCP="1"
|
|
||||||
break;
|
|
||||||
;;
|
|
||||||
|
|
||||||
x)exit;
|
|
||||||
;;
|
|
||||||
\n)exit;
|
|
||||||
;;
|
|
||||||
*)clear;
|
|
||||||
option_picked "Please choose a DHCP Type from the menu";
|
|
||||||
show_menu3;
|
|
||||||
;;
|
|
||||||
esac
|
|
||||||
done
|
|
||||||
|
|
||||||
set -o errexit
|
|
||||||
set -o errtrace
|
|
||||||
set -o nounset
|
|
||||||
set -o pipefail
|
|
||||||
shopt -s expand_aliases
|
|
||||||
alias die='EXIT=$? LINE=$LINENO error_exit'
|
|
||||||
trap die ERR
|
|
||||||
trap cleanup EXIT
|
|
||||||
|
|
||||||
function error_exit() {
|
|
||||||
trap - ERR
|
|
||||||
local DEFAULT='Unknown failure occured.'
|
|
||||||
local REASON="\e[97m${1:-$DEFAULT}\e[39m"
|
|
||||||
local FLAG="\e[91m[ERROR] \e[93m$EXIT@$LINE"
|
|
||||||
msg "$FLAG $REASON"
|
|
||||||
[ ! -z ${CTID-} ] && cleanup_ctid
|
|
||||||
exit $EXIT
|
|
||||||
}
|
|
||||||
function warn() {
|
|
||||||
local REASON="\e[97m$1\e[39m"
|
|
||||||
local FLAG="\e[93m[WARNING]\e[39m"
|
|
||||||
msg "$FLAG $REASON"
|
|
||||||
}
|
|
||||||
function info() {
|
|
||||||
local REASON="$1"
|
|
||||||
local FLAG="\e[36m[INFO]\e[39m"
|
|
||||||
msg "$FLAG $REASON"
|
|
||||||
}
|
|
||||||
function msg() {
|
|
||||||
local TEXT="$1"
|
|
||||||
echo -e "$TEXT"
|
|
||||||
}
|
|
||||||
function cleanup_ctid() {
|
|
||||||
if $(pct status $CTID &>/dev/null); then
|
|
||||||
if [ "$(pct status $CTID | awk '{print $2}')" == "running" ]; then
|
|
||||||
pct stop $CTID
|
|
||||||
fi
|
|
||||||
pct destroy $CTID
|
|
||||||
elif [ "$(pvesm list $STORAGE --vmid $CTID)" != "" ]; then
|
|
||||||
pvesm free $ROOTFS
|
|
||||||
fi
|
|
||||||
}
|
|
||||||
function cleanup() {
|
|
||||||
popd >/dev/null
|
|
||||||
rm -rf $TEMP_DIR
|
|
||||||
}
|
|
||||||
if [ "$IM" == "1" ]; then
|
|
||||||
FEATURES="nesting=1,keyctl=1"
|
|
||||||
else
|
|
||||||
FEATURES="nesting=1"
|
|
||||||
fi
|
|
||||||
|
|
||||||
TEMP_DIR=$(mktemp -d)
|
|
||||||
pushd $TEMP_DIR >/dev/null
|
|
||||||
|
|
||||||
export CTID=$(pvesh get /cluster/nextid)
|
|
||||||
export PCT_OSTYPE=debian
|
|
||||||
export PCT_OSVERSION=11
|
|
||||||
export PCT_DISK_SIZE=8
|
|
||||||
export PCT_OPTIONS="
|
|
||||||
-features $FEATURES
|
|
||||||
-hostname $HN
|
|
||||||
-net0 name=eth0,bridge=vmbr0,ip=dhcp
|
|
||||||
-onboot 1
|
|
||||||
-cores 2
|
|
||||||
-memory 2048
|
|
||||||
-unprivileged ${IM}
|
|
||||||
${PW}
|
|
||||||
"
|
|
||||||
bash -c "$(wget -qLO - https://raw.githubusercontent.com/tteck/Proxmox/main/ct/create_lxc.sh)" || exit
|
|
||||||
|
|
||||||
STORAGE_TYPE=$(pvesm status -storage $(pct config $CTID | grep rootfs | awk -F ":" '{print $2}') | awk 'NR>1 {print $2}')
|
|
||||||
if [ "$STORAGE_TYPE" == "zfspool" ]; then
|
|
||||||
warn "Some addons may not work due to ZFS not supporting 'fallocate'."
|
|
||||||
fi
|
|
||||||
LXC_CONFIG=/etc/pve/lxc/${CTID}.conf
|
|
||||||
cat <<EOF >> $LXC_CONFIG
|
|
||||||
lxc.cgroup2.devices.allow: a
|
|
||||||
lxc.cap.drop:
|
|
||||||
EOF
|
|
||||||
if [ "$DHCP" == "1" ]; then
|
|
||||||
MAC=$(pct config $CTID \
|
|
||||||
| grep -i hwaddr \
|
|
||||||
| awk '{print substr($2, 31, length($3) 17 ) }') \
|
|
||||||
|
|
||||||
echo -e "MAC Address ${BL}$MAC${CL}"
|
|
||||||
|
|
||||||
dhcp_reservation(){
|
|
||||||
printf "Please set DHCP reservation and press Enter."
|
|
||||||
read
|
|
||||||
}
|
|
||||||
dhcp_reservation
|
|
||||||
fi
|
|
||||||
|
|
||||||
echo -en "${GN} Starting LXC Container... "
|
|
||||||
pct start $CTID
|
|
||||||
echo -e "${CM}${CL} \r"
|
|
||||||
|
|
||||||
alias lxc-cmd="lxc-attach -n $CTID --"
|
|
||||||
|
|
||||||
lxc-cmd bash -c "$(wget -qLO - https://raw.githubusercontent.com/tteck/Proxmox/main/setup/$HN-install.sh)" || exit
|
|
||||||
|
|
||||||
IP=$(pct exec $CTID ip a s dev eth0 | sed -n '/inet / s/\// /p' | awk '{print $2}')
|
|
||||||
|
|
||||||
echo -e "${GN}Successfully created ${APP} LXC to${CL} ${BL}$CTID${CL}.
|
|
||||||
${BL}${APP}${CL} should be reachable by going to the following URL.
|
|
||||||
${BL}http://${IP}:8765${CL} \n"
|
|
|
@ -1,356 +0,0 @@
|
||||||
#!/usr/bin/env bash
|
|
||||||
echo -e "Loading..."
|
|
||||||
NEXTID=$(pvesh get /cluster/nextid)
|
|
||||||
INTEGER='^[0-9]+$'
|
|
||||||
YW=`echo "\033[33m"`
|
|
||||||
BL=`echo "\033[36m"`
|
|
||||||
RD=`echo "\033[01;31m"`
|
|
||||||
BGN=`echo "\033[4;92m"`
|
|
||||||
GN=`echo "\033[1;92m"`
|
|
||||||
DGN=`echo "\033[32m"`
|
|
||||||
CL=`echo "\033[m"`
|
|
||||||
BFR="\\r\\033[K"
|
|
||||||
HOLD="-"
|
|
||||||
CM="${GN}✓${CL}"
|
|
||||||
APP="Motioneye"
|
|
||||||
NSAPP=$(echo ${APP,,} | tr -d ' ')
|
|
||||||
set -o errexit
|
|
||||||
set -o errtrace
|
|
||||||
set -o nounset
|
|
||||||
set -o pipefail
|
|
||||||
shopt -s expand_aliases
|
|
||||||
alias die='EXIT=$? LINE=$LINENO error_exit'
|
|
||||||
trap die ERR
|
|
||||||
|
|
||||||
function error_exit() {
|
|
||||||
trap - ERR
|
|
||||||
local reason="Unknown failure occurred."
|
|
||||||
local msg="${1:-$reason}"
|
|
||||||
local flag="${RD}‼ ERROR ${CL}$EXIT@$LINE"
|
|
||||||
echo -e "$flag $msg" 1>&2
|
|
||||||
exit $EXIT
|
|
||||||
}
|
|
||||||
|
|
||||||
while true; do
|
|
||||||
clear
|
|
||||||
read -p "This will create a New ${APP} LXC. Proceed(y/n)?" yn
|
|
||||||
case $yn in
|
|
||||||
[Yy]* ) break;;
|
|
||||||
[Nn]* ) exit;;
|
|
||||||
* ) echo "Please answer yes or no.";;
|
|
||||||
esac
|
|
||||||
done
|
|
||||||
clear
|
|
||||||
function header_info {
|
|
||||||
echo -e "${BL}
|
|
||||||
__ __ ____ _______ _____ ____ _ _ ________ ________
|
|
||||||
| \/ |/ __ \__ __|_ _/ __ \| \ | | ____\ \ / / ____|
|
|
||||||
| \ / | | | | | | | || | | | \| | |__ \ \_/ /| |__
|
|
||||||
| |\/| | | | | | | | || | | | | __| \ / | __|
|
|
||||||
| | | | |__| | | | v3_| || |__| | |\ | |____ | | | |____
|
|
||||||
|_| |_|\____/ |_| |_____\____/|_| \_|______| |_| |______|
|
|
||||||
${CL}"
|
|
||||||
}
|
|
||||||
|
|
||||||
header_info
|
|
||||||
|
|
||||||
function msg_info() {
|
|
||||||
local msg="$1"
|
|
||||||
echo -ne " ${HOLD} ${YW}${msg}..."
|
|
||||||
}
|
|
||||||
|
|
||||||
function msg_ok() {
|
|
||||||
local msg="$1"
|
|
||||||
echo -e "${BFR} ${CM} ${GN}${msg}${CL}"
|
|
||||||
}
|
|
||||||
|
|
||||||
function PVE_CHECK() {
|
|
||||||
PVE=$(pveversion | grep "pve-manager/7" | wc -l)
|
|
||||||
|
|
||||||
if [[ $PVE != 1 ]]; then
|
|
||||||
echo -e "${RD}This script requires Proxmox Virtual Environment 7.0 or greater${CL}"
|
|
||||||
echo -e "Exiting..."
|
|
||||||
sleep 2
|
|
||||||
exit
|
|
||||||
fi
|
|
||||||
}
|
|
||||||
|
|
||||||
function default_settings() {
|
|
||||||
clear
|
|
||||||
header_info
|
|
||||||
echo -e "${BL}Using Default Settings${CL}"
|
|
||||||
echo -e "${DGN}Using CT Type ${BGN}Unprivileged${CL} ${RD}NO DEVICE PASSTHROUGH${CL}"
|
|
||||||
CT_TYPE="1"
|
|
||||||
echo -e "${DGN}Using CT Password ${BGN}Automatic Login${CL}"
|
|
||||||
PW=" "
|
|
||||||
echo -e "${DGN}Using CT ID ${BGN}$NEXTID${CL}"
|
|
||||||
CT_ID=$NEXTID
|
|
||||||
echo -e "${DGN}Using CT Name ${BGN}$NSAPP${CL}"
|
|
||||||
HN=$NSAPP
|
|
||||||
echo -e "${DGN}Using Disk Size ${BGN}8${CL}${DGN}GB${CL}"
|
|
||||||
DISK_SIZE="8"
|
|
||||||
echo -e "${DGN}Using ${BGN}2${CL}${DGN}vCPU${CL}"
|
|
||||||
CORE_COUNT="2"
|
|
||||||
echo -e "${DGN}Using ${BGN}2048${CL}${DGN}MiB RAM${CL}"
|
|
||||||
RAM_SIZE="2048"
|
|
||||||
echo -e "${DGN}Using Bridge ${BGN}vmbr0${CL}"
|
|
||||||
BRG="vmbr0"
|
|
||||||
echo -e "${DGN}Using Static IP Address ${BGN}DHCP${CL}"
|
|
||||||
NET=dhcp
|
|
||||||
echo -e "${DGN}Using Gateway Address ${BGN}NONE${CL}"
|
|
||||||
GATE=""
|
|
||||||
echo -e "${DGN}Using VLAN Tag ${BGN}NONE${CL}"
|
|
||||||
VLAN=""
|
|
||||||
}
|
|
||||||
|
|
||||||
function advanced_settings() {
|
|
||||||
clear
|
|
||||||
header_info
|
|
||||||
echo -e "${RD}Using Advanced Settings${CL}"
|
|
||||||
echo -e "${YW}Type Privileged, or Press [ENTER] for Default: Unprivileged (${RD}NO DEVICE PASSTHROUGH${CL}${YW})"
|
|
||||||
read CT_TYPE1
|
|
||||||
if [ -z $CT_TYPE1 ]; then CT_TYPE1="Unprivileged" CT_TYPE="1";
|
|
||||||
echo -en "${DGN}Set CT Type ${BL}$CT_TYPE1${CL}"
|
|
||||||
else
|
|
||||||
CT_TYPE1="Privileged"
|
|
||||||
CT_TYPE="0"
|
|
||||||
echo -en "${DGN}Set CT Type ${BL}Privileged${CL}"
|
|
||||||
fi;
|
|
||||||
echo -e " ${CM}${CL} \r"
|
|
||||||
sleep 1
|
|
||||||
clear
|
|
||||||
header_info
|
|
||||||
echo -e "${RD}Using Advanced Settings${CL}"
|
|
||||||
echo -e "${DGN}Using CT Type ${BGN}$CT_TYPE1${CL}"
|
|
||||||
echo -e "${YW}Set Password, or Press [ENTER] for Default: Automatic Login "
|
|
||||||
read PW1
|
|
||||||
if [ -z $PW1 ]; then PW1="Automatic Login" PW=" ";
|
|
||||||
echo -en "${DGN}Set CT ${BL}$PW1${CL}"
|
|
||||||
else
|
|
||||||
PW="-password $PW1"
|
|
||||||
echo -en "${DGN}Set CT Password ${BL}$PW1${CL}"
|
|
||||||
fi;
|
|
||||||
echo -e " ${CM}${CL} \r"
|
|
||||||
sleep 1
|
|
||||||
clear
|
|
||||||
header_info
|
|
||||||
echo -e "${RD}Using Advanced Settings${CL}"
|
|
||||||
echo -e "${DGN}Using CT Type ${BGN}$CT_TYPE1${CL}"
|
|
||||||
echo -e "${DGN}Using CT Password ${BGN}$PW1${CL}"
|
|
||||||
echo -e "${YW}Enter the CT ID, or Press [ENTER] to automatically generate (${NEXTID}) "
|
|
||||||
read CT_ID
|
|
||||||
if [ -z $CT_ID ]; then CT_ID=$NEXTID; fi;
|
|
||||||
echo -en "${DGN}Set CT ID To ${BL}$CT_ID${CL}"
|
|
||||||
echo -e " ${CM}${CL} \r"
|
|
||||||
sleep 1
|
|
||||||
clear
|
|
||||||
header_info
|
|
||||||
echo -e "${RD}Using Advanced Settings${CL}"
|
|
||||||
echo -e "${DGN}Using CT Type ${BGN}$CT_TYPE1${CL}"
|
|
||||||
echo -e "${DGN}Using CT Password ${BGN}$PW1${CL}"
|
|
||||||
echo -e "${DGN}Using CT ID ${BGN}$CT_ID${CL}"
|
|
||||||
echo -e "${YW}Enter CT Name (no-spaces), or Press [ENTER] for Default: $NSAPP "
|
|
||||||
read CT_NAME
|
|
||||||
if [ -z $CT_NAME ]; then
|
|
||||||
HN=$NSAPP
|
|
||||||
else
|
|
||||||
HN=$(echo ${CT_NAME,,} | tr -d ' ')
|
|
||||||
fi
|
|
||||||
echo -en "${DGN}Set CT Name To ${BL}$HN${CL}"
|
|
||||||
echo -e " ${CM}${CL} \r"
|
|
||||||
sleep 1
|
|
||||||
clear
|
|
||||||
header_info
|
|
||||||
echo -e "${RD}Using Advanced Settings${CL}"
|
|
||||||
echo -e "${DGN}Using CT Type ${BGN}$CT_TYPE1${CL}"
|
|
||||||
echo -e "${DGN}Using CT Password ${BGN}$PW1${CL}"
|
|
||||||
echo -e "${DGN}Using CT ID ${BGN}$CT_ID${CL}"
|
|
||||||
echo -e "${DGN}Using CT Name ${BGN}$HN${CL}"
|
|
||||||
echo -e "${YW}Enter a Disk Size, or Press [ENTER] for Default: 8 "
|
|
||||||
read DISK_SIZE
|
|
||||||
if [ -z $DISK_SIZE ]; then DISK_SIZE="8"; fi;
|
|
||||||
if ! [[ $DISK_SIZE =~ $INTEGER ]] ; then echo "ERROR! DISK SIZE MUST HAVE INTEGER NUMBER!"; exit; fi;
|
|
||||||
echo -en "${DGN}Set Disk Size To ${BL}$DISK_SIZE${CL}${DGN}GB${CL}"
|
|
||||||
echo -e " ${CM}${CL} \r"
|
|
||||||
sleep 1
|
|
||||||
clear
|
|
||||||
header_info
|
|
||||||
echo -e "${RD}Using Advanced Settings${CL}"
|
|
||||||
echo -e "${DGN}Using CT Type ${BGN}$CT_TYPE1${CL}"
|
|
||||||
echo -e "${DGN}Using CT Password ${BGN}$PW1${CL}"
|
|
||||||
echo -e "${DGN}Using CT ID ${BGN}$CT_ID${CL}"
|
|
||||||
echo -e "${DGN}Using CT Name ${BGN}$HN${CL}"
|
|
||||||
echo -e "${DGN}Using Disk Size ${BGN}$DISK_SIZE${CL}${DGN}GB${CL}"
|
|
||||||
echo -e "${YW}Allocate CPU cores, or Press [ENTER] for Default: 2 "
|
|
||||||
read CORE_COUNT
|
|
||||||
if [ -z $CORE_COUNT ]; then CORE_COUNT="2"; fi;
|
|
||||||
echo -en "${DGN}Set Cores To ${BL}$CORE_COUNT${CL}${DGN}vCPU${CL}"
|
|
||||||
echo -e " ${CM}${CL} \r"
|
|
||||||
sleep 1
|
|
||||||
clear
|
|
||||||
header_info
|
|
||||||
echo -e "${RD}Using Advanced Settings${CL}"
|
|
||||||
echo -e "${DGN}Using CT Type ${BGN}$CT_TYPE1${CL}"
|
|
||||||
echo -e "${DGN}Using CT Password ${BGN}$PW1${CL}"
|
|
||||||
echo -e "${DGN}Using CT ID ${BGN}$CT_ID${CL}"
|
|
||||||
echo -e "${DGN}Using CT Name ${BGN}$HN${CL}"
|
|
||||||
echo -e "${DGN}Using Disk Size ${BGN}$DISK_SIZE${CL}${DGN}GB${CL}"
|
|
||||||
echo -e "${DGN}Using ${BGN}${CORE_COUNT}${CL}${DGN}vCPU${CL}"
|
|
||||||
echo -e "${YW}Allocate RAM in MiB, or Press [ENTER] for Default: 2048 "
|
|
||||||
read RAM_SIZE
|
|
||||||
if [ -z $RAM_SIZE ]; then RAM_SIZE="2048"; fi;
|
|
||||||
echo -en "${DGN}Set RAM To ${BL}$RAM_SIZE${CL}${DGN}MiB RAM${CL}"
|
|
||||||
echo -e " ${CM}${CL} \n"
|
|
||||||
sleep 1
|
|
||||||
clear
|
|
||||||
header_info
|
|
||||||
echo -e "${RD}Using Advanced Settings${CL}"
|
|
||||||
echo -e "${DGN}Using CT Type ${BGN}$CT_TYPE1${CL}"
|
|
||||||
echo -e "${DGN}Using CT Password ${BGN}$PW1${CL}"
|
|
||||||
echo -e "${DGN}Using CT ID ${BGN}$CT_ID${CL}"
|
|
||||||
echo -e "${DGN}Using CT Name ${BGN}$HN${CL}"
|
|
||||||
echo -e "${DGN}Using Disk Size ${BGN}$DISK_SIZE${CL}${DGN}GB${CL}"
|
|
||||||
echo -e "${DGN}Using ${BGN}${CORE_COUNT}${CL}${DGN}vCPU${CL}"
|
|
||||||
echo -e "${DGN}Using ${BGN}${RAM_SIZE}${CL}${DGN}MiB RAM${CL}"
|
|
||||||
echo -e "${YW}Enter a Bridge, or Press [ENTER] for Default: vmbr0 "
|
|
||||||
read BRG
|
|
||||||
if [ -z $BRG ]; then BRG="vmbr0"; fi;
|
|
||||||
echo -en "${DGN}Set Bridge To ${BL}$BRG${CL}"
|
|
||||||
echo -e " ${CM}${CL} \n"
|
|
||||||
sleep 1
|
|
||||||
clear
|
|
||||||
header_info
|
|
||||||
echo -e "${RD}Using Advanced Settings${CL}"
|
|
||||||
echo -e "${DGN}Using CT Type ${BGN}$CT_TYPE1${CL}"
|
|
||||||
echo -e "${DGN}Using CT Password ${BGN}$PW1${CL}"
|
|
||||||
echo -e "${DGN}Using CT ID ${BGN}$CT_ID${CL}"
|
|
||||||
echo -e "${DGN}Using CT Name ${BGN}$HN${CL}"
|
|
||||||
echo -e "${DGN}Using Disk Size ${BGN}$DISK_SIZE${CL}${DGN}GB${CL}"
|
|
||||||
echo -e "${DGN}Using ${BGN}${CORE_COUNT}${CL}${DGN}vCPU${CL}"
|
|
||||||
echo -e "${DGN}Using ${BGN}${RAM_SIZE}${CL}${DGN}MiB RAM${CL}"
|
|
||||||
echo -e "${DGN}Using Bridge ${BGN}${BRG}${CL}"
|
|
||||||
echo -e "${YW}Enter a Static IPv4 CIDR Address, or Press [ENTER] for Default: DHCP "
|
|
||||||
read NET
|
|
||||||
if [ -z $NET ]; then NET="dhcp"; fi;
|
|
||||||
echo -en "${DGN}Set Static IP Address To ${BL}$NET${CL}"
|
|
||||||
echo -e " ${CM}${CL} \n"
|
|
||||||
sleep 1
|
|
||||||
clear
|
|
||||||
header_info
|
|
||||||
echo -e "${RD}Using Advanced Settings${CL}"
|
|
||||||
echo -e "${DGN}Using CT Type ${BGN}$CT_TYPE1${CL}"
|
|
||||||
echo -e "${DGN}Using CT Password ${BGN}$PW1${CL}"
|
|
||||||
echo -e "${DGN}Using CT ID ${BGN}$CT_ID${CL}"
|
|
||||||
echo -e "${DGN}Using CT Name ${BGN}$HN${CL}"
|
|
||||||
echo -e "${DGN}Using Disk Size ${BGN}$DISK_SIZE${CL}${DGN}GB${CL}"
|
|
||||||
echo -e "${DGN}Using ${BGN}${CORE_COUNT}${CL}${DGN}vCPU${CL}"
|
|
||||||
echo -e "${DGN}Using ${BGN}${RAM_SIZE}${CL}${DGN}MiB RAM${CL}"
|
|
||||||
echo -e "${DGN}Using Bridge ${BGN}${BRG}${CL}"
|
|
||||||
echo -e "${DGN}Using Static IP Address ${BGN}$NET${CL}"
|
|
||||||
echo -e "${YW}Enter a Gateway IP (mandatory if static IP is used), or Press [ENTER] for Default: NONE "
|
|
||||||
read GATE1
|
|
||||||
if [ -z $GATE1 ]; then GATE1="NONE" GATE="";
|
|
||||||
echo -en "${DGN}Set Gateway IP To ${BL}$GATE1${CL}"
|
|
||||||
else
|
|
||||||
GATE=",gw=$GATE1"
|
|
||||||
echo -en "${DGN}Set Gateway IP To ${BL}$GATE1${CL}"
|
|
||||||
fi;
|
|
||||||
echo -e " ${CM}${CL} \n"
|
|
||||||
sleep 1
|
|
||||||
clear
|
|
||||||
header_info
|
|
||||||
|
|
||||||
echo -e "${RD}Using Advanced Settings${CL}"
|
|
||||||
echo -e "${DGN}Using CT Type ${BGN}$CT_TYPE1${CL}"
|
|
||||||
echo -e "${DGN}Using CT Password ${BGN}$PW1${CL}"
|
|
||||||
echo -e "${DGN}Using CT ID ${BGN}$CT_ID${CL}"
|
|
||||||
echo -e "${DGN}Using CT Name ${BGN}$HN${CL}"
|
|
||||||
echo -e "${DGN}Using Disk Size ${BGN}$DISK_SIZE${CL}${DGN}GB${CL}"
|
|
||||||
echo -e "${DGN}Using ${BGN}${CORE_COUNT}${CL}${DGN}vCPU${CL}"
|
|
||||||
echo -e "${DGN}Using ${BGN}${RAM_SIZE}${CL}${DGN}MiB RAM${CL}"
|
|
||||||
echo -e "${DGN}Using Bridge ${BGN}${BRG}${CL}"
|
|
||||||
echo -e "${DGN}Using Static IP Address ${BGN}$NET${CL}"
|
|
||||||
echo -e "${DGN}Using Gateway IP Address ${BGN}$GATE1${CL}"
|
|
||||||
echo -e "${YW}Enter a VLAN Tag, or Press [ENTER] for Default: NONE "
|
|
||||||
read VLAN1
|
|
||||||
if [ -z $VLAN1 ]; then VLAN1="NONE" VLAN="";
|
|
||||||
echo -en "${DGN}Set VLAN Tag To ${BL}$VLAN1${CL}"
|
|
||||||
else
|
|
||||||
VLAN=",tag=$VLAN1"
|
|
||||||
echo -en "${DGN}Set VLAN Tag To ${BL}$VLAN1${CL}"
|
|
||||||
fi;
|
|
||||||
echo -e " ${CM}${CL} \n"
|
|
||||||
sleep 1
|
|
||||||
clear
|
|
||||||
header_info
|
|
||||||
echo -e "${RD}Using Advanced Settings${CL}"
|
|
||||||
echo -e "${DGN}Using CT Type ${BGN}$CT_TYPE1${CL}"
|
|
||||||
echo -e "${DGN}Using CT Password ${BGN}$PW1${CL}"
|
|
||||||
echo -e "${DGN}Using CT ID ${BGN}$CT_ID${CL}"
|
|
||||||
echo -e "${DGN}Using CT Name ${BGN}$HN${CL}"
|
|
||||||
echo -e "${DGN}Using Disk Size ${BGN}$DISK_SIZE${CL}${DGN}GB${CL}"
|
|
||||||
echo -e "${DGN}Using ${BGN}${CORE_COUNT}${CL}${DGN}vCPU${CL}"
|
|
||||||
echo -e "${DGN}Using ${BGN}${RAM_SIZE}${CL}${DGN}MiB RAM${CL}"
|
|
||||||
echo -e "${DGN}Using Bridge ${BGN}${BRG}${CL}"
|
|
||||||
echo -e "${DGN}Using Static IP Address ${BGN}$NET${CL}"
|
|
||||||
echo -e "${DGN}Using Gateway IP Address ${BGN}$GATE1${CL}"
|
|
||||||
echo -e "${DGN}Using VLAN Tag ${BGN}$VLAN1${CL}"
|
|
||||||
|
|
||||||
read -p "Are these settings correct(y/n)? " -n 1 -r
|
|
||||||
echo
|
|
||||||
if [[ ! $REPLY =~ ^[Yy]$ ]]
|
|
||||||
then
|
|
||||||
advanced_settings
|
|
||||||
fi
|
|
||||||
}
|
|
||||||
|
|
||||||
function start_script() {
|
|
||||||
echo -e "${YW}Type Advanced, or Press [ENTER] for Default Settings "
|
|
||||||
read SETTINGS
|
|
||||||
if [ -z $SETTINGS ]; then default_settings;
|
|
||||||
else
|
|
||||||
advanced_settings
|
|
||||||
fi;
|
|
||||||
}
|
|
||||||
|
|
||||||
start_script
|
|
||||||
|
|
||||||
if [ "$CT_TYPE" == "1" ]; then
|
|
||||||
FEATURES="nesting=1,keyctl=1"
|
|
||||||
else
|
|
||||||
FEATURES="nesting=1"
|
|
||||||
fi
|
|
||||||
|
|
||||||
TEMP_DIR=$(mktemp -d)
|
|
||||||
pushd $TEMP_DIR >/dev/null
|
|
||||||
|
|
||||||
export CTID=$CT_ID
|
|
||||||
export PCT_OSTYPE=debian
|
|
||||||
export PCT_OSVERSION=11
|
|
||||||
export PCT_DISK_SIZE=$DISK_SIZE
|
|
||||||
export PCT_OPTIONS="
|
|
||||||
-features $FEATURES
|
|
||||||
-hostname $HN
|
|
||||||
-net0 name=eth0,bridge=$BRG,ip=$NET$GATE$VLAN
|
|
||||||
-onboot 1
|
|
||||||
-cores $CORE_COUNT
|
|
||||||
-memory $RAM_SIZE
|
|
||||||
-unprivileged $CT_TYPE
|
|
||||||
$PW
|
|
||||||
"
|
|
||||||
bash -c "$(wget -qLO - https://raw.githubusercontent.com/tteck/Proxmox/main/ct/create_lxc.sh)" || exit
|
|
||||||
|
|
||||||
msg_info "Starting LXC Container"
|
|
||||||
pct start $CTID
|
|
||||||
msg_ok "Started LXC Container"
|
|
||||||
|
|
||||||
lxc-attach -n $CTID -- bash -c "$(wget -qLO - https://raw.githubusercontent.com/tteck/Proxmox/main/setup/motioneye-install.sh)" || exit
|
|
||||||
|
|
||||||
IP=$(pct exec $CTID ip a s dev eth0 | sed -n '/inet / s/\// /p' | awk '{print $2}')
|
|
||||||
|
|
||||||
pct set $CTID -description "# ${APP} LXC
|
|
||||||
### https://github.com/tteck/Proxmox"
|
|
||||||
|
|
||||||
msg_ok "Completed Successfully!\n"
|
|
||||||
echo -e "${APP} should be reachable by going to the following URL.
|
|
||||||
${BL}http://${IP}:8765${CL} \n"
|
|
|
@ -309,7 +309,7 @@ bash -c "$(wget -qLO - https://raw.githubusercontent.com/tteck/Proxmox/main/ct/c
|
||||||
msg_info "Starting LXC Container"
|
msg_info "Starting LXC Container"
|
||||||
pct start $CTID
|
pct start $CTID
|
||||||
msg_ok "Started LXC Container"
|
msg_ok "Started LXC Container"
|
||||||
lxc-attach -n $CTID -- bash -c "$(wget -qLO - https://raw.githubusercontent.com/tteck/Proxmox/main/setup/$var_install.sh)" || exit
|
lxc-attach -n $CTID -- bash -c "$(wget -qLO - https://raw.githubusercontent.com/tteck/Proxmox/main/install/$var_install.sh)" || exit
|
||||||
IP=$(pct exec $CTID ip a s dev eth0 | sed -n '/inet / s/\// /p' | awk '{print $2}')
|
IP=$(pct exec $CTID ip a s dev eth0 | sed -n '/inet / s/\// /p' | awk '{print $2}')
|
||||||
pct set $CTID -description "# ${APP} LXC
|
pct set $CTID -description "# ${APP} LXC
|
||||||
### https://tteck.github.io/Proxmox/
|
### https://tteck.github.io/Proxmox/
|
||||||
|
|
158
ct/mqtt-v1.sh
158
ct/mqtt-v1.sh
|
@ -1,158 +0,0 @@
|
||||||
#!/usr/bin/env bash
|
|
||||||
|
|
||||||
while true; do
|
|
||||||
read -p "This will create a New MQTT LXC Container. Proceed(y/n)?" yn
|
|
||||||
case $yn in
|
|
||||||
[Yy]* ) break;;
|
|
||||||
[Nn]* ) exit;;
|
|
||||||
* ) echo "Please answer yes or no.";;
|
|
||||||
esac
|
|
||||||
done
|
|
||||||
|
|
||||||
set -o errexit
|
|
||||||
set -o errtrace
|
|
||||||
set -o nounset
|
|
||||||
set -o pipefail
|
|
||||||
shopt -s expand_aliases
|
|
||||||
alias die='EXIT=$? LINE=$LINENO error_exit'
|
|
||||||
CHECKMARK='\033[0;32m\xE2\x9C\x94\033[0m'
|
|
||||||
trap die ERR
|
|
||||||
trap cleanup EXIT
|
|
||||||
|
|
||||||
function error_exit() {
|
|
||||||
trap - ERR
|
|
||||||
local DEFAULT='Unknown failure occured.'
|
|
||||||
local REASON="\e[97m${1:-$DEFAULT}\e[39m"
|
|
||||||
local FLAG="\e[91m[ERROR] \e[93m$EXIT@$LINE"
|
|
||||||
msg "$FLAG $REASON"
|
|
||||||
[ ! -z ${CTID-} ] && cleanup_ctid
|
|
||||||
exit $EXIT
|
|
||||||
}
|
|
||||||
function warn() {
|
|
||||||
local REASON="\e[97m$1\e[39m"
|
|
||||||
local FLAG="\e[93m[WARNING]\e[39m"
|
|
||||||
msg "$FLAG $REASON"
|
|
||||||
}
|
|
||||||
function info() {
|
|
||||||
local REASON="$1"
|
|
||||||
local FLAG="\e[36m[INFO]\e[39m"
|
|
||||||
msg "$FLAG $REASON"
|
|
||||||
}
|
|
||||||
function msg() {
|
|
||||||
local TEXT="$1"
|
|
||||||
echo -e "$TEXT"
|
|
||||||
}
|
|
||||||
function cleanup_ctid() {
|
|
||||||
if [ ! -z ${MOUNT+x} ]; then
|
|
||||||
pct unmount $CTID
|
|
||||||
fi
|
|
||||||
if $(pct status $CTID &>/dev/null); then
|
|
||||||
if [ "$(pct status $CTID | awk '{print $2}')" == "running" ]; then
|
|
||||||
pct stop $CTID
|
|
||||||
fi
|
|
||||||
pct destroy $CTID
|
|
||||||
elif [ "$(pvesm list $STORAGE --vmid $CTID)" != "" ]; then
|
|
||||||
pvesm free $ROOTFS
|
|
||||||
fi
|
|
||||||
}
|
|
||||||
function cleanup() {
|
|
||||||
popd >/dev/null
|
|
||||||
rm -rf $TEMP_DIR
|
|
||||||
}
|
|
||||||
function load_module() {
|
|
||||||
if ! $(lsmod | grep -Fq $1); then
|
|
||||||
modprobe $1 &>/dev/null || \
|
|
||||||
die "Failed to load '$1' module."
|
|
||||||
fi
|
|
||||||
MODULES_PATH=/etc/modules
|
|
||||||
if ! $(grep -Fxq "$1" $MODULES_PATH); then
|
|
||||||
echo "$1" >> $MODULES_PATH || \
|
|
||||||
die "Failed to add '$1' module to load at boot."
|
|
||||||
fi
|
|
||||||
}
|
|
||||||
TEMP_DIR=$(mktemp -d)
|
|
||||||
pushd $TEMP_DIR >/dev/null
|
|
||||||
|
|
||||||
wget -qL https://raw.githubusercontent.com/tteck/Proxmox/main/setup/mqtt_setup.sh
|
|
||||||
|
|
||||||
load_module overlay
|
|
||||||
|
|
||||||
while read -r line; do
|
|
||||||
TAG=$(echo $line | awk '{print $1}')
|
|
||||||
TYPE=$(echo $line | awk '{printf "%-10s", $2}')
|
|
||||||
FREE=$(echo $line | numfmt --field 4-6 --from-unit=K --to=iec --format %.2f | awk '{printf( "%9sB", $6)}')
|
|
||||||
ITEM=" Type: $TYPE Free: $FREE "
|
|
||||||
OFFSET=2
|
|
||||||
if [[ $((${#ITEM} + $OFFSET)) -gt ${MSG_MAX_LENGTH:-} ]]; then
|
|
||||||
MSG_MAX_LENGTH=$((${#ITEM} + $OFFSET))
|
|
||||||
fi
|
|
||||||
STORAGE_MENU+=( "$TAG" "$ITEM" "OFF" )
|
|
||||||
done < <(pvesm status -content rootdir | awk 'NR>1')
|
|
||||||
if [ $((${#STORAGE_MENU[@]}/3)) -eq 0 ]; then
|
|
||||||
warn "'Container' needs to be selected for at least one storage location."
|
|
||||||
die "Unable to detect valid storage location."
|
|
||||||
elif [ $((${#STORAGE_MENU[@]}/3)) -eq 1 ]; then
|
|
||||||
STORAGE=${STORAGE_MENU[0]}
|
|
||||||
else
|
|
||||||
while [ -z "${STORAGE:+x}" ]; do
|
|
||||||
STORAGE=$(whiptail --title "Storage Pools" --radiolist \
|
|
||||||
"Which storage pool you would like to use for the container?\n\n" \
|
|
||||||
16 $(($MSG_MAX_LENGTH + 23)) 6 \
|
|
||||||
"${STORAGE_MENU[@]}" 3>&1 1>&2 2>&3) || exit
|
|
||||||
done
|
|
||||||
fi
|
|
||||||
info "Using '$STORAGE' for storage location."
|
|
||||||
|
|
||||||
CTID=$(pvesh get /cluster/nextid)
|
|
||||||
info "Container ID is $CTID."
|
|
||||||
|
|
||||||
echo -e "${CHECKMARK} \e[1;92m Updating LXC Template List... \e[0m"
|
|
||||||
pveam update >/dev/null
|
|
||||||
|
|
||||||
echo -e "${CHECKMARK} \e[1;92m Downloading LXC Template... \e[0m"
|
|
||||||
OSTYPE=debian
|
|
||||||
OSVERSION=${OSTYPE}-11
|
|
||||||
mapfile -t TEMPLATES < <(pveam available -section system | sed -n "s/.*\($OSVERSION.*\)/\1/p" | sort -t - -k 2 -V)
|
|
||||||
TEMPLATE="${TEMPLATES[-1]}"
|
|
||||||
pveam download local $TEMPLATE >/dev/null ||
|
|
||||||
die "A problem occured while downloading the LXC template."
|
|
||||||
|
|
||||||
STORAGE_TYPE=$(pvesm status -storage $STORAGE | awk 'NR>1 {print $2}')
|
|
||||||
case $STORAGE_TYPE in
|
|
||||||
dir|nfs)
|
|
||||||
DISK_EXT=".raw"
|
|
||||||
DISK_REF="$CTID/"
|
|
||||||
;;
|
|
||||||
zfspool)
|
|
||||||
DISK_PREFIX="subvol"
|
|
||||||
DISK_FORMAT="subvol"
|
|
||||||
;;
|
|
||||||
esac
|
|
||||||
DISK=${DISK_PREFIX:-vm}-${CTID}-disk-0${DISK_EXT-}
|
|
||||||
ROOTFS=${STORAGE}:${DISK_REF-}${DISK}
|
|
||||||
|
|
||||||
echo -e "${CHECKMARK} \e[1;92m Creating LXC Container... \e[0m"
|
|
||||||
DISK_SIZE=2G
|
|
||||||
pvesm alloc $STORAGE $CTID $DISK $DISK_SIZE --format ${DISK_FORMAT:-raw} >/dev/null
|
|
||||||
if [ "$STORAGE_TYPE" == "zfspool" ]; then
|
|
||||||
warn "Some containers may not work properly due to ZFS not supporting 'fallocate'."
|
|
||||||
else
|
|
||||||
mkfs.ext4 $(pvesm path $ROOTFS) &>/dev/null
|
|
||||||
fi
|
|
||||||
ARCH=$(dpkg --print-architecture)
|
|
||||||
HOSTNAME=mqtt
|
|
||||||
TEMPLATE_STRING="local:vztmpl/${TEMPLATE}"
|
|
||||||
pct create $CTID $TEMPLATE_STRING -arch $ARCH -features nesting=1 \
|
|
||||||
-hostname $HOSTNAME -net0 name=eth0,bridge=vmbr0,ip=dhcp -onboot 1 -cores 1 -memory 512 \
|
|
||||||
-ostype $OSTYPE -rootfs $ROOTFS,size=$DISK_SIZE -storage $STORAGE >/dev/null
|
|
||||||
|
|
||||||
MOUNT=$(pct mount $CTID | cut -d"'" -f 2)
|
|
||||||
ln -fs $(readlink /etc/localtime) ${MOUNT}/etc/localtime
|
|
||||||
pct unmount $CTID && unset MOUNT
|
|
||||||
|
|
||||||
echo -e "${CHECKMARK} \e[1;92m Starting LXC Container... \e[0m"
|
|
||||||
pct start $CTID
|
|
||||||
pct push $CTID mqtt_setup.sh /mqtt_setup.sh -perms 755
|
|
||||||
pct exec $CTID /mqtt_setup.sh
|
|
||||||
IP=$(pct exec $CTID ip a s dev eth0 | sed -n '/inet / s/\// /p' | awk '{print $2}')
|
|
||||||
info "Successfully created a MQTT LXC Container to $CTID at IP Address ${IP}"
|
|
250
ct/mqtt-v2.sh
250
ct/mqtt-v2.sh
|
@ -1,250 +0,0 @@
|
||||||
#!/usr/bin/env bash
|
|
||||||
YW=`echo "\033[33m"`
|
|
||||||
BL=`echo "\033[36m"`
|
|
||||||
RD=`echo "\033[01;31m"`
|
|
||||||
CM='\xE2\x9C\x94\033'
|
|
||||||
GN=`echo "\033[1;92m"`
|
|
||||||
CL=`echo "\033[m"`
|
|
||||||
while true; do
|
|
||||||
read -p "This will create a New MQTT LXC. Proceed(y/n)?" yn
|
|
||||||
case $yn in
|
|
||||||
[Yy]* ) break;;
|
|
||||||
[Nn]* ) exit;;
|
|
||||||
* ) echo "Please answer yes or no.";;
|
|
||||||
esac
|
|
||||||
done
|
|
||||||
clear
|
|
||||||
function header_info {
|
|
||||||
echo -e "${BL}
|
|
||||||
__ __ ____ _______ _______
|
|
||||||
| \/ |/ __ \__ __|__ __|
|
|
||||||
| \ / | | | | | | | |
|
|
||||||
| |\/| | | | | | | | |
|
|
||||||
| | | | |__| | | | | |
|
|
||||||
|_| |_|\___\_\ |_| |_|
|
|
||||||
|
|
||||||
${CL}"
|
|
||||||
}
|
|
||||||
|
|
||||||
header_info
|
|
||||||
show_menu(){
|
|
||||||
printf " ${YW} 1)${YW} Privileged ${CL}\n"
|
|
||||||
printf " ${YW} 2)${GN} Unprivileged ${CL}\n"
|
|
||||||
|
|
||||||
printf "Please choose a Install Method and hit enter or ${RD}x${CL} to exit."
|
|
||||||
read opt
|
|
||||||
}
|
|
||||||
|
|
||||||
option_picked(){
|
|
||||||
message1=${@:-"${CL}Error: No message passed"}
|
|
||||||
printf " ${YW}${message1}${CL}\n"
|
|
||||||
}
|
|
||||||
show_menu
|
|
||||||
while [ "$opt" != " " ]
|
|
||||||
do
|
|
||||||
case $opt in
|
|
||||||
1) clear;
|
|
||||||
header_info;
|
|
||||||
option_picked "Using Privileged Install";
|
|
||||||
IM=0
|
|
||||||
break;
|
|
||||||
;;
|
|
||||||
2) clear;
|
|
||||||
header_info;
|
|
||||||
option_picked "Using Unprivileged Install";
|
|
||||||
IM=1
|
|
||||||
break;
|
|
||||||
;;
|
|
||||||
|
|
||||||
x)exit;
|
|
||||||
;;
|
|
||||||
\n)exit;
|
|
||||||
;;
|
|
||||||
*)clear;
|
|
||||||
option_picked "Please choose a Install Method from the menu";
|
|
||||||
show_menu;
|
|
||||||
;;
|
|
||||||
esac
|
|
||||||
done
|
|
||||||
show_menu2(){
|
|
||||||
printf " ${YW} 1)${GN} Use Automatic Login ${CL}\n"
|
|
||||||
printf " ${YW} 2)${GN} Use Password (changeme) ${CL}\n"
|
|
||||||
|
|
||||||
printf "Please choose a Password Type and hit enter or ${RD}x${CL} to exit."
|
|
||||||
read opt
|
|
||||||
}
|
|
||||||
|
|
||||||
option_picked(){
|
|
||||||
message2=${@:-"${CL}Error: No message passed"}
|
|
||||||
printf " ${YW}${message1}${CL}\n"
|
|
||||||
printf " ${YW}${message2}${CL}\n"
|
|
||||||
}
|
|
||||||
show_menu2
|
|
||||||
while [ "$opt" != " " ]
|
|
||||||
do
|
|
||||||
case $opt in
|
|
||||||
1) clear;
|
|
||||||
header_info;
|
|
||||||
option_picked "Using Automatic Login";
|
|
||||||
PW=" "
|
|
||||||
break;
|
|
||||||
;;
|
|
||||||
2) clear;
|
|
||||||
header_info;
|
|
||||||
option_picked "Using Password (changeme)";
|
|
||||||
PW="-password changeme"
|
|
||||||
break;
|
|
||||||
;;
|
|
||||||
|
|
||||||
x)exit;
|
|
||||||
;;
|
|
||||||
\n)exit;
|
|
||||||
;;
|
|
||||||
*)clear;
|
|
||||||
option_picked "Please choose a Password Type from the menu";
|
|
||||||
show_menu2;
|
|
||||||
;;
|
|
||||||
esac
|
|
||||||
done
|
|
||||||
show_menu3(){
|
|
||||||
printf " ${YW} 1)${GN} Automatic DHCP ${CL}\n"
|
|
||||||
printf " ${YW} 2)${GN} Manual DHCP ${CL}\n"
|
|
||||||
|
|
||||||
printf "Please choose a DHCP Type and hit enter or ${RD}x${CL} to exit."
|
|
||||||
read opt
|
|
||||||
}
|
|
||||||
|
|
||||||
option_picked(){
|
|
||||||
message3=${@:-"${CL}Error: No message passed"}
|
|
||||||
printf " ${YW}${message1}${CL}\n"
|
|
||||||
printf " ${YW}${message2}${CL}\n"
|
|
||||||
printf " ${YW}${message3}${CL}\n"
|
|
||||||
}
|
|
||||||
show_menu3
|
|
||||||
while [ "$opt" != " " ]
|
|
||||||
do
|
|
||||||
case $opt in
|
|
||||||
1) clear;
|
|
||||||
header_info;
|
|
||||||
option_picked "Using Automatic DHCP";
|
|
||||||
DHCP=" "
|
|
||||||
break;
|
|
||||||
;;
|
|
||||||
2) clear;
|
|
||||||
header_info;
|
|
||||||
option_picked "Using Manual DHCP";
|
|
||||||
DHCP="1"
|
|
||||||
break;
|
|
||||||
;;
|
|
||||||
|
|
||||||
x)exit;
|
|
||||||
;;
|
|
||||||
\n)exit;
|
|
||||||
;;
|
|
||||||
*)clear;
|
|
||||||
option_picked "Please choose a DHCP Type from the menu";
|
|
||||||
show_menu3;
|
|
||||||
;;
|
|
||||||
esac
|
|
||||||
done
|
|
||||||
|
|
||||||
set -o errexit
|
|
||||||
set -o errtrace
|
|
||||||
set -o nounset
|
|
||||||
set -o pipefail
|
|
||||||
shopt -s expand_aliases
|
|
||||||
alias die='EXIT=$? LINE=$LINENO error_exit'
|
|
||||||
trap die ERR
|
|
||||||
trap cleanup EXIT
|
|
||||||
|
|
||||||
function error_exit() {
|
|
||||||
trap - ERR
|
|
||||||
local DEFAULT='Unknown failure occured.'
|
|
||||||
local REASON="\e[97m${1:-$DEFAULT}\e[39m"
|
|
||||||
local FLAG="\e[91m[ERROR] \e[93m$EXIT@$LINE"
|
|
||||||
msg "$FLAG $REASON"
|
|
||||||
[ ! -z ${CTID-} ] && cleanup_ctid
|
|
||||||
exit $EXIT
|
|
||||||
}
|
|
||||||
function warn() {
|
|
||||||
local REASON="\e[97m$1\e[39m"
|
|
||||||
local FLAG="\e[93m[WARNING]\e[39m"
|
|
||||||
msg "$FLAG $REASON"
|
|
||||||
}
|
|
||||||
function info() {
|
|
||||||
local REASON="$1"
|
|
||||||
local FLAG="\e[36m[INFO]\e[39m"
|
|
||||||
msg "$FLAG $REASON"
|
|
||||||
}
|
|
||||||
function msg() {
|
|
||||||
local TEXT="$1"
|
|
||||||
echo -e "$TEXT"
|
|
||||||
}
|
|
||||||
function cleanup_ctid() {
|
|
||||||
if $(pct status $CTID &>/dev/null); then
|
|
||||||
if [ "$(pct status $CTID | awk '{print $2}')" == "running" ]; then
|
|
||||||
pct stop $CTID
|
|
||||||
fi
|
|
||||||
pct destroy $CTID
|
|
||||||
elif [ "$(pvesm list $STORAGE --vmid $CTID)" != "" ]; then
|
|
||||||
pvesm free $ROOTFS
|
|
||||||
fi
|
|
||||||
}
|
|
||||||
function cleanup() {
|
|
||||||
popd >/dev/null
|
|
||||||
rm -rf $TEMP_DIR
|
|
||||||
}
|
|
||||||
if [ "$IM" == "1" ]; then
|
|
||||||
FEATURES="nesting=1,keyctl=1"
|
|
||||||
else
|
|
||||||
FEATURES="nesting=1"
|
|
||||||
fi
|
|
||||||
|
|
||||||
TEMP_DIR=$(mktemp -d)
|
|
||||||
pushd $TEMP_DIR >/dev/null
|
|
||||||
|
|
||||||
export CTID=$(pvesh get /cluster/nextid)
|
|
||||||
export PCT_OSTYPE=debian
|
|
||||||
export PCT_OSVERSION=11
|
|
||||||
export PCT_DISK_SIZE=2
|
|
||||||
export PCT_OPTIONS="
|
|
||||||
-features $FEATURES
|
|
||||||
-hostname mqtt
|
|
||||||
-net0 name=eth0,bridge=vmbr0,ip=dhcp
|
|
||||||
-onboot 1
|
|
||||||
-cores 1
|
|
||||||
-memory 512
|
|
||||||
-unprivileged ${IM}
|
|
||||||
${PW}
|
|
||||||
"
|
|
||||||
bash -c "$(wget -qLO - https://raw.githubusercontent.com/tteck/Proxmox/main/ct/create_lxc.sh)" || exit
|
|
||||||
|
|
||||||
STORAGE_TYPE=$(pvesm status -storage $(pct config $CTID | grep rootfs | awk -F ":" '{print $2}') | awk 'NR>1 {print $2}')
|
|
||||||
if [ "$STORAGE_TYPE" == "zfspool" ]; then
|
|
||||||
warn "Some addons may not work due to ZFS not supporting 'fallocate'."
|
|
||||||
fi
|
|
||||||
if [ "$DHCP" == "1" ]; then
|
|
||||||
MAC=$(pct config $CTID \
|
|
||||||
| grep -i hwaddr \
|
|
||||||
| awk '{print substr($2, 31, length($3) 17 ) }') \
|
|
||||||
|
|
||||||
echo -e "MAC Address ${BL}$MAC${CL}"
|
|
||||||
|
|
||||||
dhcp_reservation(){
|
|
||||||
printf "Please set DHCP reservation and press Enter."
|
|
||||||
read
|
|
||||||
}
|
|
||||||
dhcp_reservation
|
|
||||||
fi
|
|
||||||
|
|
||||||
echo -en "${GN} Starting LXC Container... "
|
|
||||||
pct start $CTID
|
|
||||||
echo -e "${CM}${CL} \r"
|
|
||||||
|
|
||||||
alias lxc-cmd="lxc-attach -n $CTID --"
|
|
||||||
|
|
||||||
lxc-cmd bash -c "$(wget -qLO - https://raw.githubusercontent.com/tteck/Proxmox/main/setup/mqtt-install.sh)" || exit
|
|
||||||
|
|
||||||
IP=$(pct exec $CTID ip a s dev eth0 | sed -n '/inet / s/\// /p' | awk '{print $2}')
|
|
||||||
|
|
||||||
echo -e "${GN}Successfully created MQTT LXC to${CL} ${BL}$CTID${CL}. \n"
|
|
354
ct/mqtt-v3.sh
354
ct/mqtt-v3.sh
|
@ -1,354 +0,0 @@
|
||||||
#!/usr/bin/env bash
|
|
||||||
echo -e "Loading..."
|
|
||||||
NEXTID=$(pvesh get /cluster/nextid)
|
|
||||||
INTEGER='^[0-9]+$'
|
|
||||||
YW=`echo "\033[33m"`
|
|
||||||
BL=`echo "\033[36m"`
|
|
||||||
RD=`echo "\033[01;31m"`
|
|
||||||
BGN=`echo "\033[4;92m"`
|
|
||||||
GN=`echo "\033[1;92m"`
|
|
||||||
DGN=`echo "\033[32m"`
|
|
||||||
CL=`echo "\033[m"`
|
|
||||||
BFR="\\r\\033[K"
|
|
||||||
HOLD="-"
|
|
||||||
CM="${GN}✓${CL}"
|
|
||||||
APP="MQTT"
|
|
||||||
NSAPP=$(echo ${APP,,} | tr -d ' ')
|
|
||||||
set -o errexit
|
|
||||||
set -o errtrace
|
|
||||||
set -o nounset
|
|
||||||
set -o pipefail
|
|
||||||
shopt -s expand_aliases
|
|
||||||
alias die='EXIT=$? LINE=$LINENO error_exit'
|
|
||||||
trap die ERR
|
|
||||||
|
|
||||||
function error_exit() {
|
|
||||||
trap - ERR
|
|
||||||
local reason="Unknown failure occurred."
|
|
||||||
local msg="${1:-$reason}"
|
|
||||||
local flag="${RD}‼ ERROR ${CL}$EXIT@$LINE"
|
|
||||||
echo -e "$flag $msg" 1>&2
|
|
||||||
exit $EXIT
|
|
||||||
}
|
|
||||||
|
|
||||||
while true; do
|
|
||||||
clear
|
|
||||||
read -p "This will create a New ${APP} LXC. Proceed(y/n)?" yn
|
|
||||||
case $yn in
|
|
||||||
[Yy]* ) break;;
|
|
||||||
[Nn]* ) exit;;
|
|
||||||
* ) echo "Please answer yes or no.";;
|
|
||||||
esac
|
|
||||||
done
|
|
||||||
clear
|
|
||||||
function header_info {
|
|
||||||
echo -e "${BL}
|
|
||||||
__ __ ____ _______ _______
|
|
||||||
| \/ |/ __ \__ __|__ __|
|
|
||||||
| \ / | | | | | | | |
|
|
||||||
| |\/| | | | | | | | |
|
|
||||||
| | | | |__| | | | | |
|
|
||||||
|_| |_|\___\_\ |_| v3 |_|
|
|
||||||
${CL}"
|
|
||||||
}
|
|
||||||
|
|
||||||
header_info
|
|
||||||
|
|
||||||
function msg_info() {
|
|
||||||
local msg="$1"
|
|
||||||
echo -ne " ${HOLD} ${YW}${msg}..."
|
|
||||||
}
|
|
||||||
|
|
||||||
function msg_ok() {
|
|
||||||
local msg="$1"
|
|
||||||
echo -e "${BFR} ${CM} ${GN}${msg}${CL}"
|
|
||||||
}
|
|
||||||
|
|
||||||
function PVE_CHECK() {
|
|
||||||
PVE=$(pveversion | grep "pve-manager/7" | wc -l)
|
|
||||||
|
|
||||||
if [[ $PVE != 1 ]]; then
|
|
||||||
echo -e "${RD}This script requires Proxmox Virtual Environment 7.0 or greater${CL}"
|
|
||||||
echo -e "Exiting..."
|
|
||||||
sleep 2
|
|
||||||
exit
|
|
||||||
fi
|
|
||||||
}
|
|
||||||
|
|
||||||
function default_settings() {
|
|
||||||
clear
|
|
||||||
header_info
|
|
||||||
echo -e "${BL}Using Default Settings${CL}"
|
|
||||||
echo -e "${DGN}Using CT Type ${BGN}Unprivileged${CL} ${RD}NO DEVICE PASSTHROUGH${CL}"
|
|
||||||
CT_TYPE="1"
|
|
||||||
echo -e "${DGN}Using CT Password ${BGN}Automatic Login${CL}"
|
|
||||||
PW=" "
|
|
||||||
echo -e "${DGN}Using CT ID ${BGN}$NEXTID${CL}"
|
|
||||||
CT_ID=$NEXTID
|
|
||||||
echo -e "${DGN}Using CT Name ${BGN}$NSAPP${CL}"
|
|
||||||
HN=$NSAPP
|
|
||||||
echo -e "${DGN}Using Disk Size ${BGN}2${CL}${DGN}GB${CL}"
|
|
||||||
DISK_SIZE="2"
|
|
||||||
echo -e "${DGN}Using ${BGN}1${CL}${DGN}vCPU${CL}"
|
|
||||||
CORE_COUNT="1"
|
|
||||||
echo -e "${DGN}Using ${BGN}512${CL}${DGN}MiB RAM${CL}"
|
|
||||||
RAM_SIZE="512"
|
|
||||||
echo -e "${DGN}Using Bridge ${BGN}vmbr0${CL}"
|
|
||||||
BRG="vmbr0"
|
|
||||||
echo -e "${DGN}Using Static IP Address ${BGN}DHCP${CL}"
|
|
||||||
NET=dhcp
|
|
||||||
echo -e "${DGN}Using Gateway Address ${BGN}NONE${CL}"
|
|
||||||
GATE=""
|
|
||||||
echo -e "${DGN}Using VLAN Tag ${BGN}NONE${CL}"
|
|
||||||
VLAN=""
|
|
||||||
}
|
|
||||||
|
|
||||||
function advanced_settings() {
|
|
||||||
clear
|
|
||||||
header_info
|
|
||||||
echo -e "${RD}Using Advanced Settings${CL}"
|
|
||||||
echo -e "${YW}Type Privileged, or Press [ENTER] for Default: Unprivileged (${RD}NO DEVICE PASSTHROUGH${CL}${YW})"
|
|
||||||
read CT_TYPE1
|
|
||||||
if [ -z $CT_TYPE1 ]; then CT_TYPE1="Unprivileged" CT_TYPE="1";
|
|
||||||
echo -en "${DGN}Set CT Type ${BL}$CT_TYPE1${CL}"
|
|
||||||
else
|
|
||||||
CT_TYPE1="Privileged"
|
|
||||||
CT_TYPE="0"
|
|
||||||
echo -en "${DGN}Set CT Type ${BL}Privileged${CL}"
|
|
||||||
fi;
|
|
||||||
echo -e " ${CM}${CL} \r"
|
|
||||||
sleep 1
|
|
||||||
clear
|
|
||||||
header_info
|
|
||||||
echo -e "${RD}Using Advanced Settings${CL}"
|
|
||||||
echo -e "${DGN}Using CT Type ${BGN}$CT_TYPE1${CL}"
|
|
||||||
echo -e "${YW}Set Password, or Press [ENTER] for Default: Automatic Login "
|
|
||||||
read PW1
|
|
||||||
if [ -z $PW1 ]; then PW1="Automatic Login" PW=" ";
|
|
||||||
echo -en "${DGN}Set CT ${BL}$PW1${CL}"
|
|
||||||
else
|
|
||||||
PW="-password $PW1"
|
|
||||||
echo -en "${DGN}Set CT Password ${BL}$PW1${CL}"
|
|
||||||
fi;
|
|
||||||
echo -e " ${CM}${CL} \r"
|
|
||||||
sleep 1
|
|
||||||
clear
|
|
||||||
header_info
|
|
||||||
echo -e "${RD}Using Advanced Settings${CL}"
|
|
||||||
echo -e "${DGN}Using CT Type ${BGN}$CT_TYPE1${CL}"
|
|
||||||
echo -e "${DGN}Using CT Password ${BGN}$PW1${CL}"
|
|
||||||
echo -e "${YW}Enter the CT ID, or Press [ENTER] to automatically generate (${NEXTID}) "
|
|
||||||
read CT_ID
|
|
||||||
if [ -z $CT_ID ]; then CT_ID=$NEXTID; fi;
|
|
||||||
echo -en "${DGN}Set CT ID To ${BL}$CT_ID${CL}"
|
|
||||||
echo -e " ${CM}${CL} \r"
|
|
||||||
sleep 1
|
|
||||||
clear
|
|
||||||
header_info
|
|
||||||
echo -e "${RD}Using Advanced Settings${CL}"
|
|
||||||
echo -e "${DGN}Using CT Type ${BGN}$CT_TYPE1${CL}"
|
|
||||||
echo -e "${DGN}Using CT Password ${BGN}$PW1${CL}"
|
|
||||||
echo -e "${DGN}Using CT ID ${BGN}$CT_ID${CL}"
|
|
||||||
echo -e "${YW}Enter CT Name (no-spaces), or Press [ENTER] for Default: $NSAPP "
|
|
||||||
read CT_NAME
|
|
||||||
if [ -z $CT_NAME ]; then
|
|
||||||
HN=$NSAPP
|
|
||||||
else
|
|
||||||
HN=$(echo ${CT_NAME,,} | tr -d ' ')
|
|
||||||
fi
|
|
||||||
echo -en "${DGN}Set CT Name To ${BL}$HN${CL}"
|
|
||||||
echo -e " ${CM}${CL} \r"
|
|
||||||
sleep 1
|
|
||||||
clear
|
|
||||||
header_info
|
|
||||||
echo -e "${RD}Using Advanced Settings${CL}"
|
|
||||||
echo -e "${DGN}Using CT Type ${BGN}$CT_TYPE1${CL}"
|
|
||||||
echo -e "${DGN}Using CT Password ${BGN}$PW1${CL}"
|
|
||||||
echo -e "${DGN}Using CT ID ${BGN}$CT_ID${CL}"
|
|
||||||
echo -e "${DGN}Using CT Name ${BGN}$HN${CL}"
|
|
||||||
echo -e "${YW}Enter a Disk Size, or Press [ENTER] for Default: 2 "
|
|
||||||
read DISK_SIZE
|
|
||||||
if [ -z $DISK_SIZE ]; then DISK_SIZE="2"; fi;
|
|
||||||
if ! [[ $DISK_SIZE =~ $INTEGER ]] ; then echo "ERROR! DISK SIZE MUST HAVE INTEGER NUMBER!"; exit; fi;
|
|
||||||
echo -en "${DGN}Set Disk Size To ${BL}$DISK_SIZE${CL}${DGN}GB${CL}"
|
|
||||||
echo -e " ${CM}${CL} \r"
|
|
||||||
sleep 1
|
|
||||||
clear
|
|
||||||
header_info
|
|
||||||
echo -e "${RD}Using Advanced Settings${CL}"
|
|
||||||
echo -e "${DGN}Using CT Type ${BGN}$CT_TYPE1${CL}"
|
|
||||||
echo -e "${DGN}Using CT Password ${BGN}$PW1${CL}"
|
|
||||||
echo -e "${DGN}Using CT ID ${BGN}$CT_ID${CL}"
|
|
||||||
echo -e "${DGN}Using CT Name ${BGN}$HN${CL}"
|
|
||||||
echo -e "${DGN}Using Disk Size ${BGN}$DISK_SIZE${CL}${DGN}GB${CL}"
|
|
||||||
echo -e "${YW}Allocate CPU cores, or Press [ENTER] for Default: 1 "
|
|
||||||
read CORE_COUNT
|
|
||||||
if [ -z $CORE_COUNT ]; then CORE_COUNT="1"; fi;
|
|
||||||
echo -en "${DGN}Set Cores To ${BL}$CORE_COUNT${CL}${DGN}vCPU${CL}"
|
|
||||||
echo -e " ${CM}${CL} \r"
|
|
||||||
sleep 1
|
|
||||||
clear
|
|
||||||
header_info
|
|
||||||
echo -e "${RD}Using Advanced Settings${CL}"
|
|
||||||
echo -e "${DGN}Using CT Type ${BGN}$CT_TYPE1${CL}"
|
|
||||||
echo -e "${DGN}Using CT Password ${BGN}$PW1${CL}"
|
|
||||||
echo -e "${DGN}Using CT ID ${BGN}$CT_ID${CL}"
|
|
||||||
echo -e "${DGN}Using CT Name ${BGN}$HN${CL}"
|
|
||||||
echo -e "${DGN}Using Disk Size ${BGN}$DISK_SIZE${CL}${DGN}GB${CL}"
|
|
||||||
echo -e "${DGN}Using ${BGN}${CORE_COUNT}${CL}${DGN}vCPU${CL}"
|
|
||||||
echo -e "${YW}Allocate RAM in MiB, or Press [ENTER] for Default: 512 "
|
|
||||||
read RAM_SIZE
|
|
||||||
if [ -z $RAM_SIZE ]; then RAM_SIZE="512"; fi;
|
|
||||||
echo -en "${DGN}Set RAM To ${BL}$RAM_SIZE${CL}${DGN}MiB RAM${CL}"
|
|
||||||
echo -e " ${CM}${CL} \n"
|
|
||||||
sleep 1
|
|
||||||
clear
|
|
||||||
header_info
|
|
||||||
echo -e "${RD}Using Advanced Settings${CL}"
|
|
||||||
echo -e "${DGN}Using CT Type ${BGN}$CT_TYPE1${CL}"
|
|
||||||
echo -e "${DGN}Using CT Password ${BGN}$PW1${CL}"
|
|
||||||
echo -e "${DGN}Using CT ID ${BGN}$CT_ID${CL}"
|
|
||||||
echo -e "${DGN}Using CT Name ${BGN}$HN${CL}"
|
|
||||||
echo -e "${DGN}Using Disk Size ${BGN}$DISK_SIZE${CL}${DGN}GB${CL}"
|
|
||||||
echo -e "${DGN}Using ${BGN}${CORE_COUNT}${CL}${DGN}vCPU${CL}"
|
|
||||||
echo -e "${DGN}Using ${BGN}${RAM_SIZE}${CL}${DGN}MiB RAM${CL}"
|
|
||||||
echo -e "${YW}Enter a Bridge, or Press [ENTER] for Default: vmbr0 "
|
|
||||||
read BRG
|
|
||||||
if [ -z $BRG ]; then BRG="vmbr0"; fi;
|
|
||||||
echo -en "${DGN}Set Bridge To ${BL}$BRG${CL}"
|
|
||||||
echo -e " ${CM}${CL} \n"
|
|
||||||
sleep 1
|
|
||||||
clear
|
|
||||||
header_info
|
|
||||||
echo -e "${RD}Using Advanced Settings${CL}"
|
|
||||||
echo -e "${DGN}Using CT Type ${BGN}$CT_TYPE1${CL}"
|
|
||||||
echo -e "${DGN}Using CT Password ${BGN}$PW1${CL}"
|
|
||||||
echo -e "${DGN}Using CT ID ${BGN}$CT_ID${CL}"
|
|
||||||
echo -e "${DGN}Using CT Name ${BGN}$HN${CL}"
|
|
||||||
echo -e "${DGN}Using Disk Size ${BGN}$DISK_SIZE${CL}${DGN}GB${CL}"
|
|
||||||
echo -e "${DGN}Using ${BGN}${CORE_COUNT}${CL}${DGN}vCPU${CL}"
|
|
||||||
echo -e "${DGN}Using ${BGN}${RAM_SIZE}${CL}${DGN}MiB RAM${CL}"
|
|
||||||
echo -e "${DGN}Using Bridge ${BGN}${BRG}${CL}"
|
|
||||||
echo -e "${YW}Enter a Static IPv4 CIDR Address, or Press [ENTER] for Default: DHCP "
|
|
||||||
read NET
|
|
||||||
if [ -z $NET ]; then NET="dhcp"; fi;
|
|
||||||
echo -en "${DGN}Set Static IP Address To ${BL}$NET${CL}"
|
|
||||||
echo -e " ${CM}${CL} \n"
|
|
||||||
sleep 1
|
|
||||||
clear
|
|
||||||
header_info
|
|
||||||
echo -e "${RD}Using Advanced Settings${CL}"
|
|
||||||
echo -e "${DGN}Using CT Type ${BGN}$CT_TYPE1${CL}"
|
|
||||||
echo -e "${DGN}Using CT Password ${BGN}$PW1${CL}"
|
|
||||||
echo -e "${DGN}Using CT ID ${BGN}$CT_ID${CL}"
|
|
||||||
echo -e "${DGN}Using CT Name ${BGN}$HN${CL}"
|
|
||||||
echo -e "${DGN}Using Disk Size ${BGN}$DISK_SIZE${CL}${DGN}GB${CL}"
|
|
||||||
echo -e "${DGN}Using ${BGN}${CORE_COUNT}${CL}${DGN}vCPU${CL}"
|
|
||||||
echo -e "${DGN}Using ${BGN}${RAM_SIZE}${CL}${DGN}MiB RAM${CL}"
|
|
||||||
echo -e "${DGN}Using Bridge ${BGN}${BRG}${CL}"
|
|
||||||
echo -e "${DGN}Using Static IP Address ${BGN}$NET${CL}"
|
|
||||||
echo -e "${YW}Enter a Gateway IP (mandatory if static IP is used), or Press [ENTER] for Default: NONE "
|
|
||||||
read GATE1
|
|
||||||
if [ -z $GATE1 ]; then GATE1="NONE" GATE="";
|
|
||||||
echo -en "${DGN}Set Gateway IP To ${BL}$GATE1${CL}"
|
|
||||||
else
|
|
||||||
GATE=",gw=$GATE1"
|
|
||||||
echo -en "${DGN}Set Gateway IP To ${BL}$GATE1${CL}"
|
|
||||||
fi;
|
|
||||||
echo -e " ${CM}${CL} \n"
|
|
||||||
sleep 1
|
|
||||||
clear
|
|
||||||
header_info
|
|
||||||
|
|
||||||
echo -e "${RD}Using Advanced Settings${CL}"
|
|
||||||
echo -e "${DGN}Using CT Type ${BGN}$CT_TYPE1${CL}"
|
|
||||||
echo -e "${DGN}Using CT Password ${BGN}$PW1${CL}"
|
|
||||||
echo -e "${DGN}Using CT ID ${BGN}$CT_ID${CL}"
|
|
||||||
echo -e "${DGN}Using CT Name ${BGN}$HN${CL}"
|
|
||||||
echo -e "${DGN}Using Disk Size ${BGN}$DISK_SIZE${CL}${DGN}GB${CL}"
|
|
||||||
echo -e "${DGN}Using ${BGN}${CORE_COUNT}${CL}${DGN}vCPU${CL}"
|
|
||||||
echo -e "${DGN}Using ${BGN}${RAM_SIZE}${CL}${DGN}MiB RAM${CL}"
|
|
||||||
echo -e "${DGN}Using Bridge ${BGN}${BRG}${CL}"
|
|
||||||
echo -e "${DGN}Using Static IP Address ${BGN}$NET${CL}"
|
|
||||||
echo -e "${DGN}Using Gateway IP Address ${BGN}$GATE1${CL}"
|
|
||||||
echo -e "${YW}Enter a VLAN Tag, or Press [ENTER] for Default: NONE "
|
|
||||||
read VLAN1
|
|
||||||
if [ -z $VLAN1 ]; then VLAN1="NONE" VLAN="";
|
|
||||||
echo -en "${DGN}Set VLAN Tag To ${BL}$VLAN1${CL}"
|
|
||||||
else
|
|
||||||
VLAN=",tag=$VLAN1"
|
|
||||||
echo -en "${DGN}Set VLAN Tag To ${BL}$VLAN1${CL}"
|
|
||||||
fi;
|
|
||||||
echo -e " ${CM}${CL} \n"
|
|
||||||
sleep 1
|
|
||||||
clear
|
|
||||||
header_info
|
|
||||||
echo -e "${RD}Using Advanced Settings${CL}"
|
|
||||||
echo -e "${DGN}Using CT Type ${BGN}$CT_TYPE1${CL}"
|
|
||||||
echo -e "${DGN}Using CT Password ${BGN}$PW1${CL}"
|
|
||||||
echo -e "${DGN}Using CT ID ${BGN}$CT_ID${CL}"
|
|
||||||
echo -e "${DGN}Using CT Name ${BGN}$HN${CL}"
|
|
||||||
echo -e "${DGN}Using Disk Size ${BGN}$DISK_SIZE${CL}${DGN}GB${CL}"
|
|
||||||
echo -e "${DGN}Using ${BGN}${CORE_COUNT}${CL}${DGN}vCPU${CL}"
|
|
||||||
echo -e "${DGN}Using ${BGN}${RAM_SIZE}${CL}${DGN}MiB RAM${CL}"
|
|
||||||
echo -e "${DGN}Using Bridge ${BGN}${BRG}${CL}"
|
|
||||||
echo -e "${DGN}Using Static IP Address ${BGN}$NET${CL}"
|
|
||||||
echo -e "${DGN}Using Gateway IP Address ${BGN}$GATE1${CL}"
|
|
||||||
echo -e "${DGN}Using VLAN Tag ${BGN}$VLAN1${CL}"
|
|
||||||
|
|
||||||
read -p "Are these settings correct(y/n)? " -n 1 -r
|
|
||||||
echo
|
|
||||||
if [[ ! $REPLY =~ ^[Yy]$ ]]
|
|
||||||
then
|
|
||||||
advanced_settings
|
|
||||||
fi
|
|
||||||
}
|
|
||||||
|
|
||||||
function start_script() {
|
|
||||||
echo -e "${YW}Type Advanced, or Press [ENTER] for Default Settings "
|
|
||||||
read SETTINGS
|
|
||||||
if [ -z $SETTINGS ]; then default_settings;
|
|
||||||
else
|
|
||||||
advanced_settings
|
|
||||||
fi;
|
|
||||||
}
|
|
||||||
|
|
||||||
start_script
|
|
||||||
|
|
||||||
if [ "$CT_TYPE" == "1" ]; then
|
|
||||||
FEATURES="nesting=1,keyctl=1"
|
|
||||||
else
|
|
||||||
FEATURES="nesting=1"
|
|
||||||
fi
|
|
||||||
|
|
||||||
TEMP_DIR=$(mktemp -d)
|
|
||||||
pushd $TEMP_DIR >/dev/null
|
|
||||||
|
|
||||||
export CTID=$CT_ID
|
|
||||||
export PCT_OSTYPE=debian
|
|
||||||
export PCT_OSVERSION=11
|
|
||||||
export PCT_DISK_SIZE=$DISK_SIZE
|
|
||||||
export PCT_OPTIONS="
|
|
||||||
-features $FEATURES
|
|
||||||
-hostname $HN
|
|
||||||
-net0 name=eth0,bridge=$BRG,ip=$NET$GATE$VLAN
|
|
||||||
-onboot 1
|
|
||||||
-cores $CORE_COUNT
|
|
||||||
-memory $RAM_SIZE
|
|
||||||
-unprivileged $CT_TYPE
|
|
||||||
$PW
|
|
||||||
"
|
|
||||||
bash -c "$(wget -qLO - https://raw.githubusercontent.com/tteck/Proxmox/main/ct/create_lxc.sh)" || exit
|
|
||||||
|
|
||||||
msg_info "Starting LXC Container"
|
|
||||||
pct start $CTID
|
|
||||||
msg_ok "Started LXC Container"
|
|
||||||
|
|
||||||
lxc-attach -n $CTID -- bash -c "$(wget -qLO - https://raw.githubusercontent.com/tteck/Proxmox/main/setup/mqtt-install.sh)" || exit
|
|
||||||
|
|
||||||
IP=$(pct exec $CTID ip a s dev eth0 | sed -n '/inet / s/\// /p' | awk '{print $2}')
|
|
||||||
|
|
||||||
pct set $CTID -description "# ${APP} LXC
|
|
||||||
### https://github.com/tteck/Proxmox"
|
|
||||||
|
|
||||||
msg_ok "Completed Successfully!\n"
|
|
|
@ -285,7 +285,7 @@ bash -c "$(wget -qLO - https://raw.githubusercontent.com/tteck/Proxmox/main/ct/c
|
||||||
msg_info "Starting LXC Container"
|
msg_info "Starting LXC Container"
|
||||||
pct start $CTID
|
pct start $CTID
|
||||||
msg_ok "Started LXC Container"
|
msg_ok "Started LXC Container"
|
||||||
lxc-attach -n $CTID -- bash -c "$(wget -qLO - https://raw.githubusercontent.com/tteck/Proxmox/main/setup/$var_install.sh)" || exit
|
lxc-attach -n $CTID -- bash -c "$(wget -qLO - https://raw.githubusercontent.com/tteck/Proxmox/main/install/$var_install.sh)" || exit
|
||||||
IP=$(pct exec $CTID ip a s dev eth0 | sed -n '/inet / s/\// /p' | awk '{print $2}')
|
IP=$(pct exec $CTID ip a s dev eth0 | sed -n '/inet / s/\// /p' | awk '{print $2}')
|
||||||
pct set $CTID -description "# ${APP} LXC
|
pct set $CTID -description "# ${APP} LXC
|
||||||
### https://tteck.github.io/Proxmox/
|
### https://tteck.github.io/Proxmox/
|
||||||
|
|
356
ct/n8n-v3.sh
356
ct/n8n-v3.sh
|
@ -1,356 +0,0 @@
|
||||||
#!/usr/bin/env bash
|
|
||||||
echo -e "Loading..."
|
|
||||||
NEXTID=$(pvesh get /cluster/nextid)
|
|
||||||
INTEGER='^[0-9]+$'
|
|
||||||
YW=`echo "\033[33m"`
|
|
||||||
BL=`echo "\033[36m"`
|
|
||||||
RD=`echo "\033[01;31m"`
|
|
||||||
BGN=`echo "\033[4;92m"`
|
|
||||||
GN=`echo "\033[1;92m"`
|
|
||||||
DGN=`echo "\033[32m"`
|
|
||||||
CL=`echo "\033[m"`
|
|
||||||
BFR="\\r\\033[K"
|
|
||||||
HOLD="-"
|
|
||||||
CM="${GN}✓${CL}"
|
|
||||||
APP="n8n"
|
|
||||||
NSAPP=$(echo ${APP,,} | tr -d ' ')
|
|
||||||
set -o errexit
|
|
||||||
set -o errtrace
|
|
||||||
set -o nounset
|
|
||||||
set -o pipefail
|
|
||||||
shopt -s expand_aliases
|
|
||||||
alias die='EXIT=$? LINE=$LINENO error_exit'
|
|
||||||
trap die ERR
|
|
||||||
|
|
||||||
function error_exit() {
|
|
||||||
trap - ERR
|
|
||||||
local reason="Unknown failure occurred."
|
|
||||||
local msg="${1:-$reason}"
|
|
||||||
local flag="${RD}‼ ERROR ${CL}$EXIT@$LINE"
|
|
||||||
echo -e "$flag $msg" 1>&2
|
|
||||||
exit $EXIT
|
|
||||||
}
|
|
||||||
|
|
||||||
while true; do
|
|
||||||
clear
|
|
||||||
read -p "This will create a New ${APP} LXC. Proceed(y/n)?" yn
|
|
||||||
case $yn in
|
|
||||||
[Yy]* ) break;;
|
|
||||||
[Nn]* ) exit;;
|
|
||||||
* ) echo "Please answer yes or no.";;
|
|
||||||
esac
|
|
||||||
done
|
|
||||||
clear
|
|
||||||
function header_info {
|
|
||||||
echo -e "${RD}
|
|
||||||
___
|
|
||||||
/ _ \
|
|
||||||
_ __ | (_) |_v3_
|
|
||||||
| _ \ > _ <| _ \
|
|
||||||
| | | | (_) | | | |
|
|
||||||
|_| |_|\___/|_| |_|
|
|
||||||
${CL}"
|
|
||||||
}
|
|
||||||
|
|
||||||
header_info
|
|
||||||
|
|
||||||
function msg_info() {
|
|
||||||
local msg="$1"
|
|
||||||
echo -ne " ${HOLD} ${YW}${msg}..."
|
|
||||||
}
|
|
||||||
|
|
||||||
function msg_ok() {
|
|
||||||
local msg="$1"
|
|
||||||
echo -e "${BFR} ${CM} ${GN}${msg}${CL}"
|
|
||||||
}
|
|
||||||
|
|
||||||
function PVE_CHECK() {
|
|
||||||
PVE=$(pveversion | grep "pve-manager/7" | wc -l)
|
|
||||||
|
|
||||||
if [[ $PVE != 1 ]]; then
|
|
||||||
echo -e "${RD}This script requires Proxmox Virtual Environment 7.0 or greater${CL}"
|
|
||||||
echo -e "Exiting..."
|
|
||||||
sleep 2
|
|
||||||
exit
|
|
||||||
fi
|
|
||||||
}
|
|
||||||
|
|
||||||
function default_settings() {
|
|
||||||
clear
|
|
||||||
header_info
|
|
||||||
echo -e "${BL}Using Default Settings${CL}"
|
|
||||||
echo -e "${DGN}Using CT Type ${BGN}Unprivileged${CL} ${RD}NO DEVICE PASSTHROUGH${CL}"
|
|
||||||
CT_TYPE="1"
|
|
||||||
echo -e "${DGN}Using CT Password ${BGN}Automatic Login${CL}"
|
|
||||||
PW=" "
|
|
||||||
echo -e "${DGN}Using CT ID ${BGN}$NEXTID${CL}"
|
|
||||||
CT_ID=$NEXTID
|
|
||||||
echo -e "${DGN}Using CT Name ${BGN}$NSAPP${CL}"
|
|
||||||
HN=$NSAPP
|
|
||||||
echo -e "${DGN}Using Disk Size ${BGN}3${CL}${DGN}GB${CL}"
|
|
||||||
DISK_SIZE="3"
|
|
||||||
echo -e "${DGN}Using ${BGN}2${CL}${DGN}vCPU${CL}"
|
|
||||||
CORE_COUNT="2"
|
|
||||||
echo -e "${DGN}Using ${BGN}2048${CL}${DGN}MiB RAM${CL}"
|
|
||||||
RAM_SIZE="2048"
|
|
||||||
echo -e "${DGN}Using Bridge ${BGN}vmbr0${CL}"
|
|
||||||
BRG="vmbr0"
|
|
||||||
echo -e "${DGN}Using Static IP Address ${BGN}DHCP${CL}"
|
|
||||||
NET=dhcp
|
|
||||||
echo -e "${DGN}Using Gateway Address ${BGN}NONE${CL}"
|
|
||||||
GATE=""
|
|
||||||
echo -e "${DGN}Using VLAN Tag ${BGN}NONE${CL}"
|
|
||||||
VLAN=""
|
|
||||||
}
|
|
||||||
|
|
||||||
function advanced_settings() {
|
|
||||||
clear
|
|
||||||
header_info
|
|
||||||
echo -e "${RD}Using Advanced Settings${CL}"
|
|
||||||
echo -e "${YW}Type Privileged, or Press [ENTER] for Default: Unprivileged (${RD}NO DEVICE PASSTHROUGH${CL}${YW})"
|
|
||||||
read CT_TYPE1
|
|
||||||
if [ -z $CT_TYPE1 ]; then CT_TYPE1="Unprivileged" CT_TYPE="1";
|
|
||||||
echo -en "${DGN}Set CT Type ${BL}$CT_TYPE1${CL}"
|
|
||||||
else
|
|
||||||
CT_TYPE1="Privileged"
|
|
||||||
CT_TYPE="0"
|
|
||||||
echo -en "${DGN}Set CT Type ${BL}Privileged${CL}"
|
|
||||||
fi;
|
|
||||||
echo -e " ${CM}${CL} \r"
|
|
||||||
sleep 1
|
|
||||||
clear
|
|
||||||
header_info
|
|
||||||
echo -e "${RD}Using Advanced Settings${CL}"
|
|
||||||
echo -e "${DGN}Using CT Type ${BGN}$CT_TYPE1${CL}"
|
|
||||||
echo -e "${YW}Set Password, or Press [ENTER] for Default: Automatic Login "
|
|
||||||
read PW1
|
|
||||||
if [ -z $PW1 ]; then PW1="Automatic Login" PW=" ";
|
|
||||||
echo -en "${DGN}Set CT ${BL}$PW1${CL}"
|
|
||||||
else
|
|
||||||
PW="-password $PW1"
|
|
||||||
echo -en "${DGN}Set CT Password ${BL}$PW1${CL}"
|
|
||||||
fi;
|
|
||||||
echo -e " ${CM}${CL} \r"
|
|
||||||
sleep 1
|
|
||||||
clear
|
|
||||||
header_info
|
|
||||||
echo -e "${RD}Using Advanced Settings${CL}"
|
|
||||||
echo -e "${DGN}Using CT Type ${BGN}$CT_TYPE1${CL}"
|
|
||||||
echo -e "${DGN}Using CT Password ${BGN}$PW1${CL}"
|
|
||||||
echo -e "${YW}Enter the CT ID, or Press [ENTER] to automatically generate (${NEXTID}) "
|
|
||||||
read CT_ID
|
|
||||||
if [ -z $CT_ID ]; then CT_ID=$NEXTID; fi;
|
|
||||||
echo -en "${DGN}Set CT ID To ${BL}$CT_ID${CL}"
|
|
||||||
echo -e " ${CM}${CL} \r"
|
|
||||||
sleep 1
|
|
||||||
clear
|
|
||||||
header_info
|
|
||||||
echo -e "${RD}Using Advanced Settings${CL}"
|
|
||||||
echo -e "${DGN}Using CT Type ${BGN}$CT_TYPE1${CL}"
|
|
||||||
echo -e "${DGN}Using CT Password ${BGN}$PW1${CL}"
|
|
||||||
echo -e "${DGN}Using CT ID ${BGN}$CT_ID${CL}"
|
|
||||||
echo -e "${YW}Enter CT Name (no-spaces), or Press [ENTER] for Default: $NSAPP "
|
|
||||||
read CT_NAME
|
|
||||||
if [ -z $CT_NAME ]; then
|
|
||||||
HN=$NSAPP
|
|
||||||
else
|
|
||||||
HN=$(echo ${CT_NAME,,} | tr -d ' ')
|
|
||||||
fi
|
|
||||||
echo -en "${DGN}Set CT Name To ${BL}$HN${CL}"
|
|
||||||
echo -e " ${CM}${CL} \r"
|
|
||||||
sleep 1
|
|
||||||
clear
|
|
||||||
header_info
|
|
||||||
echo -e "${RD}Using Advanced Settings${CL}"
|
|
||||||
echo -e "${DGN}Using CT Type ${BGN}$CT_TYPE1${CL}"
|
|
||||||
echo -e "${DGN}Using CT Password ${BGN}$PW1${CL}"
|
|
||||||
echo -e "${DGN}Using CT ID ${BGN}$CT_ID${CL}"
|
|
||||||
echo -e "${DGN}Using CT Name ${BGN}$HN${CL}"
|
|
||||||
echo -e "${YW}Enter a Disk Size, or Press [ENTER] for Default: 3 "
|
|
||||||
read DISK_SIZE
|
|
||||||
if [ -z $DISK_SIZE ]; then DISK_SIZE="3"; fi;
|
|
||||||
if ! [[ $DISK_SIZE =~ $INTEGER ]] ; then echo "ERROR! DISK SIZE MUST HAVE INTEGER NUMBER!"; exit; fi;
|
|
||||||
echo -en "${DGN}Set Disk Size To ${BL}$DISK_SIZE${CL}${DGN}GB${CL}"
|
|
||||||
echo -e " ${CM}${CL} \r"
|
|
||||||
sleep 1
|
|
||||||
clear
|
|
||||||
header_info
|
|
||||||
echo -e "${RD}Using Advanced Settings${CL}"
|
|
||||||
echo -e "${DGN}Using CT Type ${BGN}$CT_TYPE1${CL}"
|
|
||||||
echo -e "${DGN}Using CT Password ${BGN}$PW1${CL}"
|
|
||||||
echo -e "${DGN}Using CT ID ${BGN}$CT_ID${CL}"
|
|
||||||
echo -e "${DGN}Using CT Name ${BGN}$HN${CL}"
|
|
||||||
echo -e "${DGN}Using Disk Size ${BGN}$DISK_SIZE${CL}${DGN}GB${CL}"
|
|
||||||
echo -e "${YW}Allocate CPU cores, or Press [ENTER] for Default: 2 "
|
|
||||||
read CORE_COUNT
|
|
||||||
if [ -z $CORE_COUNT ]; then CORE_COUNT="2"; fi;
|
|
||||||
echo -en "${DGN}Set Cores To ${BL}$CORE_COUNT${CL}${DGN}vCPU${CL}"
|
|
||||||
echo -e " ${CM}${CL} \r"
|
|
||||||
sleep 1
|
|
||||||
clear
|
|
||||||
header_info
|
|
||||||
echo -e "${RD}Using Advanced Settings${CL}"
|
|
||||||
echo -e "${DGN}Using CT Type ${BGN}$CT_TYPE1${CL}"
|
|
||||||
echo -e "${DGN}Using CT Password ${BGN}$PW1${CL}"
|
|
||||||
echo -e "${DGN}Using CT ID ${BGN}$CT_ID${CL}"
|
|
||||||
echo -e "${DGN}Using CT Name ${BGN}$HN${CL}"
|
|
||||||
echo -e "${DGN}Using Disk Size ${BGN}$DISK_SIZE${CL}${DGN}GB${CL}"
|
|
||||||
echo -e "${DGN}Using ${BGN}${CORE_COUNT}${CL}${DGN}vCPU${CL}"
|
|
||||||
echo -e "${YW}Allocate RAM in MiB, or Press [ENTER] for Default: 2048 "
|
|
||||||
read RAM_SIZE
|
|
||||||
if [ -z $RAM_SIZE ]; then RAM_SIZE="2048"; fi;
|
|
||||||
echo -en "${DGN}Set RAM To ${BL}$RAM_SIZE${CL}${DGN}MiB RAM${CL}"
|
|
||||||
echo -e " ${CM}${CL} \n"
|
|
||||||
sleep 1
|
|
||||||
clear
|
|
||||||
header_info
|
|
||||||
echo -e "${RD}Using Advanced Settings${CL}"
|
|
||||||
echo -e "${DGN}Using CT Type ${BGN}$CT_TYPE1${CL}"
|
|
||||||
echo -e "${DGN}Using CT Password ${BGN}$PW1${CL}"
|
|
||||||
echo -e "${DGN}Using CT ID ${BGN}$CT_ID${CL}"
|
|
||||||
echo -e "${DGN}Using CT Name ${BGN}$HN${CL}"
|
|
||||||
echo -e "${DGN}Using Disk Size ${BGN}$DISK_SIZE${CL}${DGN}GB${CL}"
|
|
||||||
echo -e "${DGN}Using ${BGN}${CORE_COUNT}${CL}${DGN}vCPU${CL}"
|
|
||||||
echo -e "${DGN}Using ${BGN}${RAM_SIZE}${CL}${DGN}MiB RAM${CL}"
|
|
||||||
echo -e "${YW}Enter a Bridge, or Press [ENTER] for Default: vmbr0 "
|
|
||||||
read BRG
|
|
||||||
if [ -z $BRG ]; then BRG="vmbr0"; fi;
|
|
||||||
echo -en "${DGN}Set Bridge To ${BL}$BRG${CL}"
|
|
||||||
echo -e " ${CM}${CL} \n"
|
|
||||||
sleep 1
|
|
||||||
clear
|
|
||||||
header_info
|
|
||||||
echo -e "${RD}Using Advanced Settings${CL}"
|
|
||||||
echo -e "${DGN}Using CT Type ${BGN}$CT_TYPE1${CL}"
|
|
||||||
echo -e "${DGN}Using CT Password ${BGN}$PW1${CL}"
|
|
||||||
echo -e "${DGN}Using CT ID ${BGN}$CT_ID${CL}"
|
|
||||||
echo -e "${DGN}Using CT Name ${BGN}$HN${CL}"
|
|
||||||
echo -e "${DGN}Using Disk Size ${BGN}$DISK_SIZE${CL}${DGN}GB${CL}"
|
|
||||||
echo -e "${DGN}Using ${BGN}${CORE_COUNT}${CL}${DGN}vCPU${CL}"
|
|
||||||
echo -e "${DGN}Using ${BGN}${RAM_SIZE}${CL}${DGN}MiB RAM${CL}"
|
|
||||||
echo -e "${DGN}Using Bridge ${BGN}${BRG}${CL}"
|
|
||||||
echo -e "${YW}Enter a Static IPv4 CIDR Address, or Press [ENTER] for Default: DHCP "
|
|
||||||
read NET
|
|
||||||
if [ -z $NET ]; then NET="dhcp"; fi;
|
|
||||||
echo -en "${DGN}Set Static IP Address To ${BL}$NET${CL}"
|
|
||||||
echo -e " ${CM}${CL} \n"
|
|
||||||
sleep 1
|
|
||||||
clear
|
|
||||||
header_info
|
|
||||||
echo -e "${RD}Using Advanced Settings${CL}"
|
|
||||||
echo -e "${DGN}Using CT Type ${BGN}$CT_TYPE1${CL}"
|
|
||||||
echo -e "${DGN}Using CT Password ${BGN}$PW1${CL}"
|
|
||||||
echo -e "${DGN}Using CT ID ${BGN}$CT_ID${CL}"
|
|
||||||
echo -e "${DGN}Using CT Name ${BGN}$HN${CL}"
|
|
||||||
echo -e "${DGN}Using Disk Size ${BGN}$DISK_SIZE${CL}${DGN}GB${CL}"
|
|
||||||
echo -e "${DGN}Using ${BGN}${CORE_COUNT}${CL}${DGN}vCPU${CL}"
|
|
||||||
echo -e "${DGN}Using ${BGN}${RAM_SIZE}${CL}${DGN}MiB RAM${CL}"
|
|
||||||
echo -e "${DGN}Using Bridge ${BGN}${BRG}${CL}"
|
|
||||||
echo -e "${DGN}Using Static IP Address ${BGN}$NET${CL}"
|
|
||||||
echo -e "${YW}Enter a Gateway IP (mandatory if static IP is used), or Press [ENTER] for Default: NONE "
|
|
||||||
read GATE1
|
|
||||||
if [ -z $GATE1 ]; then GATE1="NONE" GATE="";
|
|
||||||
echo -en "${DGN}Set Gateway IP To ${BL}$GATE1${CL}"
|
|
||||||
else
|
|
||||||
GATE=",gw=$GATE1"
|
|
||||||
echo -en "${DGN}Set Gateway IP To ${BL}$GATE1${CL}"
|
|
||||||
fi;
|
|
||||||
echo -e " ${CM}${CL} \n"
|
|
||||||
sleep 1
|
|
||||||
clear
|
|
||||||
header_info
|
|
||||||
|
|
||||||
echo -e "${RD}Using Advanced Settings${CL}"
|
|
||||||
echo -e "${DGN}Using CT Type ${BGN}$CT_TYPE1${CL}"
|
|
||||||
echo -e "${DGN}Using CT Password ${BGN}$PW1${CL}"
|
|
||||||
echo -e "${DGN}Using CT ID ${BGN}$CT_ID${CL}"
|
|
||||||
echo -e "${DGN}Using CT Name ${BGN}$HN${CL}"
|
|
||||||
echo -e "${DGN}Using Disk Size ${BGN}$DISK_SIZE${CL}${DGN}GB${CL}"
|
|
||||||
echo -e "${DGN}Using ${BGN}${CORE_COUNT}${CL}${DGN}vCPU${CL}"
|
|
||||||
echo -e "${DGN}Using ${BGN}${RAM_SIZE}${CL}${DGN}MiB RAM${CL}"
|
|
||||||
echo -e "${DGN}Using Bridge ${BGN}${BRG}${CL}"
|
|
||||||
echo -e "${DGN}Using Static IP Address ${BGN}$NET${CL}"
|
|
||||||
echo -e "${DGN}Using Gateway IP Address ${BGN}$GATE1${CL}"
|
|
||||||
echo -e "${YW}Enter a VLAN Tag, or Press [ENTER] for Default: NONE "
|
|
||||||
read VLAN1
|
|
||||||
if [ -z $VLAN1 ]; then VLAN1="NONE" VLAN="";
|
|
||||||
echo -en "${DGN}Set VLAN Tag To ${BL}$VLAN1${CL}"
|
|
||||||
else
|
|
||||||
VLAN=",tag=$VLAN1"
|
|
||||||
echo -en "${DGN}Set VLAN Tag To ${BL}$VLAN1${CL}"
|
|
||||||
fi;
|
|
||||||
echo -e " ${CM}${CL} \n"
|
|
||||||
sleep 1
|
|
||||||
clear
|
|
||||||
header_info
|
|
||||||
echo -e "${RD}Using Advanced Settings${CL}"
|
|
||||||
echo -e "${DGN}Using CT Type ${BGN}$CT_TYPE1${CL}"
|
|
||||||
echo -e "${DGN}Using CT Password ${BGN}$PW1${CL}"
|
|
||||||
echo -e "${DGN}Using CT ID ${BGN}$CT_ID${CL}"
|
|
||||||
echo -e "${DGN}Using CT Name ${BGN}$HN${CL}"
|
|
||||||
echo -e "${DGN}Using Disk Size ${BGN}$DISK_SIZE${CL}${DGN}GB${CL}"
|
|
||||||
echo -e "${DGN}Using ${BGN}${CORE_COUNT}${CL}${DGN}vCPU${CL}"
|
|
||||||
echo -e "${DGN}Using ${BGN}${RAM_SIZE}${CL}${DGN}MiB RAM${CL}"
|
|
||||||
echo -e "${DGN}Using Bridge ${BGN}${BRG}${CL}"
|
|
||||||
echo -e "${DGN}Using Static IP Address ${BGN}$NET${CL}"
|
|
||||||
echo -e "${DGN}Using Gateway IP Address ${BGN}$GATE1${CL}"
|
|
||||||
echo -e "${DGN}Using VLAN Tag ${BGN}$VLAN1${CL}"
|
|
||||||
|
|
||||||
read -p "Are these settings correct(y/n)? " -n 1 -r
|
|
||||||
echo
|
|
||||||
if [[ ! $REPLY =~ ^[Yy]$ ]]
|
|
||||||
then
|
|
||||||
advanced_settings
|
|
||||||
fi
|
|
||||||
}
|
|
||||||
|
|
||||||
function start_script() {
|
|
||||||
echo -e "${YW}Type Advanced, or Press [ENTER] for Default Settings "
|
|
||||||
read SETTINGS
|
|
||||||
if [ -z $SETTINGS ]; then default_settings;
|
|
||||||
else
|
|
||||||
advanced_settings
|
|
||||||
fi;
|
|
||||||
}
|
|
||||||
|
|
||||||
start_script
|
|
||||||
|
|
||||||
if [ "$CT_TYPE" == "1" ]; then
|
|
||||||
FEATURES="nesting=1,keyctl=1"
|
|
||||||
else
|
|
||||||
FEATURES="nesting=1"
|
|
||||||
fi
|
|
||||||
|
|
||||||
TEMP_DIR=$(mktemp -d)
|
|
||||||
pushd $TEMP_DIR >/dev/null
|
|
||||||
|
|
||||||
export CTID=$CT_ID
|
|
||||||
export PCT_OSTYPE=debian
|
|
||||||
export PCT_OSVERSION=11
|
|
||||||
export PCT_DISK_SIZE=$DISK_SIZE
|
|
||||||
export PCT_OPTIONS="
|
|
||||||
-features $FEATURES
|
|
||||||
-hostname $HN
|
|
||||||
-net0 name=eth0,bridge=$BRG,ip=$NET$GATE$VLAN
|
|
||||||
-onboot 1
|
|
||||||
-cores $CORE_COUNT
|
|
||||||
-memory $RAM_SIZE
|
|
||||||
-unprivileged $CT_TYPE
|
|
||||||
$PW
|
|
||||||
"
|
|
||||||
bash -c "$(wget -qLO - https://raw.githubusercontent.com/tteck/Proxmox/main/ct/create_lxc.sh)" || exit
|
|
||||||
|
|
||||||
msg_info "Starting LXC Container"
|
|
||||||
pct start $CTID
|
|
||||||
msg_ok "Started LXC Container"
|
|
||||||
|
|
||||||
lxc-attach -n $CTID -- bash -c "$(wget -qLO - https://raw.githubusercontent.com/tteck/Proxmox/main/setup/n8n-install.sh)" || exit
|
|
||||||
|
|
||||||
IP=$(pct exec $CTID ip a s dev eth0 | sed -n '/inet / s/\// /p' | awk '{print $2}')
|
|
||||||
|
|
||||||
pct set $CTID -description "# ${APP} LXC
|
|
||||||
### https://github.com/tteck/Proxmox"
|
|
||||||
|
|
||||||
msg_ok "Completed Successfully!\n"
|
|
||||||
echo -e "${APP} should be reachable by going to the following URL.
|
|
||||||
${BL}http://${IP}:5678${CL} \n"
|
|
|
@ -310,7 +310,7 @@ bash -c "$(wget -qLO - https://raw.githubusercontent.com/tteck/Proxmox/main/ct/c
|
||||||
msg_info "Starting LXC Container"
|
msg_info "Starting LXC Container"
|
||||||
pct start $CTID
|
pct start $CTID
|
||||||
msg_ok "Started LXC Container"
|
msg_ok "Started LXC Container"
|
||||||
lxc-attach -n $CTID -- bash -c "$(wget -qLO - https://raw.githubusercontent.com/tteck/Proxmox/main/setup/$var_install.sh)" || exit
|
lxc-attach -n $CTID -- bash -c "$(wget -qLO - https://raw.githubusercontent.com/tteck/Proxmox/main/install/$var_install.sh)" || exit
|
||||||
IP=$(pct exec $CTID ip a s dev eth0 | sed -n '/inet / s/\// /p' | awk '{print $2}')
|
IP=$(pct exec $CTID ip a s dev eth0 | sed -n '/inet / s/\// /p' | awk '{print $2}')
|
||||||
pct set $CTID -description "# ${APP} LXC
|
pct set $CTID -description "# ${APP} LXC
|
||||||
### https://tteck.github.io/Proxmox/
|
### https://tteck.github.io/Proxmox/
|
||||||
|
|
|
@ -309,7 +309,7 @@ bash -c "$(wget -qLO - https://raw.githubusercontent.com/tteck/Proxmox/main/ct/c
|
||||||
msg_info "Starting LXC Container"
|
msg_info "Starting LXC Container"
|
||||||
pct start $CTID
|
pct start $CTID
|
||||||
msg_ok "Started LXC Container"
|
msg_ok "Started LXC Container"
|
||||||
lxc-attach -n $CTID -- bash -c "$(wget -qLO - https://raw.githubusercontent.com/tteck/Proxmox/main/setup/$var_install.sh)" || exit
|
lxc-attach -n $CTID -- bash -c "$(wget -qLO - https://raw.githubusercontent.com/tteck/Proxmox/main/install/$var_install.sh)" || exit
|
||||||
IP=$(pct exec $CTID ip a s dev eth0 | sed -n '/inet / s/\// /p' | awk '{print $2}')
|
IP=$(pct exec $CTID ip a s dev eth0 | sed -n '/inet / s/\// /p' | awk '{print $2}')
|
||||||
pct set $CTID -description "# ${APP} LXC
|
pct set $CTID -description "# ${APP} LXC
|
||||||
### https://tteck.github.io/Proxmox/
|
### https://tteck.github.io/Proxmox/
|
||||||
|
|
|
@ -310,7 +310,7 @@ bash -c "$(wget -qLO - https://raw.githubusercontent.com/tteck/Proxmox/main/ct/c
|
||||||
msg_info "Starting LXC Container"
|
msg_info "Starting LXC Container"
|
||||||
pct start $CTID
|
pct start $CTID
|
||||||
msg_ok "Started LXC Container"
|
msg_ok "Started LXC Container"
|
||||||
lxc-attach -n $CTID -- bash -c "$(wget -qLO - https://raw.githubusercontent.com/tteck/Proxmox/main/setup/$var_install.sh)" || exit
|
lxc-attach -n $CTID -- bash -c "$(wget -qLO - https://raw.githubusercontent.com/tteck/Proxmox/main/install/$var_install.sh)" || exit
|
||||||
IP=$(pct exec $CTID ip a s dev eth0 | sed -n '/inet / s/\// /p' | awk '{print $2}')
|
IP=$(pct exec $CTID ip a s dev eth0 | sed -n '/inet / s/\// /p' | awk '{print $2}')
|
||||||
pct set $CTID -description "# ${APP} LXC
|
pct set $CTID -description "# ${APP} LXC
|
||||||
### https://tteck.github.io/Proxmox/
|
### https://tteck.github.io/Proxmox/
|
||||||
|
|
|
@ -1,162 +0,0 @@
|
||||||
#!/usr/bin/env bash
|
|
||||||
|
|
||||||
#!/usr/bin/env bash
|
|
||||||
while true; do
|
|
||||||
read -p "This will create a New Nginx Proxy Manager LXC Container. Proceed(y/n)?" yn
|
|
||||||
case $yn in
|
|
||||||
[Yy]* ) break;;
|
|
||||||
[Nn]* ) exit;;
|
|
||||||
* ) echo "Please answer yes or no.";;
|
|
||||||
esac
|
|
||||||
done
|
|
||||||
|
|
||||||
set -o errexit
|
|
||||||
set -o errtrace
|
|
||||||
set -o nounset
|
|
||||||
set -o pipefail
|
|
||||||
shopt -s expand_aliases
|
|
||||||
alias die='EXIT=$? LINE=$LINENO error_exit'
|
|
||||||
CHECKMARK='\033[0;32m\xE2\x9C\x94\033[0m'
|
|
||||||
trap die ERR
|
|
||||||
trap cleanup EXIT
|
|
||||||
|
|
||||||
function error_exit() {
|
|
||||||
trap - ERR
|
|
||||||
local DEFAULT='Unknown failure occured.'
|
|
||||||
local REASON="\e[97m${1:-$DEFAULT}\e[39m"
|
|
||||||
local FLAG="\e[91m[ERROR] \e[93m$EXIT@$LINE"
|
|
||||||
msg "$FLAG $REASON"
|
|
||||||
[ ! -z ${CTID-} ] && cleanup_ctid
|
|
||||||
exit $EXIT
|
|
||||||
}
|
|
||||||
function warn() {
|
|
||||||
local REASON="\e[97m$1\e[39m"
|
|
||||||
local FLAG="\e[93m[WARNING]\e[39m"
|
|
||||||
msg "$FLAG $REASON"
|
|
||||||
}
|
|
||||||
function info() {
|
|
||||||
local REASON="$1"
|
|
||||||
local FLAG="\e[36m[INFO]\e[39m"
|
|
||||||
msg "$FLAG $REASON"
|
|
||||||
}
|
|
||||||
function msg() {
|
|
||||||
local TEXT="$1"
|
|
||||||
echo -e "$TEXT"
|
|
||||||
}
|
|
||||||
function cleanup_ctid() {
|
|
||||||
if [ ! -z ${MOUNT+x} ]; then
|
|
||||||
pct unmount $CTID
|
|
||||||
fi
|
|
||||||
if $(pct status $CTID &>/dev/null); then
|
|
||||||
if [ "$(pct status $CTID | awk '{print $2}')" == "running" ]; then
|
|
||||||
pct stop $CTID
|
|
||||||
fi
|
|
||||||
pct destroy $CTID
|
|
||||||
elif [ "$(pvesm list $STORAGE --vmid $CTID)" != "" ]; then
|
|
||||||
pvesm free $ROOTFS
|
|
||||||
fi
|
|
||||||
}
|
|
||||||
function cleanup() {
|
|
||||||
popd >/dev/null
|
|
||||||
rm -rf $TEMP_DIR
|
|
||||||
}
|
|
||||||
function load_module() {
|
|
||||||
if ! $(lsmod | grep -Fq $1); then
|
|
||||||
modprobe $1 &>/dev/null || \
|
|
||||||
die "Failed to load '$1' module."
|
|
||||||
fi
|
|
||||||
MODULES_PATH=/etc/modules
|
|
||||||
if ! $(grep -Fxq "$1" $MODULES_PATH); then
|
|
||||||
echo "$1" >> $MODULES_PATH || \
|
|
||||||
die "Failed to add '$1' module to load at boot."
|
|
||||||
fi
|
|
||||||
}
|
|
||||||
TEMP_DIR=$(mktemp -d)
|
|
||||||
pushd $TEMP_DIR >/dev/null
|
|
||||||
|
|
||||||
wget -qL https://raw.githubusercontent.com/tteck/Proxmox/main/setup/npm_setup.sh
|
|
||||||
|
|
||||||
load_module overlay
|
|
||||||
|
|
||||||
while read -r line; do
|
|
||||||
TAG=$(echo $line | awk '{print $1}')
|
|
||||||
TYPE=$(echo $line | awk '{printf "%-10s", $2}')
|
|
||||||
FREE=$(echo $line | numfmt --field 4-6 --from-unit=K --to=iec --format %.2f | awk '{printf( "%9sB", $6)}')
|
|
||||||
ITEM=" Type: $TYPE Free: $FREE "
|
|
||||||
OFFSET=2
|
|
||||||
if [[ $((${#ITEM} + $OFFSET)) -gt ${MSG_MAX_LENGTH:-} ]]; then
|
|
||||||
MSG_MAX_LENGTH=$((${#ITEM} + $OFFSET))
|
|
||||||
fi
|
|
||||||
STORAGE_MENU+=( "$TAG" "$ITEM" "OFF" )
|
|
||||||
done < <(pvesm status -content rootdir | awk 'NR>1')
|
|
||||||
if [ $((${#STORAGE_MENU[@]}/3)) -eq 0 ]; then
|
|
||||||
warn "'Container' needs to be selected for at least one storage location."
|
|
||||||
die "Unable to detect valid storage location."
|
|
||||||
elif [ $((${#STORAGE_MENU[@]}/3)) -eq 1 ]; then
|
|
||||||
STORAGE=${STORAGE_MENU[0]}
|
|
||||||
else
|
|
||||||
while [ -z "${STORAGE:+x}" ]; do
|
|
||||||
STORAGE=$(whiptail --title "Storage Pools" --radiolist \
|
|
||||||
"Which storage pool you would like to use for the container?\n\n" \
|
|
||||||
16 $(($MSG_MAX_LENGTH + 23)) 6 \
|
|
||||||
"${STORAGE_MENU[@]}" 3>&1 1>&2 2>&3) || exit
|
|
||||||
done
|
|
||||||
fi
|
|
||||||
info "Using '$STORAGE' for storage location."
|
|
||||||
|
|
||||||
CTID=$(pvesh get /cluster/nextid)
|
|
||||||
info "LXC ID is $CTID."
|
|
||||||
|
|
||||||
echo -e "${CHECKMARK} \e[1;92m Updating LXC Template List... \e[0m"
|
|
||||||
pveam update >/dev/null
|
|
||||||
echo -e "${CHECKMARK} \e[1;92m Downloading LXC Template... \e[0m"
|
|
||||||
OSTYPE=debian
|
|
||||||
OSVERSION=${OSTYPE}-11
|
|
||||||
mapfile -t TEMPLATES < <(pveam available -section system | sed -n "s/.*\($OSVERSION.*\)/\1/p" | sort -t - -k 2 -V)
|
|
||||||
TEMPLATE="${TEMPLATES[-1]}"
|
|
||||||
pveam download local $TEMPLATE >/dev/null ||
|
|
||||||
die "A problem occured while downloading the LXC template."
|
|
||||||
|
|
||||||
STORAGE_TYPE=$(pvesm status -storage $STORAGE | awk 'NR>1 {print $2}')
|
|
||||||
case $STORAGE_TYPE in
|
|
||||||
dir|nfs)
|
|
||||||
DISK_EXT=".raw"
|
|
||||||
DISK_REF="$CTID/"
|
|
||||||
;;
|
|
||||||
zfspool)
|
|
||||||
DISK_PREFIX="subvol"
|
|
||||||
DISK_FORMAT="subvol"
|
|
||||||
;;
|
|
||||||
esac
|
|
||||||
DISK=${DISK_PREFIX:-vm}-${CTID}-disk-0${DISK_EXT-}
|
|
||||||
ROOTFS=${STORAGE}:${DISK_REF-}${DISK}
|
|
||||||
|
|
||||||
echo -e "${CHECKMARK} \e[1;92m Creating LXC... \e[0m"
|
|
||||||
DISK_SIZE=3G
|
|
||||||
pvesm alloc $STORAGE $CTID $DISK $DISK_SIZE --format ${DISK_FORMAT:-raw} >/dev/null
|
|
||||||
if [ "$STORAGE_TYPE" == "zfspool" ]; then
|
|
||||||
warn "Some containers may not work properly due to ZFS not supporting 'fallocate'."
|
|
||||||
else
|
|
||||||
mkfs.ext4 $(pvesm path $ROOTFS) &>/dev/null
|
|
||||||
fi
|
|
||||||
ARCH=$(dpkg --print-architecture)
|
|
||||||
HOSTNAME=npm
|
|
||||||
TEMPLATE_STRING="local:vztmpl/${TEMPLATE}"
|
|
||||||
pct create $CTID $TEMPLATE_STRING -arch $ARCH -features nesting=1 \
|
|
||||||
-hostname $HOSTNAME -net0 name=eth0,bridge=vmbr0,ip=dhcp -onboot 1 -cores 1 -memory 1024 \
|
|
||||||
-ostype $OSTYPE -rootfs $ROOTFS,size=$DISK_SIZE -storage $STORAGE >/dev/null
|
|
||||||
|
|
||||||
MOUNT=$(pct mount $CTID | cut -d"'" -f 2)
|
|
||||||
ln -fs $(readlink /etc/localtime) ${MOUNT}/etc/localtime
|
|
||||||
pct unmount $CTID && unset MOUNT
|
|
||||||
|
|
||||||
echo -e "${CHECKMARK} \e[1;92m Starting LXC... \e[0m"
|
|
||||||
pct start $CTID
|
|
||||||
pct push $CTID npm_setup.sh /npm_setup.sh -perms 755
|
|
||||||
pct exec $CTID /npm_setup.sh
|
|
||||||
|
|
||||||
IP=$(pct exec $CTID ip a s dev eth0 | sed -n '/inet / s/\// /p' | awk '{print $2}')
|
|
||||||
info "Successfully Created Nginx Proxy Manager LXC to $CTID."
|
|
||||||
echo -e "\e[1;92m Nginx Proxy Manager should be reachable by going to the following URL.
|
|
||||||
http://${IP}:81
|
|
||||||
\e[0m"
|
|
|
@ -1,251 +0,0 @@
|
||||||
#!/usr/bin/env bash
|
|
||||||
YW=`echo "\033[33m"`
|
|
||||||
BL=`echo "\033[36m"`
|
|
||||||
RD=`echo "\033[01;31m"`
|
|
||||||
CM='\xE2\x9C\x94\033'
|
|
||||||
GN=`echo "\033[1;92m"`
|
|
||||||
CL=`echo "\033[m"`
|
|
||||||
while true; do
|
|
||||||
read -p "This will create a New Nginx Proxy Manager LXC. Proceed(y/n)?" yn
|
|
||||||
case $yn in
|
|
||||||
[Yy]* ) break;;
|
|
||||||
[Nn]* ) exit;;
|
|
||||||
* ) echo "Please answer yes or no.";;
|
|
||||||
esac
|
|
||||||
done
|
|
||||||
clear
|
|
||||||
function header_info {
|
|
||||||
echo -e "${RD}
|
|
||||||
_ _ _____ __ __
|
|
||||||
| \ | | __ \| \/ |
|
|
||||||
| \| | |__) | \ / |
|
|
||||||
| | ___/| |\/| |
|
|
||||||
| |\ | | | | | |
|
|
||||||
|_| \_|_| |_| |_|
|
|
||||||
${CL}"
|
|
||||||
}
|
|
||||||
|
|
||||||
header_info
|
|
||||||
show_menu(){
|
|
||||||
printf " ${YW} 1)${YW} Privileged ${CL}\n"
|
|
||||||
printf " ${YW} 2)${GN} Unprivileged ${CL}\n"
|
|
||||||
|
|
||||||
printf "Please choose a Install Method and hit enter or ${RD}x${CL} to exit."
|
|
||||||
read opt
|
|
||||||
}
|
|
||||||
|
|
||||||
option_picked(){
|
|
||||||
message1=${@:-"${CL}Error: No message passed"}
|
|
||||||
printf " ${YW}${message1}${CL}\n"
|
|
||||||
}
|
|
||||||
show_menu
|
|
||||||
while [ "$opt" != " " ]
|
|
||||||
do
|
|
||||||
case $opt in
|
|
||||||
1) clear;
|
|
||||||
header_info;
|
|
||||||
option_picked "Using Privileged Install";
|
|
||||||
IM=0
|
|
||||||
break;
|
|
||||||
;;
|
|
||||||
2) clear;
|
|
||||||
header_info;
|
|
||||||
option_picked "Using Unprivileged Install";
|
|
||||||
IM=1
|
|
||||||
break;
|
|
||||||
;;
|
|
||||||
|
|
||||||
x)exit;
|
|
||||||
;;
|
|
||||||
\n)exit;
|
|
||||||
;;
|
|
||||||
*)clear;
|
|
||||||
option_picked "Please choose a Install Method from the menu";
|
|
||||||
show_menu;
|
|
||||||
;;
|
|
||||||
esac
|
|
||||||
done
|
|
||||||
show_menu2(){
|
|
||||||
printf " ${YW} 1)${GN} Use Automatic Login ${CL}\n"
|
|
||||||
printf " ${YW} 2)${GN} Use Password (changeme) ${CL}\n"
|
|
||||||
|
|
||||||
printf "Please choose a Password Type and hit enter or ${RD}x${CL} to exit."
|
|
||||||
read opt
|
|
||||||
}
|
|
||||||
|
|
||||||
option_picked(){
|
|
||||||
message2=${@:-"${CL}Error: No message passed"}
|
|
||||||
printf " ${YW}${message1}${CL}\n"
|
|
||||||
printf " ${YW}${message2}${CL}\n"
|
|
||||||
}
|
|
||||||
show_menu2
|
|
||||||
while [ "$opt" != " " ]
|
|
||||||
do
|
|
||||||
case $opt in
|
|
||||||
1) clear;
|
|
||||||
header_info;
|
|
||||||
option_picked "Using Automatic Login";
|
|
||||||
PW=" "
|
|
||||||
break;
|
|
||||||
;;
|
|
||||||
2) clear;
|
|
||||||
header_info;
|
|
||||||
option_picked "Using Password (changeme)";
|
|
||||||
PW="-password changeme"
|
|
||||||
break;
|
|
||||||
;;
|
|
||||||
|
|
||||||
x)exit;
|
|
||||||
;;
|
|
||||||
\n)exit;
|
|
||||||
;;
|
|
||||||
*)clear;
|
|
||||||
option_picked "Please choose a Password Type from the menu";
|
|
||||||
show_menu2;
|
|
||||||
;;
|
|
||||||
esac
|
|
||||||
done
|
|
||||||
show_menu3(){
|
|
||||||
printf " ${YW} 1)${GN} Automatic DHCP ${CL}\n"
|
|
||||||
printf " ${YW} 2)${GN} Manual DHCP ${CL}\n"
|
|
||||||
|
|
||||||
printf "Please choose a DHCP Type and hit enter or ${RD}x${CL} to exit."
|
|
||||||
read opt
|
|
||||||
}
|
|
||||||
|
|
||||||
option_picked(){
|
|
||||||
message3=${@:-"${CL}Error: No message passed"}
|
|
||||||
printf " ${YW}${message1}${CL}\n"
|
|
||||||
printf " ${YW}${message2}${CL}\n"
|
|
||||||
printf " ${YW}${message3}${CL}\n"
|
|
||||||
}
|
|
||||||
show_menu3
|
|
||||||
while [ "$opt" != " " ]
|
|
||||||
do
|
|
||||||
case $opt in
|
|
||||||
1) clear;
|
|
||||||
header_info;
|
|
||||||
option_picked "Using Automatic DHCP";
|
|
||||||
DHCP=" "
|
|
||||||
break;
|
|
||||||
;;
|
|
||||||
2) clear;
|
|
||||||
header_info;
|
|
||||||
option_picked "Using Manual DHCP";
|
|
||||||
DHCP="1"
|
|
||||||
break;
|
|
||||||
;;
|
|
||||||
|
|
||||||
x)exit;
|
|
||||||
;;
|
|
||||||
\n)exit;
|
|
||||||
;;
|
|
||||||
*)clear;
|
|
||||||
option_picked "Please choose a DHCP Type from the menu";
|
|
||||||
show_menu3;
|
|
||||||
;;
|
|
||||||
esac
|
|
||||||
done
|
|
||||||
|
|
||||||
set -o errexit
|
|
||||||
set -o errtrace
|
|
||||||
set -o nounset
|
|
||||||
set -o pipefail
|
|
||||||
shopt -s expand_aliases
|
|
||||||
alias die='EXIT=$? LINE=$LINENO error_exit'
|
|
||||||
trap die ERR
|
|
||||||
trap cleanup EXIT
|
|
||||||
|
|
||||||
function error_exit() {
|
|
||||||
trap - ERR
|
|
||||||
local DEFAULT='Unknown failure occured.'
|
|
||||||
local REASON="\e[97m${1:-$DEFAULT}\e[39m"
|
|
||||||
local FLAG="\e[91m[ERROR] \e[93m$EXIT@$LINE"
|
|
||||||
msg "$FLAG $REASON"
|
|
||||||
[ ! -z ${CTID-} ] && cleanup_ctid
|
|
||||||
exit $EXIT
|
|
||||||
}
|
|
||||||
function warn() {
|
|
||||||
local REASON="\e[97m$1\e[39m"
|
|
||||||
local FLAG="\e[93m[WARNING]\e[39m"
|
|
||||||
msg "$FLAG $REASON"
|
|
||||||
}
|
|
||||||
function info() {
|
|
||||||
local REASON="$1"
|
|
||||||
local FLAG="\e[36m[INFO]\e[39m"
|
|
||||||
msg "$FLAG $REASON"
|
|
||||||
}
|
|
||||||
function msg() {
|
|
||||||
local TEXT="$1"
|
|
||||||
echo -e "$TEXT"
|
|
||||||
}
|
|
||||||
function cleanup_ctid() {
|
|
||||||
if $(pct status $CTID &>/dev/null); then
|
|
||||||
if [ "$(pct status $CTID | awk '{print $2}')" == "running" ]; then
|
|
||||||
pct stop $CTID
|
|
||||||
fi
|
|
||||||
pct destroy $CTID
|
|
||||||
elif [ "$(pvesm list $STORAGE --vmid $CTID)" != "" ]; then
|
|
||||||
pvesm free $ROOTFS
|
|
||||||
fi
|
|
||||||
}
|
|
||||||
function cleanup() {
|
|
||||||
popd >/dev/null
|
|
||||||
rm -rf $TEMP_DIR
|
|
||||||
}
|
|
||||||
if [ "$IM" == "1" ]; then
|
|
||||||
FEATURES="nesting=1,keyctl=1"
|
|
||||||
else
|
|
||||||
FEATURES="nesting=1"
|
|
||||||
fi
|
|
||||||
|
|
||||||
TEMP_DIR=$(mktemp -d)
|
|
||||||
pushd $TEMP_DIR >/dev/null
|
|
||||||
|
|
||||||
export CTID=$(pvesh get /cluster/nextid)
|
|
||||||
export PCT_OSTYPE=debian
|
|
||||||
export PCT_OSVERSION=11
|
|
||||||
export PCT_DISK_SIZE=3
|
|
||||||
export PCT_OPTIONS="
|
|
||||||
-features $FEATURES
|
|
||||||
-hostname npm
|
|
||||||
-net0 name=eth0,bridge=vmbr0,ip=dhcp
|
|
||||||
-onboot 1
|
|
||||||
-cores 1
|
|
||||||
-memory 1024
|
|
||||||
-unprivileged ${IM}
|
|
||||||
${PW}
|
|
||||||
"
|
|
||||||
bash -c "$(wget -qLO - https://raw.githubusercontent.com/tteck/Proxmox/main/ct/create_lxc.sh)" || exit
|
|
||||||
|
|
||||||
STORAGE_TYPE=$(pvesm status -storage $(pct config $CTID | grep rootfs | awk -F ":" '{print $2}') | awk 'NR>1 {print $2}')
|
|
||||||
if [ "$STORAGE_TYPE" == "zfspool" ]; then
|
|
||||||
warn "Some addons may not work due to ZFS not supporting 'fallocate'."
|
|
||||||
fi
|
|
||||||
if [ "$DHCP" == "1" ]; then
|
|
||||||
MAC=$(pct config $CTID \
|
|
||||||
| grep -i hwaddr \
|
|
||||||
| awk '{print substr($2, 31, length($3) 17 ) }') \
|
|
||||||
|
|
||||||
echo -e "MAC Address ${BL}$MAC${CL}"
|
|
||||||
|
|
||||||
dhcp_reservation(){
|
|
||||||
printf "Please set DHCP reservation and press Enter."
|
|
||||||
read
|
|
||||||
}
|
|
||||||
dhcp_reservation
|
|
||||||
fi
|
|
||||||
|
|
||||||
echo -en "${GN} Starting LXC Container... "
|
|
||||||
pct start $CTID
|
|
||||||
echo -e "${CM}${CL} \r"
|
|
||||||
|
|
||||||
alias lxc-cmd="lxc-attach -n $CTID --"
|
|
||||||
|
|
||||||
lxc-cmd bash -c "$(wget -qLO - https://raw.githubusercontent.com/tteck/Proxmox/main/setup/nginx-proxy-manager-install.sh)" || exit
|
|
||||||
|
|
||||||
IP=$(pct exec $CTID ip a s dev eth0 | sed -n '/inet / s/\// /p' | awk '{print $2}')
|
|
||||||
|
|
||||||
echo -e "${GN}Successfully created Nginx Proxy Manager LXC to${CL} ${BL}$CTID${CL}.
|
|
||||||
Nginx Proxy Manager should be reachable by going to the following URL.
|
|
||||||
${BL}http://${IP}:81${CL} \n"
|
|
|
@ -1,356 +0,0 @@
|
||||||
#!/usr/bin/env bash
|
|
||||||
echo -e "Loading..."
|
|
||||||
NEXTID=$(pvesh get /cluster/nextid)
|
|
||||||
INTEGER='^[0-9]+$'
|
|
||||||
YW=`echo "\033[33m"`
|
|
||||||
BL=`echo "\033[36m"`
|
|
||||||
RD=`echo "\033[01;31m"`
|
|
||||||
BGN=`echo "\033[4;92m"`
|
|
||||||
GN=`echo "\033[1;92m"`
|
|
||||||
DGN=`echo "\033[32m"`
|
|
||||||
CL=`echo "\033[m"`
|
|
||||||
BFR="\\r\\033[K"
|
|
||||||
HOLD="-"
|
|
||||||
CM="${GN}✓${CL}"
|
|
||||||
APP="Nginx Proxy Manager"
|
|
||||||
NSAPP=$(echo ${APP,,} | tr -d ' ')
|
|
||||||
set -o errexit
|
|
||||||
set -o errtrace
|
|
||||||
set -o nounset
|
|
||||||
set -o pipefail
|
|
||||||
shopt -s expand_aliases
|
|
||||||
alias die='EXIT=$? LINE=$LINENO error_exit'
|
|
||||||
trap die ERR
|
|
||||||
|
|
||||||
function error_exit() {
|
|
||||||
trap - ERR
|
|
||||||
local reason="Unknown failure occurred."
|
|
||||||
local msg="${1:-$reason}"
|
|
||||||
local flag="${RD}‼ ERROR ${CL}$EXIT@$LINE"
|
|
||||||
echo -e "$flag $msg" 1>&2
|
|
||||||
exit $EXIT
|
|
||||||
}
|
|
||||||
|
|
||||||
while true; do
|
|
||||||
clear
|
|
||||||
read -p "This will create a New ${APP} LXC. Proceed(y/n)?" yn
|
|
||||||
case $yn in
|
|
||||||
[Yy]* ) break;;
|
|
||||||
[Nn]* ) exit;;
|
|
||||||
* ) echo "Please answer yes or no.";;
|
|
||||||
esac
|
|
||||||
done
|
|
||||||
clear
|
|
||||||
function header_info {
|
|
||||||
echo -e "${RD}
|
|
||||||
_ _ _____ __ __
|
|
||||||
| \ | | __ \| \/ |
|
|
||||||
| \| | |__) | \ / |
|
|
||||||
| | ___/| |\/| |
|
|
||||||
| |\ | | | | | |
|
|
||||||
|_| \_|_| v3 |_| |_|
|
|
||||||
${CL}"
|
|
||||||
}
|
|
||||||
|
|
||||||
header_info
|
|
||||||
|
|
||||||
function msg_info() {
|
|
||||||
local msg="$1"
|
|
||||||
echo -ne " ${HOLD} ${YW}${msg}..."
|
|
||||||
}
|
|
||||||
|
|
||||||
function msg_ok() {
|
|
||||||
local msg="$1"
|
|
||||||
echo -e "${BFR} ${CM} ${GN}${msg}${CL}"
|
|
||||||
}
|
|
||||||
|
|
||||||
function PVE_CHECK() {
|
|
||||||
PVE=$(pveversion | grep "pve-manager/7" | wc -l)
|
|
||||||
|
|
||||||
if [[ $PVE != 1 ]]; then
|
|
||||||
echo -e "${RD}This script requires Proxmox Virtual Environment 7.0 or greater${CL}"
|
|
||||||
echo -e "Exiting..."
|
|
||||||
sleep 2
|
|
||||||
exit
|
|
||||||
fi
|
|
||||||
}
|
|
||||||
|
|
||||||
function default_settings() {
|
|
||||||
clear
|
|
||||||
header_info
|
|
||||||
echo -e "${BL}Using Default Settings${CL}"
|
|
||||||
echo -e "${DGN}Using CT Type ${BGN}Unprivileged${CL} ${RD}NO DEVICE PASSTHROUGH${CL}"
|
|
||||||
CT_TYPE="1"
|
|
||||||
echo -e "${DGN}Using CT Password ${BGN}Automatic Login${CL}"
|
|
||||||
PW=" "
|
|
||||||
echo -e "${DGN}Using CT ID ${BGN}$NEXTID${CL}"
|
|
||||||
CT_ID=$NEXTID
|
|
||||||
echo -e "${DGN}Using CT Name ${BGN}$NSAPP${CL}"
|
|
||||||
HN=$NSAPP
|
|
||||||
echo -e "${DGN}Using Disk Size ${BGN}3${CL}${DGN}GB${CL}"
|
|
||||||
DISK_SIZE="3"
|
|
||||||
echo -e "${DGN}Using ${BGN}1${CL}${DGN}vCPU${CL}"
|
|
||||||
CORE_COUNT="1"
|
|
||||||
echo -e "${DGN}Using ${BGN}1024${CL}${DGN}MiB RAM${CL}"
|
|
||||||
RAM_SIZE="1024"
|
|
||||||
echo -e "${DGN}Using Bridge ${BGN}vmbr0${CL}"
|
|
||||||
BRG="vmbr0"
|
|
||||||
echo -e "${DGN}Using Static IP Address ${BGN}DHCP${CL}"
|
|
||||||
NET=dhcp
|
|
||||||
echo -e "${DGN}Using Gateway Address ${BGN}NONE${CL}"
|
|
||||||
GATE=""
|
|
||||||
echo -e "${DGN}Using VLAN Tag ${BGN}NONE${CL}"
|
|
||||||
VLAN=""
|
|
||||||
}
|
|
||||||
|
|
||||||
function advanced_settings() {
|
|
||||||
clear
|
|
||||||
header_info
|
|
||||||
echo -e "${RD}Using Advanced Settings${CL}"
|
|
||||||
echo -e "${YW}Type Privileged, or Press [ENTER] for Default: Unprivileged (${RD}NO DEVICE PASSTHROUGH${CL}${YW})"
|
|
||||||
read CT_TYPE1
|
|
||||||
if [ -z $CT_TYPE1 ]; then CT_TYPE1="Unprivileged" CT_TYPE="1";
|
|
||||||
echo -en "${DGN}Set CT Type ${BL}$CT_TYPE1${CL}"
|
|
||||||
else
|
|
||||||
CT_TYPE1="Privileged"
|
|
||||||
CT_TYPE="0"
|
|
||||||
echo -en "${DGN}Set CT Type ${BL}Privileged${CL}"
|
|
||||||
fi;
|
|
||||||
echo -e " ${CM}${CL} \r"
|
|
||||||
sleep 1
|
|
||||||
clear
|
|
||||||
header_info
|
|
||||||
echo -e "${RD}Using Advanced Settings${CL}"
|
|
||||||
echo -e "${DGN}Using CT Type ${BGN}$CT_TYPE1${CL}"
|
|
||||||
echo -e "${YW}Set Password, or Press [ENTER] for Default: Automatic Login "
|
|
||||||
read PW1
|
|
||||||
if [ -z $PW1 ]; then PW1="Automatic Login" PW=" ";
|
|
||||||
echo -en "${DGN}Set CT ${BL}$PW1${CL}"
|
|
||||||
else
|
|
||||||
PW="-password $PW1"
|
|
||||||
echo -en "${DGN}Set CT Password ${BL}$PW1${CL}"
|
|
||||||
fi;
|
|
||||||
echo -e " ${CM}${CL} \r"
|
|
||||||
sleep 1
|
|
||||||
clear
|
|
||||||
header_info
|
|
||||||
echo -e "${RD}Using Advanced Settings${CL}"
|
|
||||||
echo -e "${DGN}Using CT Type ${BGN}$CT_TYPE1${CL}"
|
|
||||||
echo -e "${DGN}Using CT Password ${BGN}$PW1${CL}"
|
|
||||||
echo -e "${YW}Enter the CT ID, or Press [ENTER] to automatically generate (${NEXTID}) "
|
|
||||||
read CT_ID
|
|
||||||
if [ -z $CT_ID ]; then CT_ID=$NEXTID; fi;
|
|
||||||
echo -en "${DGN}Set CT ID To ${BL}$CT_ID${CL}"
|
|
||||||
echo -e " ${CM}${CL} \r"
|
|
||||||
sleep 1
|
|
||||||
clear
|
|
||||||
header_info
|
|
||||||
echo -e "${RD}Using Advanced Settings${CL}"
|
|
||||||
echo -e "${DGN}Using CT Type ${BGN}$CT_TYPE1${CL}"
|
|
||||||
echo -e "${DGN}Using CT Password ${BGN}$PW1${CL}"
|
|
||||||
echo -e "${DGN}Using CT ID ${BGN}$CT_ID${CL}"
|
|
||||||
echo -e "${YW}Enter CT Name (no-spaces), or Press [ENTER] for Default: $NSAPP "
|
|
||||||
read CT_NAME
|
|
||||||
if [ -z $CT_NAME ]; then
|
|
||||||
HN=$NSAPP
|
|
||||||
else
|
|
||||||
HN=$(echo ${CT_NAME,,} | tr -d ' ')
|
|
||||||
fi
|
|
||||||
echo -en "${DGN}Set CT Name To ${BL}$HN${CL}"
|
|
||||||
echo -e " ${CM}${CL} \r"
|
|
||||||
sleep 1
|
|
||||||
clear
|
|
||||||
header_info
|
|
||||||
echo -e "${RD}Using Advanced Settings${CL}"
|
|
||||||
echo -e "${DGN}Using CT Type ${BGN}$CT_TYPE1${CL}"
|
|
||||||
echo -e "${DGN}Using CT Password ${BGN}$PW1${CL}"
|
|
||||||
echo -e "${DGN}Using CT ID ${BGN}$CT_ID${CL}"
|
|
||||||
echo -e "${DGN}Using CT Name ${BGN}$HN${CL}"
|
|
||||||
echo -e "${YW}Enter a Disk Size, or Press [ENTER] for Default: 3 "
|
|
||||||
read DISK_SIZE
|
|
||||||
if [ -z $DISK_SIZE ]; then DISK_SIZE="3"; fi;
|
|
||||||
if ! [[ $DISK_SIZE =~ $INTEGER ]] ; then echo "ERROR! DISK SIZE MUST HAVE INTEGER NUMBER!"; exit; fi;
|
|
||||||
echo -en "${DGN}Set Disk Size To ${BL}$DISK_SIZE${CL}${DGN}GB${CL}"
|
|
||||||
echo -e " ${CM}${CL} \r"
|
|
||||||
sleep 1
|
|
||||||
clear
|
|
||||||
header_info
|
|
||||||
echo -e "${RD}Using Advanced Settings${CL}"
|
|
||||||
echo -e "${DGN}Using CT Type ${BGN}$CT_TYPE1${CL}"
|
|
||||||
echo -e "${DGN}Using CT Password ${BGN}$PW1${CL}"
|
|
||||||
echo -e "${DGN}Using CT ID ${BGN}$CT_ID${CL}"
|
|
||||||
echo -e "${DGN}Using CT Name ${BGN}$HN${CL}"
|
|
||||||
echo -e "${DGN}Using Disk Size ${BGN}$DISK_SIZE${CL}${DGN}GB${CL}"
|
|
||||||
echo -e "${YW}Allocate CPU cores, or Press [ENTER] for Default: 1 "
|
|
||||||
read CORE_COUNT
|
|
||||||
if [ -z $CORE_COUNT ]; then CORE_COUNT="1"; fi;
|
|
||||||
echo -en "${DGN}Set Cores To ${BL}$CORE_COUNT${CL}${DGN}vCPU${CL}"
|
|
||||||
echo -e " ${CM}${CL} \r"
|
|
||||||
sleep 1
|
|
||||||
clear
|
|
||||||
header_info
|
|
||||||
echo -e "${RD}Using Advanced Settings${CL}"
|
|
||||||
echo -e "${DGN}Using CT Type ${BGN}$CT_TYPE1${CL}"
|
|
||||||
echo -e "${DGN}Using CT Password ${BGN}$PW1${CL}"
|
|
||||||
echo -e "${DGN}Using CT ID ${BGN}$CT_ID${CL}"
|
|
||||||
echo -e "${DGN}Using CT Name ${BGN}$HN${CL}"
|
|
||||||
echo -e "${DGN}Using Disk Size ${BGN}$DISK_SIZE${CL}${DGN}GB${CL}"
|
|
||||||
echo -e "${DGN}Using ${BGN}${CORE_COUNT}${CL}${DGN}vCPU${CL}"
|
|
||||||
echo -e "${YW}Allocate RAM in MiB, or Press [ENTER] for Default: 1024 "
|
|
||||||
read RAM_SIZE
|
|
||||||
if [ -z $RAM_SIZE ]; then RAM_SIZE="1024"; fi;
|
|
||||||
echo -en "${DGN}Set RAM To ${BL}$RAM_SIZE${CL}${DGN}MiB RAM${CL}"
|
|
||||||
echo -e " ${CM}${CL} \n"
|
|
||||||
sleep 1
|
|
||||||
clear
|
|
||||||
header_info
|
|
||||||
echo -e "${RD}Using Advanced Settings${CL}"
|
|
||||||
echo -e "${DGN}Using CT Type ${BGN}$CT_TYPE1${CL}"
|
|
||||||
echo -e "${DGN}Using CT Password ${BGN}$PW1${CL}"
|
|
||||||
echo -e "${DGN}Using CT ID ${BGN}$CT_ID${CL}"
|
|
||||||
echo -e "${DGN}Using CT Name ${BGN}$HN${CL}"
|
|
||||||
echo -e "${DGN}Using Disk Size ${BGN}$DISK_SIZE${CL}${DGN}GB${CL}"
|
|
||||||
echo -e "${DGN}Using ${BGN}${CORE_COUNT}${CL}${DGN}vCPU${CL}"
|
|
||||||
echo -e "${DGN}Using ${BGN}${RAM_SIZE}${CL}${DGN}MiB RAM${CL}"
|
|
||||||
echo -e "${YW}Enter a Bridge, or Press [ENTER] for Default: vmbr0 "
|
|
||||||
read BRG
|
|
||||||
if [ -z $BRG ]; then BRG="vmbr0"; fi;
|
|
||||||
echo -en "${DGN}Set Bridge To ${BL}$BRG${CL}"
|
|
||||||
echo -e " ${CM}${CL} \n"
|
|
||||||
sleep 1
|
|
||||||
clear
|
|
||||||
header_info
|
|
||||||
echo -e "${RD}Using Advanced Settings${CL}"
|
|
||||||
echo -e "${DGN}Using CT Type ${BGN}$CT_TYPE1${CL}"
|
|
||||||
echo -e "${DGN}Using CT Password ${BGN}$PW1${CL}"
|
|
||||||
echo -e "${DGN}Using CT ID ${BGN}$CT_ID${CL}"
|
|
||||||
echo -e "${DGN}Using CT Name ${BGN}$HN${CL}"
|
|
||||||
echo -e "${DGN}Using Disk Size ${BGN}$DISK_SIZE${CL}${DGN}GB${CL}"
|
|
||||||
echo -e "${DGN}Using ${BGN}${CORE_COUNT}${CL}${DGN}vCPU${CL}"
|
|
||||||
echo -e "${DGN}Using ${BGN}${RAM_SIZE}${CL}${DGN}MiB RAM${CL}"
|
|
||||||
echo -e "${DGN}Using Bridge ${BGN}${BRG}${CL}"
|
|
||||||
echo -e "${YW}Enter a Static IPv4 CIDR Address, or Press [ENTER] for Default: DHCP "
|
|
||||||
read NET
|
|
||||||
if [ -z $NET ]; then NET="dhcp"; fi;
|
|
||||||
echo -en "${DGN}Set Static IP Address To ${BL}$NET${CL}"
|
|
||||||
echo -e " ${CM}${CL} \n"
|
|
||||||
sleep 1
|
|
||||||
clear
|
|
||||||
header_info
|
|
||||||
echo -e "${RD}Using Advanced Settings${CL}"
|
|
||||||
echo -e "${DGN}Using CT Type ${BGN}$CT_TYPE1${CL}"
|
|
||||||
echo -e "${DGN}Using CT Password ${BGN}$PW1${CL}"
|
|
||||||
echo -e "${DGN}Using CT ID ${BGN}$CT_ID${CL}"
|
|
||||||
echo -e "${DGN}Using CT Name ${BGN}$HN${CL}"
|
|
||||||
echo -e "${DGN}Using Disk Size ${BGN}$DISK_SIZE${CL}${DGN}GB${CL}"
|
|
||||||
echo -e "${DGN}Using ${BGN}${CORE_COUNT}${CL}${DGN}vCPU${CL}"
|
|
||||||
echo -e "${DGN}Using ${BGN}${RAM_SIZE}${CL}${DGN}MiB RAM${CL}"
|
|
||||||
echo -e "${DGN}Using Bridge ${BGN}${BRG}${CL}"
|
|
||||||
echo -e "${DGN}Using Static IP Address ${BGN}$NET${CL}"
|
|
||||||
echo -e "${YW}Enter a Gateway IP (mandatory if static IP is used), or Press [ENTER] for Default: NONE "
|
|
||||||
read GATE1
|
|
||||||
if [ -z $GATE1 ]; then GATE1="NONE" GATE="";
|
|
||||||
echo -en "${DGN}Set Gateway IP To ${BL}$GATE1${CL}"
|
|
||||||
else
|
|
||||||
GATE=",gw=$GATE1"
|
|
||||||
echo -en "${DGN}Set Gateway IP To ${BL}$GATE1${CL}"
|
|
||||||
fi;
|
|
||||||
echo -e " ${CM}${CL} \n"
|
|
||||||
sleep 1
|
|
||||||
clear
|
|
||||||
header_info
|
|
||||||
|
|
||||||
echo -e "${RD}Using Advanced Settings${CL}"
|
|
||||||
echo -e "${DGN}Using CT Type ${BGN}$CT_TYPE1${CL}"
|
|
||||||
echo -e "${DGN}Using CT Password ${BGN}$PW1${CL}"
|
|
||||||
echo -e "${DGN}Using CT ID ${BGN}$CT_ID${CL}"
|
|
||||||
echo -e "${DGN}Using CT Name ${BGN}$HN${CL}"
|
|
||||||
echo -e "${DGN}Using Disk Size ${BGN}$DISK_SIZE${CL}${DGN}GB${CL}"
|
|
||||||
echo -e "${DGN}Using ${BGN}${CORE_COUNT}${CL}${DGN}vCPU${CL}"
|
|
||||||
echo -e "${DGN}Using ${BGN}${RAM_SIZE}${CL}${DGN}MiB RAM${CL}"
|
|
||||||
echo -e "${DGN}Using Bridge ${BGN}${BRG}${CL}"
|
|
||||||
echo -e "${DGN}Using Static IP Address ${BGN}$NET${CL}"
|
|
||||||
echo -e "${DGN}Using Gateway IP Address ${BGN}$GATE1${CL}"
|
|
||||||
echo -e "${YW}Enter a VLAN Tag, or Press [ENTER] for Default: NONE "
|
|
||||||
read VLAN1
|
|
||||||
if [ -z $VLAN1 ]; then VLAN1="NONE" VLAN="";
|
|
||||||
echo -en "${DGN}Set VLAN Tag To ${BL}$VLAN1${CL}"
|
|
||||||
else
|
|
||||||
VLAN=",tag=$VLAN1"
|
|
||||||
echo -en "${DGN}Set VLAN Tag To ${BL}$VLAN1${CL}"
|
|
||||||
fi;
|
|
||||||
echo -e " ${CM}${CL} \n"
|
|
||||||
sleep 1
|
|
||||||
clear
|
|
||||||
header_info
|
|
||||||
echo -e "${RD}Using Advanced Settings${CL}"
|
|
||||||
echo -e "${DGN}Using CT Type ${BGN}$CT_TYPE1${CL}"
|
|
||||||
echo -e "${DGN}Using CT Password ${BGN}$PW1${CL}"
|
|
||||||
echo -e "${DGN}Using CT ID ${BGN}$CT_ID${CL}"
|
|
||||||
echo -e "${DGN}Using CT Name ${BGN}$HN${CL}"
|
|
||||||
echo -e "${DGN}Using Disk Size ${BGN}$DISK_SIZE${CL}${DGN}GB${CL}"
|
|
||||||
echo -e "${DGN}Using ${BGN}${CORE_COUNT}${CL}${DGN}vCPU${CL}"
|
|
||||||
echo -e "${DGN}Using ${BGN}${RAM_SIZE}${CL}${DGN}MiB RAM${CL}"
|
|
||||||
echo -e "${DGN}Using Bridge ${BGN}${BRG}${CL}"
|
|
||||||
echo -e "${DGN}Using Static IP Address ${BGN}$NET${CL}"
|
|
||||||
echo -e "${DGN}Using Gateway IP Address ${BGN}$GATE1${CL}"
|
|
||||||
echo -e "${DGN}Using VLAN Tag ${BGN}$VLAN1${CL}"
|
|
||||||
|
|
||||||
read -p "Are these settings correct(y/n)? " -n 1 -r
|
|
||||||
echo
|
|
||||||
if [[ ! $REPLY =~ ^[Yy]$ ]]
|
|
||||||
then
|
|
||||||
advanced_settings
|
|
||||||
fi
|
|
||||||
}
|
|
||||||
|
|
||||||
function start_script() {
|
|
||||||
echo -e "${YW}Type Advanced, or Press [ENTER] for Default Settings "
|
|
||||||
read SETTINGS
|
|
||||||
if [ -z $SETTINGS ]; then default_settings;
|
|
||||||
else
|
|
||||||
advanced_settings
|
|
||||||
fi;
|
|
||||||
}
|
|
||||||
|
|
||||||
start_script
|
|
||||||
|
|
||||||
if [ "$CT_TYPE" == "1" ]; then
|
|
||||||
FEATURES="nesting=1,keyctl=1"
|
|
||||||
else
|
|
||||||
FEATURES="nesting=1"
|
|
||||||
fi
|
|
||||||
|
|
||||||
TEMP_DIR=$(mktemp -d)
|
|
||||||
pushd $TEMP_DIR >/dev/null
|
|
||||||
|
|
||||||
export CTID=$CT_ID
|
|
||||||
export PCT_OSTYPE=debian
|
|
||||||
export PCT_OSVERSION=11
|
|
||||||
export PCT_DISK_SIZE=$DISK_SIZE
|
|
||||||
export PCT_OPTIONS="
|
|
||||||
-features $FEATURES
|
|
||||||
-hostname $HN
|
|
||||||
-net0 name=eth0,bridge=$BRG,ip=$NET$GATE$VLAN
|
|
||||||
-onboot 1
|
|
||||||
-cores $CORE_COUNT
|
|
||||||
-memory $RAM_SIZE
|
|
||||||
-unprivileged $CT_TYPE
|
|
||||||
$PW
|
|
||||||
"
|
|
||||||
bash -c "$(wget -qLO - https://raw.githubusercontent.com/tteck/Proxmox/main/ct/create_lxc.sh)" || exit
|
|
||||||
|
|
||||||
msg_info "Starting LXC Container"
|
|
||||||
pct start $CTID
|
|
||||||
msg_ok "Started LXC Container"
|
|
||||||
|
|
||||||
lxc-attach -n $CTID -- bash -c "$(wget -qLO - https://raw.githubusercontent.com/tteck/Proxmox/main/setup/nginx-proxy-manager-install.sh)" || exit
|
|
||||||
|
|
||||||
IP=$(pct exec $CTID ip a s dev eth0 | sed -n '/inet / s/\// /p' | awk '{print $2}')
|
|
||||||
|
|
||||||
pct set $CTID -description "# ${APP} LXC
|
|
||||||
### https://github.com/tteck/Proxmox"
|
|
||||||
|
|
||||||
msg_ok "Completed Successfully!\n"
|
|
||||||
echo -e "${APP} should be reachable by going to the following URL.
|
|
||||||
${BL}http://${IP}:81${CL} \n"
|
|
|
@ -310,7 +310,7 @@ bash -c "$(wget -qLO - https://raw.githubusercontent.com/tteck/Proxmox/main/ct/c
|
||||||
msg_info "Starting LXC Container"
|
msg_info "Starting LXC Container"
|
||||||
pct start $CTID
|
pct start $CTID
|
||||||
msg_ok "Started LXC Container"
|
msg_ok "Started LXC Container"
|
||||||
lxc-attach -n $CTID -- bash -c "$(wget -qLO - https://raw.githubusercontent.com/tteck/Proxmox/main/setup/nginx-proxy-manager-install.sh)" || exit
|
lxc-attach -n $CTID -- bash -c "$(wget -qLO - https://raw.githubusercontent.com/tteck/Proxmox/main/install/nginx-proxy-manager-install.sh)" || exit
|
||||||
IP=$(pct exec $CTID ip a s dev eth0 | sed -n '/inet / s/\// /p' | awk '{print $2}')
|
IP=$(pct exec $CTID ip a s dev eth0 | sed -n '/inet / s/\// /p' | awk '{print $2}')
|
||||||
pct set $CTID -description "# ${APP} LXC
|
pct set $CTID -description "# ${APP} LXC
|
||||||
### https://tteck.github.io/Proxmox/
|
### https://tteck.github.io/Proxmox/
|
||||||
|
|
258
ct/nocodb-v2.sh
258
ct/nocodb-v2.sh
|
@ -1,258 +0,0 @@
|
||||||
#!/usr/bin/env bash
|
|
||||||
YW=`echo "\033[33m"`
|
|
||||||
BL=`echo "\033[36m"`
|
|
||||||
RD=`echo "\033[01;31m"`
|
|
||||||
CM='\xE2\x9C\x94\033'
|
|
||||||
GN=`echo "\033[1;92m"`
|
|
||||||
CL=`echo "\033[m"`
|
|
||||||
APP="NocoDB"
|
|
||||||
HN=$(echo ${APP,,} | tr -d ' ')
|
|
||||||
while true; do
|
|
||||||
read -p "This will create a New ${APP} LXC. Proceed(y/n)?" yn
|
|
||||||
case $yn in
|
|
||||||
[Yy]* ) break;;
|
|
||||||
[Nn]* ) exit;;
|
|
||||||
* ) echo "Please answer yes or no.";;
|
|
||||||
esac
|
|
||||||
done
|
|
||||||
clear
|
|
||||||
function header_info {
|
|
||||||
echo -e "${YW}
|
|
||||||
_ _ _____ ____
|
|
||||||
| \ | | | __ \| _ \
|
|
||||||
| \| | ___ ___ ___ | | | | |_) |
|
|
||||||
| |/ _ \ / __/ _ \| | | | _ <
|
|
||||||
| |\ | (_) | (_| (_) | |__| | |_) |
|
|
||||||
|_| \_|\___/ \___\___/|_____/|____/
|
|
||||||
${CL}"
|
|
||||||
}
|
|
||||||
|
|
||||||
header_info
|
|
||||||
show_menu(){
|
|
||||||
printf " ${YW} 1)${YW} Privileged ${CL}\n"
|
|
||||||
printf " ${YW} 2)${GN} Unprivileged ${CL}\n"
|
|
||||||
|
|
||||||
printf "Please choose a Install Method and hit enter or ${RD}x${CL} to exit."
|
|
||||||
read opt
|
|
||||||
}
|
|
||||||
|
|
||||||
option_picked(){
|
|
||||||
message1=${@:-"${CL}Error: No message passed"}
|
|
||||||
printf " ${YW}${message1}${CL}\n"
|
|
||||||
}
|
|
||||||
show_menu
|
|
||||||
while [ "$opt" != " " ]
|
|
||||||
do
|
|
||||||
case $opt in
|
|
||||||
1) clear;
|
|
||||||
header_info;
|
|
||||||
option_picked "Using Privileged Install";
|
|
||||||
IM=0
|
|
||||||
break;
|
|
||||||
;;
|
|
||||||
2) clear;
|
|
||||||
header_info;
|
|
||||||
option_picked "Using Unprivileged Install";
|
|
||||||
IM=1
|
|
||||||
break;
|
|
||||||
;;
|
|
||||||
|
|
||||||
x)exit;
|
|
||||||
;;
|
|
||||||
\n)exit;
|
|
||||||
;;
|
|
||||||
*)clear;
|
|
||||||
option_picked "Please choose a Install Method from the menu";
|
|
||||||
show_menu;
|
|
||||||
;;
|
|
||||||
esac
|
|
||||||
done
|
|
||||||
show_menu2(){
|
|
||||||
printf " ${YW} 1)${GN} Use Automatic Login ${CL}\n"
|
|
||||||
printf " ${YW} 2)${GN} Use Password (changeme) ${CL}\n"
|
|
||||||
|
|
||||||
printf "Please choose a Password Type and hit enter or ${RD}x${CL} to exit."
|
|
||||||
read opt
|
|
||||||
}
|
|
||||||
|
|
||||||
option_picked(){
|
|
||||||
message2=${@:-"${CL}Error: No message passed"}
|
|
||||||
printf " ${YW}${message1}${CL}\n"
|
|
||||||
printf " ${YW}${message2}${CL}\n"
|
|
||||||
}
|
|
||||||
show_menu2
|
|
||||||
while [ "$opt" != " " ]
|
|
||||||
do
|
|
||||||
case $opt in
|
|
||||||
1) clear;
|
|
||||||
header_info;
|
|
||||||
option_picked "Using Automatic Login";
|
|
||||||
PW=" "
|
|
||||||
break;
|
|
||||||
;;
|
|
||||||
2) clear;
|
|
||||||
header_info;
|
|
||||||
option_picked "Using Password (changeme)";
|
|
||||||
PW="-password changeme"
|
|
||||||
break;
|
|
||||||
;;
|
|
||||||
|
|
||||||
x)exit;
|
|
||||||
;;
|
|
||||||
\n)exit;
|
|
||||||
;;
|
|
||||||
*)clear;
|
|
||||||
option_picked "Please choose a Password Type from the menu";
|
|
||||||
show_menu2;
|
|
||||||
;;
|
|
||||||
esac
|
|
||||||
done
|
|
||||||
show_menu3(){
|
|
||||||
printf " ${YW} 1)${GN} Automatic DHCP ${CL}\n"
|
|
||||||
printf " ${YW} 2)${GN} Manual DHCP ${CL}\n"
|
|
||||||
|
|
||||||
printf "Please choose a DHCP Type and hit enter or ${RD}x${CL} to exit."
|
|
||||||
read opt
|
|
||||||
}
|
|
||||||
|
|
||||||
option_picked(){
|
|
||||||
message3=${@:-"${CL}Error: No message passed"}
|
|
||||||
printf " ${YW}${message1}${CL}\n"
|
|
||||||
printf " ${YW}${message2}${CL}\n"
|
|
||||||
printf " ${YW}${message3}${CL}\n"
|
|
||||||
}
|
|
||||||
show_menu3
|
|
||||||
while [ "$opt" != " " ]
|
|
||||||
do
|
|
||||||
case $opt in
|
|
||||||
1) clear;
|
|
||||||
header_info;
|
|
||||||
option_picked "Using Automatic DHCP";
|
|
||||||
DHCP=" "
|
|
||||||
break;
|
|
||||||
;;
|
|
||||||
2) clear;
|
|
||||||
header_info;
|
|
||||||
option_picked "Using Manual DHCP";
|
|
||||||
DHCP="1"
|
|
||||||
break;
|
|
||||||
;;
|
|
||||||
|
|
||||||
x)exit;
|
|
||||||
;;
|
|
||||||
\n)exit;
|
|
||||||
;;
|
|
||||||
*)clear;
|
|
||||||
option_picked "Please choose a DHCP Type from the menu";
|
|
||||||
show_menu3;
|
|
||||||
;;
|
|
||||||
esac
|
|
||||||
done
|
|
||||||
|
|
||||||
set -o errexit
|
|
||||||
set -o errtrace
|
|
||||||
set -o nounset
|
|
||||||
set -o pipefail
|
|
||||||
shopt -s expand_aliases
|
|
||||||
alias die='EXIT=$? LINE=$LINENO error_exit'
|
|
||||||
trap die ERR
|
|
||||||
trap cleanup EXIT
|
|
||||||
|
|
||||||
function error_exit() {
|
|
||||||
trap - ERR
|
|
||||||
local DEFAULT='Unknown failure occured.'
|
|
||||||
local REASON="\e[97m${1:-$DEFAULT}\e[39m"
|
|
||||||
local FLAG="\e[91m[ERROR] \e[93m$EXIT@$LINE"
|
|
||||||
msg "$FLAG $REASON"
|
|
||||||
[ ! -z ${CTID-} ] && cleanup_ctid
|
|
||||||
exit $EXIT
|
|
||||||
}
|
|
||||||
function warn() {
|
|
||||||
local REASON="\e[97m$1\e[39m"
|
|
||||||
local FLAG="\e[93m[WARNING]\e[39m"
|
|
||||||
msg "$FLAG $REASON"
|
|
||||||
}
|
|
||||||
function info() {
|
|
||||||
local REASON="$1"
|
|
||||||
local FLAG="\e[36m[INFO]\e[39m"
|
|
||||||
msg "$FLAG $REASON"
|
|
||||||
}
|
|
||||||
function msg() {
|
|
||||||
local TEXT="$1"
|
|
||||||
echo -e "$TEXT"
|
|
||||||
}
|
|
||||||
function cleanup_ctid() {
|
|
||||||
if $(pct status $CTID &>/dev/null); then
|
|
||||||
if [ "$(pct status $CTID | awk '{print $2}')" == "running" ]; then
|
|
||||||
pct stop $CTID
|
|
||||||
fi
|
|
||||||
pct destroy $CTID
|
|
||||||
elif [ "$(pvesm list $STORAGE --vmid $CTID)" != "" ]; then
|
|
||||||
pvesm free $ROOTFS
|
|
||||||
fi
|
|
||||||
}
|
|
||||||
function cleanup() {
|
|
||||||
popd >/dev/null
|
|
||||||
rm -rf $TEMP_DIR
|
|
||||||
}
|
|
||||||
if [ "$IM" == "1" ]; then
|
|
||||||
FEATURES="nesting=1,keyctl=1"
|
|
||||||
else
|
|
||||||
FEATURES="nesting=1"
|
|
||||||
fi
|
|
||||||
|
|
||||||
TEMP_DIR=$(mktemp -d)
|
|
||||||
pushd $TEMP_DIR >/dev/null
|
|
||||||
|
|
||||||
export CTID=$(pvesh get /cluster/nextid)
|
|
||||||
export PCT_OSTYPE=debian
|
|
||||||
export PCT_OSVERSION=11
|
|
||||||
export PCT_DISK_SIZE=4
|
|
||||||
export PCT_OPTIONS="
|
|
||||||
-features $FEATURES
|
|
||||||
-hostname $HN
|
|
||||||
-net0 name=eth0,bridge=vmbr0,ip=dhcp
|
|
||||||
-onboot 1
|
|
||||||
-cores 1
|
|
||||||
-memory 1024
|
|
||||||
-unprivileged ${IM}
|
|
||||||
${PW}
|
|
||||||
"
|
|
||||||
bash -c "$(wget -qLO - https://raw.githubusercontent.com/tteck/Proxmox/main/ct/create_lxc.sh)" || exit
|
|
||||||
|
|
||||||
STORAGE_TYPE=$(pvesm status -storage $(pct config $CTID | grep rootfs | awk -F ":" '{print $2}') | awk 'NR>1 {print $2}')
|
|
||||||
if [ "$STORAGE_TYPE" == "zfspool" ]; then
|
|
||||||
warn "Some applications may not work properly due to ZFS not supporting 'fallocate'."
|
|
||||||
fi
|
|
||||||
LXC_CONFIG=/etc/pve/lxc/${CTID}.conf
|
|
||||||
cat <<EOF >> $LXC_CONFIG
|
|
||||||
lxc.cgroup2.devices.allow: a
|
|
||||||
lxc.cap.drop:
|
|
||||||
EOF
|
|
||||||
if [ "$DHCP" == "1" ]; then
|
|
||||||
MAC=$(pct config $CTID \
|
|
||||||
| grep -i hwaddr \
|
|
||||||
| awk '{print substr($2, 31, length($3) 17 ) }') \
|
|
||||||
|
|
||||||
echo -e "MAC Address ${BL}$MAC${CL}"
|
|
||||||
|
|
||||||
dhcp_reservation(){
|
|
||||||
printf "Please set DHCP reservation and press Enter."
|
|
||||||
read
|
|
||||||
}
|
|
||||||
dhcp_reservation
|
|
||||||
fi
|
|
||||||
|
|
||||||
echo -en "${GN} Starting LXC Container... "
|
|
||||||
pct start $CTID
|
|
||||||
echo -e "${CM}${CL} \r"
|
|
||||||
|
|
||||||
alias lxc-cmd="lxc-attach -n $CTID --"
|
|
||||||
|
|
||||||
lxc-cmd bash -c "$(wget -qLO - https://raw.githubusercontent.com/tteck/Proxmox/main/setup/$HN-install.sh)" || exit
|
|
||||||
|
|
||||||
IP=$(pct exec $CTID ip a s dev eth0 | sed -n '/inet / s/\// /p' | awk '{print $2}')
|
|
||||||
|
|
||||||
echo -e "${GN}Successfully created ${APP} LXC to${CL} ${BL}$CTID${CL}.
|
|
||||||
${BL}${APP}${CL} should be reachable by going to the following URL.
|
|
||||||
${BL}http://${IP}:8080/dashboard${CL}\n"
|
|
356
ct/nocodb-v3.sh
356
ct/nocodb-v3.sh
|
@ -1,356 +0,0 @@
|
||||||
#!/usr/bin/env bash
|
|
||||||
echo -e "Loading..."
|
|
||||||
NEXTID=$(pvesh get /cluster/nextid)
|
|
||||||
INTEGER='^[0-9]+$'
|
|
||||||
YW=`echo "\033[33m"`
|
|
||||||
BL=`echo "\033[36m"`
|
|
||||||
RD=`echo "\033[01;31m"`
|
|
||||||
BGN=`echo "\033[4;92m"`
|
|
||||||
GN=`echo "\033[1;92m"`
|
|
||||||
DGN=`echo "\033[32m"`
|
|
||||||
CL=`echo "\033[m"`
|
|
||||||
BFR="\\r\\033[K"
|
|
||||||
HOLD="-"
|
|
||||||
CM="${GN}✓${CL}"
|
|
||||||
APP="NocoDB"
|
|
||||||
NSAPP=$(echo ${APP,,} | tr -d ' ')
|
|
||||||
set -o errexit
|
|
||||||
set -o errtrace
|
|
||||||
set -o nounset
|
|
||||||
set -o pipefail
|
|
||||||
shopt -s expand_aliases
|
|
||||||
alias die='EXIT=$? LINE=$LINENO error_exit'
|
|
||||||
trap die ERR
|
|
||||||
|
|
||||||
function error_exit() {
|
|
||||||
trap - ERR
|
|
||||||
local reason="Unknown failure occurred."
|
|
||||||
local msg="${1:-$reason}"
|
|
||||||
local flag="${RD}‼ ERROR ${CL}$EXIT@$LINE"
|
|
||||||
echo -e "$flag $msg" 1>&2
|
|
||||||
exit $EXIT
|
|
||||||
}
|
|
||||||
|
|
||||||
while true; do
|
|
||||||
clear
|
|
||||||
read -p "This will create a New ${APP} LXC. Proceed(y/n)?" yn
|
|
||||||
case $yn in
|
|
||||||
[Yy]* ) break;;
|
|
||||||
[Nn]* ) exit;;
|
|
||||||
* ) echo "Please answer yes or no.";;
|
|
||||||
esac
|
|
||||||
done
|
|
||||||
clear
|
|
||||||
function header_info {
|
|
||||||
echo -e "${YW}
|
|
||||||
_ _ _____ ____
|
|
||||||
| \ | | | __ \| _ \
|
|
||||||
| \| | ___ v3___ ___ | | | | |_) |
|
|
||||||
| |/ _ \ / __/ _ \| | | | _ <
|
|
||||||
| |\ | (_) | (_| (_) | |__| | |_) |
|
|
||||||
|_| \_|\___/ \___\___/|_____/|____/
|
|
||||||
${CL}"
|
|
||||||
}
|
|
||||||
|
|
||||||
header_info
|
|
||||||
|
|
||||||
function msg_info() {
|
|
||||||
local msg="$1"
|
|
||||||
echo -ne " ${HOLD} ${YW}${msg}..."
|
|
||||||
}
|
|
||||||
|
|
||||||
function msg_ok() {
|
|
||||||
local msg="$1"
|
|
||||||
echo -e "${BFR} ${CM} ${GN}${msg}${CL}"
|
|
||||||
}
|
|
||||||
|
|
||||||
function PVE_CHECK() {
|
|
||||||
PVE=$(pveversion | grep "pve-manager/7" | wc -l)
|
|
||||||
|
|
||||||
if [[ $PVE != 1 ]]; then
|
|
||||||
echo -e "${RD}This script requires Proxmox Virtual Environment 7.0 or greater${CL}"
|
|
||||||
echo -e "Exiting..."
|
|
||||||
sleep 2
|
|
||||||
exit
|
|
||||||
fi
|
|
||||||
}
|
|
||||||
|
|
||||||
function default_settings() {
|
|
||||||
clear
|
|
||||||
header_info
|
|
||||||
echo -e "${BL}Using Default Settings${CL}"
|
|
||||||
echo -e "${DGN}Using CT Type ${BGN}Unprivileged${CL} ${RD}NO DEVICE PASSTHROUGH${CL}"
|
|
||||||
CT_TYPE="1"
|
|
||||||
echo -e "${DGN}Using CT Password ${BGN}Automatic Login${CL}"
|
|
||||||
PW=" "
|
|
||||||
echo -e "${DGN}Using CT ID ${BGN}$NEXTID${CL}"
|
|
||||||
CT_ID=$NEXTID
|
|
||||||
echo -e "${DGN}Using CT Name ${BGN}$NSAPP${CL}"
|
|
||||||
HN=$NSAPP
|
|
||||||
echo -e "${DGN}Using Disk Size ${BGN}4${CL}${DGN}GB${CL}"
|
|
||||||
DISK_SIZE="4"
|
|
||||||
echo -e "${DGN}Using ${BGN}1${CL}${DGN}vCPU${CL}"
|
|
||||||
CORE_COUNT="1"
|
|
||||||
echo -e "${DGN}Using ${BGN}1024${CL}${DGN}MiB RAM${CL}"
|
|
||||||
RAM_SIZE="1024"
|
|
||||||
echo -e "${DGN}Using Bridge ${BGN}vmbr0${CL}"
|
|
||||||
BRG="vmbr0"
|
|
||||||
echo -e "${DGN}Using Static IP Address ${BGN}DHCP${CL}"
|
|
||||||
NET=dhcp
|
|
||||||
echo -e "${DGN}Using Gateway Address ${BGN}NONE${CL}"
|
|
||||||
GATE=""
|
|
||||||
echo -e "${DGN}Using VLAN Tag ${BGN}NONE${CL}"
|
|
||||||
VLAN=""
|
|
||||||
}
|
|
||||||
|
|
||||||
function advanced_settings() {
|
|
||||||
clear
|
|
||||||
header_info
|
|
||||||
echo -e "${RD}Using Advanced Settings${CL}"
|
|
||||||
echo -e "${YW}Type Privileged, or Press [ENTER] for Default: Unprivileged (${RD}NO DEVICE PASSTHROUGH${CL}${YW})"
|
|
||||||
read CT_TYPE1
|
|
||||||
if [ -z $CT_TYPE1 ]; then CT_TYPE1="Unprivileged" CT_TYPE="1";
|
|
||||||
echo -en "${DGN}Set CT Type ${BL}$CT_TYPE1${CL}"
|
|
||||||
else
|
|
||||||
CT_TYPE1="Privileged"
|
|
||||||
CT_TYPE="0"
|
|
||||||
echo -en "${DGN}Set CT Type ${BL}Privileged${CL}"
|
|
||||||
fi;
|
|
||||||
echo -e " ${CM}${CL} \r"
|
|
||||||
sleep 1
|
|
||||||
clear
|
|
||||||
header_info
|
|
||||||
echo -e "${RD}Using Advanced Settings${CL}"
|
|
||||||
echo -e "${DGN}Using CT Type ${BGN}$CT_TYPE1${CL}"
|
|
||||||
echo -e "${YW}Set Password, or Press [ENTER] for Default: Automatic Login "
|
|
||||||
read PW1
|
|
||||||
if [ -z $PW1 ]; then PW1="Automatic Login" PW=" ";
|
|
||||||
echo -en "${DGN}Set CT ${BL}$PW1${CL}"
|
|
||||||
else
|
|
||||||
PW="-password $PW1"
|
|
||||||
echo -en "${DGN}Set CT Password ${BL}$PW1${CL}"
|
|
||||||
fi;
|
|
||||||
echo -e " ${CM}${CL} \r"
|
|
||||||
sleep 1
|
|
||||||
clear
|
|
||||||
header_info
|
|
||||||
echo -e "${RD}Using Advanced Settings${CL}"
|
|
||||||
echo -e "${DGN}Using CT Type ${BGN}$CT_TYPE1${CL}"
|
|
||||||
echo -e "${DGN}Using CT Password ${BGN}$PW1${CL}"
|
|
||||||
echo -e "${YW}Enter the CT ID, or Press [ENTER] to automatically generate (${NEXTID}) "
|
|
||||||
read CT_ID
|
|
||||||
if [ -z $CT_ID ]; then CT_ID=$NEXTID; fi;
|
|
||||||
echo -en "${DGN}Set CT ID To ${BL}$CT_ID${CL}"
|
|
||||||
echo -e " ${CM}${CL} \r"
|
|
||||||
sleep 1
|
|
||||||
clear
|
|
||||||
header_info
|
|
||||||
echo -e "${RD}Using Advanced Settings${CL}"
|
|
||||||
echo -e "${DGN}Using CT Type ${BGN}$CT_TYPE1${CL}"
|
|
||||||
echo -e "${DGN}Using CT Password ${BGN}$PW1${CL}"
|
|
||||||
echo -e "${DGN}Using CT ID ${BGN}$CT_ID${CL}"
|
|
||||||
echo -e "${YW}Enter CT Name (no-spaces), or Press [ENTER] for Default: $NSAPP "
|
|
||||||
read CT_NAME
|
|
||||||
if [ -z $CT_NAME ]; then
|
|
||||||
HN=$NSAPP
|
|
||||||
else
|
|
||||||
HN=$(echo ${CT_NAME,,} | tr -d ' ')
|
|
||||||
fi
|
|
||||||
echo -en "${DGN}Set CT Name To ${BL}$HN${CL}"
|
|
||||||
echo -e " ${CM}${CL} \r"
|
|
||||||
sleep 1
|
|
||||||
clear
|
|
||||||
header_info
|
|
||||||
echo -e "${RD}Using Advanced Settings${CL}"
|
|
||||||
echo -e "${DGN}Using CT Type ${BGN}$CT_TYPE1${CL}"
|
|
||||||
echo -e "${DGN}Using CT Password ${BGN}$PW1${CL}"
|
|
||||||
echo -e "${DGN}Using CT ID ${BGN}$CT_ID${CL}"
|
|
||||||
echo -e "${DGN}Using CT Name ${BGN}$HN${CL}"
|
|
||||||
echo -e "${YW}Enter a Disk Size, or Press [ENTER] for Default: 4 "
|
|
||||||
read DISK_SIZE
|
|
||||||
if [ -z $DISK_SIZE ]; then DISK_SIZE="4"; fi;
|
|
||||||
if ! [[ $DISK_SIZE =~ $INTEGER ]] ; then echo "ERROR! DISK SIZE MUST HAVE INTEGER NUMBER!"; exit; fi;
|
|
||||||
echo -en "${DGN}Set Disk Size To ${BL}$DISK_SIZE${CL}${DGN}GB${CL}"
|
|
||||||
echo -e " ${CM}${CL} \r"
|
|
||||||
sleep 1
|
|
||||||
clear
|
|
||||||
header_info
|
|
||||||
echo -e "${RD}Using Advanced Settings${CL}"
|
|
||||||
echo -e "${DGN}Using CT Type ${BGN}$CT_TYPE1${CL}"
|
|
||||||
echo -e "${DGN}Using CT Password ${BGN}$PW1${CL}"
|
|
||||||
echo -e "${DGN}Using CT ID ${BGN}$CT_ID${CL}"
|
|
||||||
echo -e "${DGN}Using CT Name ${BGN}$HN${CL}"
|
|
||||||
echo -e "${DGN}Using Disk Size ${BGN}$DISK_SIZE${CL}${DGN}GB${CL}"
|
|
||||||
echo -e "${YW}Allocate CPU cores, or Press [ENTER] for Default: 1 "
|
|
||||||
read CORE_COUNT
|
|
||||||
if [ -z $CORE_COUNT ]; then CORE_COUNT="1"; fi;
|
|
||||||
echo -en "${DGN}Set Cores To ${BL}$CORE_COUNT${CL}${DGN}vCPU${CL}"
|
|
||||||
echo -e " ${CM}${CL} \r"
|
|
||||||
sleep 1
|
|
||||||
clear
|
|
||||||
header_info
|
|
||||||
echo -e "${RD}Using Advanced Settings${CL}"
|
|
||||||
echo -e "${DGN}Using CT Type ${BGN}$CT_TYPE1${CL}"
|
|
||||||
echo -e "${DGN}Using CT Password ${BGN}$PW1${CL}"
|
|
||||||
echo -e "${DGN}Using CT ID ${BGN}$CT_ID${CL}"
|
|
||||||
echo -e "${DGN}Using CT Name ${BGN}$HN${CL}"
|
|
||||||
echo -e "${DGN}Using Disk Size ${BGN}$DISK_SIZE${CL}${DGN}GB${CL}"
|
|
||||||
echo -e "${DGN}Using ${BGN}${CORE_COUNT}${CL}${DGN}vCPU${CL}"
|
|
||||||
echo -e "${YW}Allocate RAM in MiB, or Press [ENTER] for Default: 1024 "
|
|
||||||
read RAM_SIZE
|
|
||||||
if [ -z $RAM_SIZE ]; then RAM_SIZE="1024"; fi;
|
|
||||||
echo -en "${DGN}Set RAM To ${BL}$RAM_SIZE${CL}${DGN}MiB RAM${CL}"
|
|
||||||
echo -e " ${CM}${CL} \n"
|
|
||||||
sleep 1
|
|
||||||
clear
|
|
||||||
header_info
|
|
||||||
echo -e "${RD}Using Advanced Settings${CL}"
|
|
||||||
echo -e "${DGN}Using CT Type ${BGN}$CT_TYPE1${CL}"
|
|
||||||
echo -e "${DGN}Using CT Password ${BGN}$PW1${CL}"
|
|
||||||
echo -e "${DGN}Using CT ID ${BGN}$CT_ID${CL}"
|
|
||||||
echo -e "${DGN}Using CT Name ${BGN}$HN${CL}"
|
|
||||||
echo -e "${DGN}Using Disk Size ${BGN}$DISK_SIZE${CL}${DGN}GB${CL}"
|
|
||||||
echo -e "${DGN}Using ${BGN}${CORE_COUNT}${CL}${DGN}vCPU${CL}"
|
|
||||||
echo -e "${DGN}Using ${BGN}${RAM_SIZE}${CL}${DGN}MiB RAM${CL}"
|
|
||||||
echo -e "${YW}Enter a Bridge, or Press [ENTER] for Default: vmbr0 "
|
|
||||||
read BRG
|
|
||||||
if [ -z $BRG ]; then BRG="vmbr0"; fi;
|
|
||||||
echo -en "${DGN}Set Bridge To ${BL}$BRG${CL}"
|
|
||||||
echo -e " ${CM}${CL} \n"
|
|
||||||
sleep 1
|
|
||||||
clear
|
|
||||||
header_info
|
|
||||||
echo -e "${RD}Using Advanced Settings${CL}"
|
|
||||||
echo -e "${DGN}Using CT Type ${BGN}$CT_TYPE1${CL}"
|
|
||||||
echo -e "${DGN}Using CT Password ${BGN}$PW1${CL}"
|
|
||||||
echo -e "${DGN}Using CT ID ${BGN}$CT_ID${CL}"
|
|
||||||
echo -e "${DGN}Using CT Name ${BGN}$HN${CL}"
|
|
||||||
echo -e "${DGN}Using Disk Size ${BGN}$DISK_SIZE${CL}${DGN}GB${CL}"
|
|
||||||
echo -e "${DGN}Using ${BGN}${CORE_COUNT}${CL}${DGN}vCPU${CL}"
|
|
||||||
echo -e "${DGN}Using ${BGN}${RAM_SIZE}${CL}${DGN}MiB RAM${CL}"
|
|
||||||
echo -e "${DGN}Using Bridge ${BGN}${BRG}${CL}"
|
|
||||||
echo -e "${YW}Enter a Static IPv4 CIDR Address, or Press [ENTER] for Default: DHCP "
|
|
||||||
read NET
|
|
||||||
if [ -z $NET ]; then NET="dhcp"; fi;
|
|
||||||
echo -en "${DGN}Set Static IP Address To ${BL}$NET${CL}"
|
|
||||||
echo -e " ${CM}${CL} \n"
|
|
||||||
sleep 1
|
|
||||||
clear
|
|
||||||
header_info
|
|
||||||
echo -e "${RD}Using Advanced Settings${CL}"
|
|
||||||
echo -e "${DGN}Using CT Type ${BGN}$CT_TYPE1${CL}"
|
|
||||||
echo -e "${DGN}Using CT Password ${BGN}$PW1${CL}"
|
|
||||||
echo -e "${DGN}Using CT ID ${BGN}$CT_ID${CL}"
|
|
||||||
echo -e "${DGN}Using CT Name ${BGN}$HN${CL}"
|
|
||||||
echo -e "${DGN}Using Disk Size ${BGN}$DISK_SIZE${CL}${DGN}GB${CL}"
|
|
||||||
echo -e "${DGN}Using ${BGN}${CORE_COUNT}${CL}${DGN}vCPU${CL}"
|
|
||||||
echo -e "${DGN}Using ${BGN}${RAM_SIZE}${CL}${DGN}MiB RAM${CL}"
|
|
||||||
echo -e "${DGN}Using Bridge ${BGN}${BRG}${CL}"
|
|
||||||
echo -e "${DGN}Using Static IP Address ${BGN}$NET${CL}"
|
|
||||||
echo -e "${YW}Enter a Gateway IP (mandatory if static IP is used), or Press [ENTER] for Default: NONE "
|
|
||||||
read GATE1
|
|
||||||
if [ -z $GATE1 ]; then GATE1="NONE" GATE="";
|
|
||||||
echo -en "${DGN}Set Gateway IP To ${BL}$GATE1${CL}"
|
|
||||||
else
|
|
||||||
GATE=",gw=$GATE1"
|
|
||||||
echo -en "${DGN}Set Gateway IP To ${BL}$GATE1${CL}"
|
|
||||||
fi;
|
|
||||||
echo -e " ${CM}${CL} \n"
|
|
||||||
sleep 1
|
|
||||||
clear
|
|
||||||
header_info
|
|
||||||
|
|
||||||
echo -e "${RD}Using Advanced Settings${CL}"
|
|
||||||
echo -e "${DGN}Using CT Type ${BGN}$CT_TYPE1${CL}"
|
|
||||||
echo -e "${DGN}Using CT Password ${BGN}$PW1${CL}"
|
|
||||||
echo -e "${DGN}Using CT ID ${BGN}$CT_ID${CL}"
|
|
||||||
echo -e "${DGN}Using CT Name ${BGN}$HN${CL}"
|
|
||||||
echo -e "${DGN}Using Disk Size ${BGN}$DISK_SIZE${CL}${DGN}GB${CL}"
|
|
||||||
echo -e "${DGN}Using ${BGN}${CORE_COUNT}${CL}${DGN}vCPU${CL}"
|
|
||||||
echo -e "${DGN}Using ${BGN}${RAM_SIZE}${CL}${DGN}MiB RAM${CL}"
|
|
||||||
echo -e "${DGN}Using Bridge ${BGN}${BRG}${CL}"
|
|
||||||
echo -e "${DGN}Using Static IP Address ${BGN}$NET${CL}"
|
|
||||||
echo -e "${DGN}Using Gateway IP Address ${BGN}$GATE1${CL}"
|
|
||||||
echo -e "${YW}Enter a VLAN Tag, or Press [ENTER] for Default: NONE "
|
|
||||||
read VLAN1
|
|
||||||
if [ -z $VLAN1 ]; then VLAN1="NONE" VLAN="";
|
|
||||||
echo -en "${DGN}Set VLAN Tag To ${BL}$VLAN1${CL}"
|
|
||||||
else
|
|
||||||
VLAN=",tag=$VLAN1"
|
|
||||||
echo -en "${DGN}Set VLAN Tag To ${BL}$VLAN1${CL}"
|
|
||||||
fi;
|
|
||||||
echo -e " ${CM}${CL} \n"
|
|
||||||
sleep 1
|
|
||||||
clear
|
|
||||||
header_info
|
|
||||||
echo -e "${RD}Using Advanced Settings${CL}"
|
|
||||||
echo -e "${DGN}Using CT Type ${BGN}$CT_TYPE1${CL}"
|
|
||||||
echo -e "${DGN}Using CT Password ${BGN}$PW1${CL}"
|
|
||||||
echo -e "${DGN}Using CT ID ${BGN}$CT_ID${CL}"
|
|
||||||
echo -e "${DGN}Using CT Name ${BGN}$HN${CL}"
|
|
||||||
echo -e "${DGN}Using Disk Size ${BGN}$DISK_SIZE${CL}${DGN}GB${CL}"
|
|
||||||
echo -e "${DGN}Using ${BGN}${CORE_COUNT}${CL}${DGN}vCPU${CL}"
|
|
||||||
echo -e "${DGN}Using ${BGN}${RAM_SIZE}${CL}${DGN}MiB RAM${CL}"
|
|
||||||
echo -e "${DGN}Using Bridge ${BGN}${BRG}${CL}"
|
|
||||||
echo -e "${DGN}Using Static IP Address ${BGN}$NET${CL}"
|
|
||||||
echo -e "${DGN}Using Gateway IP Address ${BGN}$GATE1${CL}"
|
|
||||||
echo -e "${DGN}Using VLAN Tag ${BGN}$VLAN1${CL}"
|
|
||||||
|
|
||||||
read -p "Are these settings correct(y/n)? " -n 1 -r
|
|
||||||
echo
|
|
||||||
if [[ ! $REPLY =~ ^[Yy]$ ]]
|
|
||||||
then
|
|
||||||
advanced_settings
|
|
||||||
fi
|
|
||||||
}
|
|
||||||
|
|
||||||
function start_script() {
|
|
||||||
echo -e "${YW}Type Advanced, or Press [ENTER] for Default Settings "
|
|
||||||
read SETTINGS
|
|
||||||
if [ -z $SETTINGS ]; then default_settings;
|
|
||||||
else
|
|
||||||
advanced_settings
|
|
||||||
fi;
|
|
||||||
}
|
|
||||||
|
|
||||||
start_script
|
|
||||||
|
|
||||||
if [ "$CT_TYPE" == "1" ]; then
|
|
||||||
FEATURES="nesting=1,keyctl=1"
|
|
||||||
else
|
|
||||||
FEATURES="nesting=1"
|
|
||||||
fi
|
|
||||||
|
|
||||||
TEMP_DIR=$(mktemp -d)
|
|
||||||
pushd $TEMP_DIR >/dev/null
|
|
||||||
|
|
||||||
export CTID=$CT_ID
|
|
||||||
export PCT_OSTYPE=debian
|
|
||||||
export PCT_OSVERSION=11
|
|
||||||
export PCT_DISK_SIZE=$DISK_SIZE
|
|
||||||
export PCT_OPTIONS="
|
|
||||||
-features $FEATURES
|
|
||||||
-hostname $HN
|
|
||||||
-net0 name=eth0,bridge=$BRG,ip=$NET$GATE$VLAN
|
|
||||||
-onboot 1
|
|
||||||
-cores $CORE_COUNT
|
|
||||||
-memory $RAM_SIZE
|
|
||||||
-unprivileged $CT_TYPE
|
|
||||||
$PW
|
|
||||||
"
|
|
||||||
bash -c "$(wget -qLO - https://raw.githubusercontent.com/tteck/Proxmox/main/ct/create_lxc.sh)" || exit
|
|
||||||
|
|
||||||
msg_info "Starting LXC Container"
|
|
||||||
pct start $CTID
|
|
||||||
msg_ok "Started LXC Container"
|
|
||||||
|
|
||||||
lxc-attach -n $CTID -- bash -c "$(wget -qLO - https://raw.githubusercontent.com/tteck/Proxmox/main/setup/nocodb-install.sh)" || exit
|
|
||||||
|
|
||||||
IP=$(pct exec $CTID ip a s dev eth0 | sed -n '/inet / s/\// /p' | awk '{print $2}')
|
|
||||||
|
|
||||||
pct set $CTID -description "# ${APP} LXC
|
|
||||||
### https://github.com/tteck/Proxmox"
|
|
||||||
|
|
||||||
msg_ok "Completed Successfully!\n"
|
|
||||||
echo -e "${APP} should be reachable by going to the following URL.
|
|
||||||
${BL}http://${IP}:8080/dashboard${CL}\n"
|
|
|
@ -309,7 +309,7 @@ bash -c "$(wget -qLO - https://raw.githubusercontent.com/tteck/Proxmox/main/ct/c
|
||||||
msg_info "Starting LXC Container"
|
msg_info "Starting LXC Container"
|
||||||
pct start $CTID
|
pct start $CTID
|
||||||
msg_ok "Started LXC Container"
|
msg_ok "Started LXC Container"
|
||||||
lxc-attach -n $CTID -- bash -c "$(wget -qLO - https://raw.githubusercontent.com/tteck/Proxmox/main/setup/$var_install.sh)" || exit
|
lxc-attach -n $CTID -- bash -c "$(wget -qLO - https://raw.githubusercontent.com/tteck/Proxmox/main/install/$var_install.sh)" || exit
|
||||||
IP=$(pct exec $CTID ip a s dev eth0 | sed -n '/inet / s/\// /p' | awk '{print $2}')
|
IP=$(pct exec $CTID ip a s dev eth0 | sed -n '/inet / s/\// /p' | awk '{print $2}')
|
||||||
pct set $CTID -description "# ${APP} LXC
|
pct set $CTID -description "# ${APP} LXC
|
||||||
### https://tteck.github.io/Proxmox/
|
### https://tteck.github.io/Proxmox/
|
||||||
|
|
|
@ -1,161 +0,0 @@
|
||||||
#!/usr/bin/env bash
|
|
||||||
|
|
||||||
while true; do
|
|
||||||
read -p "This will create a New Node-Red LXC Container. Proceed(y/n)?" yn
|
|
||||||
case $yn in
|
|
||||||
[Yy]* ) break;;
|
|
||||||
[Nn]* ) exit;;
|
|
||||||
* ) echo "Please answer yes or no.";;
|
|
||||||
esac
|
|
||||||
done
|
|
||||||
clear
|
|
||||||
set -o errexit
|
|
||||||
set -o errtrace
|
|
||||||
set -o nounset
|
|
||||||
set -o pipefail
|
|
||||||
shopt -s expand_aliases
|
|
||||||
alias die='EXIT=$? LINE=$LINENO error_exit'
|
|
||||||
CHECKMARK='\033[0;32m\xE2\x9C\x94\033[0m'
|
|
||||||
trap die ERR
|
|
||||||
trap cleanup EXIT
|
|
||||||
|
|
||||||
function error_exit() {
|
|
||||||
trap - ERR
|
|
||||||
local DEFAULT='Unknown failure occured.'
|
|
||||||
local REASON="\e[97m${1:-$DEFAULT}\e[39m"
|
|
||||||
local FLAG="\e[91m[ERROR] \e[93m$EXIT@$LINE"
|
|
||||||
msg "$FLAG $REASON"
|
|
||||||
[ ! -z ${CTID-} ] && cleanup_ctid
|
|
||||||
exit $EXIT
|
|
||||||
}
|
|
||||||
function warn() {
|
|
||||||
local REASON="\e[97m$1\e[39m"
|
|
||||||
local FLAG="\e[93m[WARNING]\e[39m"
|
|
||||||
msg "$FLAG $REASON"
|
|
||||||
}
|
|
||||||
function info() {
|
|
||||||
local REASON="$1"
|
|
||||||
local FLAG="\e[36m[INFO]\e[39m"
|
|
||||||
msg "$FLAG $REASON"
|
|
||||||
}
|
|
||||||
function msg() {
|
|
||||||
local TEXT="$1"
|
|
||||||
echo -e "$TEXT"
|
|
||||||
}
|
|
||||||
function cleanup_ctid() {
|
|
||||||
if [ ! -z ${MOUNT+x} ]; then
|
|
||||||
pct unmount $CTID
|
|
||||||
fi
|
|
||||||
if $(pct status $CTID &>/dev/null); then
|
|
||||||
if [ "$(pct status $CTID | awk '{print $2}')" == "running" ]; then
|
|
||||||
pct stop $CTID
|
|
||||||
fi
|
|
||||||
pct destroy $CTID
|
|
||||||
elif [ "$(pvesm list $STORAGE --vmid $CTID)" != "" ]; then
|
|
||||||
pvesm free $ROOTFS
|
|
||||||
fi
|
|
||||||
}
|
|
||||||
function cleanup() {
|
|
||||||
popd >/dev/null
|
|
||||||
rm -rf $TEMP_DIR
|
|
||||||
}
|
|
||||||
function load_module() {
|
|
||||||
if ! $(lsmod | grep -Fq $1); then
|
|
||||||
modprobe $1 &>/dev/null || \
|
|
||||||
die "Failed to load '$1' module."
|
|
||||||
fi
|
|
||||||
MODULES_PATH=/etc/modules
|
|
||||||
if ! $(grep -Fxq "$1" $MODULES_PATH); then
|
|
||||||
echo "$1" >> $MODULES_PATH || \
|
|
||||||
die "Failed to add '$1' module to load at boot."
|
|
||||||
fi
|
|
||||||
}
|
|
||||||
TEMP_DIR=$(mktemp -d)
|
|
||||||
pushd $TEMP_DIR >/dev/null
|
|
||||||
|
|
||||||
wget -qL https://raw.githubusercontent.com/tteck/Proxmox/main/setup/node-red_setup.sh
|
|
||||||
|
|
||||||
load_module overlay
|
|
||||||
|
|
||||||
while read -r line; do
|
|
||||||
TAG=$(echo $line | awk '{print $1}')
|
|
||||||
TYPE=$(echo $line | awk '{printf "%-10s", $2}')
|
|
||||||
FREE=$(echo $line | numfmt --field 4-6 --from-unit=K --to=iec --format %.2f | awk '{printf( "%9sB", $6)}')
|
|
||||||
ITEM=" Type: $TYPE Free: $FREE "
|
|
||||||
OFFSET=2
|
|
||||||
if [[ $((${#ITEM} + $OFFSET)) -gt ${MSG_MAX_LENGTH:-} ]]; then
|
|
||||||
MSG_MAX_LENGTH=$((${#ITEM} + $OFFSET))
|
|
||||||
fi
|
|
||||||
STORAGE_MENU+=( "$TAG" "$ITEM" "OFF" )
|
|
||||||
done < <(pvesm status -content rootdir | awk 'NR>1')
|
|
||||||
if [ $((${#STORAGE_MENU[@]}/3)) -eq 0 ]; then
|
|
||||||
warn "'Container' needs to be selected for at least one storage location."
|
|
||||||
die "Unable to detect valid storage location."
|
|
||||||
elif [ $((${#STORAGE_MENU[@]}/3)) -eq 1 ]; then
|
|
||||||
STORAGE=${STORAGE_MENU[0]}
|
|
||||||
else
|
|
||||||
while [ -z "${STORAGE:+x}" ]; do
|
|
||||||
STORAGE=$(whiptail --title "Storage Pools" --radiolist \
|
|
||||||
"Which storage pool you would like to use for the container?\n\n" \
|
|
||||||
16 $(($MSG_MAX_LENGTH + 23)) 6 \
|
|
||||||
"${STORAGE_MENU[@]}" 3>&1 1>&2 2>&3) || exit
|
|
||||||
done
|
|
||||||
fi
|
|
||||||
info "Using '$STORAGE' for storage location."
|
|
||||||
|
|
||||||
CTID=$(pvesh get /cluster/nextid)
|
|
||||||
info "Container ID is $CTID."
|
|
||||||
|
|
||||||
echo -e "${CHECKMARK} \e[1;92m Updating LXC Template List... \e[0m"
|
|
||||||
pveam update >/dev/null
|
|
||||||
echo -e "${CHECKMARK} \e[1;92m Downloading LXC Template... \e[0m"
|
|
||||||
OSTYPE=debian
|
|
||||||
OSVERSION=${OSTYPE}-11
|
|
||||||
mapfile -t TEMPLATES < <(pveam available -section system | sed -n "s/.*\($OSVERSION.*\)/\1/p" | sort -t - -k 2 -V)
|
|
||||||
TEMPLATE="${TEMPLATES[-1]}"
|
|
||||||
pveam download local $TEMPLATE >/dev/null ||
|
|
||||||
die "A problem occured while downloading the LXC template."
|
|
||||||
|
|
||||||
STORAGE_TYPE=$(pvesm status -storage $STORAGE | awk 'NR>1 {print $2}')
|
|
||||||
case $STORAGE_TYPE in
|
|
||||||
dir|nfs)
|
|
||||||
DISK_EXT=".raw"
|
|
||||||
DISK_REF="$CTID/"
|
|
||||||
;;
|
|
||||||
zfspool)
|
|
||||||
DISK_PREFIX="subvol"
|
|
||||||
DISK_FORMAT="subvol"
|
|
||||||
;;
|
|
||||||
esac
|
|
||||||
DISK=${DISK_PREFIX:-vm}-${CTID}-disk-0${DISK_EXT-}
|
|
||||||
ROOTFS=${STORAGE}:${DISK_REF-}${DISK}
|
|
||||||
|
|
||||||
echo -e "${CHECKMARK} \e[1;92m Creating LXC Container... \e[0m"
|
|
||||||
DISK_SIZE=4G
|
|
||||||
pvesm alloc $STORAGE $CTID $DISK $DISK_SIZE --format ${DISK_FORMAT:-raw} >/dev/null
|
|
||||||
if [ "$STORAGE_TYPE" == "zfspool" ]; then
|
|
||||||
warn "Some containers may not work properly due to ZFS not supporting 'fallocate'."
|
|
||||||
else
|
|
||||||
mkfs.ext4 $(pvesm path $ROOTFS) &>/dev/null
|
|
||||||
fi
|
|
||||||
ARCH=$(dpkg --print-architecture)
|
|
||||||
HOSTNAME=nodered
|
|
||||||
TEMPLATE_STRING="local:vztmpl/${TEMPLATE}"
|
|
||||||
pct create $CTID $TEMPLATE_STRING -arch $ARCH -features nesting=1 \
|
|
||||||
-hostname $HOSTNAME -net0 name=eth0,bridge=vmbr0,ip=dhcp -onboot 1 -cores 1 -memory 1024 \
|
|
||||||
-ostype $OSTYPE -rootfs $ROOTFS,size=$DISK_SIZE -storage $STORAGE >/dev/null
|
|
||||||
|
|
||||||
MOUNT=$(pct mount $CTID | cut -d"'" -f 2)
|
|
||||||
ln -fs $(readlink /etc/localtime) ${MOUNT}/etc/localtime
|
|
||||||
pct unmount $CTID && unset MOUNT
|
|
||||||
|
|
||||||
echo -e "${CHECKMARK} \e[1;92m Starting LXC Container... \e[0m"
|
|
||||||
pct start $CTID
|
|
||||||
pct push $CTID node-red_setup.sh /node-red_setup.sh -perms 755
|
|
||||||
pct exec $CTID /node-red_setup.sh
|
|
||||||
|
|
||||||
IP=$(pct exec $CTID ip a s dev eth0 | sed -n '/inet / s/\// /p' | awk '{print $2}')
|
|
||||||
info "Successfully Created Node-Red LXC to $CTID."
|
|
||||||
echo -e "\e[1;92m Node-Red should be reachable by going to the following URL.
|
|
||||||
http://${IP}:1880
|
|
||||||
\e[0m"
|
|
|
@ -1,253 +0,0 @@
|
||||||
#!/usr/bin/env bash
|
|
||||||
YW=`echo "\033[33m"`
|
|
||||||
BL=`echo "\033[36m"`
|
|
||||||
RD=`echo "\033[01;31m"`
|
|
||||||
CM='\xE2\x9C\x94\033'
|
|
||||||
GN=`echo "\033[1;92m"`
|
|
||||||
CL=`echo "\033[m"`
|
|
||||||
while true; do
|
|
||||||
read -p "This will create a New Node-Red LXC. Proceed(y/n)?" yn
|
|
||||||
case $yn in
|
|
||||||
[Yy]* ) break;;
|
|
||||||
[Nn]* ) exit;;
|
|
||||||
* ) echo "Please answer yes or no.";;
|
|
||||||
esac
|
|
||||||
done
|
|
||||||
clear
|
|
||||||
function header_info {
|
|
||||||
echo -e "${RD}
|
|
||||||
_ _ _ _____ _
|
|
||||||
| \ | | | | | __ \ | |
|
|
||||||
| \| | ___ __| | ___ ______| |__) |___ __| |
|
|
||||||
| |/ _ \ / _ |/ _ \______| _ // _ \/ _ |
|
|
||||||
| |\ | (_) | (_| | __/ | | \ \ __/ (_| |
|
|
||||||
|_| \_|\___/ \__,_|\___| |_| \_\___|\__,_|
|
|
||||||
|
|
||||||
${CL}"
|
|
||||||
}
|
|
||||||
|
|
||||||
header_info
|
|
||||||
show_menu(){
|
|
||||||
printf " ${YW} 1)${YW} Privileged ${CL}\n"
|
|
||||||
printf " ${YW} 2)${GN} Unprivileged ${CL}\n"
|
|
||||||
|
|
||||||
printf "Please choose a Install Method and hit enter or ${RD}x${CL} to exit."
|
|
||||||
read opt
|
|
||||||
}
|
|
||||||
|
|
||||||
option_picked(){
|
|
||||||
message1=${@:-"${CL}Error: No message passed"}
|
|
||||||
printf " ${YW}${message1}${CL}\n"
|
|
||||||
}
|
|
||||||
show_menu
|
|
||||||
while [ "$opt" != " " ]
|
|
||||||
do
|
|
||||||
case $opt in
|
|
||||||
1) clear;
|
|
||||||
header_info;
|
|
||||||
option_picked "Using Privileged Install";
|
|
||||||
IM=0
|
|
||||||
break;
|
|
||||||
;;
|
|
||||||
2) clear;
|
|
||||||
header_info;
|
|
||||||
option_picked "Using Unprivileged Install";
|
|
||||||
IM=1
|
|
||||||
break;
|
|
||||||
;;
|
|
||||||
|
|
||||||
x)exit;
|
|
||||||
;;
|
|
||||||
\n)exit;
|
|
||||||
;;
|
|
||||||
*)clear;
|
|
||||||
option_picked "Please choose a Install Method from the menu";
|
|
||||||
show_menu;
|
|
||||||
;;
|
|
||||||
esac
|
|
||||||
done
|
|
||||||
show_menu2(){
|
|
||||||
printf " ${YW} 1)${GN} Use Automatic Login ${CL}\n"
|
|
||||||
printf " ${YW} 2)${GN} Use Password (changeme) ${CL}\n"
|
|
||||||
|
|
||||||
printf "Please choose a Password Type and hit enter or ${RD}x${CL} to exit."
|
|
||||||
read opt
|
|
||||||
}
|
|
||||||
|
|
||||||
option_picked(){
|
|
||||||
message2=${@:-"${CL}Error: No message passed"}
|
|
||||||
printf " ${YW}${message1}${CL}\n"
|
|
||||||
printf " ${YW}${message2}${CL}\n"
|
|
||||||
}
|
|
||||||
show_menu2
|
|
||||||
while [ "$opt" != " " ]
|
|
||||||
do
|
|
||||||
case $opt in
|
|
||||||
1) clear;
|
|
||||||
header_info;
|
|
||||||
option_picked "Using Automatic Login";
|
|
||||||
PW=" "
|
|
||||||
break;
|
|
||||||
;;
|
|
||||||
2) clear;
|
|
||||||
header_info;
|
|
||||||
option_picked "Using Password (changeme)";
|
|
||||||
PW="-password changeme"
|
|
||||||
break;
|
|
||||||
;;
|
|
||||||
|
|
||||||
x)exit;
|
|
||||||
;;
|
|
||||||
\n)exit;
|
|
||||||
;;
|
|
||||||
*)clear;
|
|
||||||
option_picked "Please choose a Password Type from the menu";
|
|
||||||
show_menu2;
|
|
||||||
;;
|
|
||||||
esac
|
|
||||||
done
|
|
||||||
show_menu3(){
|
|
||||||
printf " ${YW} 1)${GN} Automatic DHCP ${CL}\n"
|
|
||||||
printf " ${YW} 2)${GN} Manual DHCP ${CL}\n"
|
|
||||||
|
|
||||||
printf "Please choose a DHCP Type and hit enter or ${RD}x${CL} to exit."
|
|
||||||
read opt
|
|
||||||
}
|
|
||||||
|
|
||||||
option_picked(){
|
|
||||||
message3=${@:-"${CL}Error: No message passed"}
|
|
||||||
printf " ${YW}${message1}${CL}\n"
|
|
||||||
printf " ${YW}${message2}${CL}\n"
|
|
||||||
printf " ${YW}${message3}${CL}\n"
|
|
||||||
}
|
|
||||||
show_menu3
|
|
||||||
while [ "$opt" != " " ]
|
|
||||||
do
|
|
||||||
case $opt in
|
|
||||||
1) clear;
|
|
||||||
header_info;
|
|
||||||
option_picked "Using Automatic DHCP";
|
|
||||||
DHCP=" "
|
|
||||||
break;
|
|
||||||
;;
|
|
||||||
2) clear;
|
|
||||||
header_info;
|
|
||||||
option_picked "Using Manual DHCP";
|
|
||||||
DHCP="1"
|
|
||||||
break;
|
|
||||||
;;
|
|
||||||
|
|
||||||
x)exit;
|
|
||||||
;;
|
|
||||||
\n)exit;
|
|
||||||
;;
|
|
||||||
*)clear;
|
|
||||||
option_picked "Please choose a DHCP Type from the menu";
|
|
||||||
show_menu3;
|
|
||||||
;;
|
|
||||||
esac
|
|
||||||
done
|
|
||||||
|
|
||||||
set -o errexit
|
|
||||||
set -o errtrace
|
|
||||||
set -o nounset
|
|
||||||
set -o pipefail
|
|
||||||
shopt -s expand_aliases
|
|
||||||
alias die='EXIT=$? LINE=$LINENO error_exit'
|
|
||||||
trap die ERR
|
|
||||||
trap cleanup EXIT
|
|
||||||
|
|
||||||
function error_exit() {
|
|
||||||
trap - ERR
|
|
||||||
local DEFAULT='Unknown failure occured.'
|
|
||||||
local REASON="\e[97m${1:-$DEFAULT}\e[39m"
|
|
||||||
local FLAG="\e[91m[ERROR] \e[93m$EXIT@$LINE"
|
|
||||||
msg "$FLAG $REASON"
|
|
||||||
[ ! -z ${CTID-} ] && cleanup_ctid
|
|
||||||
exit $EXIT
|
|
||||||
}
|
|
||||||
function warn() {
|
|
||||||
local REASON="\e[97m$1\e[39m"
|
|
||||||
local FLAG="\e[93m[WARNING]\e[39m"
|
|
||||||
msg "$FLAG $REASON"
|
|
||||||
}
|
|
||||||
function info() {
|
|
||||||
local REASON="$1"
|
|
||||||
local FLAG="\e[36m[INFO]\e[39m"
|
|
||||||
msg "$FLAG $REASON"
|
|
||||||
}
|
|
||||||
function msg() {
|
|
||||||
local TEXT="$1"
|
|
||||||
echo -e "$TEXT"
|
|
||||||
}
|
|
||||||
function cleanup_ctid() {
|
|
||||||
if $(pct status $CTID &>/dev/null); then
|
|
||||||
if [ "$(pct status $CTID | awk '{print $2}')" == "running" ]; then
|
|
||||||
pct stop $CTID
|
|
||||||
fi
|
|
||||||
pct destroy $CTID
|
|
||||||
elif [ "$(pvesm list $STORAGE --vmid $CTID)" != "" ]; then
|
|
||||||
pvesm free $ROOTFS
|
|
||||||
fi
|
|
||||||
}
|
|
||||||
function cleanup() {
|
|
||||||
popd >/dev/null
|
|
||||||
rm -rf $TEMP_DIR
|
|
||||||
}
|
|
||||||
if [ "$IM" == "1" ]; then
|
|
||||||
FEATURES="nesting=1,keyctl=1"
|
|
||||||
else
|
|
||||||
FEATURES="nesting=1"
|
|
||||||
fi
|
|
||||||
|
|
||||||
TEMP_DIR=$(mktemp -d)
|
|
||||||
pushd $TEMP_DIR >/dev/null
|
|
||||||
|
|
||||||
export CTID=$(pvesh get /cluster/nextid)
|
|
||||||
export PCT_OSTYPE=debian
|
|
||||||
export PCT_OSVERSION=11
|
|
||||||
export PCT_DISK_SIZE=4
|
|
||||||
export PCT_OPTIONS="
|
|
||||||
-features $FEATURES
|
|
||||||
-hostname node-red
|
|
||||||
-net0 name=eth0,bridge=vmbr0,ip=dhcp
|
|
||||||
-onboot 1
|
|
||||||
-cores 1
|
|
||||||
-memory 1024
|
|
||||||
-unprivileged ${IM}
|
|
||||||
${PW}
|
|
||||||
"
|
|
||||||
bash -c "$(wget -qLO - https://raw.githubusercontent.com/tteck/Proxmox/main/ct/create_lxc.sh)" || exit
|
|
||||||
|
|
||||||
STORAGE_TYPE=$(pvesm status -storage $(pct config $CTID | grep rootfs | awk -F ":" '{print $2}') | awk 'NR>1 {print $2}')
|
|
||||||
if [ "$STORAGE_TYPE" == "zfspool" ]; then
|
|
||||||
warn "Some addons may not work due to ZFS not supporting 'fallocate'."
|
|
||||||
fi
|
|
||||||
if [ "$DHCP" == "1" ]; then
|
|
||||||
MAC=$(pct config $CTID \
|
|
||||||
| grep -i hwaddr \
|
|
||||||
| awk '{print substr($2, 31, length($3) 17 ) }') \
|
|
||||||
|
|
||||||
echo -e "MAC Address ${BL}$MAC${CL}"
|
|
||||||
|
|
||||||
dhcp_reservation(){
|
|
||||||
printf "Please set DHCP reservation and press Enter."
|
|
||||||
read
|
|
||||||
}
|
|
||||||
dhcp_reservation
|
|
||||||
fi
|
|
||||||
|
|
||||||
echo -en "${GN} Starting LXC Container... "
|
|
||||||
pct start $CTID
|
|
||||||
echo -e "${CM}${CL} \r"
|
|
||||||
|
|
||||||
alias lxc-cmd="lxc-attach -n $CTID --"
|
|
||||||
|
|
||||||
lxc-cmd bash -c "$(wget -qLO - https://raw.githubusercontent.com/tteck/Proxmox/main/setup/node-red-install.sh)" || exit
|
|
||||||
|
|
||||||
IP=$(pct exec $CTID ip a s dev eth0 | sed -n '/inet / s/\// /p' | awk '{print $2}')
|
|
||||||
|
|
||||||
echo -e "${GN}Successfully created Node-Red LXC to${CL} ${BL}$CTID${CL}.
|
|
||||||
${RD}Node-Red${CL} should be reachable by going to the following URL.
|
|
||||||
|
|
||||||
${BL}http://${IP}:1880${CL} \n"
|
|
|
@ -1,356 +0,0 @@
|
||||||
#!/usr/bin/env bash
|
|
||||||
echo -e "Loading..."
|
|
||||||
NEXTID=$(pvesh get /cluster/nextid)
|
|
||||||
INTEGER='^[0-9]+$'
|
|
||||||
YW=`echo "\033[33m"`
|
|
||||||
BL=`echo "\033[36m"`
|
|
||||||
RD=`echo "\033[01;31m"`
|
|
||||||
BGN=`echo "\033[4;92m"`
|
|
||||||
GN=`echo "\033[1;92m"`
|
|
||||||
DGN=`echo "\033[32m"`
|
|
||||||
CL=`echo "\033[m"`
|
|
||||||
BFR="\\r\\033[K"
|
|
||||||
HOLD="-"
|
|
||||||
CM="${GN}✓${CL}"
|
|
||||||
APP="Node Red"
|
|
||||||
NSAPP=$(echo ${APP,,} | tr -d ' ')
|
|
||||||
set -o errexit
|
|
||||||
set -o errtrace
|
|
||||||
set -o nounset
|
|
||||||
set -o pipefail
|
|
||||||
shopt -s expand_aliases
|
|
||||||
alias die='EXIT=$? LINE=$LINENO error_exit'
|
|
||||||
trap die ERR
|
|
||||||
|
|
||||||
function error_exit() {
|
|
||||||
trap - ERR
|
|
||||||
local reason="Unknown failure occurred."
|
|
||||||
local msg="${1:-$reason}"
|
|
||||||
local flag="${RD}‼ ERROR ${CL}$EXIT@$LINE"
|
|
||||||
echo -e "$flag $msg" 1>&2
|
|
||||||
exit $EXIT
|
|
||||||
}
|
|
||||||
|
|
||||||
while true; do
|
|
||||||
clear
|
|
||||||
read -p "This will create a New ${APP} LXC. Proceed(y/n)?" yn
|
|
||||||
case $yn in
|
|
||||||
[Yy]* ) break;;
|
|
||||||
[Nn]* ) exit;;
|
|
||||||
* ) echo "Please answer yes or no.";;
|
|
||||||
esac
|
|
||||||
done
|
|
||||||
clear
|
|
||||||
function header_info {
|
|
||||||
echo -e "${RD}
|
|
||||||
_ _ _ _____ _
|
|
||||||
| \ | | | | | __ \ | |
|
|
||||||
| \| | ___ __| | ___ ______| |__) |___ __| |
|
|
||||||
| |/ _ \ / _ |/ _ \__v3__| _ // _ \/ _ |
|
|
||||||
| |\ | (_) | (_| | __/ | | \ \ __/ (_| |
|
|
||||||
|_| \_|\___/ \__,_|\___| |_| \_\___|\__,_|
|
|
||||||
${CL}"
|
|
||||||
}
|
|
||||||
|
|
||||||
header_info
|
|
||||||
|
|
||||||
function msg_info() {
|
|
||||||
local msg="$1"
|
|
||||||
echo -ne " ${HOLD} ${YW}${msg}..."
|
|
||||||
}
|
|
||||||
|
|
||||||
function msg_ok() {
|
|
||||||
local msg="$1"
|
|
||||||
echo -e "${BFR} ${CM} ${GN}${msg}${CL}"
|
|
||||||
}
|
|
||||||
|
|
||||||
function PVE_CHECK() {
|
|
||||||
PVE=$(pveversion | grep "pve-manager/7" | wc -l)
|
|
||||||
|
|
||||||
if [[ $PVE != 1 ]]; then
|
|
||||||
echo -e "${RD}This script requires Proxmox Virtual Environment 7.0 or greater${CL}"
|
|
||||||
echo -e "Exiting..."
|
|
||||||
sleep 2
|
|
||||||
exit
|
|
||||||
fi
|
|
||||||
}
|
|
||||||
|
|
||||||
function default_settings() {
|
|
||||||
clear
|
|
||||||
header_info
|
|
||||||
echo -e "${BL}Using Default Settings${CL}"
|
|
||||||
echo -e "${DGN}Using CT Type ${BGN}Unprivileged${CL} ${RD}NO DEVICE PASSTHROUGH${CL}"
|
|
||||||
CT_TYPE="1"
|
|
||||||
echo -e "${DGN}Using CT Password ${BGN}Automatic Login${CL}"
|
|
||||||
PW=" "
|
|
||||||
echo -e "${DGN}Using CT ID ${BGN}$NEXTID${CL}"
|
|
||||||
CT_ID=$NEXTID
|
|
||||||
echo -e "${DGN}Using CT Name ${BGN}$NSAPP${CL}"
|
|
||||||
HN=$NSAPP
|
|
||||||
echo -e "${DGN}Using Disk Size ${BGN}4${CL}${DGN}GB${CL}"
|
|
||||||
DISK_SIZE="4"
|
|
||||||
echo -e "${DGN}Using ${BGN}1${CL}${DGN}vCPU${CL}"
|
|
||||||
CORE_COUNT="1"
|
|
||||||
echo -e "${DGN}Using ${BGN}1024${CL}${DGN}MiB RAM${CL}"
|
|
||||||
RAM_SIZE="1024"
|
|
||||||
echo -e "${DGN}Using Bridge ${BGN}vmbr0${CL}"
|
|
||||||
BRG="vmbr0"
|
|
||||||
echo -e "${DGN}Using Static IP Address ${BGN}DHCP${CL}"
|
|
||||||
NET=dhcp
|
|
||||||
echo -e "${DGN}Using Gateway Address ${BGN}NONE${CL}"
|
|
||||||
GATE=""
|
|
||||||
echo -e "${DGN}Using VLAN Tag ${BGN}NONE${CL}"
|
|
||||||
VLAN=""
|
|
||||||
}
|
|
||||||
|
|
||||||
function advanced_settings() {
|
|
||||||
clear
|
|
||||||
header_info
|
|
||||||
echo -e "${RD}Using Advanced Settings${CL}"
|
|
||||||
echo -e "${YW}Type Privileged, or Press [ENTER] for Default: Unprivileged (${RD}NO DEVICE PASSTHROUGH${CL}${YW})"
|
|
||||||
read CT_TYPE1
|
|
||||||
if [ -z $CT_TYPE1 ]; then CT_TYPE1="Unprivileged" CT_TYPE="1";
|
|
||||||
echo -en "${DGN}Set CT Type ${BL}$CT_TYPE1${CL}"
|
|
||||||
else
|
|
||||||
CT_TYPE1="Privileged"
|
|
||||||
CT_TYPE="0"
|
|
||||||
echo -en "${DGN}Set CT Type ${BL}Privileged${CL}"
|
|
||||||
fi;
|
|
||||||
echo -e " ${CM}${CL} \r"
|
|
||||||
sleep 1
|
|
||||||
clear
|
|
||||||
header_info
|
|
||||||
echo -e "${RD}Using Advanced Settings${CL}"
|
|
||||||
echo -e "${DGN}Using CT Type ${BGN}$CT_TYPE1${CL}"
|
|
||||||
echo -e "${YW}Set Password, or Press [ENTER] for Default: Automatic Login "
|
|
||||||
read PW1
|
|
||||||
if [ -z $PW1 ]; then PW1="Automatic Login" PW=" ";
|
|
||||||
echo -en "${DGN}Set CT ${BL}$PW1${CL}"
|
|
||||||
else
|
|
||||||
PW="-password $PW1"
|
|
||||||
echo -en "${DGN}Set CT Password ${BL}$PW1${CL}"
|
|
||||||
fi;
|
|
||||||
echo -e " ${CM}${CL} \r"
|
|
||||||
sleep 1
|
|
||||||
clear
|
|
||||||
header_info
|
|
||||||
echo -e "${RD}Using Advanced Settings${CL}"
|
|
||||||
echo -e "${DGN}Using CT Type ${BGN}$CT_TYPE1${CL}"
|
|
||||||
echo -e "${DGN}Using CT Password ${BGN}$PW1${CL}"
|
|
||||||
echo -e "${YW}Enter the CT ID, or Press [ENTER] to automatically generate (${NEXTID}) "
|
|
||||||
read CT_ID
|
|
||||||
if [ -z $CT_ID ]; then CT_ID=$NEXTID; fi;
|
|
||||||
echo -en "${DGN}Set CT ID To ${BL}$CT_ID${CL}"
|
|
||||||
echo -e " ${CM}${CL} \r"
|
|
||||||
sleep 1
|
|
||||||
clear
|
|
||||||
header_info
|
|
||||||
echo -e "${RD}Using Advanced Settings${CL}"
|
|
||||||
echo -e "${DGN}Using CT Type ${BGN}$CT_TYPE1${CL}"
|
|
||||||
echo -e "${DGN}Using CT Password ${BGN}$PW1${CL}"
|
|
||||||
echo -e "${DGN}Using CT ID ${BGN}$CT_ID${CL}"
|
|
||||||
echo -e "${YW}Enter CT Name (no-spaces), or Press [ENTER] for Default: $NSAPP "
|
|
||||||
read CT_NAME
|
|
||||||
if [ -z $CT_NAME ]; then
|
|
||||||
HN=$NSAPP
|
|
||||||
else
|
|
||||||
HN=$(echo ${CT_NAME,,} | tr -d ' ')
|
|
||||||
fi
|
|
||||||
echo -en "${DGN}Set CT Name To ${BL}$HN${CL}"
|
|
||||||
echo -e " ${CM}${CL} \r"
|
|
||||||
sleep 1
|
|
||||||
clear
|
|
||||||
header_info
|
|
||||||
echo -e "${RD}Using Advanced Settings${CL}"
|
|
||||||
echo -e "${DGN}Using CT Type ${BGN}$CT_TYPE1${CL}"
|
|
||||||
echo -e "${DGN}Using CT Password ${BGN}$PW1${CL}"
|
|
||||||
echo -e "${DGN}Using CT ID ${BGN}$CT_ID${CL}"
|
|
||||||
echo -e "${DGN}Using CT Name ${BGN}$HN${CL}"
|
|
||||||
echo -e "${YW}Enter a Disk Size, or Press [ENTER] for Default: 4 "
|
|
||||||
read DISK_SIZE
|
|
||||||
if [ -z $DISK_SIZE ]; then DISK_SIZE="4"; fi;
|
|
||||||
if ! [[ $DISK_SIZE =~ $INTEGER ]] ; then echo "ERROR! DISK SIZE MUST HAVE INTEGER NUMBER!"; exit; fi;
|
|
||||||
echo -en "${DGN}Set Disk Size To ${BL}$DISK_SIZE${CL}${DGN}GB${CL}"
|
|
||||||
echo -e " ${CM}${CL} \r"
|
|
||||||
sleep 1
|
|
||||||
clear
|
|
||||||
header_info
|
|
||||||
echo -e "${RD}Using Advanced Settings${CL}"
|
|
||||||
echo -e "${DGN}Using CT Type ${BGN}$CT_TYPE1${CL}"
|
|
||||||
echo -e "${DGN}Using CT Password ${BGN}$PW1${CL}"
|
|
||||||
echo -e "${DGN}Using CT ID ${BGN}$CT_ID${CL}"
|
|
||||||
echo -e "${DGN}Using CT Name ${BGN}$HN${CL}"
|
|
||||||
echo -e "${DGN}Using Disk Size ${BGN}$DISK_SIZE${CL}${DGN}GB${CL}"
|
|
||||||
echo -e "${YW}Allocate CPU cores, or Press [ENTER] for Default: 1 "
|
|
||||||
read CORE_COUNT
|
|
||||||
if [ -z $CORE_COUNT ]; then CORE_COUNT="1"; fi;
|
|
||||||
echo -en "${DGN}Set Cores To ${BL}$CORE_COUNT${CL}${DGN}vCPU${CL}"
|
|
||||||
echo -e " ${CM}${CL} \r"
|
|
||||||
sleep 1
|
|
||||||
clear
|
|
||||||
header_info
|
|
||||||
echo -e "${RD}Using Advanced Settings${CL}"
|
|
||||||
echo -e "${DGN}Using CT Type ${BGN}$CT_TYPE1${CL}"
|
|
||||||
echo -e "${DGN}Using CT Password ${BGN}$PW1${CL}"
|
|
||||||
echo -e "${DGN}Using CT ID ${BGN}$CT_ID${CL}"
|
|
||||||
echo -e "${DGN}Using CT Name ${BGN}$HN${CL}"
|
|
||||||
echo -e "${DGN}Using Disk Size ${BGN}$DISK_SIZE${CL}${DGN}GB${CL}"
|
|
||||||
echo -e "${DGN}Using ${BGN}${CORE_COUNT}${CL}${DGN}vCPU${CL}"
|
|
||||||
echo -e "${YW}Allocate RAM in MiB, or Press [ENTER] for Default: 1024 "
|
|
||||||
read RAM_SIZE
|
|
||||||
if [ -z $RAM_SIZE ]; then RAM_SIZE="1024"; fi;
|
|
||||||
echo -en "${DGN}Set RAM To ${BL}$RAM_SIZE${CL}${DGN}MiB RAM${CL}"
|
|
||||||
echo -e " ${CM}${CL} \n"
|
|
||||||
sleep 1
|
|
||||||
clear
|
|
||||||
header_info
|
|
||||||
echo -e "${RD}Using Advanced Settings${CL}"
|
|
||||||
echo -e "${DGN}Using CT Type ${BGN}$CT_TYPE1${CL}"
|
|
||||||
echo -e "${DGN}Using CT Password ${BGN}$PW1${CL}"
|
|
||||||
echo -e "${DGN}Using CT ID ${BGN}$CT_ID${CL}"
|
|
||||||
echo -e "${DGN}Using CT Name ${BGN}$HN${CL}"
|
|
||||||
echo -e "${DGN}Using Disk Size ${BGN}$DISK_SIZE${CL}${DGN}GB${CL}"
|
|
||||||
echo -e "${DGN}Using ${BGN}${CORE_COUNT}${CL}${DGN}vCPU${CL}"
|
|
||||||
echo -e "${DGN}Using ${BGN}${RAM_SIZE}${CL}${DGN}MiB RAM${CL}"
|
|
||||||
echo -e "${YW}Enter a Bridge, or Press [ENTER] for Default: vmbr0 "
|
|
||||||
read BRG
|
|
||||||
if [ -z $BRG ]; then BRG="vmbr0"; fi;
|
|
||||||
echo -en "${DGN}Set Bridge To ${BL}$BRG${CL}"
|
|
||||||
echo -e " ${CM}${CL} \n"
|
|
||||||
sleep 1
|
|
||||||
clear
|
|
||||||
header_info
|
|
||||||
echo -e "${RD}Using Advanced Settings${CL}"
|
|
||||||
echo -e "${DGN}Using CT Type ${BGN}$CT_TYPE1${CL}"
|
|
||||||
echo -e "${DGN}Using CT Password ${BGN}$PW1${CL}"
|
|
||||||
echo -e "${DGN}Using CT ID ${BGN}$CT_ID${CL}"
|
|
||||||
echo -e "${DGN}Using CT Name ${BGN}$HN${CL}"
|
|
||||||
echo -e "${DGN}Using Disk Size ${BGN}$DISK_SIZE${CL}${DGN}GB${CL}"
|
|
||||||
echo -e "${DGN}Using ${BGN}${CORE_COUNT}${CL}${DGN}vCPU${CL}"
|
|
||||||
echo -e "${DGN}Using ${BGN}${RAM_SIZE}${CL}${DGN}MiB RAM${CL}"
|
|
||||||
echo -e "${DGN}Using Bridge ${BGN}${BRG}${CL}"
|
|
||||||
echo -e "${YW}Enter a Static IPv4 CIDR Address, or Press [ENTER] for Default: DHCP "
|
|
||||||
read NET
|
|
||||||
if [ -z $NET ]; then NET="dhcp"; fi;
|
|
||||||
echo -en "${DGN}Set Static IP Address To ${BL}$NET${CL}"
|
|
||||||
echo -e " ${CM}${CL} \n"
|
|
||||||
sleep 1
|
|
||||||
clear
|
|
||||||
header_info
|
|
||||||
echo -e "${RD}Using Advanced Settings${CL}"
|
|
||||||
echo -e "${DGN}Using CT Type ${BGN}$CT_TYPE1${CL}"
|
|
||||||
echo -e "${DGN}Using CT Password ${BGN}$PW1${CL}"
|
|
||||||
echo -e "${DGN}Using CT ID ${BGN}$CT_ID${CL}"
|
|
||||||
echo -e "${DGN}Using CT Name ${BGN}$HN${CL}"
|
|
||||||
echo -e "${DGN}Using Disk Size ${BGN}$DISK_SIZE${CL}${DGN}GB${CL}"
|
|
||||||
echo -e "${DGN}Using ${BGN}${CORE_COUNT}${CL}${DGN}vCPU${CL}"
|
|
||||||
echo -e "${DGN}Using ${BGN}${RAM_SIZE}${CL}${DGN}MiB RAM${CL}"
|
|
||||||
echo -e "${DGN}Using Bridge ${BGN}${BRG}${CL}"
|
|
||||||
echo -e "${DGN}Using Static IP Address ${BGN}$NET${CL}"
|
|
||||||
echo -e "${YW}Enter a Gateway IP (mandatory if static IP is used), or Press [ENTER] for Default: NONE "
|
|
||||||
read GATE1
|
|
||||||
if [ -z $GATE1 ]; then GATE1="NONE" GATE="";
|
|
||||||
echo -en "${DGN}Set Gateway IP To ${BL}$GATE1${CL}"
|
|
||||||
else
|
|
||||||
GATE=",gw=$GATE1"
|
|
||||||
echo -en "${DGN}Set Gateway IP To ${BL}$GATE1${CL}"
|
|
||||||
fi;
|
|
||||||
echo -e " ${CM}${CL} \n"
|
|
||||||
sleep 1
|
|
||||||
clear
|
|
||||||
header_info
|
|
||||||
|
|
||||||
echo -e "${RD}Using Advanced Settings${CL}"
|
|
||||||
echo -e "${DGN}Using CT Type ${BGN}$CT_TYPE1${CL}"
|
|
||||||
echo -e "${DGN}Using CT Password ${BGN}$PW1${CL}"
|
|
||||||
echo -e "${DGN}Using CT ID ${BGN}$CT_ID${CL}"
|
|
||||||
echo -e "${DGN}Using CT Name ${BGN}$HN${CL}"
|
|
||||||
echo -e "${DGN}Using Disk Size ${BGN}$DISK_SIZE${CL}${DGN}GB${CL}"
|
|
||||||
echo -e "${DGN}Using ${BGN}${CORE_COUNT}${CL}${DGN}vCPU${CL}"
|
|
||||||
echo -e "${DGN}Using ${BGN}${RAM_SIZE}${CL}${DGN}MiB RAM${CL}"
|
|
||||||
echo -e "${DGN}Using Bridge ${BGN}${BRG}${CL}"
|
|
||||||
echo -e "${DGN}Using Static IP Address ${BGN}$NET${CL}"
|
|
||||||
echo -e "${DGN}Using Gateway IP Address ${BGN}$GATE1${CL}"
|
|
||||||
echo -e "${YW}Enter a VLAN Tag, or Press [ENTER] for Default: NONE "
|
|
||||||
read VLAN1
|
|
||||||
if [ -z $VLAN1 ]; then VLAN1="NONE" VLAN="";
|
|
||||||
echo -en "${DGN}Set VLAN Tag To ${BL}$VLAN1${CL}"
|
|
||||||
else
|
|
||||||
VLAN=",tag=$VLAN1"
|
|
||||||
echo -en "${DGN}Set VLAN Tag To ${BL}$VLAN1${CL}"
|
|
||||||
fi;
|
|
||||||
echo -e " ${CM}${CL} \n"
|
|
||||||
sleep 1
|
|
||||||
clear
|
|
||||||
header_info
|
|
||||||
echo -e "${RD}Using Advanced Settings${CL}"
|
|
||||||
echo -e "${DGN}Using CT Type ${BGN}$CT_TYPE1${CL}"
|
|
||||||
echo -e "${DGN}Using CT Password ${BGN}$PW1${CL}"
|
|
||||||
echo -e "${DGN}Using CT ID ${BGN}$CT_ID${CL}"
|
|
||||||
echo -e "${DGN}Using CT Name ${BGN}$HN${CL}"
|
|
||||||
echo -e "${DGN}Using Disk Size ${BGN}$DISK_SIZE${CL}${DGN}GB${CL}"
|
|
||||||
echo -e "${DGN}Using ${BGN}${CORE_COUNT}${CL}${DGN}vCPU${CL}"
|
|
||||||
echo -e "${DGN}Using ${BGN}${RAM_SIZE}${CL}${DGN}MiB RAM${CL}"
|
|
||||||
echo -e "${DGN}Using Bridge ${BGN}${BRG}${CL}"
|
|
||||||
echo -e "${DGN}Using Static IP Address ${BGN}$NET${CL}"
|
|
||||||
echo -e "${DGN}Using Gateway IP Address ${BGN}$GATE1${CL}"
|
|
||||||
echo -e "${DGN}Using VLAN Tag ${BGN}$VLAN1${CL}"
|
|
||||||
|
|
||||||
read -p "Are these settings correct(y/n)? " -n 1 -r
|
|
||||||
echo
|
|
||||||
if [[ ! $REPLY =~ ^[Yy]$ ]]
|
|
||||||
then
|
|
||||||
advanced_settings
|
|
||||||
fi
|
|
||||||
}
|
|
||||||
|
|
||||||
function start_script() {
|
|
||||||
echo -e "${YW}Type Advanced, or Press [ENTER] for Default Settings "
|
|
||||||
read SETTINGS
|
|
||||||
if [ -z $SETTINGS ]; then default_settings;
|
|
||||||
else
|
|
||||||
advanced_settings
|
|
||||||
fi;
|
|
||||||
}
|
|
||||||
|
|
||||||
start_script
|
|
||||||
|
|
||||||
if [ "$CT_TYPE" == "1" ]; then
|
|
||||||
FEATURES="nesting=1,keyctl=1"
|
|
||||||
else
|
|
||||||
FEATURES="nesting=1"
|
|
||||||
fi
|
|
||||||
|
|
||||||
TEMP_DIR=$(mktemp -d)
|
|
||||||
pushd $TEMP_DIR >/dev/null
|
|
||||||
|
|
||||||
export CTID=$CT_ID
|
|
||||||
export PCT_OSTYPE=debian
|
|
||||||
export PCT_OSVERSION=11
|
|
||||||
export PCT_DISK_SIZE=$DISK_SIZE
|
|
||||||
export PCT_OPTIONS="
|
|
||||||
-features $FEATURES
|
|
||||||
-hostname $HN
|
|
||||||
-net0 name=eth0,bridge=$BRG,ip=$NET$GATE$VLAN
|
|
||||||
-onboot 1
|
|
||||||
-cores $CORE_COUNT
|
|
||||||
-memory $RAM_SIZE
|
|
||||||
-unprivileged $CT_TYPE
|
|
||||||
$PW
|
|
||||||
"
|
|
||||||
bash -c "$(wget -qLO - https://raw.githubusercontent.com/tteck/Proxmox/main/ct/create_lxc.sh)" || exit
|
|
||||||
|
|
||||||
msg_info "Starting LXC Container"
|
|
||||||
pct start $CTID
|
|
||||||
msg_ok "Started LXC Container"
|
|
||||||
|
|
||||||
lxc-attach -n $CTID -- bash -c "$(wget -qLO - https://raw.githubusercontent.com/tteck/Proxmox/main/setup/node-red-install.sh)" || exit
|
|
||||||
|
|
||||||
IP=$(pct exec $CTID ip a s dev eth0 | sed -n '/inet / s/\// /p' | awk '{print $2}')
|
|
||||||
|
|
||||||
pct set $CTID -description "# ${APP} LXC
|
|
||||||
### https://github.com/tteck/Proxmox"
|
|
||||||
|
|
||||||
msg_ok "Completed Successfully!\n"
|
|
||||||
echo -e "${APP} should be reachable by going to the following URL.
|
|
||||||
${BL}http://${IP}:1880${CL} \n"
|
|
|
@ -309,7 +309,7 @@ bash -c "$(wget -qLO - https://raw.githubusercontent.com/tteck/Proxmox/main/ct/c
|
||||||
msg_info "Starting LXC Container"
|
msg_info "Starting LXC Container"
|
||||||
pct start $CTID
|
pct start $CTID
|
||||||
msg_ok "Started LXC Container"
|
msg_ok "Started LXC Container"
|
||||||
lxc-attach -n $CTID -- bash -c "$(wget -qLO - https://raw.githubusercontent.com/tteck/Proxmox/main/setup/$var_install.sh)" || exit
|
lxc-attach -n $CTID -- bash -c "$(wget -qLO - https://raw.githubusercontent.com/tteck/Proxmox/main/install/$var_install.sh)" || exit
|
||||||
IP=$(pct exec $CTID ip a s dev eth0 | sed -n '/inet / s/\// /p' | awk '{print $2}')
|
IP=$(pct exec $CTID ip a s dev eth0 | sed -n '/inet / s/\// /p' | awk '{print $2}')
|
||||||
pct set $CTID -description "# ${APP} LXC
|
pct set $CTID -description "# ${APP} LXC
|
||||||
### https://tteck.github.io/Proxmox/
|
### https://tteck.github.io/Proxmox/
|
||||||
|
|
252
ct/omada-v2.sh
252
ct/omada-v2.sh
|
@ -1,252 +0,0 @@
|
||||||
#!/usr/bin/env bash
|
|
||||||
clear
|
|
||||||
YW=`echo "\033[33m"`
|
|
||||||
BL=`echo "\033[36m"`
|
|
||||||
RD=`echo "\033[01;31m"`
|
|
||||||
CM='\xE2\x9C\x94\033'
|
|
||||||
GN=`echo "\033[1;92m"`
|
|
||||||
CL=`echo "\033[m"`
|
|
||||||
while true; do
|
|
||||||
read -p "This will create a New Omada Controller LXC. Proceed(y/n)?" yn
|
|
||||||
case $yn in
|
|
||||||
[Yy]* ) break;;
|
|
||||||
[Nn]* ) exit;;
|
|
||||||
* ) echo "Please answer yes or no.";;
|
|
||||||
esac
|
|
||||||
done
|
|
||||||
clear
|
|
||||||
function header_info {
|
|
||||||
echo -e "${BL}
|
|
||||||
____ _ _____ _ _ _
|
|
||||||
/ __ \ | | / ____| | | | | |
|
|
||||||
| | | |_ __ ___ __ _ __| | __ _ | | ___ _ __ | |_ _ __ ___ | | | ___ _ __
|
|
||||||
| | | | _ _ \ / _ |/ _ |/ _ | | | / _ \| _ \| __| __/ _ \| | |/ _ \ __|
|
|
||||||
| |__| | | | | | | (_| | (_| | (_| | | |___| (_) | | | | |_| | | (_) | | | __/ |
|
|
||||||
\____/|_| |_| |_|\__,_|\__,_|\__,_| \_____\___/|_| |_|\__|_| \___/|_|_|\___|_|
|
|
||||||
${CL}"
|
|
||||||
}
|
|
||||||
|
|
||||||
header_info
|
|
||||||
show_menu(){
|
|
||||||
printf " ${YW} 1)${YW} Privileged ${CL}\n"
|
|
||||||
printf " ${YW} 2)${GN} Unprivileged ${CL}\n"
|
|
||||||
|
|
||||||
printf "Please choose an Install Method and hit enter or ${RD}x${CL} to exit."
|
|
||||||
read opt
|
|
||||||
}
|
|
||||||
|
|
||||||
option_picked(){
|
|
||||||
message1=${@:-"${CL}Error: No message passed"}
|
|
||||||
printf " ${YW}${message1}${CL}\n"
|
|
||||||
}
|
|
||||||
show_menu
|
|
||||||
while [ "$opt" != " " ]
|
|
||||||
do
|
|
||||||
case $opt in
|
|
||||||
1) clear;
|
|
||||||
header_info;
|
|
||||||
option_picked "Using Privileged Install";
|
|
||||||
IM=0
|
|
||||||
break;
|
|
||||||
;;
|
|
||||||
2) clear;
|
|
||||||
header_info;
|
|
||||||
option_picked "Using Unprivileged Install";
|
|
||||||
IM=1
|
|
||||||
break;
|
|
||||||
;;
|
|
||||||
|
|
||||||
x)exit;
|
|
||||||
;;
|
|
||||||
\n)exit;
|
|
||||||
;;
|
|
||||||
*)clear;
|
|
||||||
option_picked "Please choose a Install Method from the menu";
|
|
||||||
show_menu;
|
|
||||||
;;
|
|
||||||
esac
|
|
||||||
done
|
|
||||||
show_menu2(){
|
|
||||||
printf " ${YW} 1)${GN} Use Automatic Login ${CL}\n"
|
|
||||||
printf " ${YW} 2)${GN} Use Password (changeme) ${CL}\n"
|
|
||||||
|
|
||||||
printf "Please choose a Password Type and hit enter or ${RD}x${CL} to exit."
|
|
||||||
read opt
|
|
||||||
}
|
|
||||||
|
|
||||||
option_picked(){
|
|
||||||
message2=${@:-"${CL}Error: No message passed"}
|
|
||||||
printf " ${YW}${message1}${CL}\n"
|
|
||||||
printf " ${YW}${message2}${CL}\n"
|
|
||||||
}
|
|
||||||
show_menu2
|
|
||||||
while [ "$opt" != " " ]
|
|
||||||
do
|
|
||||||
case $opt in
|
|
||||||
1) clear;
|
|
||||||
header_info;
|
|
||||||
option_picked "Using Automatic Login";
|
|
||||||
PW=" "
|
|
||||||
break;
|
|
||||||
;;
|
|
||||||
2) clear;
|
|
||||||
header_info;
|
|
||||||
option_picked "Using Password (changeme)";
|
|
||||||
PW="-password changeme"
|
|
||||||
break;
|
|
||||||
;;
|
|
||||||
|
|
||||||
x)exit;
|
|
||||||
;;
|
|
||||||
\n)exit;
|
|
||||||
;;
|
|
||||||
*)clear;
|
|
||||||
option_picked "Please choose a Password Type from the menu";
|
|
||||||
show_menu2;
|
|
||||||
;;
|
|
||||||
esac
|
|
||||||
done
|
|
||||||
show_menu3(){
|
|
||||||
printf " ${YW} 1)${GN} Automatic DHCP ${CL}\n"
|
|
||||||
printf " ${YW} 2)${GN} Manual DHCP ${CL}\n"
|
|
||||||
|
|
||||||
printf "Please choose a DHCP Type and hit enter or ${RD}x${CL} to exit."
|
|
||||||
read opt
|
|
||||||
}
|
|
||||||
|
|
||||||
option_picked(){
|
|
||||||
message3=${@:-"${CL}Error: No message passed"}
|
|
||||||
printf " ${YW}${message1}${CL}\n"
|
|
||||||
printf " ${YW}${message2}${CL}\n"
|
|
||||||
printf " ${YW}${message3}${CL}\n"
|
|
||||||
}
|
|
||||||
show_menu3
|
|
||||||
while [ "$opt" != " " ]
|
|
||||||
do
|
|
||||||
case $opt in
|
|
||||||
1) clear;
|
|
||||||
header_info;
|
|
||||||
option_picked "Using Automatic DHCP";
|
|
||||||
DHCP=" "
|
|
||||||
break;
|
|
||||||
;;
|
|
||||||
2) clear;
|
|
||||||
header_info;
|
|
||||||
option_picked "Using Manual DHCP";
|
|
||||||
DHCP="1"
|
|
||||||
break;
|
|
||||||
;;
|
|
||||||
|
|
||||||
x)exit;
|
|
||||||
;;
|
|
||||||
\n)exit;
|
|
||||||
;;
|
|
||||||
*)clear;
|
|
||||||
option_picked "Please choose a DHCP Type from the menu";
|
|
||||||
show_menu3;
|
|
||||||
;;
|
|
||||||
esac
|
|
||||||
done
|
|
||||||
|
|
||||||
set -o errexit
|
|
||||||
set -o errtrace
|
|
||||||
set -o nounset
|
|
||||||
set -o pipefail
|
|
||||||
shopt -s expand_aliases
|
|
||||||
alias die='EXIT=$? LINE=$LINENO error_exit'
|
|
||||||
trap die ERR
|
|
||||||
trap cleanup EXIT
|
|
||||||
|
|
||||||
function error_exit() {
|
|
||||||
trap - ERR
|
|
||||||
local DEFAULT='Unknown failure occured.'
|
|
||||||
local REASON="\e[97m${1:-$DEFAULT}\e[39m"
|
|
||||||
local FLAG="\e[91m[ERROR] \e[93m$EXIT@$LINE"
|
|
||||||
msg "$FLAG $REASON"
|
|
||||||
[ ! -z ${CTID-} ] && cleanup_ctid
|
|
||||||
exit $EXIT
|
|
||||||
}
|
|
||||||
function warn() {
|
|
||||||
local REASON="\e[97m$1\e[39m"
|
|
||||||
local FLAG="\e[93m[WARNING]\e[39m"
|
|
||||||
msg "$FLAG $REASON"
|
|
||||||
}
|
|
||||||
function info() {
|
|
||||||
local REASON="$1"
|
|
||||||
local FLAG="\e[36m[INFO]\e[39m"
|
|
||||||
msg "$FLAG $REASON"
|
|
||||||
}
|
|
||||||
function msg() {
|
|
||||||
local TEXT="$1"
|
|
||||||
echo -e "$TEXT"
|
|
||||||
}
|
|
||||||
function cleanup_ctid() {
|
|
||||||
if $(pct status $CTID &>/dev/null); then
|
|
||||||
if [ "$(pct status $CTID | awk '{print $2}')" == "running" ]; then
|
|
||||||
pct stop $CTID
|
|
||||||
fi
|
|
||||||
pct destroy $CTID
|
|
||||||
elif [ "$(pvesm list $STORAGE --vmid $CTID)" != "" ]; then
|
|
||||||
pvesm free $ROOTFS
|
|
||||||
fi
|
|
||||||
}
|
|
||||||
function cleanup() {
|
|
||||||
popd >/dev/null
|
|
||||||
rm -rf $TEMP_DIR
|
|
||||||
}
|
|
||||||
if [ "$IM" == "1" ]; then
|
|
||||||
FEATURES="nesting=1,keyctl=1"
|
|
||||||
else
|
|
||||||
FEATURES="nesting=1"
|
|
||||||
fi
|
|
||||||
|
|
||||||
TEMP_DIR=$(mktemp -d)
|
|
||||||
pushd $TEMP_DIR >/dev/null
|
|
||||||
|
|
||||||
export CTID=$(pvesh get /cluster/nextid)
|
|
||||||
export PCT_OSTYPE=ubuntu
|
|
||||||
export PCT_OSVERSION=20.04
|
|
||||||
export PCT_DISK_SIZE=8
|
|
||||||
export PCT_OPTIONS="
|
|
||||||
-features $FEATURES
|
|
||||||
-hostname omada
|
|
||||||
-net0 name=eth0,bridge=vmbr0,ip=dhcp
|
|
||||||
-onboot 1
|
|
||||||
-cores 2
|
|
||||||
-memory 2048
|
|
||||||
-unprivileged ${IM}
|
|
||||||
${PW}
|
|
||||||
"
|
|
||||||
bash -c "$(wget -qLO - https://raw.githubusercontent.com/tteck/Proxmox/main/ct/create_lxc.sh)" || exit
|
|
||||||
|
|
||||||
STORAGE_TYPE=$(pvesm status -storage $(pct config $CTID | grep rootfs | awk -F ":" '{print $2}') | awk 'NR>1 {print $2}')
|
|
||||||
if [ "$STORAGE_TYPE" == "zfspool" ]; then
|
|
||||||
warn "Some addons may not work due to ZFS not supporting 'fallocate'."
|
|
||||||
fi
|
|
||||||
if [ "$DHCP" == "1" ]; then
|
|
||||||
MAC=$(pct config $CTID \
|
|
||||||
| grep -i hwaddr \
|
|
||||||
| awk '{print substr($2, 31, length($3) 17 ) }') \
|
|
||||||
|
|
||||||
echo -e "MAC Address ${BL}$MAC${CL}"
|
|
||||||
|
|
||||||
dhcp_reservation(){
|
|
||||||
printf "Please set DHCP reservation and press Enter."
|
|
||||||
read
|
|
||||||
}
|
|
||||||
dhcp_reservation
|
|
||||||
fi
|
|
||||||
|
|
||||||
echo -en "${GN} Starting LXC Container... "
|
|
||||||
pct start $CTID
|
|
||||||
echo -e "${CM}${CL} \r"
|
|
||||||
|
|
||||||
alias lxc-cmd="lxc-attach -n $CTID --"
|
|
||||||
|
|
||||||
lxc-cmd bash -c "$(wget -qLO - https://raw.githubusercontent.com/tteck/Proxmox/main/setup/omada-install.sh)" || exit
|
|
||||||
|
|
||||||
IP=$(pct exec $CTID ip a s dev eth0 | sed -n '/inet / s/\// /p' | awk '{print $2}')
|
|
||||||
|
|
||||||
echo -e "${GN}Successfully created Omada Controller LXC to${CL} ${BL}$CTID${CL}.
|
|
||||||
${BL}Omada${CL} should be reachable by going to the following URL.
|
|
||||||
${BL}https://${IP}:8043${CL} \n"
|
|
356
ct/omada-v3.sh
356
ct/omada-v3.sh
|
@ -1,356 +0,0 @@
|
||||||
#!/usr/bin/env bash
|
|
||||||
echo -e "Loading..."
|
|
||||||
NEXTID=$(pvesh get /cluster/nextid)
|
|
||||||
INTEGER='^[0-9]+$'
|
|
||||||
YW=`echo "\033[33m"`
|
|
||||||
BL=`echo "\033[36m"`
|
|
||||||
RD=`echo "\033[01;31m"`
|
|
||||||
BGN=`echo "\033[4;92m"`
|
|
||||||
GN=`echo "\033[1;92m"`
|
|
||||||
DGN=`echo "\033[32m"`
|
|
||||||
CL=`echo "\033[m"`
|
|
||||||
BFR="\\r\\033[K"
|
|
||||||
HOLD="-"
|
|
||||||
CM="${GN}✓${CL}"
|
|
||||||
APP="Omada"
|
|
||||||
NSAPP=$(echo ${APP,,} | tr -d ' ')
|
|
||||||
set -o errexit
|
|
||||||
set -o errtrace
|
|
||||||
set -o nounset
|
|
||||||
set -o pipefail
|
|
||||||
shopt -s expand_aliases
|
|
||||||
alias die='EXIT=$? LINE=$LINENO error_exit'
|
|
||||||
trap die ERR
|
|
||||||
|
|
||||||
function error_exit() {
|
|
||||||
trap - ERR
|
|
||||||
local reason="Unknown failure occurred."
|
|
||||||
local msg="${1:-$reason}"
|
|
||||||
local flag="${RD}‼ ERROR ${CL}$EXIT@$LINE"
|
|
||||||
echo -e "$flag $msg" 1>&2
|
|
||||||
exit $EXIT
|
|
||||||
}
|
|
||||||
|
|
||||||
while true; do
|
|
||||||
clear
|
|
||||||
read -p "This will create a New ${APP} LXC. Proceed(y/n)?" yn
|
|
||||||
case $yn in
|
|
||||||
[Yy]* ) break;;
|
|
||||||
[Nn]* ) exit;;
|
|
||||||
* ) echo "Please answer yes or no.";;
|
|
||||||
esac
|
|
||||||
done
|
|
||||||
clear
|
|
||||||
function header_info {
|
|
||||||
echo -e "${BL}
|
|
||||||
____ _ _____ _ _ _
|
|
||||||
/ __ \ | | / ____| | | | | |
|
|
||||||
| | | |_ __ ___ v3__ _ __| | __ _ | | ___ _ __ | |_ _ __ ___ | | | ___ _ __
|
|
||||||
| | | | _ _ \ / _ |/ _ |/ _ | | | / _ \| _ \| __| __/ _ \| | |/ _ \ __|
|
|
||||||
| |__| | | | | | | (_| | (_| | (_| | | |___| (_) | | | | |_| | | (_) | | | __/ |
|
|
||||||
\____/|_| |_| |_|\__,_|\__,_|\__,_| \_____\___/|_| |_|\__|_| \___/|_|_|\___|_|
|
|
||||||
${CL}"
|
|
||||||
}
|
|
||||||
|
|
||||||
header_info
|
|
||||||
|
|
||||||
function msg_info() {
|
|
||||||
local msg="$1"
|
|
||||||
echo -ne " ${HOLD} ${YW}${msg}..."
|
|
||||||
}
|
|
||||||
|
|
||||||
function msg_ok() {
|
|
||||||
local msg="$1"
|
|
||||||
echo -e "${BFR} ${CM} ${GN}${msg}${CL}"
|
|
||||||
}
|
|
||||||
|
|
||||||
function PVE_CHECK() {
|
|
||||||
PVE=$(pveversion | grep "pve-manager/7" | wc -l)
|
|
||||||
|
|
||||||
if [[ $PVE != 1 ]]; then
|
|
||||||
echo -e "${RD}This script requires Proxmox Virtual Environment 7.0 or greater${CL}"
|
|
||||||
echo -e "Exiting..."
|
|
||||||
sleep 2
|
|
||||||
exit
|
|
||||||
fi
|
|
||||||
}
|
|
||||||
|
|
||||||
function default_settings() {
|
|
||||||
clear
|
|
||||||
header_info
|
|
||||||
echo -e "${BL}Using Default Settings${CL}"
|
|
||||||
echo -e "${DGN}Using CT Type ${BGN}Unprivileged${CL} ${RD}NO DEVICE PASSTHROUGH${CL}"
|
|
||||||
CT_TYPE="1"
|
|
||||||
echo -e "${DGN}Using CT Password ${BGN}Automatic Login${CL}"
|
|
||||||
PW=" "
|
|
||||||
echo -e "${DGN}Using CT ID ${BGN}$NEXTID${CL}"
|
|
||||||
CT_ID=$NEXTID
|
|
||||||
echo -e "${DGN}Using CT Name ${BGN}$NSAPP${CL}"
|
|
||||||
HN=$NSAPP
|
|
||||||
echo -e "${DGN}Using Disk Size ${BGN}8${CL}${DGN}GB${CL}"
|
|
||||||
DISK_SIZE="8"
|
|
||||||
echo -e "${DGN}Using ${BGN}1${CL}${DGN}vCPU${CL}"
|
|
||||||
CORE_COUNT="2"
|
|
||||||
echo -e "${DGN}Using ${BGN}512${CL}${DGN}MiB RAM${CL}"
|
|
||||||
RAM_SIZE="2048"
|
|
||||||
echo -e "${DGN}Using Bridge ${BGN}vmbr0${CL}"
|
|
||||||
BRG="vmbr0"
|
|
||||||
echo -e "${DGN}Using Static IP Address ${BGN}DHCP${CL}"
|
|
||||||
NET=dhcp
|
|
||||||
echo -e "${DGN}Using Gateway Address ${BGN}NONE${CL}"
|
|
||||||
GATE=""
|
|
||||||
echo -e "${DGN}Using VLAN Tag ${BGN}NONE${CL}"
|
|
||||||
VLAN=""
|
|
||||||
}
|
|
||||||
|
|
||||||
function advanced_settings() {
|
|
||||||
clear
|
|
||||||
header_info
|
|
||||||
echo -e "${RD}Using Advanced Settings${CL}"
|
|
||||||
echo -e "${YW}Type Privileged, or Press [ENTER] for Default: Unprivileged (${RD}NO DEVICE PASSTHROUGH${CL}${YW})"
|
|
||||||
read CT_TYPE1
|
|
||||||
if [ -z $CT_TYPE1 ]; then CT_TYPE1="Unprivileged" CT_TYPE="1";
|
|
||||||
echo -en "${DGN}Set CT Type ${BL}$CT_TYPE1${CL}"
|
|
||||||
else
|
|
||||||
CT_TYPE1="Privileged"
|
|
||||||
CT_TYPE="0"
|
|
||||||
echo -en "${DGN}Set CT Type ${BL}Privileged${CL}"
|
|
||||||
fi;
|
|
||||||
echo -e " ${CM}${CL} \r"
|
|
||||||
sleep 1
|
|
||||||
clear
|
|
||||||
header_info
|
|
||||||
echo -e "${RD}Using Advanced Settings${CL}"
|
|
||||||
echo -e "${DGN}Using CT Type ${BGN}$CT_TYPE1${CL}"
|
|
||||||
echo -e "${YW}Set Password, or Press [ENTER] for Default: Automatic Login "
|
|
||||||
read PW1
|
|
||||||
if [ -z $PW1 ]; then PW1="Automatic Login" PW=" ";
|
|
||||||
echo -en "${DGN}Set CT ${BL}$PW1${CL}"
|
|
||||||
else
|
|
||||||
PW="-password $PW1"
|
|
||||||
echo -en "${DGN}Set CT Password ${BL}$PW1${CL}"
|
|
||||||
fi;
|
|
||||||
echo -e " ${CM}${CL} \r"
|
|
||||||
sleep 1
|
|
||||||
clear
|
|
||||||
header_info
|
|
||||||
echo -e "${RD}Using Advanced Settings${CL}"
|
|
||||||
echo -e "${DGN}Using CT Type ${BGN}$CT_TYPE1${CL}"
|
|
||||||
echo -e "${DGN}Using CT Password ${BGN}$PW1${CL}"
|
|
||||||
echo -e "${YW}Enter the CT ID, or Press [ENTER] to automatically generate (${NEXTID}) "
|
|
||||||
read CT_ID
|
|
||||||
if [ -z $CT_ID ]; then CT_ID=$NEXTID; fi;
|
|
||||||
echo -en "${DGN}Set CT ID To ${BL}$CT_ID${CL}"
|
|
||||||
echo -e " ${CM}${CL} \r"
|
|
||||||
sleep 1
|
|
||||||
clear
|
|
||||||
header_info
|
|
||||||
echo -e "${RD}Using Advanced Settings${CL}"
|
|
||||||
echo -e "${DGN}Using CT Type ${BGN}$CT_TYPE1${CL}"
|
|
||||||
echo -e "${DGN}Using CT Password ${BGN}$PW1${CL}"
|
|
||||||
echo -e "${DGN}Using CT ID ${BGN}$CT_ID${CL}"
|
|
||||||
echo -e "${YW}Enter CT Name (no-spaces), or Press [ENTER] for Default: $NSAPP "
|
|
||||||
read CT_NAME
|
|
||||||
if [ -z $CT_NAME ]; then
|
|
||||||
HN=$NSAPP
|
|
||||||
else
|
|
||||||
HN=$(echo ${CT_NAME,,} | tr -d ' ')
|
|
||||||
fi
|
|
||||||
echo -en "${DGN}Set CT Name To ${BL}$HN${CL}"
|
|
||||||
echo -e " ${CM}${CL} \r"
|
|
||||||
sleep 1
|
|
||||||
clear
|
|
||||||
header_info
|
|
||||||
echo -e "${RD}Using Advanced Settings${CL}"
|
|
||||||
echo -e "${DGN}Using CT Type ${BGN}$CT_TYPE1${CL}"
|
|
||||||
echo -e "${DGN}Using CT Password ${BGN}$PW1${CL}"
|
|
||||||
echo -e "${DGN}Using CT ID ${BGN}$CT_ID${CL}"
|
|
||||||
echo -e "${DGN}Using CT Name ${BGN}$HN${CL}"
|
|
||||||
echo -e "${YW}Enter a Disk Size, or Press [ENTER] for Default: 8 "
|
|
||||||
read DISK_SIZE
|
|
||||||
if [ -z $DISK_SIZE ]; then DISK_SIZE="8"; fi;
|
|
||||||
if ! [[ $DISK_SIZE =~ $INTEGER ]] ; then echo "ERROR! DISK SIZE MUST HAVE INTEGER NUMBER!"; exit; fi;
|
|
||||||
echo -en "${DGN}Set Disk Size To ${BL}$DISK_SIZE${CL}${DGN}GB${CL}"
|
|
||||||
echo -e " ${CM}${CL} \r"
|
|
||||||
sleep 1
|
|
||||||
clear
|
|
||||||
header_info
|
|
||||||
echo -e "${RD}Using Advanced Settings${CL}"
|
|
||||||
echo -e "${DGN}Using CT Type ${BGN}$CT_TYPE1${CL}"
|
|
||||||
echo -e "${DGN}Using CT Password ${BGN}$PW1${CL}"
|
|
||||||
echo -e "${DGN}Using CT ID ${BGN}$CT_ID${CL}"
|
|
||||||
echo -e "${DGN}Using CT Name ${BGN}$HN${CL}"
|
|
||||||
echo -e "${DGN}Using Disk Size ${BGN}$DISK_SIZE${CL}${DGN}GB${CL}"
|
|
||||||
echo -e "${YW}Allocate CPU cores, or Press [ENTER] for Default: 2 "
|
|
||||||
read CORE_COUNT
|
|
||||||
if [ -z $CORE_COUNT ]; then CORE_COUNT="2"; fi;
|
|
||||||
echo -en "${DGN}Set Cores To ${BL}$CORE_COUNT${CL}${DGN}vCPU${CL}"
|
|
||||||
echo -e " ${CM}${CL} \r"
|
|
||||||
sleep 1
|
|
||||||
clear
|
|
||||||
header_info
|
|
||||||
echo -e "${RD}Using Advanced Settings${CL}"
|
|
||||||
echo -e "${DGN}Using CT Type ${BGN}$CT_TYPE1${CL}"
|
|
||||||
echo -e "${DGN}Using CT Password ${BGN}$PW1${CL}"
|
|
||||||
echo -e "${DGN}Using CT ID ${BGN}$CT_ID${CL}"
|
|
||||||
echo -e "${DGN}Using CT Name ${BGN}$HN${CL}"
|
|
||||||
echo -e "${DGN}Using Disk Size ${BGN}$DISK_SIZE${CL}${DGN}GB${CL}"
|
|
||||||
echo -e "${DGN}Using ${BGN}${CORE_COUNT}${CL}${DGN}vCPU${CL}"
|
|
||||||
echo -e "${YW}Allocate RAM in MiB, or Press [ENTER] for Default: 2048 "
|
|
||||||
read RAM_SIZE
|
|
||||||
if [ -z $RAM_SIZE ]; then RAM_SIZE="2048"; fi;
|
|
||||||
echo -en "${DGN}Set RAM To ${BL}$RAM_SIZE${CL}${DGN}MiB RAM${CL}"
|
|
||||||
echo -e " ${CM}${CL} \n"
|
|
||||||
sleep 1
|
|
||||||
clear
|
|
||||||
header_info
|
|
||||||
echo -e "${RD}Using Advanced Settings${CL}"
|
|
||||||
echo -e "${DGN}Using CT Type ${BGN}$CT_TYPE1${CL}"
|
|
||||||
echo -e "${DGN}Using CT Password ${BGN}$PW1${CL}"
|
|
||||||
echo -e "${DGN}Using CT ID ${BGN}$CT_ID${CL}"
|
|
||||||
echo -e "${DGN}Using CT Name ${BGN}$HN${CL}"
|
|
||||||
echo -e "${DGN}Using Disk Size ${BGN}$DISK_SIZE${CL}${DGN}GB${CL}"
|
|
||||||
echo -e "${DGN}Using ${BGN}${CORE_COUNT}${CL}${DGN}vCPU${CL}"
|
|
||||||
echo -e "${DGN}Using ${BGN}${RAM_SIZE}${CL}${DGN}MiB RAM${CL}"
|
|
||||||
echo -e "${YW}Enter a Bridge, or Press [ENTER] for Default: vmbr0 "
|
|
||||||
read BRG
|
|
||||||
if [ -z $BRG ]; then BRG="vmbr0"; fi;
|
|
||||||
echo -en "${DGN}Set Bridge To ${BL}$BRG${CL}"
|
|
||||||
echo -e " ${CM}${CL} \n"
|
|
||||||
sleep 1
|
|
||||||
clear
|
|
||||||
header_info
|
|
||||||
echo -e "${RD}Using Advanced Settings${CL}"
|
|
||||||
echo -e "${DGN}Using CT Type ${BGN}$CT_TYPE1${CL}"
|
|
||||||
echo -e "${DGN}Using CT Password ${BGN}$PW1${CL}"
|
|
||||||
echo -e "${DGN}Using CT ID ${BGN}$CT_ID${CL}"
|
|
||||||
echo -e "${DGN}Using CT Name ${BGN}$HN${CL}"
|
|
||||||
echo -e "${DGN}Using Disk Size ${BGN}$DISK_SIZE${CL}${DGN}GB${CL}"
|
|
||||||
echo -e "${DGN}Using ${BGN}${CORE_COUNT}${CL}${DGN}vCPU${CL}"
|
|
||||||
echo -e "${DGN}Using ${BGN}${RAM_SIZE}${CL}${DGN}MiB RAM${CL}"
|
|
||||||
echo -e "${DGN}Using Bridge ${BGN}${BRG}${CL}"
|
|
||||||
echo -e "${YW}Enter a Static IPv4 CIDR Address, or Press [ENTER] for Default: DHCP "
|
|
||||||
read NET
|
|
||||||
if [ -z $NET ]; then NET="dhcp"; fi;
|
|
||||||
echo -en "${DGN}Set Static IP Address To ${BL}$NET${CL}"
|
|
||||||
echo -e " ${CM}${CL} \n"
|
|
||||||
sleep 1
|
|
||||||
clear
|
|
||||||
header_info
|
|
||||||
echo -e "${RD}Using Advanced Settings${CL}"
|
|
||||||
echo -e "${DGN}Using CT Type ${BGN}$CT_TYPE1${CL}"
|
|
||||||
echo -e "${DGN}Using CT Password ${BGN}$PW1${CL}"
|
|
||||||
echo -e "${DGN}Using CT ID ${BGN}$CT_ID${CL}"
|
|
||||||
echo -e "${DGN}Using CT Name ${BGN}$HN${CL}"
|
|
||||||
echo -e "${DGN}Using Disk Size ${BGN}$DISK_SIZE${CL}${DGN}GB${CL}"
|
|
||||||
echo -e "${DGN}Using ${BGN}${CORE_COUNT}${CL}${DGN}vCPU${CL}"
|
|
||||||
echo -e "${DGN}Using ${BGN}${RAM_SIZE}${CL}${DGN}MiB RAM${CL}"
|
|
||||||
echo -e "${DGN}Using Bridge ${BGN}${BRG}${CL}"
|
|
||||||
echo -e "${DGN}Using Static IP Address ${BGN}$NET${CL}"
|
|
||||||
echo -e "${YW}Enter a Gateway IP (mandatory if static IP is used), or Press [ENTER] for Default: NONE "
|
|
||||||
read GATE1
|
|
||||||
if [ -z $GATE1 ]; then GATE1="NONE" GATE="";
|
|
||||||
echo -en "${DGN}Set Gateway IP To ${BL}$GATE1${CL}"
|
|
||||||
else
|
|
||||||
GATE=",gw=$GATE1"
|
|
||||||
echo -en "${DGN}Set Gateway IP To ${BL}$GATE1${CL}"
|
|
||||||
fi;
|
|
||||||
echo -e " ${CM}${CL} \n"
|
|
||||||
sleep 1
|
|
||||||
clear
|
|
||||||
header_info
|
|
||||||
|
|
||||||
echo -e "${RD}Using Advanced Settings${CL}"
|
|
||||||
echo -e "${DGN}Using CT Type ${BGN}$CT_TYPE1${CL}"
|
|
||||||
echo -e "${DGN}Using CT Password ${BGN}$PW1${CL}"
|
|
||||||
echo -e "${DGN}Using CT ID ${BGN}$CT_ID${CL}"
|
|
||||||
echo -e "${DGN}Using CT Name ${BGN}$HN${CL}"
|
|
||||||
echo -e "${DGN}Using Disk Size ${BGN}$DISK_SIZE${CL}${DGN}GB${CL}"
|
|
||||||
echo -e "${DGN}Using ${BGN}${CORE_COUNT}${CL}${DGN}vCPU${CL}"
|
|
||||||
echo -e "${DGN}Using ${BGN}${RAM_SIZE}${CL}${DGN}MiB RAM${CL}"
|
|
||||||
echo -e "${DGN}Using Bridge ${BGN}${BRG}${CL}"
|
|
||||||
echo -e "${DGN}Using Static IP Address ${BGN}$NET${CL}"
|
|
||||||
echo -e "${DGN}Using Gateway IP Address ${BGN}$GATE1${CL}"
|
|
||||||
echo -e "${YW}Enter a VLAN Tag, or Press [ENTER] for Default: NONE "
|
|
||||||
read VLAN1
|
|
||||||
if [ -z $VLAN1 ]; then VLAN1="NONE" VLAN="";
|
|
||||||
echo -en "${DGN}Set VLAN Tag To ${BL}$VLAN1${CL}"
|
|
||||||
else
|
|
||||||
VLAN=",tag=$VLAN1"
|
|
||||||
echo -en "${DGN}Set VLAN Tag To ${BL}$VLAN1${CL}"
|
|
||||||
fi;
|
|
||||||
echo -e " ${CM}${CL} \n"
|
|
||||||
sleep 1
|
|
||||||
clear
|
|
||||||
header_info
|
|
||||||
echo -e "${RD}Using Advanced Settings${CL}"
|
|
||||||
echo -e "${DGN}Using CT Type ${BGN}$CT_TYPE1${CL}"
|
|
||||||
echo -e "${DGN}Using CT Password ${BGN}$PW1${CL}"
|
|
||||||
echo -e "${DGN}Using CT ID ${BGN}$CT_ID${CL}"
|
|
||||||
echo -e "${DGN}Using CT Name ${BGN}$HN${CL}"
|
|
||||||
echo -e "${DGN}Using Disk Size ${BGN}$DISK_SIZE${CL}${DGN}GB${CL}"
|
|
||||||
echo -e "${DGN}Using ${BGN}${CORE_COUNT}${CL}${DGN}vCPU${CL}"
|
|
||||||
echo -e "${DGN}Using ${BGN}${RAM_SIZE}${CL}${DGN}MiB RAM${CL}"
|
|
||||||
echo -e "${DGN}Using Bridge ${BGN}${BRG}${CL}"
|
|
||||||
echo -e "${DGN}Using Static IP Address ${BGN}$NET${CL}"
|
|
||||||
echo -e "${DGN}Using Gateway IP Address ${BGN}$GATE1${CL}"
|
|
||||||
echo -e "${DGN}Using VLAN Tag ${BGN}$VLAN1${CL}"
|
|
||||||
|
|
||||||
read -p "Are these settings correct(y/n)? " -n 1 -r
|
|
||||||
echo
|
|
||||||
if [[ ! $REPLY =~ ^[Yy]$ ]]
|
|
||||||
then
|
|
||||||
advanced_settings
|
|
||||||
fi
|
|
||||||
}
|
|
||||||
|
|
||||||
function start_script() {
|
|
||||||
echo -e "${YW}Type Advanced, or Press [ENTER] for Default Settings "
|
|
||||||
read SETTINGS
|
|
||||||
if [ -z $SETTINGS ]; then default_settings;
|
|
||||||
else
|
|
||||||
advanced_settings
|
|
||||||
fi;
|
|
||||||
}
|
|
||||||
|
|
||||||
start_script
|
|
||||||
|
|
||||||
if [ "$CT_TYPE" == "1" ]; then
|
|
||||||
FEATURES="nesting=1,keyctl=1"
|
|
||||||
else
|
|
||||||
FEATURES="nesting=1"
|
|
||||||
fi
|
|
||||||
|
|
||||||
TEMP_DIR=$(mktemp -d)
|
|
||||||
pushd $TEMP_DIR >/dev/null
|
|
||||||
|
|
||||||
export CTID=$CT_ID
|
|
||||||
export PCT_OSTYPE=ubuntu
|
|
||||||
export PCT_OSVERSION=20.04
|
|
||||||
export PCT_DISK_SIZE=$DISK_SIZE
|
|
||||||
export PCT_OPTIONS="
|
|
||||||
-features $FEATURES
|
|
||||||
-hostname $HN
|
|
||||||
-net0 name=eth0,bridge=$BRG,ip=$NET$GATE$VLAN
|
|
||||||
-onboot 1
|
|
||||||
-cores $CORE_COUNT
|
|
||||||
-memory $RAM_SIZE
|
|
||||||
-unprivileged $CT_TYPE
|
|
||||||
$PW
|
|
||||||
"
|
|
||||||
bash -c "$(wget -qLO - https://raw.githubusercontent.com/tteck/Proxmox/main/ct/create_lxc.sh)" || exit
|
|
||||||
|
|
||||||
msg_info "Starting LXC Container"
|
|
||||||
pct start $CTID
|
|
||||||
msg_ok "Started LXC Container"
|
|
||||||
|
|
||||||
lxc-attach -n $CTID -- bash -c "$(wget -qLO - https://raw.githubusercontent.com/tteck/Proxmox/main/setup/omada-install.sh)" || exit
|
|
||||||
|
|
||||||
IP=$(pct exec $CTID ip a s dev eth0 | sed -n '/inet / s/\// /p' | awk '{print $2}')
|
|
||||||
|
|
||||||
pct set $CTID -description "# ${APP} LXC
|
|
||||||
### https://github.com/tteck/Proxmox"
|
|
||||||
|
|
||||||
msg_ok "Completed Successfully!\n"
|
|
||||||
echo -e "${APP} should be reachable by going to the following URL.
|
|
||||||
${BL}https://${IP}:8043${CL} \n"
|
|
|
@ -318,7 +318,7 @@ bash -c "$(wget -qLO - https://raw.githubusercontent.com/tteck/Proxmox/main/ct/c
|
||||||
msg_info "Starting LXC Container"
|
msg_info "Starting LXC Container"
|
||||||
pct start $CTID
|
pct start $CTID
|
||||||
msg_ok "Started LXC Container"
|
msg_ok "Started LXC Container"
|
||||||
lxc-attach -n $CTID -- bash -c "$(wget -qLO - https://raw.githubusercontent.com/tteck/Proxmox/main/setup/$var_install.sh)" || exit
|
lxc-attach -n $CTID -- bash -c "$(wget -qLO - https://raw.githubusercontent.com/tteck/Proxmox/main/install/$var_install.sh)" || exit
|
||||||
IP=$(pct exec $CTID ip a s dev eth0 | sed -n '/inet / s/\// /p' | awk '{print $2}')
|
IP=$(pct exec $CTID ip a s dev eth0 | sed -n '/inet / s/\// /p' | awk '{print $2}')
|
||||||
pct set $CTID -description "# ${APP} LXC
|
pct set $CTID -description "# ${APP} LXC
|
||||||
### https://tteck.github.io/Proxmox/
|
### https://tteck.github.io/Proxmox/
|
||||||
|
|
|
@ -320,7 +320,7 @@ EOF
|
||||||
msg_info "Starting LXC Container"
|
msg_info "Starting LXC Container"
|
||||||
pct start $CTID
|
pct start $CTID
|
||||||
msg_ok "Started LXC Container"
|
msg_ok "Started LXC Container"
|
||||||
lxc-attach -n $CTID -- bash -c "$(wget -qLO - https://raw.githubusercontent.com/tteck/Proxmox/main/setup/$var_install.sh)" || exit
|
lxc-attach -n $CTID -- bash -c "$(wget -qLO - https://raw.githubusercontent.com/tteck/Proxmox/main/install/$var_install.sh)" || exit
|
||||||
IP=$(pct exec $CTID ip a s dev eth0 | sed -n '/inet / s/\// /p' | awk '{print $2}')
|
IP=$(pct exec $CTID ip a s dev eth0 | sed -n '/inet / s/\// /p' | awk '{print $2}')
|
||||||
pct set $CTID -description "# ${APP} LXC
|
pct set $CTID -description "# ${APP} LXC
|
||||||
### https://tteck.github.io/Proxmox/
|
### https://tteck.github.io/Proxmox/
|
||||||
|
|
361
ct/openhab-v3.sh
361
ct/openhab-v3.sh
|
@ -1,361 +0,0 @@
|
||||||
#!/usr/bin/env bash
|
|
||||||
echo -e "Loading..."
|
|
||||||
APP="openHAB"
|
|
||||||
var_disk="8"
|
|
||||||
var_cpu="2"
|
|
||||||
var_ram="2048"
|
|
||||||
var_os="debian"
|
|
||||||
var_version="11"
|
|
||||||
NEXTID=$(pvesh get /cluster/nextid)
|
|
||||||
INTEGER='^[0-9]+$'
|
|
||||||
NSAPP=$(echo ${APP,,} | tr -d ' ')
|
|
||||||
var_install="${NSAPP}-install"
|
|
||||||
YW=`echo "\033[33m"`
|
|
||||||
BL=`echo "\033[36m"`
|
|
||||||
RD=`echo "\033[01;31m"`
|
|
||||||
BGN=`echo "\033[4;92m"`
|
|
||||||
GN=`echo "\033[1;92m"`
|
|
||||||
DGN=`echo "\033[32m"`
|
|
||||||
CL=`echo "\033[m"`
|
|
||||||
BFR="\\r\\033[K"
|
|
||||||
HOLD="-"
|
|
||||||
CM="${GN}✓${CL}"
|
|
||||||
set -o errexit
|
|
||||||
set -o errtrace
|
|
||||||
set -o nounset
|
|
||||||
set -o pipefail
|
|
||||||
shopt -s expand_aliases
|
|
||||||
alias die='EXIT=$? LINE=$LINENO error_exit'
|
|
||||||
trap die ERR
|
|
||||||
|
|
||||||
function error_exit() {
|
|
||||||
trap - ERR
|
|
||||||
local reason="Unknown failure occurred."
|
|
||||||
local msg="${1:-$reason}"
|
|
||||||
local flag="${RD}‼ ERROR ${CL}$EXIT@$LINE"
|
|
||||||
echo -e "$flag $msg" 1>&2
|
|
||||||
exit $EXIT
|
|
||||||
}
|
|
||||||
|
|
||||||
function msg_info() {
|
|
||||||
local msg="$1"
|
|
||||||
echo -ne " ${HOLD} ${YW}${msg}..."
|
|
||||||
}
|
|
||||||
|
|
||||||
function msg_ok() {
|
|
||||||
local msg="$1"
|
|
||||||
echo -e "${BFR} ${CM} ${GN}${msg}${CL}"
|
|
||||||
}
|
|
||||||
|
|
||||||
while true; do
|
|
||||||
clear
|
|
||||||
read -p "This will create a New ${APP} LXC. Proceed(y/n)?" yn
|
|
||||||
case $yn in
|
|
||||||
[Yy]* ) break;;
|
|
||||||
[Nn]* ) exit;;
|
|
||||||
* ) echo "Please answer yes or no.";;
|
|
||||||
esac
|
|
||||||
done
|
|
||||||
clear
|
|
||||||
function header_info {
|
|
||||||
echo -e "${YW}
|
|
||||||
_ _ ____
|
|
||||||
| | | | /\ | _ \
|
|
||||||
___ _ __ ___ _ __ | |__| | / \ | |_) |
|
|
||||||
/ _ \| _ \ / _ \ _ \| __ | / /\ \ | _ <
|
|
||||||
| (_) | |_) | __/ | | | | | |/ ____ \| |_) |
|
|
||||||
\___/| .__/ \___|_| |_|_| |_/_/ v3 \_\____/
|
|
||||||
| |
|
|
||||||
|_|
|
|
||||||
${CL}"
|
|
||||||
}
|
|
||||||
|
|
||||||
header_info
|
|
||||||
|
|
||||||
function PVE_CHECK() {
|
|
||||||
PVE=$(pveversion | grep "pve-manager/7" | wc -l)
|
|
||||||
|
|
||||||
if [[ $PVE != 1 ]]; then
|
|
||||||
echo -e "${RD}This script requires Proxmox Virtual Environment 7.0 or greater${CL}"
|
|
||||||
echo -e "Exiting..."
|
|
||||||
sleep 2
|
|
||||||
exit
|
|
||||||
fi
|
|
||||||
}
|
|
||||||
|
|
||||||
function default_settings() {
|
|
||||||
clear
|
|
||||||
header_info
|
|
||||||
echo -e "${BL}Using Default Settings${CL}"
|
|
||||||
echo -e "${DGN}Using CT Type ${BGN}Privileged${CL}"
|
|
||||||
CT_TYPE="0"
|
|
||||||
echo -e "${DGN}Using CT Password ${BGN}Automatic Login${CL}"
|
|
||||||
PW=" "
|
|
||||||
echo -e "${DGN}Using CT ID ${BGN}$NEXTID${CL}"
|
|
||||||
CT_ID=$NEXTID
|
|
||||||
echo -e "${DGN}Using CT Name ${BGN}$NSAPP${CL}"
|
|
||||||
HN=$NSAPP
|
|
||||||
echo -e "${DGN}Using Disk Size ${BGN}$var_disk${CL}${DGN}GB${CL}"
|
|
||||||
DISK_SIZE="$var_disk"
|
|
||||||
echo -e "${DGN}Using ${BGN}$var_cpu${CL}${DGN}vCPU${CL}"
|
|
||||||
CORE_COUNT="$var_cpu"
|
|
||||||
echo -e "${DGN}Using ${BGN}$var_ram${CL}${DGN}MiB RAM${CL}"
|
|
||||||
RAM_SIZE="$var_ram"
|
|
||||||
echo -e "${DGN}Using Bridge ${BGN}vmbr0${CL}"
|
|
||||||
BRG="vmbr0"
|
|
||||||
echo -e "${DGN}Using Static IP Address ${BGN}DHCP${CL}"
|
|
||||||
NET=dhcp
|
|
||||||
echo -e "${DGN}Using Gateway Address ${BGN}NONE${CL}"
|
|
||||||
GATE=""
|
|
||||||
echo -e "${DGN}Using VLAN Tag ${BGN}NONE${CL}"
|
|
||||||
VLAN=""
|
|
||||||
}
|
|
||||||
|
|
||||||
function advanced_settings() {
|
|
||||||
clear
|
|
||||||
header_info
|
|
||||||
echo -e "${RD}Using Advanced Settings${CL}"
|
|
||||||
echo -e "${YW}Type Unprivileged, or Press [ENTER] for Default: Privileged"
|
|
||||||
read CT_TYPE1
|
|
||||||
if [ -z $CT_TYPE1 ]; then CT_TYPE1="Privileged" CT_TYPE="0";
|
|
||||||
echo -en "${DGN}Set CT Type ${BL}$CT_TYPE1${CL}"
|
|
||||||
else
|
|
||||||
CT_TYPE1="Unprivileged"
|
|
||||||
CT_TYPE="1"
|
|
||||||
echo -en "${DGN}Set CT Type ${BL}Unprivileged${CL}"
|
|
||||||
fi;
|
|
||||||
echo -e " ${CM}${CL} \r"
|
|
||||||
sleep 1
|
|
||||||
clear
|
|
||||||
header_info
|
|
||||||
echo -e "${RD}Using Advanced Settings${CL}"
|
|
||||||
echo -e "${DGN}Using CT Type ${BGN}$CT_TYPE1${CL}"
|
|
||||||
echo -e "${YW}Set Password, or Press [ENTER] for Default: Automatic Login "
|
|
||||||
read PW1
|
|
||||||
if [ -z $PW1 ]; then PW1="Automatic Login" PW=" ";
|
|
||||||
echo -en "${DGN}Set CT ${BL}$PW1${CL}"
|
|
||||||
else
|
|
||||||
PW="-password $PW1"
|
|
||||||
echo -en "${DGN}Set CT Password ${BL}$PW1${CL}"
|
|
||||||
fi;
|
|
||||||
echo -e " ${CM}${CL} \r"
|
|
||||||
sleep 1
|
|
||||||
clear
|
|
||||||
header_info
|
|
||||||
echo -e "${RD}Using Advanced Settings${CL}"
|
|
||||||
echo -e "${DGN}Using CT Type ${BGN}$CT_TYPE1${CL}"
|
|
||||||
echo -e "${DGN}Using CT Password ${BGN}$PW1${CL}"
|
|
||||||
echo -e "${YW}Enter the CT ID, or Press [ENTER] to automatically generate (${NEXTID}) "
|
|
||||||
read CT_ID
|
|
||||||
if [ -z $CT_ID ]; then CT_ID=$NEXTID; fi;
|
|
||||||
echo -en "${DGN}Set CT ID To ${BL}$CT_ID${CL}"
|
|
||||||
echo -e " ${CM}${CL} \r"
|
|
||||||
sleep 1
|
|
||||||
clear
|
|
||||||
header_info
|
|
||||||
echo -e "${RD}Using Advanced Settings${CL}"
|
|
||||||
echo -e "${DGN}Using CT Type ${BGN}$CT_TYPE1${CL}"
|
|
||||||
echo -e "${DGN}Using CT Password ${BGN}$PW1${CL}"
|
|
||||||
echo -e "${DGN}Using CT ID ${BGN}$CT_ID${CL}"
|
|
||||||
echo -e "${YW}Enter CT Name (no-spaces), or Press [ENTER] for Default: $NSAPP "
|
|
||||||
read CT_NAME
|
|
||||||
if [ -z $CT_NAME ]; then
|
|
||||||
HN=$NSAPP
|
|
||||||
else
|
|
||||||
HN=$(echo ${CT_NAME,,} | tr -d ' ')
|
|
||||||
fi
|
|
||||||
echo -en "${DGN}Set CT Name To ${BL}$HN${CL}"
|
|
||||||
echo -e " ${CM}${CL} \r"
|
|
||||||
sleep 1
|
|
||||||
clear
|
|
||||||
header_info
|
|
||||||
echo -e "${RD}Using Advanced Settings${CL}"
|
|
||||||
echo -e "${DGN}Using CT Type ${BGN}$CT_TYPE1${CL}"
|
|
||||||
echo -e "${DGN}Using CT Password ${BGN}$PW1${CL}"
|
|
||||||
echo -e "${DGN}Using CT ID ${BGN}$CT_ID${CL}"
|
|
||||||
echo -e "${DGN}Using CT Name ${BGN}$HN${CL}"
|
|
||||||
echo -e "${YW}Enter a Disk Size, or Press [ENTER] for Default: $var_disk "
|
|
||||||
read DISK_SIZE
|
|
||||||
if [ -z $DISK_SIZE ]; then DISK_SIZE="$var_disk"; fi;
|
|
||||||
if ! [[ $DISK_SIZE =~ $INTEGER ]] ; then echo "ERROR! DISK SIZE MUST HAVE INTEGER NUMBER!"; exit; fi;
|
|
||||||
echo -en "${DGN}Set Disk Size To ${BL}$DISK_SIZE${CL}${DGN}GB${CL}"
|
|
||||||
echo -e " ${CM}${CL} \r"
|
|
||||||
sleep 1
|
|
||||||
clear
|
|
||||||
header_info
|
|
||||||
echo -e "${RD}Using Advanced Settings${CL}"
|
|
||||||
echo -e "${DGN}Using CT Type ${BGN}$CT_TYPE1${CL}"
|
|
||||||
echo -e "${DGN}Using CT Password ${BGN}$PW1${CL}"
|
|
||||||
echo -e "${DGN}Using CT ID ${BGN}$CT_ID${CL}"
|
|
||||||
echo -e "${DGN}Using CT Name ${BGN}$HN${CL}"
|
|
||||||
echo -e "${DGN}Using Disk Size ${BGN}$DISK_SIZE${CL}${DGN}GB${CL}"
|
|
||||||
echo -e "${YW}Allocate CPU cores, or Press [ENTER] for Default: $var_cpu "
|
|
||||||
read CORE_COUNT
|
|
||||||
if [ -z $CORE_COUNT ]; then CORE_COUNT="$var_cpu"; fi;
|
|
||||||
echo -en "${DGN}Set Cores To ${BL}$CORE_COUNT${CL}${DGN}vCPU${CL}"
|
|
||||||
echo -e " ${CM}${CL} \r"
|
|
||||||
sleep 1
|
|
||||||
clear
|
|
||||||
header_info
|
|
||||||
echo -e "${RD}Using Advanced Settings${CL}"
|
|
||||||
echo -e "${DGN}Using CT Type ${BGN}$CT_TYPE1${CL}"
|
|
||||||
echo -e "${DGN}Using CT Password ${BGN}$PW1${CL}"
|
|
||||||
echo -e "${DGN}Using CT ID ${BGN}$CT_ID${CL}"
|
|
||||||
echo -e "${DGN}Using CT Name ${BGN}$HN${CL}"
|
|
||||||
echo -e "${DGN}Using Disk Size ${BGN}$DISK_SIZE${CL}${DGN}GB${CL}"
|
|
||||||
echo -e "${DGN}Using ${BGN}${CORE_COUNT}${CL}${DGN}vCPU${CL}"
|
|
||||||
echo -e "${YW}Allocate RAM in MiB, or Press [ENTER] for Default: $var_ram "
|
|
||||||
read RAM_SIZE
|
|
||||||
if [ -z $RAM_SIZE ]; then RAM_SIZE="$var_ram"; fi;
|
|
||||||
echo -en "${DGN}Set RAM To ${BL}$RAM_SIZE${CL}${DGN}MiB RAM${CL}"
|
|
||||||
echo -e " ${CM}${CL} \n"
|
|
||||||
sleep 1
|
|
||||||
clear
|
|
||||||
header_info
|
|
||||||
echo -e "${RD}Using Advanced Settings${CL}"
|
|
||||||
echo -e "${DGN}Using CT Type ${BGN}$CT_TYPE1${CL}"
|
|
||||||
echo -e "${DGN}Using CT Password ${BGN}$PW1${CL}"
|
|
||||||
echo -e "${DGN}Using CT ID ${BGN}$CT_ID${CL}"
|
|
||||||
echo -e "${DGN}Using CT Name ${BGN}$HN${CL}"
|
|
||||||
echo -e "${DGN}Using Disk Size ${BGN}$DISK_SIZE${CL}${DGN}GB${CL}"
|
|
||||||
echo -e "${DGN}Using ${BGN}${CORE_COUNT}${CL}${DGN}vCPU${CL}"
|
|
||||||
echo -e "${DGN}Using ${BGN}${RAM_SIZE}${CL}${DGN}MiB RAM${CL}"
|
|
||||||
echo -e "${YW}Enter a Bridge, or Press [ENTER] for Default: vmbr0 "
|
|
||||||
read BRG
|
|
||||||
if [ -z $BRG ]; then BRG="vmbr0"; fi;
|
|
||||||
echo -en "${DGN}Set Bridge To ${BL}$BRG${CL}"
|
|
||||||
echo -e " ${CM}${CL} \n"
|
|
||||||
sleep 1
|
|
||||||
clear
|
|
||||||
header_info
|
|
||||||
echo -e "${RD}Using Advanced Settings${CL}"
|
|
||||||
echo -e "${DGN}Using CT Type ${BGN}$CT_TYPE1${CL}"
|
|
||||||
echo -e "${DGN}Using CT Password ${BGN}$PW1${CL}"
|
|
||||||
echo -e "${DGN}Using CT ID ${BGN}$CT_ID${CL}"
|
|
||||||
echo -e "${DGN}Using CT Name ${BGN}$HN${CL}"
|
|
||||||
echo -e "${DGN}Using Disk Size ${BGN}$DISK_SIZE${CL}${DGN}GB${CL}"
|
|
||||||
echo -e "${DGN}Using ${BGN}${CORE_COUNT}${CL}${DGN}vCPU${CL}"
|
|
||||||
echo -e "${DGN}Using ${BGN}${RAM_SIZE}${CL}${DGN}MiB RAM${CL}"
|
|
||||||
echo -e "${DGN}Using Bridge ${BGN}${BRG}${CL}"
|
|
||||||
echo -e "${YW}Enter a Static IPv4 CIDR Address, or Press [ENTER] for Default: DHCP "
|
|
||||||
read NET
|
|
||||||
if [ -z $NET ]; then NET="dhcp"; fi;
|
|
||||||
echo -en "${DGN}Set Static IP Address To ${BL}$NET${CL}"
|
|
||||||
echo -e " ${CM}${CL} \n"
|
|
||||||
sleep 1
|
|
||||||
clear
|
|
||||||
header_info
|
|
||||||
echo -e "${RD}Using Advanced Settings${CL}"
|
|
||||||
echo -e "${DGN}Using CT Type ${BGN}$CT_TYPE1${CL}"
|
|
||||||
echo -e "${DGN}Using CT Password ${BGN}$PW1${CL}"
|
|
||||||
echo -e "${DGN}Using CT ID ${BGN}$CT_ID${CL}"
|
|
||||||
echo -e "${DGN}Using CT Name ${BGN}$HN${CL}"
|
|
||||||
echo -e "${DGN}Using Disk Size ${BGN}$DISK_SIZE${CL}${DGN}GB${CL}"
|
|
||||||
echo -e "${DGN}Using ${BGN}${CORE_COUNT}${CL}${DGN}vCPU${CL}"
|
|
||||||
echo -e "${DGN}Using ${BGN}${RAM_SIZE}${CL}${DGN}MiB RAM${CL}"
|
|
||||||
echo -e "${DGN}Using Bridge ${BGN}${BRG}${CL}"
|
|
||||||
echo -e "${DGN}Using Static IP Address ${BGN}$NET${CL}"
|
|
||||||
echo -e "${YW}Enter a Gateway IP (mandatory if static IP is used), or Press [ENTER] for Default: NONE "
|
|
||||||
read GATE1
|
|
||||||
if [ -z $GATE1 ]; then GATE1="NONE" GATE="";
|
|
||||||
echo -en "${DGN}Set Gateway IP To ${BL}$GATE1${CL}"
|
|
||||||
else
|
|
||||||
GATE=",gw=$GATE1"
|
|
||||||
echo -en "${DGN}Set Gateway IP To ${BL}$GATE1${CL}"
|
|
||||||
fi;
|
|
||||||
echo -e " ${CM}${CL} \n"
|
|
||||||
sleep 1
|
|
||||||
clear
|
|
||||||
header_info
|
|
||||||
|
|
||||||
echo -e "${RD}Using Advanced Settings${CL}"
|
|
||||||
echo -e "${DGN}Using CT Type ${BGN}$CT_TYPE1${CL}"
|
|
||||||
echo -e "${DGN}Using CT Password ${BGN}$PW1${CL}"
|
|
||||||
echo -e "${DGN}Using CT ID ${BGN}$CT_ID${CL}"
|
|
||||||
echo -e "${DGN}Using CT Name ${BGN}$HN${CL}"
|
|
||||||
echo -e "${DGN}Using Disk Size ${BGN}$DISK_SIZE${CL}${DGN}GB${CL}"
|
|
||||||
echo -e "${DGN}Using ${BGN}${CORE_COUNT}${CL}${DGN}vCPU${CL}"
|
|
||||||
echo -e "${DGN}Using ${BGN}${RAM_SIZE}${CL}${DGN}MiB RAM${CL}"
|
|
||||||
echo -e "${DGN}Using Bridge ${BGN}${BRG}${CL}"
|
|
||||||
echo -e "${DGN}Using Static IP Address ${BGN}$NET${CL}"
|
|
||||||
echo -e "${DGN}Using Gateway IP Address ${BGN}$GATE1${CL}"
|
|
||||||
echo -e "${YW}Enter a VLAN Tag, or Press [ENTER] for Default: NONE "
|
|
||||||
read VLAN1
|
|
||||||
if [ -z $VLAN1 ]; then VLAN1="NONE" VLAN="";
|
|
||||||
echo -en "${DGN}Set VLAN Tag To ${BL}$VLAN1${CL}"
|
|
||||||
else
|
|
||||||
VLAN=",tag=$VLAN1"
|
|
||||||
echo -en "${DGN}Set VLAN Tag To ${BL}$VLAN1${CL}"
|
|
||||||
fi;
|
|
||||||
echo -e " ${CM}${CL} \n"
|
|
||||||
sleep 1
|
|
||||||
clear
|
|
||||||
header_info
|
|
||||||
echo -e "${RD}Using Advanced Settings${CL}"
|
|
||||||
echo -e "${DGN}Using CT Type ${BGN}$CT_TYPE1${CL}"
|
|
||||||
echo -e "${DGN}Using CT Password ${BGN}$PW1${CL}"
|
|
||||||
echo -e "${DGN}Using CT ID ${BGN}$CT_ID${CL}"
|
|
||||||
echo -e "${DGN}Using CT Name ${BGN}$HN${CL}"
|
|
||||||
echo -e "${DGN}Using Disk Size ${BGN}$DISK_SIZE${CL}${DGN}GB${CL}"
|
|
||||||
echo -e "${DGN}Using ${BGN}${CORE_COUNT}${CL}${DGN}vCPU${CL}"
|
|
||||||
echo -e "${DGN}Using ${BGN}${RAM_SIZE}${CL}${DGN}MiB RAM${CL}"
|
|
||||||
echo -e "${DGN}Using Bridge ${BGN}${BRG}${CL}"
|
|
||||||
echo -e "${DGN}Using Static IP Address ${BGN}$NET${CL}"
|
|
||||||
echo -e "${DGN}Using Gateway IP Address ${BGN}$GATE1${CL}"
|
|
||||||
echo -e "${DGN}Using VLAN Tag ${BGN}$VLAN1${CL}"
|
|
||||||
|
|
||||||
read -p "Are these settings correct(y/n)? " -n 1 -r
|
|
||||||
echo
|
|
||||||
if [[ ! $REPLY =~ ^[Yy]$ ]]
|
|
||||||
then
|
|
||||||
advanced_settings
|
|
||||||
fi
|
|
||||||
}
|
|
||||||
|
|
||||||
function start_script() {
|
|
||||||
echo -e "${YW}Type Advanced, or Press [ENTER] for Default Settings "
|
|
||||||
read SETTINGS
|
|
||||||
if [ -z $SETTINGS ]; then default_settings;
|
|
||||||
else
|
|
||||||
advanced_settings
|
|
||||||
fi;
|
|
||||||
}
|
|
||||||
|
|
||||||
start_script
|
|
||||||
|
|
||||||
if [ "$CT_TYPE" == "1" ]; then
|
|
||||||
FEATURES="nesting=1,keyctl=1"
|
|
||||||
else
|
|
||||||
FEATURES="nesting=1"
|
|
||||||
fi
|
|
||||||
|
|
||||||
export CTID=$CT_ID
|
|
||||||
export PCT_OSTYPE=$var_os
|
|
||||||
export PCT_OSVERSION=$var_version
|
|
||||||
export PCT_DISK_SIZE=$DISK_SIZE
|
|
||||||
export PCT_OPTIONS="
|
|
||||||
-features $FEATURES
|
|
||||||
-hostname $HN
|
|
||||||
-net0 name=eth0,bridge=$BRG,ip=$NET$GATE$VLAN
|
|
||||||
-onboot 1
|
|
||||||
-cores $CORE_COUNT
|
|
||||||
-memory $RAM_SIZE
|
|
||||||
-unprivileged $CT_TYPE
|
|
||||||
$PW
|
|
||||||
"
|
|
||||||
bash -c "$(wget -qLO - https://raw.githubusercontent.com/tteck/Proxmox/main/ct/create_lxc.sh)" || exit
|
|
||||||
|
|
||||||
msg_info "Starting LXC Container"
|
|
||||||
pct start $CTID
|
|
||||||
msg_ok "Started LXC Container"
|
|
||||||
|
|
||||||
lxc-attach -n $CTID -- bash -c "$(wget -qLO - https://raw.githubusercontent.com/tteck/Proxmox/main/setup/$var_install.sh)" || exit
|
|
||||||
|
|
||||||
IP=$(pct exec $CTID ip a s dev eth0 | sed -n '/inet / s/\// /p' | awk '{print $2}')
|
|
||||||
|
|
||||||
pct set $CTID -description "# ${APP} LXC
|
|
||||||
### https://github.com/tteck/Proxmox"
|
|
||||||
|
|
||||||
msg_ok "Completed Successfully!\n"
|
|
||||||
echo -e "${APP} should be reachable by going to the following URL.
|
|
||||||
${BL}http://${IP}:8080${CL}\n"
|
|
|
@ -310,7 +310,7 @@ bash -c "$(wget -qLO - https://raw.githubusercontent.com/tteck/Proxmox/main/ct/c
|
||||||
msg_info "Starting LXC Container"
|
msg_info "Starting LXC Container"
|
||||||
pct start $CTID
|
pct start $CTID
|
||||||
msg_ok "Started LXC Container"
|
msg_ok "Started LXC Container"
|
||||||
lxc-attach -n $CTID -- bash -c "$(wget -qLO - https://raw.githubusercontent.com/tteck/Proxmox/main/setup/$var_install.sh)" || exit
|
lxc-attach -n $CTID -- bash -c "$(wget -qLO - https://raw.githubusercontent.com/tteck/Proxmox/main/install/$var_install.sh)" || exit
|
||||||
IP=$(pct exec $CTID ip a s dev eth0 | sed -n '/inet / s/\// /p' | awk '{print $2}')
|
IP=$(pct exec $CTID ip a s dev eth0 | sed -n '/inet / s/\// /p' | awk '{print $2}')
|
||||||
pct set $CTID -description "# ${APP} LXC
|
pct set $CTID -description "# ${APP} LXC
|
||||||
### https://tteck.github.io/Proxmox/
|
### https://tteck.github.io/Proxmox/
|
||||||
|
|
|
@ -310,7 +310,7 @@ bash -c "$(wget -qLO - https://raw.githubusercontent.com/tteck/Proxmox/main/ct/c
|
||||||
msg_info "Starting LXC Container"
|
msg_info "Starting LXC Container"
|
||||||
pct start $CTID
|
pct start $CTID
|
||||||
msg_ok "Started LXC Container"
|
msg_ok "Started LXC Container"
|
||||||
lxc-attach -n $CTID -- bash -c "$(wget -qLO - https://raw.githubusercontent.com/tteck/Proxmox/main/setup/$var_install.sh)" || exit
|
lxc-attach -n $CTID -- bash -c "$(wget -qLO - https://raw.githubusercontent.com/tteck/Proxmox/main/install/$var_install.sh)" || exit
|
||||||
IP=$(pct exec $CTID ip a s dev eth0 | sed -n '/inet / s/\// /p' | awk '{print $2}')
|
IP=$(pct exec $CTID ip a s dev eth0 | sed -n '/inet / s/\// /p' | awk '{print $2}')
|
||||||
pct set $CTID -description "# ${APP} LXC
|
pct set $CTID -description "# ${APP} LXC
|
||||||
### https://tteck.github.io/Proxmox/
|
### https://tteck.github.io/Proxmox/
|
||||||
|
|
|
@ -1,259 +0,0 @@
|
||||||
#!/usr/bin/env bash
|
|
||||||
YW=`echo "\033[33m"`
|
|
||||||
BL=`echo "\033[36m"`
|
|
||||||
RD=`echo "\033[01;31m"`
|
|
||||||
CM='\xE2\x9C\x94\033'
|
|
||||||
GN=`echo "\033[1;92m"`
|
|
||||||
CL=`echo "\033[m"`
|
|
||||||
PP=`echo "\e[1;35m"`
|
|
||||||
APP="PhotoPrism"
|
|
||||||
HN=$(echo ${APP,,} | tr -d ' ')
|
|
||||||
while true; do
|
|
||||||
read -p "This will create a New ${APP} LXC. Proceed(y/n)?" yn
|
|
||||||
case $yn in
|
|
||||||
[Yy]* ) break;;
|
|
||||||
[Nn]* ) exit;;
|
|
||||||
* ) echo "Please answer yes or no.";;
|
|
||||||
esac
|
|
||||||
done
|
|
||||||
clear
|
|
||||||
function header_info {
|
|
||||||
echo -e "${PP}
|
|
||||||
_____ _ _ _____ _
|
|
||||||
| __ \| | | | | __ \ (_)
|
|
||||||
| |__) | |__ ___ | |_ ___ | |__) | __ _ ___ _ __ ___
|
|
||||||
| ___/| _ \ / _ \| __/ _ \| ___/ __| / __| _ _ \
|
|
||||||
| | | | | | (_) | || (_) | | | | | \__ \ | | | | |
|
|
||||||
|_| |_| |_|\___/ \__\___/|_| |_| |_|___/_| |_| |_|
|
|
||||||
${CL}"
|
|
||||||
}
|
|
||||||
|
|
||||||
header_info
|
|
||||||
show_menu(){
|
|
||||||
printf " ${YW} 1)${YW} Privileged ${CL}\n"
|
|
||||||
printf " ${YW} 2)${GN} Unprivileged ${CL}\n"
|
|
||||||
|
|
||||||
printf "Please choose a Install Method and hit enter or ${RD}x${CL} to exit."
|
|
||||||
read opt
|
|
||||||
}
|
|
||||||
|
|
||||||
option_picked(){
|
|
||||||
message1=${@:-"${CL}Error: No message passed"}
|
|
||||||
printf " ${YW}${message1}${CL}\n"
|
|
||||||
}
|
|
||||||
show_menu
|
|
||||||
while [ "$opt" != " " ]
|
|
||||||
do
|
|
||||||
case $opt in
|
|
||||||
1) clear;
|
|
||||||
header_info;
|
|
||||||
option_picked "Using Privileged Install";
|
|
||||||
IM=0
|
|
||||||
break;
|
|
||||||
;;
|
|
||||||
2) clear;
|
|
||||||
header_info;
|
|
||||||
option_picked "Using Unprivileged Install";
|
|
||||||
IM=1
|
|
||||||
break;
|
|
||||||
;;
|
|
||||||
|
|
||||||
x)exit;
|
|
||||||
;;
|
|
||||||
\n)exit;
|
|
||||||
;;
|
|
||||||
*)clear;
|
|
||||||
option_picked "Please choose a Install Method from the menu";
|
|
||||||
show_menu;
|
|
||||||
;;
|
|
||||||
esac
|
|
||||||
done
|
|
||||||
show_menu2(){
|
|
||||||
printf " ${YW} 1)${GN} Use Automatic Login ${CL}\n"
|
|
||||||
printf " ${YW} 2)${GN} Use Password (changeme) ${CL}\n"
|
|
||||||
|
|
||||||
printf "Please choose a Password Type and hit enter or ${RD}x${CL} to exit."
|
|
||||||
read opt
|
|
||||||
}
|
|
||||||
|
|
||||||
option_picked(){
|
|
||||||
message2=${@:-"${CL}Error: No message passed"}
|
|
||||||
printf " ${YW}${message1}${CL}\n"
|
|
||||||
printf " ${YW}${message2}${CL}\n"
|
|
||||||
}
|
|
||||||
show_menu2
|
|
||||||
while [ "$opt" != " " ]
|
|
||||||
do
|
|
||||||
case $opt in
|
|
||||||
1) clear;
|
|
||||||
header_info;
|
|
||||||
option_picked "Using Automatic Login";
|
|
||||||
PW=" "
|
|
||||||
break;
|
|
||||||
;;
|
|
||||||
2) clear;
|
|
||||||
header_info;
|
|
||||||
option_picked "Using Password (changeme)";
|
|
||||||
PW="-password changeme"
|
|
||||||
break;
|
|
||||||
;;
|
|
||||||
|
|
||||||
x)exit;
|
|
||||||
;;
|
|
||||||
\n)exit;
|
|
||||||
;;
|
|
||||||
*)clear;
|
|
||||||
option_picked "Please choose a Password Type from the menu";
|
|
||||||
show_menu2;
|
|
||||||
;;
|
|
||||||
esac
|
|
||||||
done
|
|
||||||
show_menu3(){
|
|
||||||
printf " ${YW} 1)${GN} Automatic DHCP ${CL}\n"
|
|
||||||
printf " ${YW} 2)${GN} Manual DHCP ${CL}\n"
|
|
||||||
|
|
||||||
printf "Please choose a DHCP Type and hit enter or ${RD}x${CL} to exit."
|
|
||||||
read opt
|
|
||||||
}
|
|
||||||
|
|
||||||
option_picked(){
|
|
||||||
message3=${@:-"${CL}Error: No message passed"}
|
|
||||||
printf " ${YW}${message1}${CL}\n"
|
|
||||||
printf " ${YW}${message2}${CL}\n"
|
|
||||||
printf " ${YW}${message3}${CL}\n"
|
|
||||||
}
|
|
||||||
show_menu3
|
|
||||||
while [ "$opt" != " " ]
|
|
||||||
do
|
|
||||||
case $opt in
|
|
||||||
1) clear;
|
|
||||||
header_info;
|
|
||||||
option_picked "Using Automatic DHCP";
|
|
||||||
DHCP=" "
|
|
||||||
break;
|
|
||||||
;;
|
|
||||||
2) clear;
|
|
||||||
header_info;
|
|
||||||
option_picked "Using Manual DHCP";
|
|
||||||
DHCP="1"
|
|
||||||
break;
|
|
||||||
;;
|
|
||||||
|
|
||||||
x)exit;
|
|
||||||
;;
|
|
||||||
\n)exit;
|
|
||||||
;;
|
|
||||||
*)clear;
|
|
||||||
option_picked "Please choose a DHCP Type from the menu";
|
|
||||||
show_menu3;
|
|
||||||
;;
|
|
||||||
esac
|
|
||||||
done
|
|
||||||
|
|
||||||
set -o errexit
|
|
||||||
set -o errtrace
|
|
||||||
set -o nounset
|
|
||||||
set -o pipefail
|
|
||||||
shopt -s expand_aliases
|
|
||||||
alias die='EXIT=$? LINE=$LINENO error_exit'
|
|
||||||
trap die ERR
|
|
||||||
trap cleanup EXIT
|
|
||||||
|
|
||||||
function error_exit() {
|
|
||||||
trap - ERR
|
|
||||||
local DEFAULT='Unknown failure occured.'
|
|
||||||
local REASON="\e[97m${1:-$DEFAULT}\e[39m"
|
|
||||||
local FLAG="\e[91m[ERROR] \e[93m$EXIT@$LINE"
|
|
||||||
msg "$FLAG $REASON"
|
|
||||||
[ ! -z ${CTID-} ] && cleanup_ctid
|
|
||||||
exit $EXIT
|
|
||||||
}
|
|
||||||
function warn() {
|
|
||||||
local REASON="\e[97m$1\e[39m"
|
|
||||||
local FLAG="\e[93m[WARNING]\e[39m"
|
|
||||||
msg "$FLAG $REASON"
|
|
||||||
}
|
|
||||||
function info() {
|
|
||||||
local REASON="$1"
|
|
||||||
local FLAG="\e[36m[INFO]\e[39m"
|
|
||||||
msg "$FLAG $REASON"
|
|
||||||
}
|
|
||||||
function msg() {
|
|
||||||
local TEXT="$1"
|
|
||||||
echo -e "$TEXT"
|
|
||||||
}
|
|
||||||
function cleanup_ctid() {
|
|
||||||
if $(pct status $CTID &>/dev/null); then
|
|
||||||
if [ "$(pct status $CTID | awk '{print $2}')" == "running" ]; then
|
|
||||||
pct stop $CTID
|
|
||||||
fi
|
|
||||||
pct destroy $CTID
|
|
||||||
elif [ "$(pvesm list $STORAGE --vmid $CTID)" != "" ]; then
|
|
||||||
pvesm free $ROOTFS
|
|
||||||
fi
|
|
||||||
}
|
|
||||||
function cleanup() {
|
|
||||||
popd >/dev/null
|
|
||||||
rm -rf $TEMP_DIR
|
|
||||||
}
|
|
||||||
if [ "$IM" == "1" ]; then
|
|
||||||
FEATURES="nesting=1,keyctl=1"
|
|
||||||
else
|
|
||||||
FEATURES="nesting=1"
|
|
||||||
fi
|
|
||||||
|
|
||||||
TEMP_DIR=$(mktemp -d)
|
|
||||||
pushd $TEMP_DIR >/dev/null
|
|
||||||
|
|
||||||
export CTID=$(pvesh get /cluster/nextid)
|
|
||||||
export PCT_OSTYPE=debian
|
|
||||||
export PCT_OSVERSION=11
|
|
||||||
export PCT_DISK_SIZE=8
|
|
||||||
export PCT_OPTIONS="
|
|
||||||
-features $FEATURES
|
|
||||||
-hostname $HN
|
|
||||||
-net0 name=eth0,bridge=vmbr0,ip=dhcp
|
|
||||||
-onboot 1
|
|
||||||
-cores 2
|
|
||||||
-memory 2048
|
|
||||||
-unprivileged ${IM}
|
|
||||||
${PW}
|
|
||||||
"
|
|
||||||
bash -c "$(wget -qLO - https://raw.githubusercontent.com/tteck/Proxmox/main/ct/create_lxc.sh)" || exit
|
|
||||||
|
|
||||||
STORAGE_TYPE=$(pvesm status -storage $(pct config $CTID | grep rootfs | awk -F ":" '{print $2}') | awk 'NR>1 {print $2}')
|
|
||||||
if [ "$STORAGE_TYPE" == "zfspool" ]; then
|
|
||||||
warn "Some addons may not work due to ZFS not supporting 'fallocate'."
|
|
||||||
fi
|
|
||||||
LXC_CONFIG=/etc/pve/lxc/${CTID}.conf
|
|
||||||
cat <<EOF >> $LXC_CONFIG
|
|
||||||
lxc.cgroup2.devices.allow: a
|
|
||||||
lxc.cap.drop:
|
|
||||||
EOF
|
|
||||||
if [ "$DHCP" == "1" ]; then
|
|
||||||
MAC=$(pct config $CTID \
|
|
||||||
| grep -i hwaddr \
|
|
||||||
| awk '{print substr($2, 31, length($3) 17 ) }') \
|
|
||||||
|
|
||||||
echo -e "MAC Address ${BL}$MAC${CL}"
|
|
||||||
|
|
||||||
dhcp_reservation(){
|
|
||||||
printf "Please set DHCP reservation and press Enter."
|
|
||||||
read
|
|
||||||
}
|
|
||||||
dhcp_reservation
|
|
||||||
fi
|
|
||||||
|
|
||||||
echo -en "${GN} Starting LXC Container... "
|
|
||||||
pct start $CTID
|
|
||||||
echo -e "${CM}${CL} \r"
|
|
||||||
|
|
||||||
alias lxc-cmd="lxc-attach -n $CTID --"
|
|
||||||
|
|
||||||
lxc-cmd bash -c "$(wget -qLO - https://raw.githubusercontent.com/tteck/Proxmox/main/setup/$HN-install.sh)" || exit
|
|
||||||
|
|
||||||
IP=$(pct exec $CTID ip a s dev eth0 | sed -n '/inet / s/\// /p' | awk '{print $2}')
|
|
||||||
|
|
||||||
echo -e "${GN}Successfully created ${APP} LXC to${CL} ${BL}$CTID${CL}.
|
|
||||||
${APP} should be reachable by going to the following URL.
|
|
||||||
${BL}http://${IP}:2342${CL} \n"
|
|
|
@ -1,357 +0,0 @@
|
||||||
#!/usr/bin/env bash
|
|
||||||
echo -e "Loading..."
|
|
||||||
NEXTID=$(pvesh get /cluster/nextid)
|
|
||||||
INTEGER='^[0-9]+$'
|
|
||||||
PP=`echo "\e[1;35m"`
|
|
||||||
YW=`echo "\033[33m"`
|
|
||||||
BL=`echo "\033[36m"`
|
|
||||||
RD=`echo "\033[01;31m"`
|
|
||||||
BGN=`echo "\033[4;92m"`
|
|
||||||
GN=`echo "\033[1;92m"`
|
|
||||||
DGN=`echo "\033[32m"`
|
|
||||||
CL=`echo "\033[m"`
|
|
||||||
BFR="\\r\\033[K"
|
|
||||||
HOLD="-"
|
|
||||||
CM="${GN}✓${CL}"
|
|
||||||
APP="PhotoPrism"
|
|
||||||
NSAPP=$(echo ${APP,,} | tr -d ' ')
|
|
||||||
set -o errexit
|
|
||||||
set -o errtrace
|
|
||||||
set -o nounset
|
|
||||||
set -o pipefail
|
|
||||||
shopt -s expand_aliases
|
|
||||||
alias die='EXIT=$? LINE=$LINENO error_exit'
|
|
||||||
trap die ERR
|
|
||||||
|
|
||||||
function error_exit() {
|
|
||||||
trap - ERR
|
|
||||||
local reason="Unknown failure occurred."
|
|
||||||
local msg="${1:-$reason}"
|
|
||||||
local flag="${RD}‼ ERROR ${CL}$EXIT@$LINE"
|
|
||||||
echo -e "$flag $msg" 1>&2
|
|
||||||
exit $EXIT
|
|
||||||
}
|
|
||||||
|
|
||||||
while true; do
|
|
||||||
clear
|
|
||||||
read -p "This will create a New ${APP} LXC. Proceed(y/n)?" yn
|
|
||||||
case $yn in
|
|
||||||
[Yy]* ) break;;
|
|
||||||
[Nn]* ) exit;;
|
|
||||||
* ) echo "Please answer yes or no.";;
|
|
||||||
esac
|
|
||||||
done
|
|
||||||
clear
|
|
||||||
function header_info {
|
|
||||||
echo -e "${PP}
|
|
||||||
_____ _ _ _____ _
|
|
||||||
| __ \| | | | | __ \ (_)
|
|
||||||
| |__) | |__ ___ | |_ ___ | |__) | __ _ ___ _ __ ___
|
|
||||||
| ___/| _ \ / _ \| __/ _ \| ___/ __| / __| _ _ \
|
|
||||||
| | | | | | (_) | || (_) | | | | | \__ \ | | | | |
|
|
||||||
|_| v3 |_| |_|\___/ \__\___/|_| |_| |_|___/_| |_| |_|
|
|
||||||
${CL}"
|
|
||||||
}
|
|
||||||
|
|
||||||
header_info
|
|
||||||
|
|
||||||
function msg_info() {
|
|
||||||
local msg="$1"
|
|
||||||
echo -ne " ${HOLD} ${YW}${msg}..."
|
|
||||||
}
|
|
||||||
|
|
||||||
function msg_ok() {
|
|
||||||
local msg="$1"
|
|
||||||
echo -e "${BFR} ${CM} ${GN}${msg}${CL}"
|
|
||||||
}
|
|
||||||
|
|
||||||
function PVE_CHECK() {
|
|
||||||
PVE=$(pveversion | grep "pve-manager/7" | wc -l)
|
|
||||||
|
|
||||||
if [[ $PVE != 1 ]]; then
|
|
||||||
echo -e "${RD}This script requires Proxmox Virtual Environment 7.0 or greater${CL}"
|
|
||||||
echo -e "Exiting..."
|
|
||||||
sleep 2
|
|
||||||
exit
|
|
||||||
fi
|
|
||||||
}
|
|
||||||
|
|
||||||
function default_settings() {
|
|
||||||
clear
|
|
||||||
header_info
|
|
||||||
echo -e "${BL}Using Default Settings${CL}"
|
|
||||||
echo -e "${DGN}Using CT Type ${BGN}Unprivileged${CL} ${RD}NO DEVICE PASSTHROUGH${CL}"
|
|
||||||
CT_TYPE="1"
|
|
||||||
echo -e "${DGN}Using CT Password ${BGN}Automatic Login${CL}"
|
|
||||||
PW=" "
|
|
||||||
echo -e "${DGN}Using CT ID ${BGN}$NEXTID${CL}"
|
|
||||||
CT_ID=$NEXTID
|
|
||||||
echo -e "${DGN}Using CT Name ${BGN}$NSAPP${CL}"
|
|
||||||
HN=$NSAPP
|
|
||||||
echo -e "${DGN}Using Disk Size ${BGN}8${CL}${DGN}GB${CL}"
|
|
||||||
DISK_SIZE="8"
|
|
||||||
echo -e "${DGN}Using ${BGN}2${CL}${DGN}vCPU${CL}"
|
|
||||||
CORE_COUNT="2"
|
|
||||||
echo -e "${DGN}Using ${BGN}2048${CL}${DGN}MiB RAM${CL}"
|
|
||||||
RAM_SIZE="2048"
|
|
||||||
echo -e "${DGN}Using Bridge ${BGN}vmbr0${CL}"
|
|
||||||
BRG="vmbr0"
|
|
||||||
echo -e "${DGN}Using Static IP Address ${BGN}DHCP${CL}"
|
|
||||||
NET=dhcp
|
|
||||||
echo -e "${DGN}Using Gateway Address ${BGN}NONE${CL}"
|
|
||||||
GATE=""
|
|
||||||
echo -e "${DGN}Using VLAN Tag ${BGN}NONE${CL}"
|
|
||||||
VLAN=""
|
|
||||||
}
|
|
||||||
|
|
||||||
function advanced_settings() {
|
|
||||||
clear
|
|
||||||
header_info
|
|
||||||
echo -e "${RD}Using Advanced Settings${CL}"
|
|
||||||
echo -e "${YW}Type Privileged, or Press [ENTER] for Default: Unprivileged (${RD}NO DEVICE PASSTHROUGH${CL}${YW})"
|
|
||||||
read CT_TYPE1
|
|
||||||
if [ -z $CT_TYPE1 ]; then CT_TYPE1="Unprivileged" CT_TYPE="1";
|
|
||||||
echo -en "${DGN}Set CT Type ${BL}$CT_TYPE1${CL}"
|
|
||||||
else
|
|
||||||
CT_TYPE1="Privileged"
|
|
||||||
CT_TYPE="0"
|
|
||||||
echo -en "${DGN}Set CT Type ${BL}Privileged${CL}"
|
|
||||||
fi;
|
|
||||||
echo -e " ${CM}${CL} \r"
|
|
||||||
sleep 1
|
|
||||||
clear
|
|
||||||
header_info
|
|
||||||
echo -e "${RD}Using Advanced Settings${CL}"
|
|
||||||
echo -e "${DGN}Using CT Type ${BGN}$CT_TYPE1${CL}"
|
|
||||||
echo -e "${YW}Set Password, or Press [ENTER] for Default: Automatic Login "
|
|
||||||
read PW1
|
|
||||||
if [ -z $PW1 ]; then PW1="Automatic Login" PW=" ";
|
|
||||||
echo -en "${DGN}Set CT ${BL}$PW1${CL}"
|
|
||||||
else
|
|
||||||
PW="-password $PW1"
|
|
||||||
echo -en "${DGN}Set CT Password ${BL}$PW1${CL}"
|
|
||||||
fi;
|
|
||||||
echo -e " ${CM}${CL} \r"
|
|
||||||
sleep 1
|
|
||||||
clear
|
|
||||||
header_info
|
|
||||||
echo -e "${RD}Using Advanced Settings${CL}"
|
|
||||||
echo -e "${DGN}Using CT Type ${BGN}$CT_TYPE1${CL}"
|
|
||||||
echo -e "${DGN}Using CT Password ${BGN}$PW1${CL}"
|
|
||||||
echo -e "${YW}Enter the CT ID, or Press [ENTER] to automatically generate (${NEXTID}) "
|
|
||||||
read CT_ID
|
|
||||||
if [ -z $CT_ID ]; then CT_ID=$NEXTID; fi;
|
|
||||||
echo -en "${DGN}Set CT ID To ${BL}$CT_ID${CL}"
|
|
||||||
echo -e " ${CM}${CL} \r"
|
|
||||||
sleep 1
|
|
||||||
clear
|
|
||||||
header_info
|
|
||||||
echo -e "${RD}Using Advanced Settings${CL}"
|
|
||||||
echo -e "${DGN}Using CT Type ${BGN}$CT_TYPE1${CL}"
|
|
||||||
echo -e "${DGN}Using CT Password ${BGN}$PW1${CL}"
|
|
||||||
echo -e "${DGN}Using CT ID ${BGN}$CT_ID${CL}"
|
|
||||||
echo -e "${YW}Enter CT Name (no-spaces), or Press [ENTER] for Default: $NSAPP "
|
|
||||||
read CT_NAME
|
|
||||||
if [ -z $CT_NAME ]; then
|
|
||||||
HN=$NSAPP
|
|
||||||
else
|
|
||||||
HN=$(echo ${CT_NAME,,} | tr -d ' ')
|
|
||||||
fi
|
|
||||||
echo -en "${DGN}Set CT Name To ${BL}$HN${CL}"
|
|
||||||
echo -e " ${CM}${CL} \r"
|
|
||||||
sleep 1
|
|
||||||
clear
|
|
||||||
header_info
|
|
||||||
echo -e "${RD}Using Advanced Settings${CL}"
|
|
||||||
echo -e "${DGN}Using CT Type ${BGN}$CT_TYPE1${CL}"
|
|
||||||
echo -e "${DGN}Using CT Password ${BGN}$PW1${CL}"
|
|
||||||
echo -e "${DGN}Using CT ID ${BGN}$CT_ID${CL}"
|
|
||||||
echo -e "${DGN}Using CT Name ${BGN}$HN${CL}"
|
|
||||||
echo -e "${YW}Enter a Disk Size, or Press [ENTER] for Default: 8 "
|
|
||||||
read DISK_SIZE
|
|
||||||
if [ -z $DISK_SIZE ]; then DISK_SIZE="8"; fi;
|
|
||||||
if ! [[ $DISK_SIZE =~ $INTEGER ]] ; then echo "ERROR! DISK SIZE MUST HAVE INTEGER NUMBER!"; exit; fi;
|
|
||||||
echo -en "${DGN}Set Disk Size To ${BL}$DISK_SIZE${CL}${DGN}GB${CL}"
|
|
||||||
echo -e " ${CM}${CL} \r"
|
|
||||||
sleep 1
|
|
||||||
clear
|
|
||||||
header_info
|
|
||||||
echo -e "${RD}Using Advanced Settings${CL}"
|
|
||||||
echo -e "${DGN}Using CT Type ${BGN}$CT_TYPE1${CL}"
|
|
||||||
echo -e "${DGN}Using CT Password ${BGN}$PW1${CL}"
|
|
||||||
echo -e "${DGN}Using CT ID ${BGN}$CT_ID${CL}"
|
|
||||||
echo -e "${DGN}Using CT Name ${BGN}$HN${CL}"
|
|
||||||
echo -e "${DGN}Using Disk Size ${BGN}$DISK_SIZE${CL}${DGN}GB${CL}"
|
|
||||||
echo -e "${YW}Allocate CPU cores, or Press [ENTER] for Default: 2 "
|
|
||||||
read CORE_COUNT
|
|
||||||
if [ -z $CORE_COUNT ]; then CORE_COUNT="2"; fi;
|
|
||||||
echo -en "${DGN}Set Cores To ${BL}$CORE_COUNT${CL}${DGN}vCPU${CL}"
|
|
||||||
echo -e " ${CM}${CL} \r"
|
|
||||||
sleep 1
|
|
||||||
clear
|
|
||||||
header_info
|
|
||||||
echo -e "${RD}Using Advanced Settings${CL}"
|
|
||||||
echo -e "${DGN}Using CT Type ${BGN}$CT_TYPE1${CL}"
|
|
||||||
echo -e "${DGN}Using CT Password ${BGN}$PW1${CL}"
|
|
||||||
echo -e "${DGN}Using CT ID ${BGN}$CT_ID${CL}"
|
|
||||||
echo -e "${DGN}Using CT Name ${BGN}$HN${CL}"
|
|
||||||
echo -e "${DGN}Using Disk Size ${BGN}$DISK_SIZE${CL}${DGN}GB${CL}"
|
|
||||||
echo -e "${DGN}Using ${BGN}${CORE_COUNT}${CL}${DGN}vCPU${CL}"
|
|
||||||
echo -e "${YW}Allocate RAM in MiB, or Press [ENTER] for Default: 2048 "
|
|
||||||
read RAM_SIZE
|
|
||||||
if [ -z $RAM_SIZE ]; then RAM_SIZE="2048"; fi;
|
|
||||||
echo -en "${DGN}Set RAM To ${BL}$RAM_SIZE${CL}${DGN}MiB RAM${CL}"
|
|
||||||
echo -e " ${CM}${CL} \n"
|
|
||||||
sleep 1
|
|
||||||
clear
|
|
||||||
header_info
|
|
||||||
echo -e "${RD}Using Advanced Settings${CL}"
|
|
||||||
echo -e "${DGN}Using CT Type ${BGN}$CT_TYPE1${CL}"
|
|
||||||
echo -e "${DGN}Using CT Password ${BGN}$PW1${CL}"
|
|
||||||
echo -e "${DGN}Using CT ID ${BGN}$CT_ID${CL}"
|
|
||||||
echo -e "${DGN}Using CT Name ${BGN}$HN${CL}"
|
|
||||||
echo -e "${DGN}Using Disk Size ${BGN}$DISK_SIZE${CL}${DGN}GB${CL}"
|
|
||||||
echo -e "${DGN}Using ${BGN}${CORE_COUNT}${CL}${DGN}vCPU${CL}"
|
|
||||||
echo -e "${DGN}Using ${BGN}${RAM_SIZE}${CL}${DGN}MiB RAM${CL}"
|
|
||||||
echo -e "${YW}Enter a Bridge, or Press [ENTER] for Default: vmbr0 "
|
|
||||||
read BRG
|
|
||||||
if [ -z $BRG ]; then BRG="vmbr0"; fi;
|
|
||||||
echo -en "${DGN}Set Bridge To ${BL}$BRG${CL}"
|
|
||||||
echo -e " ${CM}${CL} \n"
|
|
||||||
sleep 1
|
|
||||||
clear
|
|
||||||
header_info
|
|
||||||
echo -e "${RD}Using Advanced Settings${CL}"
|
|
||||||
echo -e "${DGN}Using CT Type ${BGN}$CT_TYPE1${CL}"
|
|
||||||
echo -e "${DGN}Using CT Password ${BGN}$PW1${CL}"
|
|
||||||
echo -e "${DGN}Using CT ID ${BGN}$CT_ID${CL}"
|
|
||||||
echo -e "${DGN}Using CT Name ${BGN}$HN${CL}"
|
|
||||||
echo -e "${DGN}Using Disk Size ${BGN}$DISK_SIZE${CL}${DGN}GB${CL}"
|
|
||||||
echo -e "${DGN}Using ${BGN}${CORE_COUNT}${CL}${DGN}vCPU${CL}"
|
|
||||||
echo -e "${DGN}Using ${BGN}${RAM_SIZE}${CL}${DGN}MiB RAM${CL}"
|
|
||||||
echo -e "${DGN}Using Bridge ${BGN}${BRG}${CL}"
|
|
||||||
echo -e "${YW}Enter a Static IPv4 CIDR Address, or Press [ENTER] for Default: DHCP "
|
|
||||||
read NET
|
|
||||||
if [ -z $NET ]; then NET="dhcp"; fi;
|
|
||||||
echo -en "${DGN}Set Static IP Address To ${BL}$NET${CL}"
|
|
||||||
echo -e " ${CM}${CL} \n"
|
|
||||||
sleep 1
|
|
||||||
clear
|
|
||||||
header_info
|
|
||||||
echo -e "${RD}Using Advanced Settings${CL}"
|
|
||||||
echo -e "${DGN}Using CT Type ${BGN}$CT_TYPE1${CL}"
|
|
||||||
echo -e "${DGN}Using CT Password ${BGN}$PW1${CL}"
|
|
||||||
echo -e "${DGN}Using CT ID ${BGN}$CT_ID${CL}"
|
|
||||||
echo -e "${DGN}Using CT Name ${BGN}$HN${CL}"
|
|
||||||
echo -e "${DGN}Using Disk Size ${BGN}$DISK_SIZE${CL}${DGN}GB${CL}"
|
|
||||||
echo -e "${DGN}Using ${BGN}${CORE_COUNT}${CL}${DGN}vCPU${CL}"
|
|
||||||
echo -e "${DGN}Using ${BGN}${RAM_SIZE}${CL}${DGN}MiB RAM${CL}"
|
|
||||||
echo -e "${DGN}Using Bridge ${BGN}${BRG}${CL}"
|
|
||||||
echo -e "${DGN}Using Static IP Address ${BGN}$NET${CL}"
|
|
||||||
echo -e "${YW}Enter a Gateway IP (mandatory if static IP is used), or Press [ENTER] for Default: NONE "
|
|
||||||
read GATE1
|
|
||||||
if [ -z $GATE1 ]; then GATE1="NONE" GATE="";
|
|
||||||
echo -en "${DGN}Set Gateway IP To ${BL}$GATE1${CL}"
|
|
||||||
else
|
|
||||||
GATE=",gw=$GATE1"
|
|
||||||
echo -en "${DGN}Set Gateway IP To ${BL}$GATE1${CL}"
|
|
||||||
fi;
|
|
||||||
echo -e " ${CM}${CL} \n"
|
|
||||||
sleep 1
|
|
||||||
clear
|
|
||||||
header_info
|
|
||||||
|
|
||||||
echo -e "${RD}Using Advanced Settings${CL}"
|
|
||||||
echo -e "${DGN}Using CT Type ${BGN}$CT_TYPE1${CL}"
|
|
||||||
echo -e "${DGN}Using CT Password ${BGN}$PW1${CL}"
|
|
||||||
echo -e "${DGN}Using CT ID ${BGN}$CT_ID${CL}"
|
|
||||||
echo -e "${DGN}Using CT Name ${BGN}$HN${CL}"
|
|
||||||
echo -e "${DGN}Using Disk Size ${BGN}$DISK_SIZE${CL}${DGN}GB${CL}"
|
|
||||||
echo -e "${DGN}Using ${BGN}${CORE_COUNT}${CL}${DGN}vCPU${CL}"
|
|
||||||
echo -e "${DGN}Using ${BGN}${RAM_SIZE}${CL}${DGN}MiB RAM${CL}"
|
|
||||||
echo -e "${DGN}Using Bridge ${BGN}${BRG}${CL}"
|
|
||||||
echo -e "${DGN}Using Static IP Address ${BGN}$NET${CL}"
|
|
||||||
echo -e "${DGN}Using Gateway IP Address ${BGN}$GATE1${CL}"
|
|
||||||
echo -e "${YW}Enter a VLAN Tag, or Press [ENTER] for Default: NONE "
|
|
||||||
read VLAN1
|
|
||||||
if [ -z $VLAN1 ]; then VLAN1="NONE" VLAN="";
|
|
||||||
echo -en "${DGN}Set VLAN Tag To ${BL}$VLAN1${CL}"
|
|
||||||
else
|
|
||||||
VLAN=",tag=$VLAN1"
|
|
||||||
echo -en "${DGN}Set VLAN Tag To ${BL}$VLAN1${CL}"
|
|
||||||
fi;
|
|
||||||
echo -e " ${CM}${CL} \n"
|
|
||||||
sleep 1
|
|
||||||
clear
|
|
||||||
header_info
|
|
||||||
echo -e "${RD}Using Advanced Settings${CL}"
|
|
||||||
echo -e "${DGN}Using CT Type ${BGN}$CT_TYPE1${CL}"
|
|
||||||
echo -e "${DGN}Using CT Password ${BGN}$PW1${CL}"
|
|
||||||
echo -e "${DGN}Using CT ID ${BGN}$CT_ID${CL}"
|
|
||||||
echo -e "${DGN}Using CT Name ${BGN}$HN${CL}"
|
|
||||||
echo -e "${DGN}Using Disk Size ${BGN}$DISK_SIZE${CL}${DGN}GB${CL}"
|
|
||||||
echo -e "${DGN}Using ${BGN}${CORE_COUNT}${CL}${DGN}vCPU${CL}"
|
|
||||||
echo -e "${DGN}Using ${BGN}${RAM_SIZE}${CL}${DGN}MiB RAM${CL}"
|
|
||||||
echo -e "${DGN}Using Bridge ${BGN}${BRG}${CL}"
|
|
||||||
echo -e "${DGN}Using Static IP Address ${BGN}$NET${CL}"
|
|
||||||
echo -e "${DGN}Using Gateway IP Address ${BGN}$GATE1${CL}"
|
|
||||||
echo -e "${DGN}Using VLAN Tag ${BGN}$VLAN1${CL}"
|
|
||||||
|
|
||||||
read -p "Are these settings correct(y/n)? " -n 1 -r
|
|
||||||
echo
|
|
||||||
if [[ ! $REPLY =~ ^[Yy]$ ]]
|
|
||||||
then
|
|
||||||
advanced_settings
|
|
||||||
fi
|
|
||||||
}
|
|
||||||
|
|
||||||
function start_script() {
|
|
||||||
echo -e "${YW}Type Advanced, or Press [ENTER] for Default Settings "
|
|
||||||
read SETTINGS
|
|
||||||
if [ -z $SETTINGS ]; then default_settings;
|
|
||||||
else
|
|
||||||
advanced_settings
|
|
||||||
fi;
|
|
||||||
}
|
|
||||||
|
|
||||||
start_script
|
|
||||||
|
|
||||||
if [ "$CT_TYPE" == "1" ]; then
|
|
||||||
FEATURES="nesting=1,keyctl=1"
|
|
||||||
else
|
|
||||||
FEATURES="nesting=1"
|
|
||||||
fi
|
|
||||||
|
|
||||||
TEMP_DIR=$(mktemp -d)
|
|
||||||
pushd $TEMP_DIR >/dev/null
|
|
||||||
|
|
||||||
export CTID=$CT_ID
|
|
||||||
export PCT_OSTYPE=debian
|
|
||||||
export PCT_OSVERSION=11
|
|
||||||
export PCT_DISK_SIZE=$DISK_SIZE
|
|
||||||
export PCT_OPTIONS="
|
|
||||||
-features $FEATURES
|
|
||||||
-hostname $HN
|
|
||||||
-net0 name=eth0,bridge=$BRG,ip=$NET$GATE$VLAN
|
|
||||||
-onboot 1
|
|
||||||
-cores $CORE_COUNT
|
|
||||||
-memory $RAM_SIZE
|
|
||||||
-unprivileged $CT_TYPE
|
|
||||||
$PW
|
|
||||||
"
|
|
||||||
bash -c "$(wget -qLO - https://raw.githubusercontent.com/tteck/Proxmox/main/ct/create_lxc.sh)" || exit
|
|
||||||
|
|
||||||
msg_info "Starting LXC Container"
|
|
||||||
pct start $CTID
|
|
||||||
msg_ok "Started LXC Container"
|
|
||||||
|
|
||||||
lxc-attach -n $CTID -- bash -c "$(wget -qLO - https://raw.githubusercontent.com/tteck/Proxmox/main/setup/photoprism-install.sh)" || exit
|
|
||||||
|
|
||||||
IP=$(pct exec $CTID ip a s dev eth0 | sed -n '/inet / s/\// /p' | awk '{print $2}')
|
|
||||||
|
|
||||||
pct set $CTID -description "# ${APP} LXC
|
|
||||||
### https://github.com/tteck/Proxmox"
|
|
||||||
|
|
||||||
msg_ok "Completed Successfully!\n"
|
|
||||||
echo -e "${APP} should be reachable by going to the following URL.
|
|
||||||
${BL}http://${IP}:2342${CL} \n"
|
|
|
@ -309,7 +309,7 @@ bash -c "$(wget -qLO - https://raw.githubusercontent.com/tteck/Proxmox/main/ct/c
|
||||||
msg_info "Starting LXC Container"
|
msg_info "Starting LXC Container"
|
||||||
pct start $CTID
|
pct start $CTID
|
||||||
msg_ok "Started LXC Container"
|
msg_ok "Started LXC Container"
|
||||||
lxc-attach -n $CTID -- bash -c "$(wget -qLO - https://raw.githubusercontent.com/tteck/Proxmox/main/setup/$var_install.sh)" || exit
|
lxc-attach -n $CTID -- bash -c "$(wget -qLO - https://raw.githubusercontent.com/tteck/Proxmox/main/install/$var_install.sh)" || exit
|
||||||
IP=$(pct exec $CTID ip a s dev eth0 | sed -n '/inet / s/\// /p' | awk '{print $2}')
|
IP=$(pct exec $CTID ip a s dev eth0 | sed -n '/inet / s/\// /p' | awk '{print $2}')
|
||||||
pct set $CTID -description "# ${APP} LXC
|
pct set $CTID -description "# ${APP} LXC
|
||||||
### https://tteck.github.io/Proxmox/
|
### https://tteck.github.io/Proxmox/
|
||||||
|
|
162
ct/pihole-v1.sh
162
ct/pihole-v1.sh
|
@ -1,162 +0,0 @@
|
||||||
#!/usr/bin/env bash
|
|
||||||
|
|
||||||
while true; do
|
|
||||||
read -p "This will create a New Pi-hole LXC. Proceed(y/n)?" yn
|
|
||||||
case $yn in
|
|
||||||
[Yy]* ) break;;
|
|
||||||
[Nn]* ) exit;;
|
|
||||||
* ) echo "Please answer yes or no.";;
|
|
||||||
esac
|
|
||||||
done
|
|
||||||
|
|
||||||
set -o errexit
|
|
||||||
set -o errtrace
|
|
||||||
set -o nounset
|
|
||||||
set -o pipefail
|
|
||||||
shopt -s expand_aliases
|
|
||||||
alias die='EXIT=$? LINE=$LINENO error_exit'
|
|
||||||
CHECKMARK='\033[0;32m\xE2\x9C\x94\033[0m'
|
|
||||||
trap die ERR
|
|
||||||
trap cleanup EXIT
|
|
||||||
|
|
||||||
function error_exit() {
|
|
||||||
trap - ERR
|
|
||||||
local DEFAULT='Unknown failure occured.'
|
|
||||||
local REASON="\e[97m${1:-$DEFAULT}\e[39m"
|
|
||||||
local FLAG="\e[91m[ERROR] \e[93m$EXIT@$LINE"
|
|
||||||
msg "$FLAG $REASON"
|
|
||||||
[ ! -z ${CTID-} ] && cleanup_ctid
|
|
||||||
exit $EXIT
|
|
||||||
}
|
|
||||||
function warn() {
|
|
||||||
local REASON="\e[97m$1\e[39m"
|
|
||||||
local FLAG="\e[93m[WARNING]\e[39m"
|
|
||||||
msg "$FLAG $REASON"
|
|
||||||
}
|
|
||||||
function info() {
|
|
||||||
local REASON="$1"
|
|
||||||
local FLAG="\e[36m[INFO]\e[39m"
|
|
||||||
msg "$FLAG $REASON"
|
|
||||||
}
|
|
||||||
function msg() {
|
|
||||||
local TEXT="$1"
|
|
||||||
echo -e "$TEXT"
|
|
||||||
}
|
|
||||||
function cleanup_ctid() {
|
|
||||||
if [ ! -z ${MOUNT+x} ]; then
|
|
||||||
pct unmount $CTID
|
|
||||||
fi
|
|
||||||
if $(pct status $CTID &>/dev/null); then
|
|
||||||
if [ "$(pct status $CTID | awk '{print $2}')" == "running" ]; then
|
|
||||||
pct stop $CTID
|
|
||||||
fi
|
|
||||||
pct destroy $CTID
|
|
||||||
elif [ "$(pvesm list $STORAGE --vmid $CTID)" != "" ]; then
|
|
||||||
pvesm free $ROOTFS
|
|
||||||
fi
|
|
||||||
}
|
|
||||||
function cleanup() {
|
|
||||||
popd >/dev/null
|
|
||||||
rm -rf $TEMP_DIR
|
|
||||||
}
|
|
||||||
function load_module() {
|
|
||||||
if ! $(lsmod | grep -Fq $1); then
|
|
||||||
modprobe $1 &>/dev/null || \
|
|
||||||
die "Failed to load '$1' module."
|
|
||||||
fi
|
|
||||||
MODULES_PATH=/etc/modules
|
|
||||||
if ! $(grep -Fxq "$1" $MODULES_PATH); then
|
|
||||||
echo "$1" >> $MODULES_PATH || \
|
|
||||||
die "Failed to add '$1' module to load at boot."
|
|
||||||
fi
|
|
||||||
}
|
|
||||||
TEMP_DIR=$(mktemp -d)
|
|
||||||
pushd $TEMP_DIR >/dev/null
|
|
||||||
|
|
||||||
wget -qL https://raw.githubusercontent.com/tteck/Proxmox/main/setup/pihole_setup.sh
|
|
||||||
|
|
||||||
load_module overlay
|
|
||||||
|
|
||||||
while read -r line; do
|
|
||||||
TAG=$(echo $line | awk '{print $1}')
|
|
||||||
TYPE=$(echo $line | awk '{printf "%-10s", $2}')
|
|
||||||
FREE=$(echo $line | numfmt --field 4-6 --from-unit=K --to=iec --format %.2f | awk '{printf( "%9sB", $6)}')
|
|
||||||
ITEM=" Type: $TYPE Free: $FREE "
|
|
||||||
OFFSET=2
|
|
||||||
if [[ $((${#ITEM} + $OFFSET)) -gt ${MSG_MAX_LENGTH:-} ]]; then
|
|
||||||
MSG_MAX_LENGTH=$((${#ITEM} + $OFFSET))
|
|
||||||
fi
|
|
||||||
STORAGE_MENU+=( "$TAG" "$ITEM" "OFF" )
|
|
||||||
done < <(pvesm status -content rootdir | awk 'NR>1')
|
|
||||||
if [ $((${#STORAGE_MENU[@]}/3)) -eq 0 ]; then
|
|
||||||
warn "'Container' needs to be selected for at least one storage location."
|
|
||||||
die "Unable to detect valid storage location."
|
|
||||||
elif [ $((${#STORAGE_MENU[@]}/3)) -eq 1 ]; then
|
|
||||||
STORAGE=${STORAGE_MENU[0]}
|
|
||||||
else
|
|
||||||
while [ -z "${STORAGE:+x}" ]; do
|
|
||||||
STORAGE=$(whiptail --title "Storage Pools" --radiolist \
|
|
||||||
"Which storage pool you would like to use for the container?\n\n" \
|
|
||||||
16 $(($MSG_MAX_LENGTH + 23)) 6 \
|
|
||||||
"${STORAGE_MENU[@]}" 3>&1 1>&2 2>&3) || exit
|
|
||||||
done
|
|
||||||
fi
|
|
||||||
info "Using '$STORAGE' for storage location."
|
|
||||||
|
|
||||||
CTID=$(pvesh get /cluster/nextid)
|
|
||||||
info "LXC ID is $CTID."
|
|
||||||
|
|
||||||
echo -e "${CHECKMARK} \e[1;92m Updating LXC Template List... \e[0m"
|
|
||||||
pveam update >/dev/null
|
|
||||||
|
|
||||||
echo -e "${CHECKMARK} \e[1;92m Downloading LXC Template... \e[0m"
|
|
||||||
OSTYPE=debian
|
|
||||||
OSVERSION=${OSTYPE}-11
|
|
||||||
mapfile -t TEMPLATES < <(pveam available -section system | sed -n "s/.*\($OSVERSION.*\)/\1/p" | sort -t - -k 2 -V)
|
|
||||||
TEMPLATE="${TEMPLATES[-1]}"
|
|
||||||
pveam download local $TEMPLATE >/dev/null ||
|
|
||||||
die "A problem occured while downloading the LXC template."
|
|
||||||
|
|
||||||
STORAGE_TYPE=$(pvesm status -storage $STORAGE | awk 'NR>1 {print $2}')
|
|
||||||
case $STORAGE_TYPE in
|
|
||||||
dir|nfs)
|
|
||||||
DISK_EXT=".raw"
|
|
||||||
DISK_REF="$CTID/"
|
|
||||||
;;
|
|
||||||
zfspool)
|
|
||||||
DISK_PREFIX="subvol"
|
|
||||||
DISK_FORMAT="subvol"
|
|
||||||
;;
|
|
||||||
esac
|
|
||||||
DISK=${DISK_PREFIX:-vm}-${CTID}-disk-0${DISK_EXT-}
|
|
||||||
ROOTFS=${STORAGE}:${DISK_REF-}${DISK}
|
|
||||||
|
|
||||||
echo -e "${CHECKMARK} \e[1;92m Creating LXC... \e[0m"
|
|
||||||
DISK_SIZE=2G
|
|
||||||
pvesm alloc $STORAGE $CTID $DISK $DISK_SIZE --format ${DISK_FORMAT:-raw} >/dev/null
|
|
||||||
if [ "$STORAGE_TYPE" == "zfspool" ]; then
|
|
||||||
warn "Some containers may not work properly due to ZFS not supporting 'fallocate'."
|
|
||||||
else
|
|
||||||
mkfs.ext4 $(pvesm path $ROOTFS) &>/dev/null
|
|
||||||
fi
|
|
||||||
ARCH=$(dpkg --print-architecture)
|
|
||||||
HOSTNAME=pi-hole
|
|
||||||
TEMPLATE_STRING="local:vztmpl/${TEMPLATE}"
|
|
||||||
pct create $CTID $TEMPLATE_STRING -arch $ARCH -features nesting=1 \
|
|
||||||
-hostname $HOSTNAME -net0 name=eth0,bridge=vmbr0,ip=dhcp -onboot 1 -cores 1 -memory 512 \
|
|
||||||
-ostype $OSTYPE -rootfs $ROOTFS,size=$DISK_SIZE -storage $STORAGE >/dev/null
|
|
||||||
|
|
||||||
MOUNT=$(pct mount $CTID | cut -d"'" -f 2)
|
|
||||||
ln -fs $(readlink /etc/localtime) ${MOUNT}/etc/localtime
|
|
||||||
pct unmount $CTID && unset MOUNT
|
|
||||||
|
|
||||||
echo -e "${CHECKMARK} \e[1;92m Starting LXC... \e[0m"
|
|
||||||
pct start $CTID
|
|
||||||
pct push $CTID pihole_setup.sh /pihole_setup.sh -perms 755
|
|
||||||
pct exec $CTID /pihole_setup.sh
|
|
||||||
|
|
||||||
IP=$(pct exec $CTID ip a s dev eth0 | sed -n '/inet / s/\// /p' | awk '{print $2}')
|
|
||||||
info "Successfully created a Pi-hole LXC to $CTID"
|
|
||||||
echo -e "\e[1;92m Pi-hole should be reachable by going to the following URL.
|
|
||||||
http://${IP}
|
|
||||||
\e[0m"
|
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue