Initial status for developed files on dagda

This commit is contained in:
mailcat
2026-07-20 20:49:36 +02:00
commit 337378a362
102 changed files with 37778 additions and 0 deletions
+12
View File
@@ -0,0 +1,12 @@
#!/bin/sh
set -eu
APP_DIR="/share/homes/mailcat/mailcat"
ACCOUNT="backup"
PYTHON="/opt/bin/python3"
LOG_DIR="/share/homes/mailcat/mailcat/log"
MAIL_TO="hans@australius.nl"
MKDIR="/bin/mkdir"
"$MKDIR" -p "$LOG_DIR"
cd "$APP_DIR"
"$PYTHON" "$APP_DIR/dagelijks_overzicht.py" --account "$ACCOUNT" --mail-to "$MAIL_TO" >> "$LOG_DIR/daily_report.out" 2>&1
+26
View File
@@ -0,0 +1,26 @@
#!/bin/sh
set -eu
APP_DIR="/share/homes/mailcat/mailcat"
ACCOUNT="backup"
PYTHON="/opt/bin/python3"
STATE_DIR="/share/homes/mailcat/mailcat/state"
LOG_DIR="/share/homes/mailcat/mailcat/log"
RUN_DIR="/share/homes/mailcat/mailcat/run"
PID_FILE="/share/homes/mailcat/mailcat/run/mailcat.pid"
MKDIR="/bin/mkdir"
"$MKDIR" -p "$STATE_DIR" "$LOG_DIR" "$RUN_DIR"
if [ -f "$PID_FILE" ]; then
old_pid=""
IFS= read -r old_pid < "$PID_FILE" || true
if [ -n "$old_pid" ] && kill -0 "$old_pid" 2>/dev/null; then
echo "mailcat already running: $old_pid"
exit 0
fi
fi
cd "$APP_DIR"
"$PYTHON" "$APP_DIR/sort_mail_daemon.py" --account "$ACCOUNT" --folder INBOX --state-file "$STATE_DIR/sort_mail_daemon_state.json" --log-file "$LOG_DIR/sort_mail_daemon.log" >> "$LOG_DIR/daemon.out" 2>&1 &
pid="$!"
echo "$pid" > "$PID_FILE"
echo "mailcat started: $pid"
+32
View File
@@ -0,0 +1,32 @@
#!/bin/sh
set -eu
APP_DIR="/share/homes/mailcat/mailcat"
PYTHON="/opt/bin/python3"
LOG_DIR="/share/homes/mailcat/mailcat/log"
RUN_DIR="/share/homes/mailcat/mailcat/run"
WEB_PID_FILE="/share/homes/mailcat/mailcat/run/mailcat_web.pid"
WEB_HOST="0.0.0.0"
WEB_PORT="4321"
WEB_CONFIG="/share/homes/mailcat/mailcat/web_config.json"
MKDIR="/bin/mkdir"
if [ ! -f "$WEB_CONFIG" ]; then
echo "missing web config: $WEB_CONFIG"
exit 1
fi
"$MKDIR" -p "$LOG_DIR" "$RUN_DIR"
if [ -f "$WEB_PID_FILE" ]; then
old_pid=""
IFS= read -r old_pid < "$WEB_PID_FILE" || true
if [ -n "$old_pid" ] && kill -0 "$old_pid" 2>/dev/null; then
echo "mailcat web already running: $old_pid"
exit 0
fi
fi
cd "$APP_DIR"
"$PYTHON" "$APP_DIR/manage_routes_web.py" --host "$WEB_HOST" --port "$WEB_PORT" --config "$WEB_CONFIG" >> "$LOG_DIR/web.out" 2>&1 &
pid="$!"
echo "$pid" > "$WEB_PID_FILE"
echo "mailcat web started: $pid"
+18
View File
@@ -0,0 +1,18 @@
#!/bin/sh
set -eu
PID_FILE="/share/homes/mailcat/mailcat/run/mailcat.pid"
LOG_DIR="/share/homes/mailcat/mailcat/log"
if [ -f "$PID_FILE" ]; then
pid=""
IFS= read -r pid < "$PID_FILE" || true
if [ -n "$pid" ] && kill -0 "$pid" 2>/dev/null; then
echo "mailcat running: $pid"
exit 0
fi
echo "mailcat not running: stale pid file ($pid)"
exit 1
fi
echo "mailcat not running"
echo "logs: $LOG_DIR"
exit 1
+21
View File
@@ -0,0 +1,21 @@
#!/bin/sh
set -eu
WEB_PID_FILE="/share/homes/mailcat/mailcat/run/mailcat_web.pid"
WEB_HOST="0.0.0.0"
WEB_PORT="4321"
LOG_DIR="/share/homes/mailcat/mailcat/log"
if [ -f "$WEB_PID_FILE" ]; then
pid=""
IFS= read -r pid < "$WEB_PID_FILE" || true
if [ -n "$pid" ] && kill -0 "$pid" 2>/dev/null; then
echo "mailcat web running: $pid"
echo "url: http://$WEB_HOST:$WEB_PORT/"
exit 0
fi
echo "mailcat web not running: stale pid file ($pid)"
exit 1
fi
echo "mailcat web not running"
echo "logs: $LOG_DIR/web.out"
exit 1
+41
View File
@@ -0,0 +1,41 @@
#!/bin/sh
set -eu
PID_FILE="/share/homes/mailcat/mailcat/run/mailcat.pid"
RM="/bin/rm"
if [ ! -f "$PID_FILE" ]; then
echo "mailcat not running: no pid file"
exit 0
fi
pid=""
IFS= read -r pid < "$PID_FILE" || true
if [ -z "$pid" ]; then
"$RM" -f "$PID_FILE"
echo "mailcat not running: empty pid file removed"
exit 0
fi
if kill -0 "$pid" 2>/dev/null; then
kill "$pid"
timeout=20
while [ "$timeout" -gt 0 ] && kill -0 "$pid" 2>/dev/null; do
sleep 1
timeout=$((timeout - 1))
done
if kill -0 "$pid" 2>/dev/null; then
echo "mailcat still running after SIGTERM, sending SIGKILL: $pid"
kill -KILL "$pid" 2>/dev/null || true
timeout=5
while [ "$timeout" -gt 0 ] && kill -0 "$pid" 2>/dev/null; do
sleep 1
timeout=$((timeout - 1))
done
if kill -0 "$pid" 2>/dev/null; then
echo "mailcat still running after SIGKILL: $pid"
exit 1
fi
fi
fi
"$RM" -f "$PID_FILE"
echo "mailcat stopped"
+41
View File
@@ -0,0 +1,41 @@
#!/bin/sh
set -eu
WEB_PID_FILE="/share/homes/mailcat/mailcat/run/mailcat_web.pid"
RM="/bin/rm"
if [ ! -f "$WEB_PID_FILE" ]; then
echo "mailcat web not running: no pid file"
exit 0
fi
pid=""
IFS= read -r pid < "$WEB_PID_FILE" || true
if [ -z "$pid" ]; then
"$RM" -f "$WEB_PID_FILE"
echo "mailcat web not running: empty pid file removed"
exit 0
fi
if kill -0 "$pid" 2>/dev/null; then
kill "$pid"
timeout=20
while [ "$timeout" -gt 0 ] && kill -0 "$pid" 2>/dev/null; do
sleep 1
timeout=$((timeout - 1))
done
if kill -0 "$pid" 2>/dev/null; then
echo "mailcat web still running after SIGTERM, sending SIGKILL: $pid"
kill -KILL "$pid" 2>/dev/null || true
timeout=5
while [ "$timeout" -gt 0 ] && kill -0 "$pid" 2>/dev/null; do
sleep 1
timeout=$((timeout - 1))
done
if kill -0 "$pid" 2>/dev/null; then
echo "mailcat web still running after SIGKILL: $pid"
exit 1
fi
fi
fi
"$RM" -f "$WEB_PID_FILE"
echo "mailcat web stopped"