Update 2025-04-17_20:44:56

This commit is contained in:
root
2025-04-17 20:44:56 +02:00
parent 5cae372ac6
commit 32924945d9
3 changed files with 108 additions and 20 deletions

21
.gitignore vendored Normal file
View 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/

View File

@ -1,5 +1,5 @@
#!/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.
# Set variables
@ -36,11 +36,11 @@ log() {
local color_reset="$(tput sgr0)"
local color=""
case "$level" in
INFO) color="$(tput setaf 2)" ;; # green
WARNING) color="$(tput setaf 3)" ;; # yellow
ERROR) color="$(tput setaf 1)" ;; # red
DEBUG) color="$(tput setaf 4)" ;; # blue
esac
INFO) color="$(tput setaf 6)" ;; # cyan
WARNING) color="$(tput setaf 3)" ;; # yellow
ERROR) color="$(tput setaf 1)" ;; # red
DEBUG) color="$(tput bold; tput setaf 4)" ;; # bold blue
esac
echo "${color}[$level] $*${color_reset}"
}
@ -66,17 +66,11 @@ create_repo() {
prepare_commit() {
git add .
if git diff --quiet HEAD && ! git rev-parse --verify HEAD >/dev/null 2>&1; then
log INFO "Creating initial 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
log INFO "Committing changes"
git commit -m "$COMMIT_MESSAGE" || log INFO "Nothing to commit"
}
setup_remote() {
if git remote | grep -q '^origin$'; then
log INFO "Updating remote origin URL"
@ -181,6 +175,59 @@ check_or_create_repo
# 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
if [[ "$PWD" == "$HOME" || "$PWD" == "/" ]]; then
log ERROR "Refusing to run inside \$PWD=$PWD"
@ -197,10 +244,27 @@ if [ ! -d .git ]; then
git config init.defaultBranch main
git checkout -b main
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"
fi
# 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
# Set or update remote

View File

@ -1,5 +1,5 @@
#!/bin/bash
# Version 08
# Version 09
# Setup script for new game deployment (dirs only, port check)
set -e
@ -26,13 +26,13 @@ if [ -z "$PORT" ]; then
exit 2
fi
echo "Using free port $PORT"
echo
echo "Creating project folder at $DIR"
install -d -m 0750 -o games -g games "$DIR/static"
echo
chown -R games:games "$DIR"
chmod -R 755 "$DIR"
cd "$DIR"
python3 -m venv venv
source venv/bin/activate
@ -74,7 +74,6 @@ echo
systemctl daemon-reexec
systemctl daemon-reload
systemctl enable --now "$GAMENAME"
systemctl status "$GAMENAME"
echo
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 ""
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 " proxy_redirect off;"
echo " }"
@ -103,4 +102,8 @@ echo "[DEBUG] Port: $PORT"
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] 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