turnkey code refactoring

This commit is contained in:
tteckster 2023-08-29 19:17:30 -04:00 committed by GitHub
parent 8feaf1ef84
commit 604c20df17
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
7 changed files with 49 additions and 126 deletions

View File

@ -7,11 +7,14 @@
# bash -c "$(wget -qLO - https://github.com/tteck/Proxmox/raw/main/turnkey/turnkey-core.sh)" # bash -c "$(wget -qLO - https://github.com/tteck/Proxmox/raw/main/turnkey/turnkey-core.sh)"
# Setup script environment # Setup script environment
NAME="core"
PASS="$(openssl rand -base64 8)" PASS="$(openssl rand -base64 8)"
TEMPLATE_SEARCH="debian-11-turnkey-core_17.1-1_amd64.tar.gz" CTID=$(pvesh get /cluster/nextid)
TEMPLATE_SEARCH="debian-11-turnkey-${NAME}_17.1-1_amd64.tar.gz"
PCT_DISK_SIZE="4"
PCT_OPTIONS=" PCT_OPTIONS="
-features keyctl=1,nesting=1 -features keyctl=1,nesting=1
-hostname turnkey-core -hostname turnkey-${NAME}
-tags proxmox-helper-scripts -tags proxmox-helper-scripts
-onboot 1 -onboot 1
-cores 2 -cores 2
@ -118,20 +121,6 @@ function select_storage() {
fi fi
} }
# Test if required variables are set
CTID=$(pvesh get /cluster/nextid)
[[ "${CTID:-}" ]] || die "You need to set 'CTID' variable."
# Test if ID is valid
[ "$CTID" -ge "100" ] || die "ID cannot be less than 100."
# Test if ID is in use
if pct status $CTID &>/dev/null; then
warn "ID '$CTID' is already in use."
unset CTID
die "Cannot use ID that is already in use."
fi
# Get template storage # Get template storage
TEMPLATE_STORAGE=$(select_storage template) || exit TEMPLATE_STORAGE=$(select_storage template) || exit
info "Using '$TEMPLATE_STORAGE' for template storage." info "Using '$TEMPLATE_STORAGE' for template storage."
@ -168,8 +157,8 @@ pct create $CTID ${TEMPLATE_STORAGE}:vztmpl/${TEMPLATE} ${PCT_OPTIONS[@]} >/dev/
msg "Starting LXC Container..." msg "Starting LXC Container..."
pct start "$CTID" pct start "$CTID"
info "LXC container '$CTID' was successfully created." info "LXC container '$CTID' was successfully created."
echo "TurnKey Core Password" >>~/turnkey-core.creds # file is located in the Proxmox root directory echo "TurnKey ${NAME} Password" >>~/turnkey-${NAME}.creds # file is located in the Proxmox root directory
echo $PASS >>~/turnkey-core.creds #run `cat turnkey-core.creds` in the Proxmox shell echo $PASS >>~/turnkey-${NAME}.creds
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

View File

