feat: package docker deployment and publish flow
This commit is contained in:
28
scripts/init-docker-config.sh
Normal file
28
scripts/init-docker-config.sh
Normal file
@ -0,0 +1,28 @@
|
||||
#!/usr/bin/env sh
|
||||
set -eu
|
||||
|
||||
mkdir -p config runtime/codex data/workspace/stage data/workspace/session data/workspace/backup
|
||||
|
||||
if [ ! -f .env ]; then
|
||||
cp .env.example .env
|
||||
echo "created .env from .env.example"
|
||||
fi
|
||||
|
||||
if [ ! -f config/settings.json ]; then
|
||||
cp config/settings.docker.example.json config/settings.json
|
||||
echo "created config/settings.json from config/settings.docker.example.json"
|
||||
fi
|
||||
|
||||
if [ ! -f runtime/cookies.json ]; then
|
||||
cp runtime/cookies.example.json runtime/cookies.json
|
||||
echo "created runtime/cookies.json placeholder"
|
||||
fi
|
||||
|
||||
if [ ! -f runtime/upload_config.json ]; then
|
||||
cp runtime/upload_config.example.json runtime/upload_config.json
|
||||
echo "created runtime/upload_config.json placeholder"
|
||||
fi
|
||||
|
||||
if [ ! -x runtime/biliup ]; then
|
||||
echo "warning: runtime/biliup is missing or not executable; publish will fail until you provide it" >&2
|
||||
fi
|
||||
@ -1,35 +1,35 @@
|
||||
#!/usr/bin/env bash
|
||||
set -euo pipefail
|
||||
|
||||
LOG_FILE="${1:?log file required}"
|
||||
MAX_BYTES="${2:-20971520}"
|
||||
BACKUPS="${3:-5}"
|
||||
|
||||
mkdir -p "$(dirname "$LOG_FILE")"
|
||||
touch "$LOG_FILE"
|
||||
|
||||
rotate_logs() {
|
||||
local size
|
||||
size="$(stat -c%s "$LOG_FILE" 2>/dev/null || echo 0)"
|
||||
if [[ "$size" -lt "$MAX_BYTES" ]]; then
|
||||
return
|
||||
fi
|
||||
|
||||
local index
|
||||
for ((index=BACKUPS; index>=1; index--)); do
|
||||
if [[ -f "${LOG_FILE}.${index}" ]]; then
|
||||
if [[ "$index" -eq "$BACKUPS" ]]; then
|
||||
rm -f "${LOG_FILE}.${index}"
|
||||
else
|
||||
mv "${LOG_FILE}.${index}" "${LOG_FILE}.$((index + 1))"
|
||||
fi
|
||||
fi
|
||||
done
|
||||
mv "$LOG_FILE" "${LOG_FILE}.1"
|
||||
: > "$LOG_FILE"
|
||||
}
|
||||
|
||||
while IFS= read -r line || [[ -n "$line" ]]; do
|
||||
rotate_logs
|
||||
printf '%s\n' "$line" | tee -a "$LOG_FILE"
|
||||
done
|
||||
#!/usr/bin/env bash
|
||||
set -euo pipefail
|
||||
|
||||
LOG_FILE="${1:?log file required}"
|
||||
MAX_BYTES="${2:-20971520}"
|
||||
BACKUPS="${3:-5}"
|
||||
|
||||
mkdir -p "$(dirname "$LOG_FILE")"
|
||||
touch "$LOG_FILE"
|
||||
|
||||
rotate_logs() {
|
||||
local size
|
||||
size="$(stat -c%s "$LOG_FILE" 2>/dev/null || echo 0)"
|
||||
if [[ "$size" -lt "$MAX_BYTES" ]]; then
|
||||
return
|
||||
fi
|
||||
|
||||
local index
|
||||
for ((index=BACKUPS; index>=1; index--)); do
|
||||
if [[ -f "${LOG_FILE}.${index}" ]]; then
|
||||
if [[ "$index" -eq "$BACKUPS" ]]; then
|
||||
rm -f "${LOG_FILE}.${index}"
|
||||
else
|
||||
mv "${LOG_FILE}.${index}" "${LOG_FILE}.$((index + 1))"
|
||||
fi
|
||||
fi
|
||||
done
|
||||
mv "$LOG_FILE" "${LOG_FILE}.1"
|
||||
: > "$LOG_FILE"
|
||||
}
|
||||
|
||||
while IFS= read -r line || [[ -n "$line" ]]; do
|
||||
rotate_logs
|
||||
printf '%s\n' "$line" | tee -a "$LOG_FILE"
|
||||
done
|
||||
|
||||
Reference in New Issue
Block a user