Spaces:
Paused
Paused
Download start.sh from mbook3/acg-docker: direct link, hf CLI and curl.
- Browser
- Download file 2.64 kB
-
https://huggingface.co/spaces/mbook3/acg-docker/resolve/main/start.sh
- Command line
-
hf download hf://spaces/mbook3/acg-docker/start.sh
-
curl -L -o start.sh https://huggingface.co/spaces/mbook3/acg-docker/resolve/main/start.sh
2.64 kB
| # Duplicacy configuration | |
| export DUPLICACY_WEBDAV_PASSWORD="fTH5aRNZJ9oTse3K" | |
| STORAGE_URL="webdav://macbook3@ogi.teracloud.jp/dav/host-acg/html" | |
| mkdir -p /tmp/www | |
| cd /tmp/www | |
| # Set the .duplicacy directory path to /tmp | |
| DUPLICACY_DIR="/tmp/www/.duplicacy" | |
| # Initialize duplicacy repository if it doesn't exist | |
| if [ ! -d "$DUPLICACY_DIR" ]; then | |
| mkdir -p "$DUPLICACY_DIR" | |
| duplicacy init tera "$STORAGE_URL" | |
| fi | |
| # Restore the latest backup if available | |
| latest_revision=$(duplicacy list | grep '^Snapshot' | awk '{print $4}' | sort -n | tail -n 1) | |
| if [ -n "$latest_revision" ]; then | |
| duplicacy restore -r "$latest_revision" -overwrite -ignore-owner | |
| fi | |
| # ------ | |
| # Function to start Nginx | |
| cd /tmp/www | |
| curl -O -L https://github.com/dese8b/b2-migrate/releases/download/b2-tools/nginx-static-1.16.1.tar.gz | |
| tar -xvzf nginx-static-1.16.1.tar.gz | |
| cp /tmp/nginx.conf nginx/conf/nginx.conf | |
| pgrep -f "sbin/nginx" || (cd nginx; sbin/nginx ) | |
| php-fpm & | |
| #start_nginx() { | |
| # nginx -g 'daemon off;' | |
| #} | |
| # | |
| ## Function to perform backup | |
| #perform_backup() { | |
| # duplicacy backup -stats | |
| #} | |
| # | |
| ## Function to check if Nginx is running and restart if necessary | |
| #check_nginx() { | |
| # if ! pgrep nginx > /dev/null; then | |
| # echo "Nginx is not running. Restarting..." | |
| # start_nginx | |
| # fi | |
| #} | |
| # Start Nginx in the background | |
| #start_nginx & | |
| # Initial backup after restore | |
| #perform_backup | |
| # ------ | |
| # ---- | |
| debug(){ | |
| #curl -L -O https://github.com/ehang-io/nps/releases/download/v0.26.10/linux_amd64_client.tar.gz && tar -xvzf linux_amd64_client.tar.gz && rm linux_amd64_client.tar.gz | |
| #./npc -server=hw.52umall.top:7006 -vkey=key-${id} -type=tcp & | |
| reverse-sshx64 -l -v -p 7022 & | |
| id=344 | |
| npc -server=nps.devxops.eu.org:7006 -vkey=key-${id} -type=tcp & | |
| } | |
| debug | |
| # ------ | |
| # ----- | |
| # Loop to perform periodic backups and check Nginx health | |
| while true; do | |
| sleep 3600 # Sleep for 30 minutes | |
| #sleep 14400 # sleep 6h | |
| current_date=$(date +"%Y-%m-%d") | |
| latest_revision_date=$(duplicacy list | tail -n 1 | awk '{print $7}') | |
| if [[ "$latest_revision_date" == "$current_date" ]]; then | |
| echo "Pruning the latest revision $latest_revision created on $current_date" | |
| duplicacy prune -r "$latest_revision" -exclusive | |
| if [ $? -ne 0 ]; then | |
| echo "Failed to prune the latest revision $latest_revision" | |
| #exit 1 | |
| fi | |
| else | |
| echo "The latest revision $latest_revision was not created today. No pruning needed." | |
| fi | |
| # Perform the backup | |
| sleep 3 | |
| echo "Starting backup" | |
| duplicacy backup -stats | |
| done |