@ -7,11 +7,14 @@
# bash -c "$(wget -qLO - https://github.com/tteck/Proxmox/raw/main/turnkey/turnkey-fileserver.sh)" # bash -c "$(wget -qLO - https://github.com/tteck/Proxmox/raw/main/turnkey/turnkey-fileserver.sh)"
# Setup script environment # Setup script environment
NAME="fileserver"
PASS="$(openssl rand -base64 8)" PASS="$(openssl rand -base64 8)"
TEMPLATE_SEARCH="debian-11-turnkey-fileserver_17.1-1_amd64.tar.gz" CTID=$(pvesh get /cluster/nextid)
TEMPLATE_SEARCH="debian-11-turnkey-${NAME}_17.1-1_amd64.tar.gz"
PCT_DISK_SIZE="8"
PCT_OPTIONS=" PCT_OPTIONS="
-features keyctl=1,nesting=1 -features keyctl=1,nesting=1
-hostname turnkey-fileserver -hostname turnkey-${NAME}
-tags proxmox-helper-scripts -tags proxmox-helper-scripts
-onboot 1 -onboot 1
-cores 2 -cores 2
@ -118,20 +121,6 @@ function select_storage() {
fi fi
} }
# Test if required variables are set
CTID=$(pvesh get /cluster/nextid)
[[ "${CTID:-}" ]] || die "You need to set 'CTID' variable."
# Test if ID is valid
[ "$CTID" -ge "100" ] || die "ID cannot be less than 100."
# Test if ID is in use
if pct status $CTID &>/dev/null; then
warn "ID '$CTID' is already in use."
unset CTID
die "Cannot use ID that is already in use."
fi
# Get template storage # Get template storage
TEMPLATE_STORAGE=$(select_storage template) || exit TEMPLATE_STORAGE=$(select_storage template) || exit
info "Using '$TEMPLATE_STORAGE' for template storage." info "Using '$TEMPLATE_STORAGE' for template storage."
@ -168,8 +157,8 @@ pct create $CTID ${TEMPLATE_STORAGE}:vztmpl/${TEMPLATE} ${PCT_OPTIONS[@]} >/dev/
msg "Starting LXC Container..." msg "Starting LXC Container..."
pct start "$CTID" pct start "$CTID"
info "LXC container '$CTID' was successfully created." info "LXC container '$CTID' was successfully created."
echo "TurnKey File Server Password" >>~/turnkey-fileserver.creds # file is located in the Proxmox root directory echo "TurnKey ${NAME} Password" >>~/turnkey-${NAME}.creds # file is located in the Proxmox root directory
echo $PASS >>~/turnkey-fileserver.creds #run `cat turnkey-fileserver.creds` in the Proxmox shell echo $PASS >>~/turnkey-${NAME}.creds
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

View File

@ -7,11 +7,14 @@
# bash -c "$(wget -qLO - https://github.com/tteck/Proxmox/raw/main/turnkey/turnkey-gitlab.sh)" # bash -c "$(wget -qLO - https://github.com/tteck/Proxmox/raw/main/turnkey/turnkey-gitlab.sh)"
# Setup script environment # Setup script environment
NAME="gitlab"
PASS="$(openssl rand -base64 8)" PASS="$(openssl rand -base64 8)"
TEMPLATE_SEARCH="debian-11-turnkey-gitlab_17.1-1_amd64.tar.gz" CTID=$(pvesh get /cluster/nextid)
TEMPLATE_SEARCH="debian-11-turnkey-${NAME}_17.1-1_amd64.tar.gz"
PCT_DISK_SIZE="8"
PCT_OPTIONS=" PCT_OPTIONS="
-features keyctl=1,nesting=1 -features keyctl=1,nesting=1
-hostname turnkey-gitlab -hostname turnkey-${NAME}
-tags proxmox-helper-scripts -tags proxmox-helper-scripts
-onboot 1 -onboot 1
-cores 4 -cores 4
@ -118,20 +121,6 @@ function select_storage() {
fi fi
} }
# Test if required variables are set
CTID=$(pvesh get /cluster/nextid)
[[ "${CTID:-}" ]] || die "You need to set 'CTID' variable."
# Test if ID is valid
[ "$CTID" -ge "100" ] || die "ID cannot be less than 100."
# Test if ID is in use
if pct status $CTID &>/dev/null; then
warn "ID '$CTID' is already in use."
unset CTID
die "Cannot use ID that is already in use."
fi
# Get template storage # Get template storage
TEMPLATE_STORAGE=$(select_storage template) || exit TEMPLATE_STORAGE=$(select_storage template) || exit
info "Using '$TEMPLATE_STORAGE' for template storage." info "Using '$TEMPLATE_STORAGE' for template storage."
@ -168,8 +157,8 @@ pct create $CTID ${TEMPLATE_STORAGE}:vztmpl/${TEMPLATE} ${PCT_OPTIONS[@]} >/dev/
msg "Starting LXC Container..." msg "Starting LXC Container..."
pct start "$CTID" pct start "$CTID"
info "LXC container '$CTID' was successfully created." info "LXC container '$CTID' was successfully created."
echo "TurnKey GitLab Password" >>~/turnkey-gitlab.creds # file is located in the Proxmox root directory echo "TurnKey ${NAME} Password" >>~/turnkey-${NAME}.creds # file is located in the Proxmox root directory
echo $PASS >>~/turnkey-gitlab.creds #run `cat turnkey-gitlab.creds` in the Proxmox shell echo $PASS >>~/turnkey-${NAME}.creds
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

