mirror of
https://gitlab.com/hacklab01/pivilion.git
synced 2026-08-06 16:08:22 +00:00
31 lines
1 KiB
Bash
Executable file
31 lines
1 KiB
Bash
Executable file
#!/bin/bash
|
|
set -euo pipefail
|
|
source /usr/local/lib/pivilion/common.sh
|
|
[ "$(id -u)" -eq 0 ] || exec sudo "$0" "$@"
|
|
pivilion_load_config
|
|
|
|
backup_gallery() {
|
|
local destination="$PIVILION_DIR/backups/gen-$(date +%Y%m%d-%H%M%S)"
|
|
install -d -m 0755 -o "$PIVILION_USER" -g "$PIVILION_GROUP" "$PIVILION_DIR/backups"
|
|
cp -a "$PIVILION_WEBROOT/gen" "$destination"
|
|
chown -R "$PIVILION_USER:$PIVILION_GROUP" "$destination"
|
|
echo "Gallery backup: $destination"
|
|
}
|
|
|
|
select choice in "Enable" "Disable"; do
|
|
case "$choice" in
|
|
Enable)
|
|
backup_gallery
|
|
a2ensite 000-upload.conf >/dev/null
|
|
systemctl reload apache2
|
|
install -d -m 2775 -o www-data -g www-data "$PIVILION_WEBROOT/gen/upload"
|
|
echo "Generator enabled at http://<device-address>:81/"
|
|
break ;;
|
|
Disable)
|
|
a2dissite 000-upload.conf >/dev/null || true
|
|
systemctl reload apache2
|
|
echo "Generator disabled."
|
|
break ;;
|
|
*) echo "Choose 1 or 2." ;;
|
|
esac
|
|
done
|