mirror of https://github.com/tteck/Proxmox.git
turnkey scripts code refactoring
This commit is contained in:
parent
e073c01895
commit
9c44b26add
|
@ -1,10 +1,8 @@
|
||||||
#!/usr/bin/env bash
|
#!/usr/bin/env bash
|
||||||
# A primitive script to install TurnKey LXC templates using basic settings.
|
|
||||||
# Copyright (c) 2021-2023 tteck
|
# Copyright (c) 2021-2023 tteck
|
||||||
# Author: tteck (tteckster)
|
# Author: tteck (tteckster)
|
||||||
# License: MIT
|
# License: MIT
|
||||||
# https://github.com/tteck/Proxmox/raw/main/LICENSE
|
# https://github.com/tteck/Proxmox/raw/main/LICENSE
|
||||||
# bash -c "$(wget -qLO - https://github.com/tteck/Proxmox/raw/main/turnkey/turnkey-core.sh)"
|
|
||||||
|
|
||||||
# Setup script environment
|
# Setup script environment
|
||||||
NAME="core"
|
NAME="core"
|
||||||
|
@ -39,10 +37,7 @@ EOF
|
||||||
header_info
|
header_info
|
||||||
read -p "Press ENTER to continue..."
|
read -p "Press ENTER to continue..."
|
||||||
header_info
|
header_info
|
||||||
set -o errexit #Exit immediately if a pipeline returns a non-zero status
|
set -eEuo pipefail
|
||||||
set -o errtrace #Trap ERR from shell functions, command substitutions, and commands from subshell
|
|
||||||
set -o nounset #Treat unset variables as an error
|
|
||||||
set -o pipefail #Pipe will exit with last non-zero status if applicable
|
|
||||||
shopt -s expand_aliases
|
shopt -s expand_aliases
|
||||||
alias die='EXIT=$? LINE=$LINENO error_exit'
|
alias die='EXIT=$? LINE=$LINENO error_exit'
|
||||||
trap die ERR
|
trap die ERR
|
||||||
|
@ -78,9 +73,13 @@ function cleanup_ctid() {
|
||||||
pct destroy $CTID
|
pct destroy $CTID
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
|
# Stop Proxmox VE Monitor-All if running
|
||||||
if systemctl is-active -q ping-instances.service; then
|
if systemctl is-active -q ping-instances.service; then
|
||||||
systemctl stop ping-instances.service
|
systemctl stop ping-instances.service
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
# Set the CONTENT and CONTENT_LABEL variables
|
||||||
function select_storage() {
|
function select_storage() {
|
||||||
local CLASS=$1
|
local CLASS=$1
|
||||||
local CONTENT
|
local CONTENT
|
||||||
|
@ -102,18 +101,18 @@ function select_storage() {
|
||||||
if [[ $((${#ITEM} + $OFFSET)) -gt ${MSG_MAX_LENGTH:-} ]]; then
|
if [[ $((${#ITEM} + $OFFSET)) -gt ${MSG_MAX_LENGTH:-} ]]; then
|
||||||
local MSG_MAX_LENGTH=$((${#ITEM} + $OFFSET))
|
local MSG_MAX_LENGTH=$((${#ITEM} + $OFFSET))
|
||||||
fi
|
fi
|
||||||
MENU+=( "$TAG" "$ITEM" "OFF" )
|
MENU+=("$TAG" "$ITEM" "OFF")
|
||||||
done < <(pvesm status -content $CONTENT | awk 'NR>1')
|
done < <(pvesm status -content $CONTENT | awk 'NR>1')
|
||||||
|
|
||||||
# Select storage location
|
# Select storage location
|
||||||
if [ $((${#MENU[@]}/3)) -eq 0 ]; then # No storage locations are detected
|
if [ $((${#MENU[@]} / 3)) -eq 0 ]; then
|
||||||
warn "'$CONTENT_LABEL' needs to be selected for at least one storage location."
|
warn "'$CONTENT_LABEL' needs to be selected for at least one storage location."
|
||||||
die "Unable to detect valid storage location."
|
die "Unable to detect valid storage location."
|
||||||
elif [ $((${#MENU[@]}/3)) -eq 1 ]; then # Only one storage location is detected
|
elif [ $((${#MENU[@]} / 3)) -eq 1 ]; then
|
||||||
printf ${MENU[0]}
|
printf ${MENU[0]}
|
||||||
else # More than one storage location is detected
|
else
|
||||||
local STORAGE
|
local STORAGE
|
||||||
while [ -z "${STORAGE:+x}" ]; do # Generate graphical menu
|
while [ -z "${STORAGE:+x}" ]; do
|
||||||
STORAGE=$(whiptail --title "Storage Pools" --radiolist \
|
STORAGE=$(whiptail --title "Storage Pools" --radiolist \
|
||||||
"Which storage pool you would like to use for the ${CONTENT_LABEL,,}?\n\n" \
|
"Which storage pool you would like to use for the ${CONTENT_LABEL,,}?\n\n" \
|
||||||
16 $(($MSG_MAX_LENGTH + 23)) 6 \
|
16 $(($MSG_MAX_LENGTH + 23)) 6 \
|
||||||
|
@ -147,24 +146,49 @@ if ! pveam list $TEMPLATE_STORAGE | grep -q $TEMPLATE; then
|
||||||
die "A problem occured while downloading the LXC template."
|
die "A problem occured while downloading the LXC template."
|
||||||
fi
|
fi
|
||||||
|
|
||||||
PCT_OPTIONS=( ${PCT_OPTIONS[@]:-${DEFAULT_PCT_OPTIONS[@]}} )
|
# Create variable for 'pct' options
|
||||||
[[ " ${PCT_OPTIONS[@]} " =~ " -rootfs " ]] || PCT_OPTIONS+=( -rootfs $CONTAINER_STORAGE:${PCT_DISK_SIZE:-8} )
|
PCT_OPTIONS=(${PCT_OPTIONS[@]:-${DEFAULT_PCT_OPTIONS[@]}})
|
||||||
|
[[ " ${PCT_OPTIONS[@]} " =~ " -rootfs " ]] || PCT_OPTIONS+=(-rootfs $CONTAINER_STORAGE:${PCT_DISK_SIZE:-8})
|
||||||
|
|
||||||
# Create LXC
|
# Create LXC
|
||||||
msg "Creating LXC container..."
|
msg "Creating LXC container..."
|
||||||
pct create $CTID ${TEMPLATE_STORAGE}:vztmpl/${TEMPLATE} ${PCT_OPTIONS[@]} >/dev/null ||
|
pct create $CTID ${TEMPLATE_STORAGE}:vztmpl/${TEMPLATE} ${PCT_OPTIONS[@]} >/dev/null ||
|
||||||
die "A problem occured while trying to create container."
|
die "A problem occured while trying to create container."
|
||||||
|
|
||||||
# Success message
|
# Save password
|
||||||
|
echo "TurnKey ${NAME} password: ${PASS}" >>~/turnkey-${NAME}.creds # file is located in the Proxmox root directory
|
||||||
|
|
||||||
|
# Start container
|
||||||
msg "Starting LXC Container..."
|
msg "Starting LXC Container..."
|
||||||
pct start "$CTID"
|
pct start "$CTID"
|
||||||
sleep 5
|
sleep 5
|
||||||
IP=$(pct exec $CTID ip route get 8.8.8.8 | sed -n '/src/{s/.*src *\([^ ]*\).*/\1/p;q}')
|
|
||||||
echo "TurnKey ${NAME} Password" >>~/turnkey-${NAME}.creds # file is located in the Proxmox root directory
|
# Get container IP
|
||||||
echo $PASS >>~/turnkey-${NAME}.creds
|
max_attempts=5
|
||||||
|
attempt=1
|
||||||
|
IP=""
|
||||||
|
while [[ $attempt -le $max_attempts ]]; do
|
||||||
|
IP=$(pct exec $CTID ip route get 8.8.8.8 | sed -n '/src/{s/.*src *\([^ ]*\).*/\1/p;q}')
|
||||||
|
if [[ -n $IP ]]; then
|
||||||
|
break
|
||||||
|
else
|
||||||
|
warn "Attempt $attempt: IP address not found. Pausing for 5 seconds..."
|
||||||
|
sleep 5
|
||||||
|
((attempt++))
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
|
||||||
|
if [[ -z $IP ]]; then
|
||||||
|
warn "Maximum number of attempts reached. IP address not found."
|
||||||
|
IP="NOT FOUND"
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Start Proxmox VE Monitor-All if available
|
||||||
if [[ -f /etc/systemd/system/ping-instances.service ]]; then
|
if [[ -f /etc/systemd/system/ping-instances.service ]]; then
|
||||||
systemctl start ping-instances.service
|
systemctl start ping-instances.service
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
# Success message
|
||||||
header_info
|
header_info
|
||||||
echo
|
echo
|
||||||
info "LXC container '$CTID' was successfully created, and its IP address is ${IP}."
|
info "LXC container '$CTID' was successfully created, and its IP address is ${IP}."
|
||||||
|
|
|
@ -1,10 +1,8 @@
|
||||||
#!/usr/bin/env bash
|
#!/usr/bin/env bash
|
||||||
# A primitive script to install TurnKey LXC templates using basic settings.
|
|
||||||
# Copyright (c) 2021-2023 tteck
|
# Copyright (c) 2021-2023 tteck
|
||||||
# Author: tteck (tteckster)
|
# Author: tteck (tteckster)
|
||||||
# License: MIT
|
# License: MIT
|
||||||
# https://github.com/tteck/Proxmox/raw/main/LICENSE
|
# https://github.com/tteck/Proxmox/raw/main/LICENSE
|
||||||
# bash -c "$(wget -qLO - https://github.com/tteck/Proxmox/raw/main/turnkey/turnkey-fileserver.sh)"
|
|
||||||
|
|
||||||
# Setup script environment
|
# Setup script environment
|
||||||
NAME="fileserver"
|
NAME="fileserver"
|
||||||
|
@ -39,10 +37,7 @@ EOF
|
||||||
header_info
|
header_info
|
||||||
read -p "Press ENTER to continue..."
|
read -p "Press ENTER to continue..."
|
||||||
header_info
|
header_info
|
||||||
set -o errexit #Exit immediately if a pipeline returns a non-zero status
|
set -eEuo pipefail
|
||||||
set -o errtrace #Trap ERR from shell functions, command substitutions, and commands from subshell
|
|
||||||
set -o nounset #Treat unset variables as an error
|
|
||||||
set -o pipefail #Pipe will exit with last non-zero status if applicable
|
|
||||||
shopt -s expand_aliases
|
shopt -s expand_aliases
|
||||||
alias die='EXIT=$? LINE=$LINENO error_exit'
|
alias die='EXIT=$? LINE=$LINENO error_exit'
|
||||||
trap die ERR
|
trap die ERR
|
||||||
|
@ -78,9 +73,13 @@ function cleanup_ctid() {
|
||||||
pct destroy $CTID
|
pct destroy $CTID
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
|
# Stop Proxmox VE Monitor-All if running
|
||||||
if systemctl is-active -q ping-instances.service; then
|
if systemctl is-active -q ping-instances.service; then
|
||||||
systemctl stop ping-instances.service
|
systemctl stop ping-instances.service
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
# Set the CONTENT and CONTENT_LABEL variables
|
||||||
function select_storage() {
|
function select_storage() {
|
||||||
local CLASS=$1
|
local CLASS=$1
|
||||||
local CONTENT
|
local CONTENT
|
||||||
|
@ -102,18 +101,18 @@ function select_storage() {
|
||||||
if [[ $((${#ITEM} + $OFFSET)) -gt ${MSG_MAX_LENGTH:-} ]]; then
|
if [[ $((${#ITEM} + $OFFSET)) -gt ${MSG_MAX_LENGTH:-} ]]; then
|
||||||
local MSG_MAX_LENGTH=$((${#ITEM} + $OFFSET))
|
local MSG_MAX_LENGTH=$((${#ITEM} + $OFFSET))
|
||||||
fi
|
fi
|
||||||
MENU+=( "$TAG" "$ITEM" "OFF" )
|
MENU+=("$TAG" "$ITEM" "OFF")
|
||||||
done < <(pvesm status -content $CONTENT | awk 'NR>1')
|
done < <(pvesm status -content $CONTENT | awk 'NR>1')
|
||||||
|
|
||||||
# Select storage location
|
# Select storage location
|
||||||
if [ $((${#MENU[@]}/3)) -eq 0 ]; then # No storage locations are detected
|
if [ $((${#MENU[@]} / 3)) -eq 0 ]; then
|
||||||
warn "'$CONTENT_LABEL' needs to be selected for at least one storage location."
|
warn "'$CONTENT_LABEL' needs to be selected for at least one storage location."
|
||||||
die "Unable to detect valid storage location."
|
die "Unable to detect valid storage location."
|
||||||
elif [ $((${#MENU[@]}/3)) -eq 1 ]; then # Only one storage location is detected
|
elif [ $((${#MENU[@]} / 3)) -eq 1 ]; then
|
||||||
printf ${MENU[0]}
|
printf ${MENU[0]}
|
||||||
else # More than one storage location is detected
|
else
|
||||||
local STORAGE
|
local STORAGE
|
||||||
while [ -z "${STORAGE:+x}" ]; do # Generate graphical menu
|
while [ -z "${STORAGE:+x}" ]; do
|
||||||
STORAGE=$(whiptail --title "Storage Pools" --radiolist \
|
STORAGE=$(whiptail --title "Storage Pools" --radiolist \
|
||||||
"Which storage pool you would like to use for the ${CONTENT_LABEL,,}?\n\n" \
|
"Which storage pool you would like to use for the ${CONTENT_LABEL,,}?\n\n" \
|
||||||
16 $(($MSG_MAX_LENGTH + 23)) 6 \
|
16 $(($MSG_MAX_LENGTH + 23)) 6 \
|
||||||
|
@ -147,24 +146,49 @@ if ! pveam list $TEMPLATE_STORAGE | grep -q $TEMPLATE; then
|
||||||
die "A problem occured while downloading the LXC template."
|
die "A problem occured while downloading the LXC template."
|
||||||
fi
|
fi
|
||||||
|
|
||||||
PCT_OPTIONS=( ${PCT_OPTIONS[@]:-${DEFAULT_PCT_OPTIONS[@]}} )
|
# Create variable for 'pct' options
|
||||||
[[ " ${PCT_OPTIONS[@]} " =~ " -rootfs " ]] || PCT_OPTIONS+=( -rootfs $CONTAINER_STORAGE:${PCT_DISK_SIZE:-4} )
|
PCT_OPTIONS=(${PCT_OPTIONS[@]:-${DEFAULT_PCT_OPTIONS[@]}})
|
||||||
|
[[ " ${PCT_OPTIONS[@]} " =~ " -rootfs " ]] || PCT_OPTIONS+=(-rootfs $CONTAINER_STORAGE:${PCT_DISK_SIZE:-8})
|
||||||
|
|
||||||
# Create LXC
|
# Create LXC
|
||||||
msg "Creating LXC container..."
|
msg "Creating LXC container..."
|
||||||
pct create $CTID ${TEMPLATE_STORAGE}:vztmpl/${TEMPLATE} ${PCT_OPTIONS[@]} >/dev/null ||
|
pct create $CTID ${TEMPLATE_STORAGE}:vztmpl/${TEMPLATE} ${PCT_OPTIONS[@]} >/dev/null ||
|
||||||
die "A problem occured while trying to create container."
|
die "A problem occured while trying to create container."
|
||||||
|
|
||||||
# Success message
|
# Save password
|
||||||
|
echo "TurnKey ${NAME} password: ${PASS}" >>~/turnkey-${NAME}.creds # file is located in the Proxmox root directory
|
||||||
|
|
||||||
|
# Start container
|
||||||
msg "Starting LXC Container..."
|
msg "Starting LXC Container..."
|
||||||
pct start "$CTID"
|
pct start "$CTID"
|
||||||
sleep 5
|
sleep 5
|
||||||
IP=$(pct exec $CTID ip route get 8.8.8.8 | sed -n '/src/{s/.*src *\([^ ]*\).*/\1/p;q}')
|
|
||||||
echo "TurnKey ${NAME} Password" >>~/turnkey-${NAME}.creds # file is located in the Proxmox root directory
|
# Get container IP
|
||||||
echo $PASS >>~/turnkey-${NAME}.creds
|
max_attempts=5
|
||||||
|
attempt=1
|
||||||
|
IP=""
|
||||||
|
while [[ $attempt -le $max_attempts ]]; do
|
||||||
|
IP=$(pct exec $CTID ip route get 8.8.8.8 | sed -n '/src/{s/.*src *\([^ ]*\).*/\1/p;q}')
|
||||||
|
if [[ -n $IP ]]; then
|
||||||
|
break
|
||||||
|
else
|
||||||
|
warn "Attempt $attempt: IP address not found. Pausing for 5 seconds..."
|
||||||
|
sleep 5
|
||||||
|
((attempt++))
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
|
||||||
|
if [[ -z $IP ]]; then
|
||||||
|
warn "Maximum number of attempts reached. IP address not found."
|
||||||
|
IP="NOT FOUND"
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Start Proxmox VE Monitor-All if available
|
||||||
if [[ -f /etc/systemd/system/ping-instances.service ]]; then
|
if [[ -f /etc/systemd/system/ping-instances.service ]]; then
|
||||||
systemctl start ping-instances.service
|
systemctl start ping-instances.service
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
# Success message
|
||||||
header_info
|
header_info
|
||||||
echo
|
echo
|
||||||
info "LXC container '$CTID' was successfully created, and its IP address is ${IP}."
|
info "LXC container '$CTID' was successfully created, and its IP address is ${IP}."
|
||||||
|
|
|
@ -1,10 +1,8 @@
|
||||||
#!/usr/bin/env bash
|
#!/usr/bin/env bash
|
||||||
# A primitive script to install TurnKey LXC templates using basic settings.
|
|
||||||
# Copyright (c) 2021-2023 tteck
|
# Copyright (c) 2021-2023 tteck
|
||||||
# Author: tteck (tteckster)
|
# Author: tteck (tteckster)
|
||||||
# License: MIT
|
# License: MIT
|
||||||
# https://github.com/tteck/Proxmox/raw/main/LICENSE
|
# https://github.com/tteck/Proxmox/raw/main/LICENSE
|
||||||
# bash -c "$(wget -qLO - https://github.com/tteck/Proxmox/raw/main/turnkey/turnkey-gitea.sh)"
|
|
||||||
|
|
||||||
# Setup script environment
|
# Setup script environment
|
||||||
NAME="gitea"
|
NAME="gitea"
|
||||||
|
@ -39,10 +37,7 @@ EOF
|
||||||
header_info
|
header_info
|
||||||
read -p "Press ENTER to continue..."
|
read -p "Press ENTER to continue..."
|
||||||
header_info
|
header_info
|
||||||
set -o errexit #Exit immediately if a pipeline returns a non-zero status
|
set -eEuo pipefail
|
||||||
set -o errtrace #Trap ERR from shell functions, command substitutions, and commands from subshell
|
|
||||||
set -o nounset #Treat unset variables as an error
|
|
||||||
set -o pipefail #Pipe will exit with last non-zero status if applicable
|
|
||||||
shopt -s expand_aliases
|
shopt -s expand_aliases
|
||||||
alias die='EXIT=$? LINE=$LINENO error_exit'
|
alias die='EXIT=$? LINE=$LINENO error_exit'
|
||||||
trap die ERR
|
trap die ERR
|
||||||
|
@ -78,9 +73,13 @@ function cleanup_ctid() {
|
||||||
pct destroy $CTID
|
pct destroy $CTID
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
|
# Stop Proxmox VE Monitor-All if running
|
||||||
if systemctl is-active -q ping-instances.service; then
|
if systemctl is-active -q ping-instances.service; then
|
||||||
systemctl stop ping-instances.service
|
systemctl stop ping-instances.service
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
# Set the CONTENT and CONTENT_LABEL variables
|
||||||
function select_storage() {
|
function select_storage() {
|
||||||
local CLASS=$1
|
local CLASS=$1
|
||||||
local CONTENT
|
local CONTENT
|
||||||
|
@ -102,18 +101,18 @@ function select_storage() {
|
||||||
if [[ $((${#ITEM} + $OFFSET)) -gt ${MSG_MAX_LENGTH:-} ]]; then
|
if [[ $((${#ITEM} + $OFFSET)) -gt ${MSG_MAX_LENGTH:-} ]]; then
|
||||||
local MSG_MAX_LENGTH=$((${#ITEM} + $OFFSET))
|
local MSG_MAX_LENGTH=$((${#ITEM} + $OFFSET))
|
||||||
fi
|
fi
|
||||||
MENU+=( "$TAG" "$ITEM" "OFF" )
|
MENU+=("$TAG" "$ITEM" "OFF")
|
||||||
done < <(pvesm status -content $CONTENT | awk 'NR>1')
|
done < <(pvesm status -content $CONTENT | awk 'NR>1')
|
||||||
|
|
||||||
# Select storage location
|
# Select storage location
|
||||||
if [ $((${#MENU[@]}/3)) -eq 0 ]; then # No storage locations are detected
|
if [ $((${#MENU[@]} / 3)) -eq 0 ]; then
|
||||||
warn "'$CONTENT_LABEL' needs to be selected for at least one storage location."
|
warn "'$CONTENT_LABEL' needs to be selected for at least one storage location."
|
||||||
die "Unable to detect valid storage location."
|
die "Unable to detect valid storage location."
|
||||||
elif [ $((${#MENU[@]}/3)) -eq 1 ]; then # Only one storage location is detected
|
elif [ $((${#MENU[@]} / 3)) -eq 1 ]; then
|
||||||
printf ${MENU[0]}
|
printf ${MENU[0]}
|
||||||
else # More than one storage location is detected
|
else
|
||||||
local STORAGE
|
local STORAGE
|
||||||
while [ -z "${STORAGE:+x}" ]; do # Generate graphical menu
|
while [ -z "${STORAGE:+x}" ]; do
|
||||||
STORAGE=$(whiptail --title "Storage Pools" --radiolist \
|
STORAGE=$(whiptail --title "Storage Pools" --radiolist \
|
||||||
"Which storage pool you would like to use for the ${CONTENT_LABEL,,}?\n\n" \
|
"Which storage pool you would like to use for the ${CONTENT_LABEL,,}?\n\n" \
|
||||||
16 $(($MSG_MAX_LENGTH + 23)) 6 \
|
16 $(($MSG_MAX_LENGTH + 23)) 6 \
|
||||||
|
@ -147,24 +146,49 @@ if ! pveam list $TEMPLATE_STORAGE | grep -q $TEMPLATE; then
|
||||||
die "A problem occured while downloading the LXC template."
|
die "A problem occured while downloading the LXC template."
|
||||||
fi
|
fi
|
||||||
|
|
||||||
PCT_OPTIONS=( ${PCT_OPTIONS[@]:-${DEFAULT_PCT_OPTIONS[@]}} )
|
# Create variable for 'pct' options
|
||||||
[[ " ${PCT_OPTIONS[@]} " =~ " -rootfs " ]] || PCT_OPTIONS+=( -rootfs $CONTAINER_STORAGE:${PCT_DISK_SIZE:-8} )
|
PCT_OPTIONS=(${PCT_OPTIONS[@]:-${DEFAULT_PCT_OPTIONS[@]}})
|
||||||
|
[[ " ${PCT_OPTIONS[@]} " =~ " -rootfs " ]] || PCT_OPTIONS+=(-rootfs $CONTAINER_STORAGE:${PCT_DISK_SIZE:-8})
|
||||||
|
|
||||||
# Create LXC
|
# Create LXC
|
||||||
msg "Creating LXC container..."
|
msg "Creating LXC container..."
|
||||||
pct create $CTID ${TEMPLATE_STORAGE}:vztmpl/${TEMPLATE} ${PCT_OPTIONS[@]} >/dev/null ||
|
pct create $CTID ${TEMPLATE_STORAGE}:vztmpl/${TEMPLATE} ${PCT_OPTIONS[@]} >/dev/null ||
|
||||||
die "A problem occured while trying to create container."
|
die "A problem occured while trying to create container."
|
||||||
|
|
||||||
# Success message
|
# Save password
|
||||||
|
echo "TurnKey ${NAME} password: ${PASS}" >>~/turnkey-${NAME}.creds # file is located in the Proxmox root directory
|
||||||
|
|
||||||
|
# Start container
|
||||||
msg "Starting LXC Container..."
|
msg "Starting LXC Container..."
|
||||||
pct start "$CTID"
|
pct start "$CTID"
|
||||||
sleep 5
|
sleep 5
|
||||||
IP=$(pct exec $CTID ip route get 8.8.8.8 | sed -n '/src/{s/.*src *\([^ ]*\).*/\1/p;q}')
|
|
||||||
echo "TurnKey ${NAME} Password" >>~/turnkey-${NAME}.creds # file is located in the Proxmox root directory
|
# Get container IP
|
||||||
echo $PASS >>~/turnkey-${NAME}.creds
|
max_attempts=5
|
||||||
|
attempt=1
|
||||||
|
IP=""
|
||||||
|
while [[ $attempt -le $max_attempts ]]; do
|
||||||
|
IP=$(pct exec $CTID ip route get 8.8.8.8 | sed -n '/src/{s/.*src *\([^ ]*\).*/\1/p;q}')
|
||||||
|
if [[ -n $IP ]]; then
|
||||||
|
break
|
||||||
|
else
|
||||||
|
warn "Attempt $attempt: IP address not found. Pausing for 5 seconds..."
|
||||||
|
sleep 5
|
||||||
|
((attempt++))
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
|
||||||
|
if [[ -z $IP ]]; then
|
||||||
|
warn "Maximum number of attempts reached. IP address not found."
|
||||||
|
IP="NOT FOUND"
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Start Proxmox VE Monitor-All if available
|
||||||
if [[ -f /etc/systemd/system/ping-instances.service ]]; then
|
if [[ -f /etc/systemd/system/ping-instances.service ]]; then
|
||||||
systemctl start ping-instances.service
|
systemctl start ping-instances.service
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
# Success message
|
||||||
header_info
|
header_info
|
||||||
echo
|
echo
|
||||||
info "LXC container '$CTID' was successfully created, and its IP address is ${IP}."
|
info "LXC container '$CTID' was successfully created, and its IP address is ${IP}."
|
||||||
|
|
|
@ -1,10 +1,8 @@
|
||||||
#!/usr/bin/env bash
|
#!/usr/bin/env bash
|
||||||
# A primitive script to install TurnKey LXC templates using basic settings.
|
|
||||||
# Copyright (c) 2021-2023 tteck
|
# Copyright (c) 2021-2023 tteck
|
||||||
# Author: tteck (tteckster)
|
# Author: tteck (tteckster)
|
||||||
# License: MIT
|
# License: MIT
|
||||||
# https://github.com/tteck/Proxmox/raw/main/LICENSE
|
# https://github.com/tteck/Proxmox/raw/main/LICENSE
|
||||||
# bash -c "$(wget -qLO - https://github.com/tteck/Proxmox/raw/main/turnkey/turnkey-gitlab.sh)"
|
|
||||||
|
|
||||||
# Setup script environment
|
# Setup script environment
|
||||||
NAME="gitlab"
|
NAME="gitlab"
|
||||||
|
@ -39,10 +37,7 @@ EOF
|
||||||
header_info
|
header_info
|
||||||
read -p "Press ENTER to continue..."
|
read -p "Press ENTER to continue..."
|
||||||
header_info
|
header_info
|
||||||
set -o errexit #Exit immediately if a pipeline returns a non-zero status
|
set -eEuo pipefail
|
||||||
set -o errtrace #Trap ERR from shell functions, command substitutions, and commands from subshell
|
|
||||||
set -o nounset #Treat unset variables as an error
|
|
||||||
set -o pipefail #Pipe will exit with last non-zero status if applicable
|
|
||||||
shopt -s expand_aliases
|
shopt -s expand_aliases
|
||||||
alias die='EXIT=$? LINE=$LINENO error_exit'
|
alias die='EXIT=$? LINE=$LINENO error_exit'
|
||||||
trap die ERR
|
trap die ERR
|
||||||
|
@ -78,9 +73,13 @@ function cleanup_ctid() {
|
||||||
pct destroy $CTID
|
pct destroy $CTID
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
|
# Stop Proxmox VE Monitor-All if running
|
||||||
if systemctl is-active -q ping-instances.service; then
|
if systemctl is-active -q ping-instances.service; then
|
||||||
systemctl stop ping-instances.service
|
systemctl stop ping-instances.service
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
# Set the CONTENT and CONTENT_LABEL variables
|
||||||
function select_storage() {
|
function select_storage() {
|
||||||
local CLASS=$1
|
local CLASS=$1
|
||||||
local CONTENT
|
local CONTENT
|
||||||
|
@ -102,18 +101,18 @@ function select_storage() {
|
||||||
if [[ $((${#ITEM} + $OFFSET)) -gt ${MSG_MAX_LENGTH:-} ]]; then
|
if [[ $((${#ITEM} + $OFFSET)) -gt ${MSG_MAX_LENGTH:-} ]]; then
|
||||||
local MSG_MAX_LENGTH=$((${#ITEM} + $OFFSET))
|
local MSG_MAX_LENGTH=$((${#ITEM} + $OFFSET))
|
||||||
fi
|
fi
|
||||||
MENU+=( "$TAG" "$ITEM" "OFF" )
|
MENU+=("$TAG" "$ITEM" "OFF")
|
||||||
done < <(pvesm status -content $CONTENT | awk 'NR>1')
|
done < <(pvesm status -content $CONTENT | awk 'NR>1')
|
||||||
|
|
||||||
# Select storage location
|
# Select storage location
|
||||||
if [ $((${#MENU[@]}/3)) -eq 0 ]; then # No storage locations are detected
|
if [ $((${#MENU[@]} / 3)) -eq 0 ]; then
|
||||||
warn "'$CONTENT_LABEL' needs to be selected for at least one storage location."
|
warn "'$CONTENT_LABEL' needs to be selected for at least one storage location."
|
||||||
die "Unable to detect valid storage location."
|
die "Unable to detect valid storage location."
|
||||||
elif [ $((${#MENU[@]}/3)) -eq 1 ]; then # Only one storage location is detected
|
elif [ $((${#MENU[@]} / 3)) -eq 1 ]; then
|
||||||
printf ${MENU[0]}
|
printf ${MENU[0]}
|
||||||
else # More than one storage location is detected
|
else
|
||||||
local STORAGE
|
local STORAGE
|
||||||
while [ -z "${STORAGE:+x}" ]; do # Generate graphical menu
|
while [ -z "${STORAGE:+x}" ]; do
|
||||||
STORAGE=$(whiptail --title "Storage Pools" --radiolist \
|
STORAGE=$(whiptail --title "Storage Pools" --radiolist \
|
||||||
"Which storage pool you would like to use for the ${CONTENT_LABEL,,}?\n\n" \
|
"Which storage pool you would like to use for the ${CONTENT_LABEL,,}?\n\n" \
|
||||||
16 $(($MSG_MAX_LENGTH + 23)) 6 \
|
16 $(($MSG_MAX_LENGTH + 23)) 6 \
|
||||||
|
@ -147,24 +146,49 @@ if ! pveam list $TEMPLATE_STORAGE | grep -q $TEMPLATE; then
|
||||||
die "A problem occured while downloading the LXC template."
|
die "A problem occured while downloading the LXC template."
|
||||||
fi
|
fi
|
||||||
|
|
||||||
PCT_OPTIONS=( ${PCT_OPTIONS[@]:-${DEFAULT_PCT_OPTIONS[@]}} )
|
# Create variable for 'pct' options
|
||||||
[[ " ${PCT_OPTIONS[@]} " =~ " -rootfs " ]] || PCT_OPTIONS+=( -rootfs $CONTAINER_STORAGE:${PCT_DISK_SIZE:-8} )
|
PCT_OPTIONS=(${PCT_OPTIONS[@]:-${DEFAULT_PCT_OPTIONS[@]}})
|
||||||
|
[[ " ${PCT_OPTIONS[@]} " =~ " -rootfs " ]] || PCT_OPTIONS+=(-rootfs $CONTAINER_STORAGE:${PCT_DISK_SIZE:-8})
|
||||||
|
|
||||||
# Create LXC
|
# Create LXC
|
||||||
msg "Creating LXC container..."
|
msg "Creating LXC container..."
|
||||||
pct create $CTID ${TEMPLATE_STORAGE}:vztmpl/${TEMPLATE} ${PCT_OPTIONS[@]} >/dev/null ||
|
pct create $CTID ${TEMPLATE_STORAGE}:vztmpl/${TEMPLATE} ${PCT_OPTIONS[@]} >/dev/null ||
|
||||||
die "A problem occured while trying to create container."
|
die "A problem occured while trying to create container."
|
||||||
|
|
||||||
# Success message
|
# Save password
|
||||||
|
echo "TurnKey ${NAME} password: ${PASS}" >>~/turnkey-${NAME}.creds # file is located in the Proxmox root directory
|
||||||
|
|
||||||
|
# Start container
|
||||||
msg "Starting LXC Container..."
|
msg "Starting LXC Container..."
|
||||||
pct start "$CTID"
|
pct start "$CTID"
|
||||||
sleep 5
|
sleep 5
|
||||||
IP=$(pct exec $CTID ip route get 8.8.8.8 | sed -n '/src/{s/.*src *\([^ ]*\).*/\1/p;q}')
|
|
||||||
echo "TurnKey ${NAME} Password" >>~/turnkey-${NAME}.creds # file is located in the Proxmox root directory
|
# Get container IP
|
||||||
echo $PASS >>~/turnkey-${NAME}.creds
|
max_attempts=5
|
||||||
|
attempt=1
|
||||||
|
IP=""
|
||||||
|
while [[ $attempt -le $max_attempts ]]; do
|
||||||
|
IP=$(pct exec $CTID ip route get 8.8.8.8 | sed -n '/src/{s/.*src *\([^ ]*\).*/\1/p;q}')
|
||||||
|
if [[ -n $IP ]]; then
|
||||||
|
break
|
||||||
|
else
|
||||||
|
warn "Attempt $attempt: IP address not found. Pausing for 5 seconds..."
|
||||||
|
sleep 5
|
||||||
|
((attempt++))
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
|
||||||
|
if [[ -z $IP ]]; then
|
||||||
|
warn "Maximum number of attempts reached. IP address not found."
|
||||||
|
IP="NOT FOUND"
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Start Proxmox VE Monitor-All if available
|
||||||
if [[ -f /etc/systemd/system/ping-instances.service ]]; then
|
if [[ -f /etc/systemd/system/ping-instances.service ]]; then
|
||||||
systemctl start ping-instances.service
|
systemctl start ping-instances.service
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
# Success message
|
||||||
header_info
|
header_info
|
||||||
echo
|
echo
|
||||||
info "LXC container '$CTID' was successfully created, and its IP address is ${IP}."
|
info "LXC container '$CTID' was successfully created, and its IP address is ${IP}."
|
||||||
|
|
|
@ -1,10 +1,8 @@
|
||||||
#!/usr/bin/env bash
|
#!/usr/bin/env bash
|
||||||
# A primitive script to install TurnKey LXC templates using basic settings.
|
|
||||||
# Copyright (c) 2021-2023 tteck
|
# Copyright (c) 2021-2023 tteck
|
||||||
# Author: tteck (tteckster)
|
# Author: tteck (tteckster)
|
||||||
# License: MIT
|
# License: MIT
|
||||||
# https://github.com/tteck/Proxmox/raw/main/LICENSE
|
# https://github.com/tteck/Proxmox/raw/main/LICENSE
|
||||||
# bash -c "$(wget -qLO - https://github.com/tteck/Proxmox/raw/main/turnkey/turnkey-nextcloud.sh)"
|
|
||||||
|
|
||||||
# Setup script environment
|
# Setup script environment
|
||||||
NAME="nextcloud"
|
NAME="nextcloud"
|
||||||
|
@ -39,10 +37,7 @@ EOF
|
||||||
header_info
|
header_info
|
||||||
read -p "Press ENTER to continue..."
|
read -p "Press ENTER to continue..."
|
||||||
header_info
|
header_info
|
||||||
set -o errexit #Exit immediately if a pipeline returns a non-zero status
|
set -eEuo pipefail
|
||||||
set -o errtrace #Trap ERR from shell functions, command substitutions, and commands from subshell
|
|
||||||
set -o nounset #Treat unset variables as an error
|
|
||||||
set -o pipefail #Pipe will exit with last non-zero status if applicable
|
|
||||||
shopt -s expand_aliases
|
shopt -s expand_aliases
|
||||||
alias die='EXIT=$? LINE=$LINENO error_exit'
|
alias die='EXIT=$? LINE=$LINENO error_exit'
|
||||||
trap die ERR
|
trap die ERR
|
||||||
|
@ -78,9 +73,13 @@ function cleanup_ctid() {
|
||||||
pct destroy $CTID
|
pct destroy $CTID
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
|
# Stop Proxmox VE Monitor-All if running
|
||||||
if systemctl is-active -q ping-instances.service; then
|
if systemctl is-active -q ping-instances.service; then
|
||||||
systemctl stop ping-instances.service
|
systemctl stop ping-instances.service
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
# Set the CONTENT and CONTENT_LABEL variables
|
||||||
function select_storage() {
|
function select_storage() {
|
||||||
local CLASS=$1
|
local CLASS=$1
|
||||||
local CONTENT
|
local CONTENT
|
||||||
|
@ -102,18 +101,18 @@ function select_storage() {
|
||||||
if [[ $((${#ITEM} + $OFFSET)) -gt ${MSG_MAX_LENGTH:-} ]]; then
|
if [[ $((${#ITEM} + $OFFSET)) -gt ${MSG_MAX_LENGTH:-} ]]; then
|
||||||
local MSG_MAX_LENGTH=$((${#ITEM} + $OFFSET))
|
local MSG_MAX_LENGTH=$((${#ITEM} + $OFFSET))
|
||||||
fi
|
fi
|
||||||
MENU+=( "$TAG" "$ITEM" "OFF" )
|
MENU+=("$TAG" "$ITEM" "OFF")
|
||||||
done < <(pvesm status -content $CONTENT | awk 'NR>1')
|
done < <(pvesm status -content $CONTENT | awk 'NR>1')
|
||||||
|
|
||||||
# Select storage location
|
# Select storage location
|
||||||
if [ $((${#MENU[@]}/3)) -eq 0 ]; then # No storage locations are detected
|
if [ $((${#MENU[@]} / 3)) -eq 0 ]; then
|
||||||
warn "'$CONTENT_LABEL' needs to be selected for at least one storage location."
|
warn "'$CONTENT_LABEL' needs to be selected for at least one storage location."
|
||||||
die "Unable to detect valid storage location."
|
die "Unable to detect valid storage location."
|
||||||
elif [ $((${#MENU[@]}/3)) -eq 1 ]; then # Only one storage location is detected
|
elif [ $((${#MENU[@]} / 3)) -eq 1 ]; then
|
||||||
printf ${MENU[0]}
|
printf ${MENU[0]}
|
||||||
else # More than one storage location is detected
|
else
|
||||||
local STORAGE
|
local STORAGE
|
||||||
while [ -z "${STORAGE:+x}" ]; do # Generate graphical menu
|
while [ -z "${STORAGE:+x}" ]; do
|
||||||
STORAGE=$(whiptail --title "Storage Pools" --radiolist \
|
STORAGE=$(whiptail --title "Storage Pools" --radiolist \
|
||||||
"Which storage pool you would like to use for the ${CONTENT_LABEL,,}?\n\n" \
|
"Which storage pool you would like to use for the ${CONTENT_LABEL,,}?\n\n" \
|
||||||
16 $(($MSG_MAX_LENGTH + 23)) 6 \
|
16 $(($MSG_MAX_LENGTH + 23)) 6 \
|
||||||
|
@ -147,24 +146,49 @@ if ! pveam list $TEMPLATE_STORAGE | grep -q $TEMPLATE; then
|
||||||
die "A problem occured while downloading the LXC template."
|
die "A problem occured while downloading the LXC template."
|
||||||
fi
|
fi
|
||||||
|
|
||||||
PCT_OPTIONS=( ${PCT_OPTIONS[@]:-${DEFAULT_PCT_OPTIONS[@]}} )
|
# Create variable for 'pct' options
|
||||||
[[ " ${PCT_OPTIONS[@]} " =~ " -rootfs " ]] || PCT_OPTIONS+=( -rootfs $CONTAINER_STORAGE:${PCT_DISK_SIZE:-8} )
|
PCT_OPTIONS=(${PCT_OPTIONS[@]:-${DEFAULT_PCT_OPTIONS[@]}})
|
||||||
|
[[ " ${PCT_OPTIONS[@]} " =~ " -rootfs " ]] || PCT_OPTIONS+=(-rootfs $CONTAINER_STORAGE:${PCT_DISK_SIZE:-8})
|
||||||
|
|
||||||
# Create LXC
|
# Create LXC
|
||||||
msg "Creating LXC container..."
|
msg "Creating LXC container..."
|
||||||
pct create $CTID ${TEMPLATE_STORAGE}:vztmpl/${TEMPLATE} ${PCT_OPTIONS[@]} >/dev/null ||
|
pct create $CTID ${TEMPLATE_STORAGE}:vztmpl/${TEMPLATE} ${PCT_OPTIONS[@]} >/dev/null ||
|
||||||
die "A problem occured while trying to create container."
|
die "A problem occured while trying to create container."
|
||||||
|
|
||||||
# Success message
|
# Save password
|
||||||
|
echo "TurnKey ${NAME} password: ${PASS}" >>~/turnkey-${NAME}.creds # file is located in the Proxmox root directory
|
||||||
|
|
||||||
|
# Start container
|
||||||
msg "Starting LXC Container..."
|
msg "Starting LXC Container..."
|
||||||
pct start "$CTID"
|
pct start "$CTID"
|
||||||
sleep 5
|
sleep 5
|
||||||
IP=$(pct exec $CTID ip route get 8.8.8.8 | sed -n '/src/{s/.*src *\([^ ]*\).*/\1/p;q}')
|
|
||||||
echo "TurnKey ${NAME} Password" >>~/turnkey-${NAME}.creds # file is located in the Proxmox root directory
|
# Get container IP
|
||||||
echo $PASS >>~/turnkey-${NAME}.creds
|
max_attempts=5
|
||||||
|
attempt=1
|
||||||
|
IP=""
|
||||||
|
while [[ $attempt -le $max_attempts ]]; do
|
||||||
|
IP=$(pct exec $CTID ip route get 8.8.8.8 | sed -n '/src/{s/.*src *\([^ ]*\).*/\1/p;q}')
|
||||||
|
if [[ -n $IP ]]; then
|
||||||
|
break
|
||||||
|
else
|
||||||
|
warn "Attempt $attempt: IP address not found. Pausing for 5 seconds..."
|
||||||
|
sleep 5
|
||||||
|
((attempt++))
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
|
||||||
|
if [[ -z $IP ]]; then
|
||||||
|
warn "Maximum number of attempts reached. IP address not found."
|
||||||
|
IP="NOT FOUND"
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Start Proxmox VE Monitor-All if available
|
||||||
if [[ -f /etc/systemd/system/ping-instances.service ]]; then
|
if [[ -f /etc/systemd/system/ping-instances.service ]]; then
|
||||||
systemctl start ping-instances.service
|
systemctl start ping-instances.service
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
# Success message
|
||||||
header_info
|
header_info
|
||||||
echo
|
echo
|
||||||
info "LXC container '$CTID' was successfully created, and its IP address is ${IP}."
|
info "LXC container '$CTID' was successfully created, and its IP address is ${IP}."
|
||||||
|
|
|
@ -1,5 +1,4 @@
|
||||||
#!/usr/bin/env bash
|
#!/usr/bin/env bash
|
||||||
# A primitive script to install TurnKey LXC templates using basic settings.
|
|
||||||
# Copyright (c) 2021-2023 tteck
|
# Copyright (c) 2021-2023 tteck
|
||||||
# Author: tteck (tteckster)
|
# Author: tteck (tteckster)
|
||||||
# License: MIT
|
# License: MIT
|
||||||
|
@ -38,10 +37,7 @@ EOF
|
||||||
header_info
|
header_info
|
||||||
read -p "Press ENTER to continue..."
|
read -p "Press ENTER to continue..."
|
||||||
header_info
|
header_info
|
||||||
set -o errexit #Exit immediately if a pipeline returns a non-zero status
|
set -eEuo pipefail
|
||||||
set -o errtrace #Trap ERR from shell functions, command substitutions, and commands from subshell
|
|
||||||
set -o nounset #Treat unset variables as an error
|
|
||||||
set -o pipefail #Pipe will exit with last non-zero status if applicable
|
|
||||||
shopt -s expand_aliases
|
shopt -s expand_aliases
|
||||||
alias die='EXIT=$? LINE=$LINENO error_exit'
|
alias die='EXIT=$? LINE=$LINENO error_exit'
|
||||||
trap die ERR
|
trap die ERR
|
||||||
|
@ -82,6 +78,8 @@ function cleanup_ctid() {
|
||||||
if systemctl is-active -q ping-instances.service; then
|
if systemctl is-active -q ping-instances.service; then
|
||||||
systemctl stop ping-instances.service
|
systemctl stop ping-instances.service
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
# Set the CONTENT and CONTENT_LABEL variables
|
||||||
function select_storage() {
|
function select_storage() {
|
||||||
local CLASS=$1
|
local CLASS=$1
|
||||||
local CONTENT
|
local CONTENT
|
||||||
|
@ -103,18 +101,18 @@ function select_storage() {
|
||||||
if [[ $((${#ITEM} + $OFFSET)) -gt ${MSG_MAX_LENGTH:-} ]]; then
|
if [[ $((${#ITEM} + $OFFSET)) -gt ${MSG_MAX_LENGTH:-} ]]; then
|
||||||
local MSG_MAX_LENGTH=$((${#ITEM} + $OFFSET))
|
local MSG_MAX_LENGTH=$((${#ITEM} + $OFFSET))
|
||||||
fi
|
fi
|
||||||
MENU+=( "$TAG" "$ITEM" "OFF" )
|
MENU+=("$TAG" "$ITEM" "OFF")
|
||||||
done < <(pvesm status -content $CONTENT | awk 'NR>1')
|
done < <(pvesm status -content $CONTENT | awk 'NR>1')
|
||||||
|
|
||||||
# Select storage location
|
# Select storage location
|
||||||
if [ $((${#MENU[@]}/3)) -eq 0 ]; then # No storage locations are detected
|
if [ $((${#MENU[@]} / 3)) -eq 0 ]; then
|
||||||
warn "'$CONTENT_LABEL' needs to be selected for at least one storage location."
|
warn "'$CONTENT_LABEL' needs to be selected for at least one storage location."
|
||||||
die "Unable to detect valid storage location."
|
die "Unable to detect valid storage location."
|
||||||
elif [ $((${#MENU[@]}/3)) -eq 1 ]; then # Only one storage location is detected
|
elif [ $((${#MENU[@]} / 3)) -eq 1 ]; then
|
||||||
printf ${MENU[0]}
|
printf ${MENU[0]}
|
||||||
else # More than one storage location is detected
|
else
|
||||||
local STORAGE
|
local STORAGE
|
||||||
while [ -z "${STORAGE:+x}" ]; do # Generate graphical menu
|
while [ -z "${STORAGE:+x}" ]; do
|
||||||
STORAGE=$(whiptail --title "Storage Pools" --radiolist \
|
STORAGE=$(whiptail --title "Storage Pools" --radiolist \
|
||||||
"Which storage pool you would like to use for the ${CONTENT_LABEL,,}?\n\n" \
|
"Which storage pool you would like to use for the ${CONTENT_LABEL,,}?\n\n" \
|
||||||
16 $(($MSG_MAX_LENGTH + 23)) 6 \
|
16 $(($MSG_MAX_LENGTH + 23)) 6 \
|
||||||
|
@ -149,8 +147,8 @@ if ! pveam list $TEMPLATE_STORAGE | grep -q $TEMPLATE; then
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Create variable for 'pct' options
|
# Create variable for 'pct' options
|
||||||
PCT_OPTIONS=( ${PCT_OPTIONS[@]:-${DEFAULT_PCT_OPTIONS[@]}} )
|
PCT_OPTIONS=(${PCT_OPTIONS[@]:-${DEFAULT_PCT_OPTIONS[@]}})
|
||||||
[[ " ${PCT_OPTIONS[@]} " =~ " -rootfs " ]] || PCT_OPTIONS+=( -rootfs $CONTAINER_STORAGE:${PCT_DISK_SIZE:-8} )
|
[[ " ${PCT_OPTIONS[@]} " =~ " -rootfs " ]] || PCT_OPTIONS+=(-rootfs $CONTAINER_STORAGE:${PCT_DISK_SIZE:-8})
|
||||||
|
|
||||||
# Create LXC
|
# Create LXC
|
||||||
msg "Creating LXC container..."
|
msg "Creating LXC container..."
|
||||||
|
@ -166,10 +164,9 @@ pct start "$CTID"
|
||||||
sleep 5
|
sleep 5
|
||||||
|
|
||||||
# Get container IP
|
# Get container IP
|
||||||
max_attempts=6
|
max_attempts=5
|
||||||
attempt=1
|
attempt=1
|
||||||
IP=""
|
IP=""
|
||||||
|
|
||||||
while [[ $attempt -le $max_attempts ]]; do
|
while [[ $attempt -le $max_attempts ]]; do
|
||||||
IP=$(pct exec $CTID ip route get 8.8.8.8 | sed -n '/src/{s/.*src *\([^ ]*\).*/\1/p;q}')
|
IP=$(pct exec $CTID ip route get 8.8.8.8 | sed -n '/src/{s/.*src *\([^ ]*\).*/\1/p;q}')
|
||||||
if [[ -n $IP ]]; then
|
if [[ -n $IP ]]; then
|
||||||
|
|
|
@ -1,5 +1,4 @@
|
||||||
#!/usr/bin/env bash
|
#!/usr/bin/env bash
|
||||||
# A primitive script to install TurnKey LXC templates using basic settings.
|
|
||||||
# Copyright (c) 2021-2023 tteck
|
# Copyright (c) 2021-2023 tteck
|
||||||
# Author: tteck (tteckster)
|
# Author: tteck (tteckster)
|
||||||
# License: MIT
|
# License: MIT
|
||||||
|
@ -38,10 +37,7 @@ EOF
|
||||||
header_info
|
header_info
|
||||||
read -p "Press ENTER to continue..."
|
read -p "Press ENTER to continue..."
|
||||||
header_info
|
header_info
|
||||||
set -o errexit #Exit immediately if a pipeline returns a non-zero status
|
set -eEuo pipefail
|
||||||
set -o errtrace #Trap ERR from shell functions, command substitutions, and commands from subshell
|
|
||||||
set -o nounset #Treat unset variables as an error
|
|
||||||
set -o pipefail #Pipe will exit with last non-zero status if applicable
|
|
||||||
shopt -s expand_aliases
|
shopt -s expand_aliases
|
||||||
alias die='EXIT=$? LINE=$LINENO error_exit'
|
alias die='EXIT=$? LINE=$LINENO error_exit'
|
||||||
trap die ERR
|
trap die ERR
|
||||||
|
@ -78,11 +74,12 @@ function cleanup_ctid() {
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
# Start Proxmox VE Monitor-All if running
|
# Stop Proxmox VE Monitor-All if running
|
||||||
if systemctl is-active -q ping-instances.service; then
|
if systemctl is-active -q ping-instances.service; then
|
||||||
systemctl stop ping-instances.service
|
systemctl stop ping-instances.service
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
# Set the CONTENT and CONTENT_LABEL variables
|
||||||
function select_storage() {
|
function select_storage() {
|
||||||
local CLASS=$1
|
local CLASS=$1
|
||||||
local CONTENT
|
local CONTENT
|
||||||
|
@ -104,18 +101,18 @@ function select_storage() {
|
||||||
if [[ $((${#ITEM} + $OFFSET)) -gt ${MSG_MAX_LENGTH:-} ]]; then
|
if [[ $((${#ITEM} + $OFFSET)) -gt ${MSG_MAX_LENGTH:-} ]]; then
|
||||||
local MSG_MAX_LENGTH=$((${#ITEM} + $OFFSET))
|
local MSG_MAX_LENGTH=$((${#ITEM} + $OFFSET))
|
||||||
fi
|
fi
|
||||||
MENU+=( "$TAG" "$ITEM" "OFF" )
|
MENU+=("$TAG" "$ITEM" "OFF")
|
||||||
done < <(pvesm status -content $CONTENT | awk 'NR>1')
|
done < <(pvesm status -content $CONTENT | awk 'NR>1')
|
||||||
|
|
||||||
# Select storage location
|
# Select storage location
|
||||||
if [ $((${#MENU[@]}/3)) -eq 0 ]; then # No storage locations are detected
|
if [ $((${#MENU[@]} / 3)) -eq 0 ]; then
|
||||||
warn "'$CONTENT_LABEL' needs to be selected for at least one storage location."
|
warn "'$CONTENT_LABEL' needs to be selected for at least one storage location."
|
||||||
die "Unable to detect valid storage location."
|
die "Unable to detect valid storage location."
|
||||||
elif [ $((${#MENU[@]}/3)) -eq 1 ]; then # Only one storage location is detected
|
elif [ $((${#MENU[@]} / 3)) -eq 1 ]; then
|
||||||
printf ${MENU[0]}
|
printf ${MENU[0]}
|
||||||
else # More than one storage location is detected
|
else
|
||||||
local STORAGE
|
local STORAGE
|
||||||
while [ -z "${STORAGE:+x}" ]; do # Generate graphical menu
|
while [ -z "${STORAGE:+x}" ]; do
|
||||||
STORAGE=$(whiptail --title "Storage Pools" --radiolist \
|
STORAGE=$(whiptail --title "Storage Pools" --radiolist \
|
||||||
"Which storage pool you would like to use for the ${CONTENT_LABEL,,}?\n\n" \
|
"Which storage pool you would like to use for the ${CONTENT_LABEL,,}?\n\n" \
|
||||||
16 $(($MSG_MAX_LENGTH + 23)) 6 \
|
16 $(($MSG_MAX_LENGTH + 23)) 6 \
|
||||||
|
@ -150,8 +147,8 @@ if ! pveam list $TEMPLATE_STORAGE | grep -q $TEMPLATE; then
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Create variable for 'pct' options
|
# Create variable for 'pct' options
|
||||||
PCT_OPTIONS=( ${PCT_OPTIONS[@]:-${DEFAULT_PCT_OPTIONS[@]}} )
|
PCT_OPTIONS=(${PCT_OPTIONS[@]:-${DEFAULT_PCT_OPTIONS[@]}})
|
||||||
[[ " ${PCT_OPTIONS[@]} " =~ " -rootfs " ]] || PCT_OPTIONS+=( -rootfs $CONTAINER_STORAGE:${PCT_DISK_SIZE:-8} )
|
[[ " ${PCT_OPTIONS[@]} " =~ " -rootfs " ]] || PCT_OPTIONS+=(-rootfs $CONTAINER_STORAGE:${PCT_DISK_SIZE:-8})
|
||||||
|
|
||||||
# Create LXC
|
# Create LXC
|
||||||
msg "Creating LXC container..."
|
msg "Creating LXC container..."
|
||||||
|
@ -167,10 +164,9 @@ pct start "$CTID"
|
||||||
sleep 5
|
sleep 5
|
||||||
|
|
||||||
# Get container IP
|
# Get container IP
|
||||||
max_attempts=6
|
max_attempts=5
|
||||||
attempt=1
|
attempt=1
|
||||||
IP=""
|
IP=""
|
||||||
|
|
||||||
while [[ $attempt -le $max_attempts ]]; do
|
while [[ $attempt -le $max_attempts ]]; do
|
||||||
IP=$(pct exec $CTID ip route get 8.8.8.8 | sed -n '/src/{s/.*src *\([^ ]*\).*/\1/p;q}')
|
IP=$(pct exec $CTID ip route get 8.8.8.8 | sed -n '/src/{s/.*src *\([^ ]*\).*/\1/p;q}')
|
||||||
if [[ -n $IP ]]; then
|
if [[ -n $IP ]]; then
|
||||||
|
|
|
@ -1,10 +1,8 @@
|
||||||
#!/usr/bin/env bash
|
#!/usr/bin/env bash
|
||||||
# A primitive script to install TurnKey LXC templates using basic settings.
|
|
||||||
# Copyright (c) 2021-2023 tteck
|
# Copyright (c) 2021-2023 tteck
|
||||||
# Author: tteck (tteckster)
|
# Author: tteck (tteckster)
|
||||||
# License: MIT
|
# License: MIT
|
||||||
# https://github.com/tteck/Proxmox/raw/main/LICENSE
|
# https://github.com/tteck/Proxmox/raw/main/LICENSE
|
||||||
# bash -c "$(wget -qLO - https://github.com/tteck/Proxmox/raw/main/turnkey/turnkey-owncloud.sh)"
|
|
||||||
|
|
||||||
# Setup script environment
|
# Setup script environment
|
||||||
NAME="owncloud"
|
NAME="owncloud"
|
||||||
|
@ -39,10 +37,7 @@ EOF
|
||||||
header_info
|
header_info
|
||||||
read -p "Press ENTER to continue..."
|
read -p "Press ENTER to continue..."
|
||||||
header_info
|
header_info
|
||||||
set -o errexit #Exit immediately if a pipeline returns a non-zero status
|
set -eEuo pipefail
|
||||||
set -o errtrace #Trap ERR from shell functions, command substitutions, and commands from subshell
|
|
||||||
set -o nounset #Treat unset variables as an error
|
|
||||||
set -o pipefail #Pipe will exit with last non-zero status if applicable
|
|
||||||
shopt -s expand_aliases
|
shopt -s expand_aliases
|
||||||
alias die='EXIT=$? LINE=$LINENO error_exit'
|
alias die='EXIT=$? LINE=$LINENO error_exit'
|
||||||
trap die ERR
|
trap die ERR
|
||||||
|
@ -78,9 +73,13 @@ function cleanup_ctid() {
|
||||||
pct destroy $CTID
|
pct destroy $CTID
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
|
# Stop Proxmox VE Monitor-All if running
|
||||||
if systemctl is-active -q ping-instances.service; then
|
if systemctl is-active -q ping-instances.service; then
|
||||||
systemctl stop ping-instances.service
|
systemctl stop ping-instances.service
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
# Set the CONTENT and CONTENT_LABEL variables
|
||||||
function select_storage() {
|
function select_storage() {
|
||||||
local CLASS=$1
|
local CLASS=$1
|
||||||
local CONTENT
|
local CONTENT
|
||||||
|
@ -102,18 +101,18 @@ function select_storage() {
|
||||||
if [[ $((${#ITEM} + $OFFSET)) -gt ${MSG_MAX_LENGTH:-} ]]; then
|
if [[ $((${#ITEM} + $OFFSET)) -gt ${MSG_MAX_LENGTH:-} ]]; then
|
||||||
local MSG_MAX_LENGTH=$((${#ITEM} + $OFFSET))
|
local MSG_MAX_LENGTH=$((${#ITEM} + $OFFSET))
|
||||||
fi
|
fi
|
||||||
MENU+=( "$TAG" "$ITEM" "OFF" )
|
MENU+=("$TAG" "$ITEM" "OFF")
|
||||||
done < <(pvesm status -content $CONTENT | awk 'NR>1')
|
done < <(pvesm status -content $CONTENT | awk 'NR>1')
|
||||||
|
|
||||||
# Select storage location
|
# Select storage location
|
||||||
if [ $((${#MENU[@]}/3)) -eq 0 ]; then # No storage locations are detected
|
if [ $((${#MENU[@]} / 3)) -eq 0 ]; then
|
||||||
warn "'$CONTENT_LABEL' needs to be selected for at least one storage location."
|
warn "'$CONTENT_LABEL' needs to be selected for at least one storage location."
|
||||||
die "Unable to detect valid storage location."
|
die "Unable to detect valid storage location."
|
||||||
elif [ $((${#MENU[@]}/3)) -eq 1 ]; then # Only one storage location is detected
|
elif [ $((${#MENU[@]} / 3)) -eq 1 ]; then
|
||||||
printf ${MENU[0]}
|
printf ${MENU[0]}
|
||||||
else # More than one storage location is detected
|
else
|
||||||
local STORAGE
|
local STORAGE
|
||||||
while [ -z "${STORAGE:+x}" ]; do # Generate graphical menu
|
while [ -z "${STORAGE:+x}" ]; do
|
||||||
STORAGE=$(whiptail --title "Storage Pools" --radiolist \
|
STORAGE=$(whiptail --title "Storage Pools" --radiolist \
|
||||||
"Which storage pool you would like to use for the ${CONTENT_LABEL,,}?\n\n" \
|
"Which storage pool you would like to use for the ${CONTENT_LABEL,,}?\n\n" \
|
||||||
16 $(($MSG_MAX_LENGTH + 23)) 6 \
|
16 $(($MSG_MAX_LENGTH + 23)) 6 \
|
||||||
|
@ -147,24 +146,49 @@ if ! pveam list $TEMPLATE_STORAGE | grep -q $TEMPLATE; then
|
||||||
die "A problem occured while downloading the LXC template."
|
die "A problem occured while downloading the LXC template."
|
||||||
fi
|
fi
|
||||||
|
|
||||||
PCT_OPTIONS=( ${PCT_OPTIONS[@]:-${DEFAULT_PCT_OPTIONS[@]}} )
|
# Create variable for 'pct' options
|
||||||
[[ " ${PCT_OPTIONS[@]} " =~ " -rootfs " ]] || PCT_OPTIONS+=( -rootfs $CONTAINER_STORAGE:${PCT_DISK_SIZE:-8} )
|
PCT_OPTIONS=(${PCT_OPTIONS[@]:-${DEFAULT_PCT_OPTIONS[@]}})
|
||||||
|
[[ " ${PCT_OPTIONS[@]} " =~ " -rootfs " ]] || PCT_OPTIONS+=(-rootfs $CONTAINER_STORAGE:${PCT_DISK_SIZE:-8})
|
||||||
|
|
||||||
# Create LXC
|
# Create LXC
|
||||||
msg "Creating LXC container..."
|
msg "Creating LXC container..."
|
||||||
pct create $CTID ${TEMPLATE_STORAGE}:vztmpl/${TEMPLATE} ${PCT_OPTIONS[@]} >/dev/null ||
|
pct create $CTID ${TEMPLATE_STORAGE}:vztmpl/${TEMPLATE} ${PCT_OPTIONS[@]} >/dev/null ||
|
||||||
die "A problem occured while trying to create container."
|
die "A problem occured while trying to create container."
|
||||||
|
|
||||||
# Success message
|
# Save password
|
||||||
|
echo "TurnKey ${NAME} password: ${PASS}" >>~/turnkey-${NAME}.creds # file is located in the Proxmox root directory
|
||||||
|
|
||||||
|
# Start container
|
||||||
msg "Starting LXC Container..."
|
msg "Starting LXC Container..."
|
||||||
pct start "$CTID"
|
pct start "$CTID"
|
||||||
sleep 5
|
sleep 5
|
||||||
IP=$(pct exec $CTID ip route get 8.8.8.8 | sed -n '/src/{s/.*src *\([^ ]*\).*/\1/p;q}')
|
|
||||||
echo "TurnKey ${NAME} Password" >>~/turnkey-${NAME}.creds # file is located in the Proxmox root directory
|
# Get container IP
|
||||||
echo $PASS >>~/turnkey-${NAME}.creds
|
max_attempts=5
|
||||||
|
attempt=1
|
||||||
|
IP=""
|
||||||
|
while [[ $attempt -le $max_attempts ]]; do
|
||||||
|
IP=$(pct exec $CTID ip route get 8.8.8.8 | sed -n '/src/{s/.*src *\([^ ]*\).*/\1/p;q}')
|
||||||
|
if [[ -n $IP ]]; then
|
||||||
|
break
|
||||||
|
else
|
||||||
|
warn "Attempt $attempt: IP address not found. Pausing for 5 seconds..."
|
||||||
|
sleep 5
|
||||||
|
((attempt++))
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
|
||||||
|
if [[ -z $IP ]]; then
|
||||||
|
warn "Maximum number of attempts reached. IP address not found."
|
||||||
|
IP="NOT FOUND"
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Start Proxmox VE Monitor-All if available
|
||||||
if [[ -f /etc/systemd/system/ping-instances.service ]]; then
|
if [[ -f /etc/systemd/system/ping-instances.service ]]; then
|
||||||
systemctl start ping-instances.service
|
systemctl start ping-instances.service
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
# Success message
|
||||||
header_info
|
header_info
|
||||||
echo
|
echo
|
||||||
info "LXC container '$CTID' was successfully created, and its IP address is ${IP}."
|
info "LXC container '$CTID' was successfully created, and its IP address is ${IP}."
|
||||||
|
|
|
@ -1,10 +1,8 @@
|
||||||
#!/usr/bin/env bash
|
#!/usr/bin/env bash
|
||||||
# A primitive script to install TurnKey LXC templates using basic settings.
|
|
||||||
# Copyright (c) 2021-2023 tteck
|
# Copyright (c) 2021-2023 tteck
|
||||||
# Author: tteck (tteckster)
|
# Author: tteck (tteckster)
|
||||||
# License: MIT
|
# License: MIT
|
||||||
# https://github.com/tteck/Proxmox/raw/main/LICENSE
|
# https://github.com/tteck/Proxmox/raw/main/LICENSE
|
||||||
# bash -c "$(wget -qLO - https://github.com/tteck/Proxmox/raw/main/turnkey/turnkey-torrentserver.sh)"
|
|
||||||
|
|
||||||
# Setup script environment
|
# Setup script environment
|
||||||
NAME="torrentserver"
|
NAME="torrentserver"
|
||||||
|
@ -39,10 +37,7 @@ EOF
|
||||||
header_info
|
header_info
|
||||||
read -p "Press ENTER to continue..."
|
read -p "Press ENTER to continue..."
|
||||||
header_info
|
header_info
|
||||||
set -o errexit #Exit immediately if a pipeline returns a non-zero status
|
set -eEuo pipefail
|
||||||
set -o errtrace #Trap ERR from shell functions, command substitutions, and commands from subshell
|
|
||||||
set -o nounset #Treat unset variables as an error
|
|
||||||
set -o pipefail #Pipe will exit with last non-zero status if applicable
|
|
||||||
shopt -s expand_aliases
|
shopt -s expand_aliases
|
||||||
alias die='EXIT=$? LINE=$LINENO error_exit'
|
alias die='EXIT=$? LINE=$LINENO error_exit'
|
||||||
trap die ERR
|
trap die ERR
|
||||||
|
@ -78,9 +73,13 @@ function cleanup_ctid() {
|
||||||
pct destroy $CTID
|
pct destroy $CTID
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
|
# Stop Proxmox VE Monitor-All if running
|
||||||
if systemctl is-active -q ping-instances.service; then
|
if systemctl is-active -q ping-instances.service; then
|
||||||
systemctl stop ping-instances.service
|
systemctl stop ping-instances.service
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
# Set the CONTENT and CONTENT_LABEL variables
|
||||||
function select_storage() {
|
function select_storage() {
|
||||||
local CLASS=$1
|
local CLASS=$1
|
||||||
local CONTENT
|
local CONTENT
|
||||||
|
@ -102,18 +101,18 @@ function select_storage() {
|
||||||
if [[ $((${#ITEM} + $OFFSET)) -gt ${MSG_MAX_LENGTH:-} ]]; then
|
if [[ $((${#ITEM} + $OFFSET)) -gt ${MSG_MAX_LENGTH:-} ]]; then
|
||||||
local MSG_MAX_LENGTH=$((${#ITEM} + $OFFSET))
|
local MSG_MAX_LENGTH=$((${#ITEM} + $OFFSET))
|
||||||
fi
|
fi
|
||||||
MENU+=( "$TAG" "$ITEM" "OFF" )
|
MENU+=("$TAG" "$ITEM" "OFF")
|
||||||
done < <(pvesm status -content $CONTENT | awk 'NR>1')
|
done < <(pvesm status -content $CONTENT | awk 'NR>1')
|
||||||
|
|
||||||
# Select storage location
|
# Select storage location
|
||||||
if [ $((${#MENU[@]}/3)) -eq 0 ]; then # No storage locations are detected
|
if [ $((${#MENU[@]} / 3)) -eq 0 ]; then
|
||||||
warn "'$CONTENT_LABEL' needs to be selected for at least one storage location."
|
warn "'$CONTENT_LABEL' needs to be selected for at least one storage location."
|
||||||
die "Unable to detect valid storage location."
|
die "Unable to detect valid storage location."
|
||||||
elif [ $((${#MENU[@]}/3)) -eq 1 ]; then # Only one storage location is detected
|
elif [ $((${#MENU[@]} / 3)) -eq 1 ]; then
|
||||||
printf ${MENU[0]}
|
printf ${MENU[0]}
|
||||||
else # More than one storage location is detected
|
else
|
||||||
local STORAGE
|
local STORAGE
|
||||||
while [ -z "${STORAGE:+x}" ]; do # Generate graphical menu
|
while [ -z "${STORAGE:+x}" ]; do
|
||||||
STORAGE=$(whiptail --title "Storage Pools" --radiolist \
|
STORAGE=$(whiptail --title "Storage Pools" --radiolist \
|
||||||
"Which storage pool you would like to use for the ${CONTENT_LABEL,,}?\n\n" \
|
"Which storage pool you would like to use for the ${CONTENT_LABEL,,}?\n\n" \
|
||||||
16 $(($MSG_MAX_LENGTH + 23)) 6 \
|
16 $(($MSG_MAX_LENGTH + 23)) 6 \
|
||||||
|
@ -147,24 +146,49 @@ if ! pveam list $TEMPLATE_STORAGE | grep -q $TEMPLATE; then
|
||||||
die "A problem occured while downloading the LXC template."
|
die "A problem occured while downloading the LXC template."
|
||||||
fi
|
fi
|
||||||
|
|
||||||
PCT_OPTIONS=( ${PCT_OPTIONS[@]:-${DEFAULT_PCT_OPTIONS[@]}} )
|
# Create variable for 'pct' options
|
||||||
[[ " ${PCT_OPTIONS[@]} " =~ " -rootfs " ]] || PCT_OPTIONS+=( -rootfs $CONTAINER_STORAGE:${PCT_DISK_SIZE:-8} )
|
PCT_OPTIONS=(${PCT_OPTIONS[@]:-${DEFAULT_PCT_OPTIONS[@]}})
|
||||||
|
[[ " ${PCT_OPTIONS[@]} " =~ " -rootfs " ]] || PCT_OPTIONS+=(-rootfs $CONTAINER_STORAGE:${PCT_DISK_SIZE:-8})
|
||||||
|
|
||||||
# Create LXC
|
# Create LXC
|
||||||
msg "Creating LXC container..."
|
msg "Creating LXC container..."
|
||||||
pct create $CTID ${TEMPLATE_STORAGE}:vztmpl/${TEMPLATE} ${PCT_OPTIONS[@]} >/dev/null ||
|
pct create $CTID ${TEMPLATE_STORAGE}:vztmpl/${TEMPLATE} ${PCT_OPTIONS[@]} >/dev/null ||
|
||||||
die "A problem occured while trying to create container."
|
die "A problem occured while trying to create container."
|
||||||
|
|
||||||
# Success message
|
# Save password
|
||||||
|
echo "TurnKey ${NAME} password: ${PASS}" >>~/turnkey-${NAME}.creds # file is located in the Proxmox root directory
|
||||||
|
|
||||||
|
# Start container
|
||||||
msg "Starting LXC Container..."
|
msg "Starting LXC Container..."
|
||||||
pct start "$CTID"
|
pct start "$CTID"
|
||||||
sleep 5
|
sleep 5
|
||||||
IP=$(pct exec $CTID ip route get 8.8.8.8 | sed -n '/src/{s/.*src *\([^ ]*\).*/\1/p;q}')
|
|
||||||
echo "TurnKey ${NAME} Password" >>~/turnkey-${NAME}.creds # file is located in the Proxmox root directory
|
# Get container IP
|
||||||
echo $PASS >>~/turnkey-${NAME}.creds
|
max_attempts=5
|
||||||
|
attempt=1
|
||||||
|
IP=""
|
||||||
|
while [[ $attempt -le $max_attempts ]]; do
|
||||||
|
IP=$(pct exec $CTID ip route get 8.8.8.8 | sed -n '/src/{s/.*src *\([^ ]*\).*/\1/p;q}')
|
||||||
|
if [[ -n $IP ]]; then
|
||||||
|
break
|
||||||
|
else
|
||||||
|
warn "Attempt $attempt: IP address not found. Pausing for 5 seconds..."
|
||||||
|
sleep 5
|
||||||
|
((attempt++))
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
|
||||||
|
if [[ -z $IP ]]; then
|
||||||
|
warn "Maximum number of attempts reached. IP address not found."
|
||||||
|
IP="NOT FOUND"
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Start Proxmox VE Monitor-All if available
|
||||||
if [[ -f /etc/systemd/system/ping-instances.service ]]; then
|
if [[ -f /etc/systemd/system/ping-instances.service ]]; then
|
||||||
systemctl start ping-instances.service
|
systemctl start ping-instances.service
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
# Success message
|
||||||
header_info
|
header_info
|
||||||
echo
|
echo
|
||||||
info "LXC container '$CTID' was successfully created, and its IP address is ${IP}."
|
info "LXC container '$CTID' was successfully created, and its IP address is ${IP}."
|
||||||
|
|
|
@ -1,10 +1,8 @@
|
||||||
#!/usr/bin/env bash
|
#!/usr/bin/env bash
|
||||||
# A primitive script to install TurnKey LXC templates using basic settings.
|
|
||||||
# Copyright (c) 2021-2023 tteck
|
# Copyright (c) 2021-2023 tteck
|
||||||
# Author: tteck (tteckster)
|
# Author: tteck (tteckster)
|
||||||
# License: MIT
|
# License: MIT
|
||||||
# https://github.com/tteck/Proxmox/raw/main/LICENSE
|
# https://github.com/tteck/Proxmox/raw/main/LICENSE
|
||||||
# bash -c "$(wget -qLO - https://github.com/tteck/Proxmox/raw/main/turnkey/turnkey-wordpress.sh)"
|
|
||||||
|
|
||||||
# Setup script environment
|
# Setup script environment
|
||||||
NAME="wordpress"
|
NAME="wordpress"
|
||||||
|
@ -39,10 +37,7 @@ EOF
|
||||||
header_info
|
header_info
|
||||||
read -p "Press ENTER to continue..."
|
read -p "Press ENTER to continue..."
|
||||||
header_info
|
header_info
|
||||||
set -o errexit #Exit immediately if a pipeline returns a non-zero status
|
set -eEuo pipefail
|
||||||
set -o errtrace #Trap ERR from shell functions, command substitutions, and commands from subshell
|
|
||||||
set -o nounset #Treat unset variables as an error
|
|
||||||
set -o pipefail #Pipe will exit with last non-zero status if applicable
|
|
||||||
shopt -s expand_aliases
|
shopt -s expand_aliases
|
||||||
alias die='EXIT=$? LINE=$LINENO error_exit'
|
alias die='EXIT=$? LINE=$LINENO error_exit'
|
||||||
trap die ERR
|
trap die ERR
|
||||||
|
@ -78,9 +73,13 @@ function cleanup_ctid() {
|
||||||
pct destroy $CTID
|
pct destroy $CTID
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
|
# Stop Proxmox VE Monitor-All if running
|
||||||
if systemctl is-active -q ping-instances.service; then
|
if systemctl is-active -q ping-instances.service; then
|
||||||
systemctl stop ping-instances.service
|
systemctl stop ping-instances.service
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
# Set the CONTENT and CONTENT_LABEL variables
|
||||||
function select_storage() {
|
function select_storage() {
|
||||||
local CLASS=$1
|
local CLASS=$1
|
||||||
local CONTENT
|
local CONTENT
|
||||||
|
@ -102,18 +101,18 @@ function select_storage() {
|
||||||
if [[ $((${#ITEM} + $OFFSET)) -gt ${MSG_MAX_LENGTH:-} ]]; then
|
if [[ $((${#ITEM} + $OFFSET)) -gt ${MSG_MAX_LENGTH:-} ]]; then
|
||||||
local MSG_MAX_LENGTH=$((${#ITEM} + $OFFSET))
|
local MSG_MAX_LENGTH=$((${#ITEM} + $OFFSET))
|
||||||
fi
|
fi
|
||||||
MENU+=( "$TAG" "$ITEM" "OFF" )
|
MENU+=("$TAG" "$ITEM" "OFF")
|
||||||
done < <(pvesm status -content $CONTENT | awk 'NR>1')
|
done < <(pvesm status -content $CONTENT | awk 'NR>1')
|
||||||
|
|
||||||
# Select storage location
|
# Select storage location
|
||||||
if [ $((${#MENU[@]}/3)) -eq 0 ]; then # No storage locations are detected
|
if [ $((${#MENU[@]} / 3)) -eq 0 ]; then
|
||||||
warn "'$CONTENT_LABEL' needs to be selected for at least one storage location."
|
warn "'$CONTENT_LABEL' needs to be selected for at least one storage location."
|
||||||
die "Unable to detect valid storage location."
|
die "Unable to detect valid storage location."
|
||||||
elif [ $((${#MENU[@]}/3)) -eq 1 ]; then # Only one storage location is detected
|
elif [ $((${#MENU[@]} / 3)) -eq 1 ]; then
|
||||||
printf ${MENU[0]}
|
printf ${MENU[0]}
|
||||||
else # More than one storage location is detected
|
else
|
||||||
local STORAGE
|
local STORAGE
|
||||||
while [ -z "${STORAGE:+x}" ]; do # Generate graphical menu
|
while [ -z "${STORAGE:+x}" ]; do
|
||||||
STORAGE=$(whiptail --title "Storage Pools" --radiolist \
|
STORAGE=$(whiptail --title "Storage Pools" --radiolist \
|
||||||
"Which storage pool you would like to use for the ${CONTENT_LABEL,,}?\n\n" \
|
"Which storage pool you would like to use for the ${CONTENT_LABEL,,}?\n\n" \
|
||||||
16 $(($MSG_MAX_LENGTH + 23)) 6 \
|
16 $(($MSG_MAX_LENGTH + 23)) 6 \
|
||||||
|
@ -147,24 +146,49 @@ if ! pveam list $TEMPLATE_STORAGE | grep -q $TEMPLATE; then
|
||||||
die "A problem occured while downloading the LXC template."
|
die "A problem occured while downloading the LXC template."
|
||||||
fi
|
fi
|
||||||
|
|
||||||
PCT_OPTIONS=( ${PCT_OPTIONS[@]:-${DEFAULT_PCT_OPTIONS[@]}} )
|
# Create variable for 'pct' options
|
||||||
[[ " ${PCT_OPTIONS[@]} " =~ " -rootfs " ]] || PCT_OPTIONS+=( -rootfs $CONTAINER_STORAGE:${PCT_DISK_SIZE:-8} )
|
PCT_OPTIONS=(${PCT_OPTIONS[@]:-${DEFAULT_PCT_OPTIONS[@]}})
|
||||||
|
[[ " ${PCT_OPTIONS[@]} " =~ " -rootfs " ]] || PCT_OPTIONS+=(-rootfs $CONTAINER_STORAGE:${PCT_DISK_SIZE:-8})
|
||||||
|
|
||||||
# Create LXC
|
# Create LXC
|
||||||
msg "Creating LXC container..."
|
msg "Creating LXC container..."
|
||||||
pct create $CTID ${TEMPLATE_STORAGE}:vztmpl/${TEMPLATE} ${PCT_OPTIONS[@]} >/dev/null ||
|
pct create $CTID ${TEMPLATE_STORAGE}:vztmpl/${TEMPLATE} ${PCT_OPTIONS[@]} >/dev/null ||
|
||||||
die "A problem occured while trying to create container."
|
die "A problem occured while trying to create container."
|
||||||
|
|
||||||
# Success message
|
# Save password
|
||||||
|
echo "TurnKey ${NAME} password: ${PASS}" >>~/turnkey-${NAME}.creds # file is located in the Proxmox root directory
|
||||||
|
|
||||||
|
# Start container
|
||||||
msg "Starting LXC Container..."
|
msg "Starting LXC Container..."
|
||||||
pct start "$CTID"
|
pct start "$CTID"
|
||||||
sleep 5
|
sleep 5
|
||||||
IP=$(pct exec $CTID ip route get 8.8.8.8 | sed -n '/src/{s/.*src *\([^ ]*\).*/\1/p;q}')
|
|
||||||
echo "TurnKey ${NAME} Password" >>~/turnkey-${NAME}.creds # file is located in the Proxmox root directory
|
# Get container IP
|
||||||
echo $PASS >>~/turnkey-${NAME}.creds
|
max_attempts=5
|
||||||
|
attempt=1
|
||||||
|
IP=""
|
||||||
|
while [[ $attempt -le $max_attempts ]]; do
|
||||||
|
IP=$(pct exec $CTID ip route get 8.8.8.8 | sed -n '/src/{s/.*src *\([^ ]*\).*/\1/p;q}')
|
||||||
|
if [[ -n $IP ]]; then
|
||||||
|
break
|
||||||
|
else
|
||||||
|
warn "Attempt $attempt: IP address not found. Pausing for 5 seconds..."
|
||||||
|
sleep 5
|
||||||
|
((attempt++))
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
|
||||||
|
if [[ -z $IP ]]; then
|
||||||
|
warn "Maximum number of attempts reached. IP address not found."
|
||||||
|
IP="NOT FOUND"
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Start Proxmox VE Monitor-All if available
|
||||||
if [[ -f /etc/systemd/system/ping-instances.service ]]; then
|
if [[ -f /etc/systemd/system/ping-instances.service ]]; then
|
||||||
systemctl start ping-instances.service
|
systemctl start ping-instances.service
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
# Success message
|
||||||
header_info
|
header_info
|
||||||
echo
|
echo
|
||||||
info "LXC container '$CTID' was successfully created, and its IP address is ${IP}."
|
info "LXC container '$CTID' was successfully created, and its IP address is ${IP}."
|
||||||
|
|
|
@ -1,5 +1,4 @@
|
||||||
#!/usr/bin/env bash
|
#!/usr/bin/env bash
|
||||||
# A primitive script to install TurnKey LXC templates using basic settings.
|
|
||||||
# Copyright (c) 2021-2023 tteck
|
# Copyright (c) 2021-2023 tteck
|
||||||
# Author: tteck (tteckster)
|
# Author: tteck (tteckster)
|
||||||
# License: MIT
|
# License: MIT
|
||||||
|
@ -38,10 +37,7 @@ EOF
|
||||||
header_info
|
header_info
|
||||||
read -p "Press ENTER to continue..."
|
read -p "Press ENTER to continue..."
|
||||||
header_info
|
header_info
|
||||||
set -o errexit #Exit immediately if a pipeline returns a non-zero status
|
set -eEuo pipefail
|
||||||
set -o errtrace #Trap ERR from shell functions, command substitutions, and commands from subshell
|
|
||||||
set -o nounset #Treat unset variables as an error
|
|
||||||
set -o pipefail #Pipe will exit with last non-zero status if applicable
|
|
||||||
shopt -s expand_aliases
|
shopt -s expand_aliases
|
||||||
alias die='EXIT=$? LINE=$LINENO error_exit'
|
alias die='EXIT=$? LINE=$LINENO error_exit'
|
||||||
trap die ERR
|
trap die ERR
|
||||||
|
@ -77,9 +73,13 @@ function cleanup_ctid() {
|
||||||
pct destroy $CTID
|
pct destroy $CTID
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
|
# Stop Proxmox VE Monitor-All if running
|
||||||
if systemctl is-active -q ping-instances.service; then
|
if systemctl is-active -q ping-instances.service; then
|
||||||
systemctl stop ping-instances.service
|
systemctl stop ping-instances.service
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
# Set the CONTENT and CONTENT_LABEL variables
|
||||||
function select_storage() {
|
function select_storage() {
|
||||||
local CLASS=$1
|
local CLASS=$1
|
||||||
local CONTENT
|
local CONTENT
|
||||||
|
@ -101,18 +101,18 @@ function select_storage() {
|
||||||
if [[ $((${#ITEM} + $OFFSET)) -gt ${MSG_MAX_LENGTH:-} ]]; then
|
if [[ $((${#ITEM} + $OFFSET)) -gt ${MSG_MAX_LENGTH:-} ]]; then
|
||||||
local MSG_MAX_LENGTH=$((${#ITEM} + $OFFSET))
|
local MSG_MAX_LENGTH=$((${#ITEM} + $OFFSET))
|
||||||
fi
|
fi
|
||||||
MENU+=( "$TAG" "$ITEM" "OFF" )
|
MENU+=("$TAG" "$ITEM" "OFF")
|
||||||
done < <(pvesm status -content $CONTENT | awk 'NR>1')
|
done < <(pvesm status -content $CONTENT | awk 'NR>1')
|
||||||
|
|
||||||
# Select storage location
|
# Select storage location
|
||||||
if [ $((${#MENU[@]}/3)) -eq 0 ]; then # No storage locations are detected
|
if [ $((${#MENU[@]} / 3)) -eq 0 ]; then
|
||||||
warn "'$CONTENT_LABEL' needs to be selected for at least one storage location."
|
warn "'$CONTENT_LABEL' needs to be selected for at least one storage location."
|
||||||
die "Unable to detect valid storage location."
|
die "Unable to detect valid storage location."
|
||||||
elif [ $((${#MENU[@]}/3)) -eq 1 ]; then # Only one storage location is detected
|
elif [ $((${#MENU[@]} / 3)) -eq 1 ]; then
|
||||||
printf ${MENU[0]}
|
printf ${MENU[0]}
|
||||||
else # More than one storage location is detected
|
else
|
||||||
local STORAGE
|
local STORAGE
|
||||||
while [ -z "${STORAGE:+x}" ]; do # Generate graphical menu
|
while [ -z "${STORAGE:+x}" ]; do
|
||||||
STORAGE=$(whiptail --title "Storage Pools" --radiolist \
|
STORAGE=$(whiptail --title "Storage Pools" --radiolist \
|
||||||
"Which storage pool you would like to use for the ${CONTENT_LABEL,,}?\n\n" \
|
"Which storage pool you would like to use for the ${CONTENT_LABEL,,}?\n\n" \
|
||||||
16 $(($MSG_MAX_LENGTH + 23)) 6 \
|
16 $(($MSG_MAX_LENGTH + 23)) 6 \
|
||||||
|
@ -146,24 +146,49 @@ if ! pveam list $TEMPLATE_STORAGE | grep -q $TEMPLATE; then
|
||||||
die "A problem occured while downloading the LXC template."
|
die "A problem occured while downloading the LXC template."
|
||||||
fi
|
fi
|
||||||
|
|
||||||
PCT_OPTIONS=( ${PCT_OPTIONS[@]:-${DEFAULT_PCT_OPTIONS[@]}} )
|
# Create variable for 'pct' options
|
||||||
[[ " ${PCT_OPTIONS[@]} " =~ " -rootfs " ]] || PCT_OPTIONS+=( -rootfs $CONTAINER_STORAGE:${PCT_DISK_SIZE:-8} )
|
PCT_OPTIONS=(${PCT_OPTIONS[@]:-${DEFAULT_PCT_OPTIONS[@]}})
|
||||||
|
[[ " ${PCT_OPTIONS[@]} " =~ " -rootfs " ]] || PCT_OPTIONS+=(-rootfs $CONTAINER_STORAGE:${PCT_DISK_SIZE:-8})
|
||||||
|
|
||||||
# Create LXC
|
# Create LXC
|
||||||
msg "Creating LXC container..."
|
msg "Creating LXC container..."
|
||||||
pct create $CTID ${TEMPLATE_STORAGE}:vztmpl/${TEMPLATE} ${PCT_OPTIONS[@]} >/dev/null ||
|
pct create $CTID ${TEMPLATE_STORAGE}:vztmpl/${TEMPLATE} ${PCT_OPTIONS[@]} >/dev/null ||
|
||||||
die "A problem occured while trying to create container."
|
die "A problem occured while trying to create container."
|
||||||
|
|
||||||
# Success message
|
# Save password
|
||||||
|
echo "TurnKey ${NAME} password: ${PASS}" >>~/turnkey-${NAME}.creds # file is located in the Proxmox root directory
|
||||||
|
|
||||||
|
# Start container
|
||||||
msg "Starting LXC Container..."
|
msg "Starting LXC Container..."
|
||||||
pct start "$CTID"
|
pct start "$CTID"
|
||||||
sleep 5
|
sleep 5
|
||||||
IP=$(pct exec $CTID ip route get 8.8.8.8 | sed -n '/src/{s/.*src *\([^ ]*\).*/\1/p;q}')
|
|
||||||
echo "TurnKey ${NAME} Password" >>~/turnkey-${NAME}.creds # file is located in the Proxmox root directory
|
# Get container IP
|
||||||
echo $PASS >>~/turnkey-${NAME}.creds
|
max_attempts=5
|
||||||
|
attempt=1
|
||||||
|
IP=""
|
||||||
|
while [[ $attempt -le $max_attempts ]]; do
|
||||||
|
IP=$(pct exec $CTID ip route get 8.8.8.8 | sed -n '/src/{s/.*src *\([^ ]*\).*/\1/p;q}')
|
||||||
|
if [[ -n $IP ]]; then
|
||||||
|
break
|
||||||
|
else
|
||||||
|
warn "Attempt $attempt: IP address not found. Pausing for 5 seconds..."
|
||||||
|
sleep 5
|
||||||
|
((attempt++))
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
|
||||||
|
if [[ -z $IP ]]; then
|
||||||
|
warn "Maximum number of attempts reached. IP address not found."
|
||||||
|
IP="NOT FOUND"
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Start Proxmox VE Monitor-All if available
|
||||||
if [[ -f /etc/systemd/system/ping-instances.service ]]; then
|
if [[ -f /etc/systemd/system/ping-instances.service ]]; then
|
||||||
systemctl start ping-instances.service
|
systemctl start ping-instances.service
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
# Success message
|
||||||
header_info
|
header_info
|
||||||
echo
|
echo
|
||||||
info "LXC container '$CTID' was successfully created, and its IP address is ${IP}."
|
info "LXC container '$CTID' was successfully created, and its IP address is ${IP}."
|
||||||
|
|
Loading…
Reference in New Issue