View File

@ -7,11 +7,14 @@
# bash -c "$(wget -qLO - https://github.com/tteck/Proxmox/raw/main/turnkey/turnkey-nextcloud.sh)" # bash -c "$(wget -qLO - https://github.com/tteck/Proxmox/raw/main/turnkey/turnkey-nextcloud.sh)"
# Setup script environment # Setup script environment
NAME="nextcloud"
PASS="$(openssl rand -base64 8)" PASS="$(openssl rand -base64 8)"
TEMPLATE_SEARCH="debian-11-turnkey-nextcloud_17.2-1_amd64.tar.gz" CTID=$(pvesh get /cluster/nextid)
TEMPLATE_SEARCH="debian-11-turnkey-${NAME}_17.2-1_amd64.tar.gz"
PCT_DISK_SIZE="10"
PCT_OPTIONS=" PCT_OPTIONS="
-features keyctl=1,nesting=1 -features keyctl=1,nesting=1
-hostname turnkey-nextcloud -hostname turnkey-${NAME}
-tags proxmox-helper-scripts -tags proxmox-helper-scripts
-onboot 1 -onboot 1
-cores 2 -cores 2
@ -118,20 +121,6 @@ function select_storage() {
fi fi
} }
# Test if required variables are set
CTID=$(pvesh get /cluster/nextid)
[[ "${CTID:-}" ]] || die "You need to set 'CTID' variable."
# Test if ID is valid
[ "$CTID" -ge "100" ] || die "ID cannot be less than 100."
# Test if ID is in use
if pct status $CTID &>/dev/null; then
warn "ID '$CTID' is already in use."
unset CTID
die "Cannot use ID that is already in use."
fi
# Get template storage # Get template storage
TEMPLATE_STORAGE=$(select_storage template) || exit TEMPLATE_STORAGE=$(select_storage template) || exit
info "Using '$TEMPLATE_STORAGE' for template storage." info "Using '$TEMPLATE_STORAGE' for template storage."
@ -168,8 +157,8 @@ pct create $CTID ${TEMPLATE_STORAGE}:vztmpl/${TEMPLATE} ${PCT_OPTIONS[@]} >/dev/
msg "Starting LXC Container..." msg "Starting LXC Container..."
pct start "$CTID" pct start "$CTID"
info "LXC container '$CTID' was successfully created." info "LXC container '$CTID' was successfully created."
echo "TurnKey Nextcloud Password" >>~/turnkey-nextcloud.creds # file is located in the Proxmox root directory echo "TurnKey ${NAME} Password" >>~/turnkey-${NAME}.creds # file is located in the Proxmox root directory
echo $PASS >>~/turnkey-nextcloud.creds #run `cat turnkey-nextcloud.creds` in the Proxmox shell echo $PASS >>~/turnkey-${NAME}.creds
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

View File

