Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .gitmodules
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
[submodule "proxmox-launchpad"]
path = proxmox-launchpad
url = https://github.com/maxklema/proxmox-launchpad.git
1 change: 1 addition & 0 deletions ci-cd automation/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
# CI/CD Automation
Original file line number Diff line number Diff line change
@@ -1,8 +1,16 @@
#!/bin/bash
# Script to check if a container exists
# Script to check if a container exists, and if so, whether it needs to be updated or cloned.
# Last Modified by Maxwell Klema on July 13th, 2025
# -----------------------------------------------------

outputError() {
echo -e "${BOLD}━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━${RESET}"
echo -e "${BOLD}${MAGENTA}❌ Script Failed. Exiting... ${RESET}"
echo -e "$2"
echo -e "${BOLD}━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━${RESET}"
exit $1
}

RESET="\033[0m"
BOLD="\033[1m"
MAGENTA='\033[35m'
Expand All @@ -11,13 +19,11 @@ echo -e "${BOLD}━━━━━━━━━━━━━━━━━━━━━
echo -e "${BOLD}${MAGENTA}🔎 Check Container Exists ${RESET}"
echo -e "${BOLD}━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━${RESET}"

set +e
TYPE_RUNNER="true"
source /var/lib/vz/snippets/helper-scripts/PVE_user_authentication.sh
source /var/lib/vz/snippets/helper-scripts/verify_container_ownership.sh

STATUS=$?

if [ "$STATUS" != 0 ]; then
exit 1;
fi
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,5 +25,5 @@ QUOTED_CMD=$(printf ' %q' "${CMD[@]}")

tmux new-session -d -s delete-runner "$QUOTED_CMD"

echo "✅ Container with name \"$CONTAINER_NAME\" will been permanently deleted."
echo "✅ Container with name \"$CONTAINER_NAME\" will be permanently deleted."
exit 0 # Container Deleted Successfully
18 changes: 3 additions & 15 deletions ...helper-scripts/PVE_user_authentication.sh → ...helper-scripts/PVE_user_authentication.sh
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -15,21 +15,9 @@ if [ -z "$PROXMOX_PASSWORD" ]; then
fi

USER_AUTHENTICATED=$(ssh root@10.15.234.122 "node /root/bin/js/runner.js authenticateUser \"$PROXMOX_USERNAME\" \"$PROXMOX_PASSWORD\"")
RETRIES=3

while [ $USER_AUTHENTICATED == 'false' ]; do
if [ $RETRIES -gt 0 ]; then
echo "❌ Authentication Failed. Try Again"
read -p "Enter Proxmox Username → " PROXMOX_USERNAME
read -sp "Enter Proxmox Password → " PROXMOX_PASSWORD
echo ""

USER_AUTHENTICATED=$(ssh root@10.15.234.122 "node /root/bin/js/runner.js authenticateUser \"$PROXMOX_USERNAME\" \"$PROXMOX_PASSWORD\"")
RETRIES=$(($RETRIES-1))
else
echo "Too many incorrect attempts. Exiting..."
exit 2
fi
done
if [ $USER_AUTHENTICATED == 'false' ]; then
outputError 1 "Your Proxmox account, $PROXMOX_USERNAME@pve, was not authenticated. Retry with valid credentials."
fi

echo "🎉 Your proxmox account, $PROXMOX_USERNAME@pve, has been authenticated"
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,8 @@ else
--full true
fi

AUTH_TOKEN_RESPONSE=$(curl --location --request POST https://api.github.com/repos/$REPO_BASE_NAME_WITH_OWNER/$REPO_BASE_NAME/actions/runners/registration-token --header "Authorization: token $GITHUB_PAT")
TOKEN=$(echo "$AUTH_TOKEN_RESPONSE" | jq -r '.token')
# AUTH_TOKEN_RESPONSE=$(curl --location --request POST https://api.github.com/repos/$REPO_BASE_NAME_WITH_OWNER/$REPO_BASE_NAME/actions/runners/registration-token --header "Authorization: token $GITHUB_PAT")
# TOKEN=$(echo "$AUTH_TOKEN_RESPONSE" | jq -r '.token')

# Remove rsa keys ====
pct start $NEXT_ID
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,13 @@ PROXMOX_USERNAME="$3"
PROXMOX_PASSWORD="$4"
CONTAINER_NAME="$5"

set -x
sleep 2

# Delete Container

CONTAINER_ID=$( { pct list; ssh root@10.15.0.5 'pct list'; } | awk -v name="$CONTAINER_NAME" '$3 == name {print $1}')
echo "echo $CONTAINER_ID"

if (( $CONTAINER_ID % 2 == 0 )); then
if ssh root@10.15.0.5 "pct status $CONTAINER_ID" | grep -q "status: running"; then
Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -20,18 +20,18 @@ if [ "$TYPE_RUNNER" != "true" ]; then
if (( $CONTAINER_ID % 2 == 0 )); then
CONTAINER_OWNERSHIP=$(ssh root@10.15.0.5 "pct config \"$CONTAINER_ID\" | grep "tags" | grep \"$PROXMOX_USERNAME\"")
else
CONTAINER_OWNERSHIP=$(pct config "$CONTAINER_ID" | grep "tags" | grep -x "tags: $PROXMOX_USERNAME")
CONTAINER_OWNERSHIP=$(pct config "$CONTAINER_ID" | grep "tags" | grep -E "(^|;)$PROXMOX_USERNAME(;|$)")
fi
else
CONTAINER_OWNERSHIP=$(ssh root@10.15.0.5 "pct config \"$CONTAINER_ID\" | grep "tags" | grep \"$PROXMOX_USERNAME\"")
PVE1="false"
if [ -z "$CONTAINER_OWNERSHIP" ]; then
CONTAINER_OWNERSHIP=$(pct config "$CONTAINER_ID" | grep "tags" | grep -x "tags: $PROXMOX_USERNAME")
CONTAINER_OWNERSHIP=$(pct config "$CONTAINER_ID" | grep "tags" | grep -E "(^|;)$PROXMOX_USERNAME(;|$)")
PVE1="true"
fi
fi

if [ -z "$CONTAINER_OWNERSHIP" ]; then
echo "❌ You do not own the container with name \"$CONTAINER_NAME\"."
return 2
outputError 1 "You do not own the container with name \"$CONTAINER_NAME\"."
fi
Empty file.
Loading