From 05431b716d259412f49b2bce825e072f16aeeeb7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Kov=C3=A1cs=20Zolt=C3=A1n?= Date: Wed, 5 Mar 2025 20:24:53 +0100 Subject: [PATCH] New recipe added: staticweb_filebrowser. --- .metadata | Bin 9632 -> 10891 bytes .../config/filebrowser-config | 1 + .../staticweb_filebrowser/docker-compose.yml | 28 ++++++ .../volumes/filebrowser_data/database.db | 0 .../volumes/filebrowser_data/filebrowser.json | 8 ++ .../storage/volumes/staticweb/index.html | 10 ++ .../tools/backup.d/storage_backup.sh | 93 ++++++++++++++++++ 7 files changed, 140 insertions(+) create mode 120000 .recipes/staticweb_filebrowser/config/filebrowser-config create mode 100644 .recipes/staticweb_filebrowser/docker-compose.yml create mode 100644 .recipes/staticweb_filebrowser/storage/volumes/filebrowser_data/database.db create mode 100644 .recipes/staticweb_filebrowser/storage/volumes/filebrowser_data/filebrowser.json create mode 100644 .recipes/staticweb_filebrowser/storage/volumes/staticweb/index.html create mode 100644 .recipes/staticweb_filebrowser/tools/backup.d/storage_backup.sh diff --git a/.metadata b/.metadata index 24ace8dc218574be31d75b0e49754c41407ddf31..337b2e08760b3d02897765529263c4f3ec61b584 100644 GIT binary patch delta 1122 zcmZ4B-5t8Yfzi0QB(WqjxjZ!~J}omRHK{1Syg0RpA-gI+ClgAtEjf|S00h3~nY$2Vt0DTuCHX~(>8bi<`8lPzsl`A()G8F?w=IGgZyCfV z4>JBI)OhyI1`;&?Anbldmq@0?rzDmn>Vt@+#Nt%F zlq3{$B^E<`Ce67>2jsKK4;ZB;&ynJoJVBUsvKo*-jpG&$->y|q;6aWSpmyiU^EhWr zKEuX|LrXlj9*d3V#PrDrIYcJgF-dIpJav%y=STA)ByJB{T@wma6JN1Fw)@bhEHb8M_T4d!WPtmIQfdAtd4W>6IBk zO{rFvu3rZgPBpuu01*a}dir`qMKU~>A_Xcq{i1jn6sRCmVc@4Dhy}J|a+SE;SbHa}24zz6^$z>Gxz delta 227 zcmeAUUEsaJfpPK&CZWj_)C4ChNU}~2;FI2bjPVLgkbScN%PdBr@C7H*8GvBfK?M^K zy`gb4Kbsx% + + + + Test page + + +

It works!

+ + diff --git a/.recipes/staticweb_filebrowser/tools/backup.d/storage_backup.sh b/.recipes/staticweb_filebrowser/tools/backup.d/storage_backup.sh new file mode 100644 index 0000000..7334e22 --- /dev/null +++ b/.recipes/staticweb_filebrowser/tools/backup.d/storage_backup.sh @@ -0,0 +1,93 @@ +#!/bin/bash +# +# A service script to backup the web storage of a static website. +# Creates a tarball in $BASE_DIR/storage/backups/tarballs folder +# (by default). Optional parameters may change the source and/or +# target folder. +# +# Author: Kovács Zoltán +# License: GNU/GPL 3+ https://www.gnu.org/licenses/gpl-3.0.en.html +# 2025-01-22 Initial version. + +# Accepted environment variables and their defaults. +# +PAR_BASEDIR=${PAR_BASEDIR:-""} # Service's base folder +PAR_BACKUPDIR=${PAR_BACKUPDIR:-""} # Folder to dump within +PAR_SOURCEDIR=${PAR_SOURCEDIR:-""} # Folder to save + +# Messages (maybe overridden by configuration). +# +MSG_MISSINGDEP="Fatal: missing dependency" +MSG_NONREAD="The source directory isn't readable" +MSG_NONWRITE="The target directory isn't writable" + +# Other initialisations. +# +BACKUPDIR="storage/backups/tarballs" # Folder to dump within +SOURCEDIR="storage/volumes/staticweb" # Folder to backup +USER=${USER:-LOGNAME} # Fix for cron enviroment only +YMLFILE="docker-compose.yml" + +# Checks the dependencies. +# +TR=$(which tr 2>/dev/null) +if [ -z "$TR" ]; then echo "$MSG_MISSINGDEP tr."; exit 1 ; fi +for item in basename cat cut date dirname hostname pwd tar +do + if [ -n "$(which $item)" ] + then export $(echo $item | "$TR" '[:lower:]' '[:upper:]' | "$TR" '-' '_')=$(which $item) + else echo "$MSG_MISSINGDEP $item." >&2; exit 1; fi +done +# All dependencies are available via "$THECOMMAND" (upper case) call. + +# Where I'm? +# https://gist.github.com/TheMengzor/968e5ea87e99d9c41782 +SOURCE="$0" +while [ -h "$SOURCE" ]; do + # resolve $SOURCE until the file is no longer a symlink + SCRPATH="$( cd -P "$("$DIRNAME" "$SOURCE" )" && echo "$PWD" )" #" + SOURCE="$("$READLINK" "$SOURCE")" + # if $SOURCE was a relative symlink, we need to resolve it + # relative to the path where the symlink file was located + [[ $SOURCE != /* ]] && SOURCE="$SCRPATH/$SOURCE" +done; SCRPATH="$( cd -P "$("$DIRNAME" "$SOURCE" )" && echo "$PWD" )" #" + +# Searches the base folder, containing a docker-compose.yml file. +# +# Called from the base folder (./)? +BASE_DIR="$PAR_BASEDIR" +TEST_DIR="$SCRPATH" +[[ -z "$BASE_DIR" ]] && [[ -r "$TEST_DIR/$YMLFILE" ]] && BASE_DIR="$TEST_DIR" +# Called from ./tools? +TEST_DIR="$("$DIRNAME" "$TEST_DIR")" +[[ -z "$BASE_DIR" ]] && [[ -r "$TEST_DIR/$YMLFILE" ]] && BASE_DIR="$TEST_DIR" +# Called from ./tools/*.d? +TEST_DIR="$("$DIRNAME" "$TEST_DIR")" +[[ -z "$BASE_DIR" ]] && [[ -r "$TEST_DIR/$YMLFILE" ]] && BASE_DIR="$TEST_DIR" +# On failure gives it up here. +if [ -z "$BASE_DIR" -o ! -r "$BASE_DIR/$YMLFILE" ]; then + echo "$MSG_MISSINGYML" >&2; exit 1 +fi +# Sets the absolute paths. +BACKUPDIR="${PAR_BACKUPDIR:-$BASE_DIR/$BACKUPDIR}" +SOURCEDIR="${PAR_SOURCEDIR:-$BASE_DIR/$SOURCEDIR}" + +# The dump target folder must be writable. +# +[[ ! -w "$BACKUPDIR" ]] \ +&& echo "$MSG_NONWRITE: $BACKUPDIR" >&2 && exit 1 + +# The source folder must be readable. +# +[[ ! -r "$SOURCEDIR" ]] \ +&& echo "$MSG_NONREAD: $SOURCEDIR" >&2 && exit 1 + +# Tries the FS backup. +# +if [ -w "$BACKUPDIR" ]; then + BACKUP_NAME=$("$BASENAME" "$SOURCEDIR").$("$DATE" '+%Y%m%d_%H%M%S').$("$HOSTNAME") + (cd $SOURCEDIR; "$TAR" cz . \ + > "$BACKUPDIR/$BACKUP_NAME.tgz" 2>>"$BACKUPDIR/$BACKUP_NAME.log") +fi + +# That's all, Folks! :)