33 lines
1.6 KiB
Bash
Executable File
33 lines
1.6 KiB
Bash
Executable File
#!/bin/bash
|
|
set -euo pipefail
|
|
|
|
PLUGIN_DIR="$(cd "$(dirname "$0")/.." && pwd)"
|
|
|
|
# Ensure expected permissions and ownership so DirectAdmin can update plugin.conf.
|
|
if [ "$(id -u)" -eq 0 ]; then
|
|
chown -R diradmin:diradmin "$PLUGIN_DIR" || true
|
|
else
|
|
echo "borg-restore: warning: not running as root, cannot chown to diradmin" >&2
|
|
fi
|
|
|
|
chmod 755 "$PLUGIN_DIR" "$PLUGIN_DIR/hooks" "$PLUGIN_DIR/user" "$PLUGIN_DIR/scripts" "$PLUGIN_DIR/images" || true
|
|
chmod 755 "$PLUGIN_DIR/user/index.html" "$PLUGIN_DIR/scripts/install.sh" "$PLUGIN_DIR/scripts/uninstall.sh" "$PLUGIN_DIR/scripts/restore.sh" "$PLUGIN_DIR/scripts/worker.sh" || true
|
|
chmod 644 "$PLUGIN_DIR/plugin.conf" "$PLUGIN_DIR/hooks/user_txt.html" "$PLUGIN_DIR/plugin-settings.conf" "$PLUGIN_DIR/user/enhanced.css" "$PLUGIN_DIR/user/evolution.css" "$PLUGIN_DIR/images/user_icon.svg" || true
|
|
|
|
DATA_DIR="$PLUGIN_DIR/data"
|
|
mkdir -p "$DATA_DIR/jobs/pending" "$DATA_DIR/jobs/processing" "$DATA_DIR/jobs/done" "$DATA_DIR/logs" "$DATA_DIR/pids" "$DATA_DIR/cancel"
|
|
chmod 700 "$DATA_DIR" "$DATA_DIR/jobs" "$DATA_DIR/jobs/pending" "$DATA_DIR/jobs/processing" "$DATA_DIR/jobs/done" "$DATA_DIR/logs" "$DATA_DIR/pids" "$DATA_DIR/cancel" || true
|
|
if [ "$(id -u)" -eq 0 ]; then
|
|
chown -R diradmin:diradmin "$DATA_DIR" || true
|
|
fi
|
|
|
|
CRON_FILE="/etc/cron.d/borg-restore"
|
|
if [ "$(id -u)" -eq 0 ]; then
|
|
echo "* * * * * root /usr/local/directadmin/plugins/borg-restore/scripts/worker.sh >/dev/null 2>&1" > "$CRON_FILE"
|
|
chmod 644 "$CRON_FILE" || true
|
|
else
|
|
echo "borg-restore: warning: not running as root, cannot install cron job" >&2
|
|
fi
|
|
|
|
echo "borg-restore: install complete"
|