Update 2025-04-17_20:44:56
This commit is contained in:
21
.gitignore
vendored
Normal file
21
.gitignore
vendored
Normal file
@ -0,0 +1,21 @@
|
|||||||
|
# Bytecode-Dateien
|
||||||
|
__pycache__/
|
||||||
|
*.py[cod]
|
||||||
|
|
||||||
|
# Virtuelle Umgebungen
|
||||||
|
.venv/
|
||||||
|
venv/
|
||||||
|
|
||||||
|
# Betriebssystem-Dateien
|
||||||
|
.DS_Store
|
||||||
|
Thumbs.db
|
||||||
|
|
||||||
|
# Logfiles und Dumps
|
||||||
|
*.log
|
||||||
|
*.bak
|
||||||
|
*.swp
|
||||||
|
*.tmp
|
||||||
|
|
||||||
|
# IDEs und Editoren
|
||||||
|
.vscode/
|
||||||
|
.idea/
|
@ -1,5 +1,5 @@
|
|||||||
#!/bin/zsh
|
#!/bin/zsh
|
||||||
# Script Version: 1.5
|
# Script Version: 19
|
||||||
# Description: Pushes the current folder (e.g. /etc) to a nested Gitea repo using provided nesting arguments. Auto-creates the remote repo via Gitea API if missing.
|
# Description: Pushes the current folder (e.g. /etc) to a nested Gitea repo using provided nesting arguments. Auto-creates the remote repo via Gitea API if missing.
|
||||||
|
|
||||||
# Set variables
|
# Set variables
|
||||||
@ -36,11 +36,11 @@ log() {
|
|||||||
local color_reset="$(tput sgr0)"
|
local color_reset="$(tput sgr0)"
|
||||||
local color=""
|
local color=""
|
||||||
case "$level" in
|
case "$level" in
|
||||||
INFO) color="$(tput setaf 2)" ;; # green
|
INFO) color="$(tput setaf 6)" ;; # cyan
|
||||||
WARNING) color="$(tput setaf 3)" ;; # yellow
|
WARNING) color="$(tput setaf 3)" ;; # yellow
|
||||||
ERROR) color="$(tput setaf 1)" ;; # red
|
ERROR) color="$(tput setaf 1)" ;; # red
|
||||||
DEBUG) color="$(tput setaf 4)" ;; # blue
|
DEBUG) color="$(tput bold; tput setaf 4)" ;; # bold blue
|
||||||
esac
|
esac
|
||||||
echo "${color}[$level] $*${color_reset}"
|
echo "${color}[$level] $*${color_reset}"
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -66,17 +66,11 @@ create_repo() {
|
|||||||
|
|
||||||
prepare_commit() {
|
prepare_commit() {
|
||||||
git add .
|
git add .
|
||||||
if git diff --quiet HEAD && ! git rev-parse --verify HEAD >/dev/null 2>&1; then
|
log INFO "Committing changes"
|
||||||
log INFO "Creating initial commit"
|
git commit -m "$COMMIT_MESSAGE" || log INFO "Nothing to commit"
|
||||||
git commit -m "$COMMIT_MESSAGE"
|
|
||||||
elif ! git diff --quiet HEAD; then
|
|
||||||
log INFO "Committing changes"
|
|
||||||
git commit -m "$COMMIT_MESSAGE"
|
|
||||||
else
|
|
||||||
log INFO "Nothing to commit"
|
|
||||||
fi
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
setup_remote() {
|
setup_remote() {
|
||||||
if git remote | grep -q '^origin$'; then
|
if git remote | grep -q '^origin$'; then
|
||||||
log INFO "Updating remote origin URL"
|
log INFO "Updating remote origin URL"
|
||||||
@ -181,6 +175,59 @@ check_or_create_repo
|
|||||||
# Main Process
|
# Main Process
|
||||||
# ========
|
# ========
|
||||||
|
|
||||||
|
# Add safe.directory for current repo if needed
|
||||||
|
if [ -n "$GIT_REMOTE" ]; then
|
||||||
|
SAFE_DIR="$(pwd)"
|
||||||
|
git config --global --add safe.directory "$SAFE_DIR"
|
||||||
|
log DEBUG "Added safe.directory: $SAFE_DIR"
|
||||||
|
fi
|
||||||
|
|
||||||
|
|
||||||
|
# Create default .gitignore if not present
|
||||||
|
if [ ! -f .gitignore ]; then
|
||||||
|
log INFO "Creating default .gitignore"
|
||||||
|
cat > .gitignore <<EOF
|
||||||
|
# Bytecode-Dateien
|
||||||
|
__pycache__/
|
||||||
|
*.py[cod]
|
||||||
|
|
||||||
|
# Virtuelle Umgebungen
|
||||||
|
.venv/
|
||||||
|
venv/
|
||||||
|
|
||||||
|
# Betriebssystem-Dateien
|
||||||
|
.DS_Store
|
||||||
|
Thumbs.db
|
||||||
|
|
||||||
|
# Logfiles und Dumps
|
||||||
|
*.log
|
||||||
|
*.bak
|
||||||
|
*.swp
|
||||||
|
*.tmp
|
||||||
|
|
||||||
|
# IDEs und Editoren
|
||||||
|
.vscode/
|
||||||
|
.idea/
|
||||||
|
EOF
|
||||||
|
fi
|
||||||
|
|
||||||
|
|
||||||
|
# Ensure Git user identity is configured
|
||||||
|
log DEBUG "Checking Git user configuration..."
|
||||||
|
if ! git config user.name >/dev/null 2>&1; then
|
||||||
|
git config --global user.name "$(whoami)"
|
||||||
|
log DEBUG "Set Git user.name to $(whoami)"
|
||||||
|
else
|
||||||
|
log DEBUG "Git user.name already set to $(git config --show-origin user.name)"
|
||||||
|
fi
|
||||||
|
if ! git config user.email >/dev/null 2>&1; then
|
||||||
|
git config --global user.email "$(whoami)@$(hostname -f)"
|
||||||
|
log DEBUG "Set Git user.email to $(whoami)@$(hostname -f)"
|
||||||
|
else
|
||||||
|
log DEBUG "Git user.email already set to $(git config --show-origin user.email)"
|
||||||
|
fi
|
||||||
|
|
||||||
|
|
||||||
# Safety check against pushing from / or $HOME
|
# Safety check against pushing from / or $HOME
|
||||||
if [[ "$PWD" == "$HOME" || "$PWD" == "/" ]]; then
|
if [[ "$PWD" == "$HOME" || "$PWD" == "/" ]]; then
|
||||||
log ERROR "Refusing to run inside \$PWD=$PWD"
|
log ERROR "Refusing to run inside \$PWD=$PWD"
|
||||||
@ -197,10 +244,27 @@ if [ ! -d .git ]; then
|
|||||||
git config init.defaultBranch main
|
git config init.defaultBranch main
|
||||||
git checkout -b main
|
git checkout -b main
|
||||||
else
|
else
|
||||||
|
CURRENT_BRANCH=$(git symbolic-ref --short HEAD 2>/dev/null)
|
||||||
|
if [ "$CURRENT_BRANCH" != "main" ]; then
|
||||||
|
log WARNING "Current branch is '$CURRENT_BRANCH', renaming to 'main'"
|
||||||
|
if ! git rev-parse HEAD >/dev/null 2>&1; then
|
||||||
|
git checkout -b main
|
||||||
|
else
|
||||||
|
git branch -m main
|
||||||
|
fi
|
||||||
|
fi
|
||||||
log DEBUG ".git directory already present"
|
log DEBUG ".git directory already present"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Ensure at least one commit exists
|
# Ensure at least one commit exists
|
||||||
|
|
||||||
|
# Create placeholder file if no untracked files exist
|
||||||
|
if [ -z "$(git ls-files)" ]; then
|
||||||
|
touch .gitkeep
|
||||||
|
git add .gitkeep
|
||||||
|
log DEBUG "Added .gitkeep to ensure initial commit"
|
||||||
|
fi
|
||||||
|
|
||||||
prepare_commit
|
prepare_commit
|
||||||
|
|
||||||
# Set or update remote
|
# Set or update remote
|
||||||
|
13
init_game.sh
13
init_game.sh
@ -1,5 +1,5 @@
|
|||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
# Version 08
|
# Version 09
|
||||||
# Setup script for new game deployment (dirs only, port check)
|
# Setup script for new game deployment (dirs only, port check)
|
||||||
|
|
||||||
set -e
|
set -e
|
||||||
@ -26,13 +26,13 @@ if [ -z "$PORT" ]; then
|
|||||||
exit 2
|
exit 2
|
||||||
fi
|
fi
|
||||||
|
|
||||||
echo "Using free port $PORT"
|
|
||||||
echo
|
|
||||||
|
|
||||||
echo "Creating project folder at $DIR"
|
echo "Creating project folder at $DIR"
|
||||||
install -d -m 0750 -o games -g games "$DIR/static"
|
install -d -m 0750 -o games -g games "$DIR/static"
|
||||||
echo
|
echo
|
||||||
|
|
||||||
|
chown -R games:games "$DIR"
|
||||||
|
chmod -R 755 "$DIR"
|
||||||
cd "$DIR"
|
cd "$DIR"
|
||||||
python3 -m venv venv
|
python3 -m venv venv
|
||||||
source venv/bin/activate
|
source venv/bin/activate
|
||||||
@ -74,7 +74,6 @@ echo
|
|||||||
systemctl daemon-reexec
|
systemctl daemon-reexec
|
||||||
systemctl daemon-reload
|
systemctl daemon-reload
|
||||||
systemctl enable --now "$GAMENAME"
|
systemctl enable --now "$GAMENAME"
|
||||||
systemctl status "$GAMENAME"
|
|
||||||
echo
|
echo
|
||||||
|
|
||||||
echo "Creating nginx config"
|
echo "Creating nginx config"
|
||||||
@ -87,7 +86,7 @@ echo " access_log /var/log/nginx/games_access.log;"
|
|||||||
echo " error_log /var/log/nginx/games.error.log;"
|
echo " error_log /var/log/nginx/games.error.log;"
|
||||||
echo ""
|
echo ""
|
||||||
echo " location / {"
|
echo " location / {"
|
||||||
echo " proxy_pass http://10.0.3.32:$PORT ;"
|
echo " proxy_pass http://10.0.3.32:$PORT ;" # needs a space after "PORT" dont delete it
|
||||||
echo " include proxy_params;"
|
echo " include proxy_params;"
|
||||||
echo " proxy_redirect off;"
|
echo " proxy_redirect off;"
|
||||||
echo " }"
|
echo " }"
|
||||||
@ -103,4 +102,8 @@ echo "[DEBUG] Port: $PORT"
|
|||||||
echo "[INFO] Spiel $GAMENAME vorbereitet unter http://$DOMAIN → Port $PORT im Container"
|
echo "[INFO] Spiel $GAMENAME vorbereitet unter http://$DOMAIN → Port $PORT im Container"
|
||||||
echo "[INFO] Nginx-Logs: /var/log/nginx/games.access.log & games.error.log"
|
echo "[INFO] Nginx-Logs: /var/log/nginx/games.access.log & games.error.log"
|
||||||
echo "[INFO] Verzeichnisstruktur angelegt. Bitte Quellcode und statische Dateien manuell hinzufügen."
|
echo "[INFO] Verzeichnisstruktur angelegt. Bitte Quellcode und statische Dateien manuell hinzufügen."
|
||||||
|
echo "[INFO] sc-restart $GAMENAME.service"
|
||||||
|
echo "[INFO] sc-status $GAMENAME.service"
|
||||||
|
echo "[INFO] journalctl -u $GAMENAME.service -n 100 --no-pager"
|
||||||
|
cd /var/www/$GAMENAME
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user