@ -7,11 +7,14 @@
# bash -c "$(wget -qLO - https://github.com/tteck/Proxmox/raw/main/turnkey/turnkey-observium.sh)" # bash -c "$(wget -qLO - https://github.com/tteck/Proxmox/raw/main/turnkey/turnkey-observium.sh)"
# Setup script environment # Setup script environment
NAME="observium"
PASS="$(openssl rand -base64 8)" PASS="$(openssl rand -base64 8)"
TEMPLATE_SEARCH="debian-11-turnkey-observium_17.2-1_amd64.tar.gz" CTID=$(pvesh get /cluster/nextid)
TEMPLATE_SEARCH="debian-11-turnkey-${NAME}_17.2-1_amd64.tar.gz"
PCT_DISK_SIZE="4"
PCT_OPTIONS=" PCT_OPTIONS="
-features keyctl=1,nesting=1 -features keyctl=1,nesting=1
-hostname turnkey-observium -hostname turnkey-${NAME}
-tags proxmox-helper-scripts -tags proxmox-helper-scripts
-onboot 1 -onboot 1
-cores 2 -cores 2
@ -118,20 +121,6 @@ function select_storage() {
fi fi
} }
# Test if required variables are set
CTID=$(pvesh get /cluster/nextid)
[[ "${CTID:-}" ]] || die "You need to set 'CTID' variable."
# Test if ID is valid
[ "$CTID" -ge "100" ] || die "ID cannot be less than 100."
# Test if ID is in use
if pct status $CTID &>/dev/null; then
warn "ID '$CTID' is already in use."
unset CTID
die "Cannot use ID that is already in use."
fi
# Get template storage # Get template storage
TEMPLATE_STORAGE=$(select_storage template) || exit TEMPLATE_STORAGE=$(select_storage template) || exit
info "Using '$TEMPLATE_STORAGE' for template storage." info "Using '$TEMPLATE_STORAGE' for template storage."
@ -168,8 +157,8 @@ pct create $CTID ${TEMPLATE_STORAGE}:vztmpl/${TEMPLATE} ${PCT_OPTIONS[@]} >/dev/
msg "Starting LXC Container..." msg "Starting LXC Container..."
pct start "$CTID" pct start "$CTID"
info "LXC container '$CTID' was successfully created." info "LXC container '$CTID' was successfully created."
echo "TurnKey Observium Password" >>~/turnkey-observium.creds # file is located in the Proxmox root directory echo "TurnKey ${NAME} Password" >>~/turnkey-${NAME}.creds # file is located in the Proxmox root directory
echo $PASS >>~/turnkey-observium.creds #run `cat turnkey-observium.creds` in the Proxmox shell echo $PASS >>~/turnkey-${NAME}.creds
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

View File

@ -7,11 +7,14 @@
# bash -c "$(wget -qLO - https://github.com/tteck/Proxmox/raw/main/turnkey/turnkey-owncloud.sh)" # bash -c "$(wget -qLO - https://github.com/tteck/Proxmox/raw/main/turnkey/turnkey-owncloud.sh)"
# Setup script environment # Setup script environment
NAME="owncloud"
PASS="$(openssl rand -base64 8)" PASS="$(openssl rand -base64 8)"
TEMPLATE_SEARCH="debian-11-turnkey-owncloud_17.1-1_amd64.tar.gz" CTID=$(pvesh get /cluster/nextid)
TEMPLATE_SEARCH="debian-11-turnkey-${NAME}_17.1-1_amd64.tar.gz"
PCT_DISK_SIZE="10"
PCT_OPTIONS=" PCT_OPTIONS="
-features keyctl=1,nesting=1 -features keyctl=1,nesting=1
-hostname turnkey-owncloud -hostname turnkey-${NAME}
-tags proxmox-helper-scripts -tags proxmox-helper-scripts
-onboot 1 -onboot 1
-cores 2 -cores 2
@ -118,20 +121,6 @@ function select_storage() {
fi fi
} }
# Test if required variables are set
CTID=$(pvesh get /cluster/nextid)
[[ "${CTID:-}" ]] || die "You need to set 'CTID' variable."
# Test if ID is valid
[ "$CTID" -ge "100" ] || die "ID cannot be less than 100."
# Test if ID is in use
if pct status $CTID &>/dev/null; then
warn "ID '$CTID' is already in use."
unset CTID
die "Cannot use ID that is already in use."
fi
# Get template storage # Get template storage
TEMPLATE_STORAGE=$(select_storage template) || exit TEMPLATE_STORAGE=$(select_storage template) || exit
info "Using '$TEMPLATE_STORAGE' for template storage." info "Using '$TEMPLATE_STORAGE' for template storage."
@ -168,8 +157,8 @@ pct create $CTID ${TEMPLATE_STORAGE}:vztmpl/${TEMPLATE} ${PCT_OPTIONS[@]} >/dev/
msg "Starting LXC Container..." msg "Starting LXC Container..."
pct start "$CTID" pct start "$CTID"
info "LXC container '$CTID' was successfully created." info "LXC container '$CTID' was successfully created."
echo "TurnKey ownCloud Password" >>~/turnkey-owncloud.creds # file is located in the Proxmox root directory echo "TurnKey ${NAME} Password" >>~/turnkey-${NAME}.creds # file is located in the Proxmox root directory
echo $PASS >>~/turnkey-owncloud.creds #run `cat turnkey-owncloud.creds` in the Proxmox shell echo $PASS >>~/turnkey-${NAME}.creds
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

