Jelajahi Sumber

turnkey code refactoring

tteckster 1 tahun lalu
induk
melakukan
604c20df17

+ 7 - 18
turnkey/turnkey-core.sh

@@ -7,11 +7,14 @@
 # bash -c "$(wget -qLO - https://github.com/tteck/Proxmox/raw/main/turnkey/turnkey-core.sh)"
 
 # Setup script environment
+NAME="core"
 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="
     -features keyctl=1,nesting=1
-    -hostname turnkey-core
+    -hostname turnkey-${NAME}
     -tags proxmox-helper-scripts
     -onboot 1
     -cores 2
@@ -118,20 +121,6 @@ function select_storage() {
   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
 TEMPLATE_STORAGE=$(select_storage template) || exit
 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..."
 pct start "$CTID"
 info "LXC container '$CTID' was successfully created."
-echo "TurnKey Core Password" >>~/turnkey-core.creds # file is located in the Proxmox root directory
-echo $PASS >>~/turnkey-core.creds #run `cat turnkey-core.creds` in the Proxmox shell
+echo "TurnKey ${NAME} Password" >>~/turnkey-${NAME}.creds # file is located in the Proxmox root directory
+echo $PASS >>~/turnkey-${NAME}.creds
 if [[ -f /etc/systemd/system/ping-instances.service ]]; then
   systemctl start ping-instances.service
 fi

+ 7 - 18
turnkey/turnkey-fileserver.sh

@@ -7,11 +7,14 @@
 # bash -c "$(wget -qLO - https://github.com/tteck/Proxmox/raw/main/turnkey/turnkey-fileserver.sh)"
 
 # Setup script environment
+NAME="fileserver"
 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="
     -features keyctl=1,nesting=1
-    -hostname turnkey-fileserver
+    -hostname turnkey-${NAME}
     -tags proxmox-helper-scripts
     -onboot 1
     -cores 2
@@ -118,20 +121,6 @@ function select_storage() {
   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
 TEMPLATE_STORAGE=$(select_storage template) || exit
 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..."
 pct start "$CTID"
 info "LXC container '$CTID' was successfully created."
-echo "TurnKey File Server Password" >>~/turnkey-fileserver.creds # file is located in the Proxmox root directory
-echo $PASS >>~/turnkey-fileserver.creds #run `cat turnkey-fileserver.creds` in the Proxmox shell
+echo "TurnKey ${NAME} Password" >>~/turnkey-${NAME}.creds # file is located in the Proxmox root directory
+echo $PASS >>~/turnkey-${NAME}.creds
 if [[ -f /etc/systemd/system/ping-instances.service ]]; then
   systemctl start ping-instances.service
 fi

+ 7 - 18
turnkey/turnkey-gitlab.sh

@@ -7,11 +7,14 @@
 # bash -c "$(wget -qLO - https://github.com/tteck/Proxmox/raw/main/turnkey/turnkey-gitlab.sh)"
 
 # Setup script environment
+NAME="gitlab"
 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="
     -features keyctl=1,nesting=1
-    -hostname turnkey-gitlab
+    -hostname turnkey-${NAME}
     -tags proxmox-helper-scripts
     -onboot 1
     -cores 4
@@ -118,20 +121,6 @@ function select_storage() {
   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
 TEMPLATE_STORAGE=$(select_storage template) || exit
 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..."
 pct start "$CTID"
 info "LXC container '$CTID' was successfully created."
-echo "TurnKey GitLab Password" >>~/turnkey-gitlab.creds # file is located in the Proxmox root directory
-echo $PASS >>~/turnkey-gitlab.creds #run `cat turnkey-gitlab.creds` in the Proxmox shell
+echo "TurnKey ${NAME} Password" >>~/turnkey-${NAME}.creds # file is located in the Proxmox root directory
+echo $PASS >>~/turnkey-${NAME}.creds
 if [[ -f /etc/systemd/system/ping-instances.service ]]; then
   systemctl start ping-instances.service
 fi

+ 7 - 18
turnkey/turnkey-nextcloud.sh

@@ -7,11 +7,14 @@
 # bash -c "$(wget -qLO - https://github.com/tteck/Proxmox/raw/main/turnkey/turnkey-nextcloud.sh)"
 
 # Setup script environment
+NAME="nextcloud"
 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="
     -features keyctl=1,nesting=1
-    -hostname turnkey-nextcloud
+    -hostname turnkey-${NAME}
     -tags proxmox-helper-scripts
     -onboot 1
     -cores 2
@@ -118,20 +121,6 @@ function select_storage() {
   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
 TEMPLATE_STORAGE=$(select_storage template) || exit
 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..."
 pct start "$CTID"
 info "LXC container '$CTID' was successfully created."
-echo "TurnKey Nextcloud Password" >>~/turnkey-nextcloud.creds # file is located in the Proxmox root directory
-echo $PASS >>~/turnkey-nextcloud.creds #run `cat turnkey-nextcloud.creds` in the Proxmox shell
+echo "TurnKey ${NAME} Password" >>~/turnkey-${NAME}.creds # file is located in the Proxmox root directory
+echo $PASS >>~/turnkey-${NAME}.creds
 if [[ -f /etc/systemd/system/ping-instances.service ]]; then
   systemctl start ping-instances.service
 fi

+ 7 - 18
turnkey/turnkey-observium.sh

@@ -7,11 +7,14 @@
 # bash -c "$(wget -qLO - https://github.com/tteck/Proxmox/raw/main/turnkey/turnkey-observium.sh)"
 
 # Setup script environment
+NAME="observium"
 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="
     -features keyctl=1,nesting=1
-    -hostname turnkey-observium
+    -hostname turnkey-${NAME}
     -tags proxmox-helper-scripts
     -onboot 1
     -cores 2
@@ -118,20 +121,6 @@ function select_storage() {
   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
 TEMPLATE_STORAGE=$(select_storage template) || exit
 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..."
 pct start "$CTID"
 info "LXC container '$CTID' was successfully created."
-echo "TurnKey Observium Password" >>~/turnkey-observium.creds # file is located in the Proxmox root directory
-echo $PASS >>~/turnkey-observium.creds #run `cat turnkey-observium.creds` in the Proxmox shell
+echo "TurnKey ${NAME} Password" >>~/turnkey-${NAME}.creds # file is located in the Proxmox root directory
+echo $PASS >>~/turnkey-${NAME}.creds
 if [[ -f /etc/systemd/system/ping-instances.service ]]; then
   systemctl start ping-instances.service
 fi

+ 7 - 18
turnkey/turnkey-owncloud.sh

@@ -7,11 +7,14 @@
 # bash -c "$(wget -qLO - https://github.com/tteck/Proxmox/raw/main/turnkey/turnkey-owncloud.sh)"
 
 # Setup script environment
+NAME="owncloud"
 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="
     -features keyctl=1,nesting=1
-    -hostname turnkey-owncloud
+    -hostname turnkey-${NAME}
     -tags proxmox-helper-scripts
     -onboot 1
     -cores 2
@@ -118,20 +121,6 @@ function select_storage() {
   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
 TEMPLATE_STORAGE=$(select_storage template) || exit
 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..."
 pct start "$CTID"
 info "LXC container '$CTID' was successfully created."
-echo "TurnKey ownCloud Password" >>~/turnkey-owncloud.creds # file is located in the Proxmox root directory
-echo $PASS >>~/turnkey-owncloud.creds #run `cat turnkey-owncloud.creds` in the Proxmox shell
+echo "TurnKey ${NAME} Password" >>~/turnkey-${NAME}.creds # file is located in the Proxmox root directory
+echo $PASS >>~/turnkey-${NAME}.creds
 if [[ -f /etc/systemd/system/ping-instances.service ]]; then
   systemctl start ping-instances.service
 fi

+ 7 - 18
turnkey/turnkey-wordpress.sh

@@ -7,11 +7,14 @@
 # bash -c "$(wget -qLO - https://github.com/tteck/Proxmox/raw/main/turnkey/turnkey-wordpress.sh)"
 
 # Setup script environment
+NAME="wordpress"
 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="
     -features keyctl=1,nesting=1
-    -hostname turnkey-wordpress
+    -hostname turnkey-${NAME}
     -tags proxmox-helper-scripts
     -onboot 1
     -cores 2
@@ -118,20 +121,6 @@ function select_storage() {
   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
 TEMPLATE_STORAGE=$(select_storage template) || exit
 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..."
 pct start "$CTID"
 info "LXC container '$CTID' was successfully created."
-echo "TurnKey WordPress Password" >>~/turnkey-wordpress.creds # file is located in the Proxmox root directory
-echo $PASS >>~/turnkey-wordpress.creds #run `cat turnkey-wordpress.creds` in the Proxmox shell
+echo "TurnKey ${NAME} Password" >>~/turnkey-${NAME}.creds # file is located in the Proxmox root directory
+echo $PASS >>~/turnkey-${NAME}.creds
 if [[ -f /etc/systemd/system/ping-instances.service ]]; then
   systemctl start ping-instances.service
 fi