View File

@ -7,11 +7,14 @@
# bash -c "$(wget -qLO - https://github.com/tteck/Proxmox/raw/main/turnkey/turnkey-wordpress.sh)" # bash -c "$(wget -qLO - https://github.com/tteck/Proxmox/raw/main/turnkey/turnkey-wordpress.sh)"
# Setup script environment # Setup script environment
NAME="wordpress"
PASS="$(openssl rand -base64 8)" PASS="$(openssl rand -base64 8)"
TEMPLATE_SEARCH="debian-11-turnkey-wordpress_17.1-1_amd64.tar.gz" CTID=$(pvesh get /cluster/nextid)
TEMPLATE_SEARCH="debian-11-turnkey-${NAME}_17.1-1_amd64.tar.gz"
PCT_DISK_SIZE="8"
PCT_OPTIONS=" PCT_OPTIONS="
-features keyctl=1,nesting=1 -features keyctl=1,nesting=1
-hostname turnkey-wordpress -hostname turnkey-${NAME}
-tags proxmox-helper-scripts -tags proxmox-helper-scripts
-onboot 1 -onboot 1
-cores 2 -cores 2
@ -118,20 +121,6 @@ function select_storage() {
fi fi
} }
# Test if required variables are set
CTID=$(pvesh get /cluster/nextid)
[[ "${CTID:-}" ]] || die "You need to set 'CTID' variable."
# Test if ID is valid
[ "$CTID" -ge "100" ] || die "ID cannot be less than 100."
# Test if ID is in use
if pct status $CTID &>/dev/null; then
warn "ID '$CTID' is already in use."
unset CTID
die "Cannot use ID that is already in use."
fi
# Get template storage # Get template storage
TEMPLATE_STORAGE=$(select_storage template) || exit TEMPLATE_STORAGE=$(select_storage template) || exit
info "Using '$TEMPLATE_STORAGE' for template storage." info "Using '$TEMPLATE_STORAGE' for template storage."
@ -168,8 +157,8 @@ pct create $CTID ${TEMPLATE_STORAGE}:vztmpl/${TEMPLATE} ${PCT_OPTIONS[@]} >/dev/
msg "Starting LXC Container..." msg "Starting LXC Container..."
pct start "$CTID" pct start "$CTID"
info "LXC container '$CTID' was successfully created." info "LXC container '$CTID' was successfully created."
echo "TurnKey WordPress Password" >>~/turnkey-wordpress.creds # file is located in the Proxmox root directory echo "TurnKey ${NAME} Password" >>~/turnkey-${NAME}.creds # file is located in the Proxmox root directory
echo $PASS >>~/turnkey-wordpress.creds #run `cat turnkey-wordpress.creds` in the Proxmox shell echo $PASS >>~/turnkey-${NAME}.creds
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