diff --git a/elabctl.conf b/elabctl.conf index 4b782ba..4bf2988 100644 --- a/elabctl.conf +++ b/elabctl.conf @@ -13,6 +13,10 @@ # where do we store the MySQL database and the uploaded files? #declare DATA_DIR='/var/elabftw' +# optional, set a different path for uploaded files +# default is DATA_DIR/web +#declare UPLOAD_DIR=/path/to/uploaded_files + # name of the web container (default: elabftw) #declare ELAB_WEB_CONTAINER_NAME='elabftw' @@ -46,3 +50,4 @@ declare BORG_KEEP_MONTHLY=6 # optional, only set if required (rsync.net) #declare BORG_REMOTE_PATH=borg1 + diff --git a/elabctl.sh b/elabctl.sh index 0c12e8e..ac59f5e 100755 --- a/elabctl.sh +++ b/elabctl.sh @@ -15,6 +15,8 @@ declare DUMP_DELETE_DAYS=+0 declare CONF_FILE='/etc/elabftw.yml' # default data directory declare DATA_DIR='/var/elabftw' +# allow override default web subfolder in data dir +declare UPLOAD_DIR="${DATA_DIR}/web" # default conf file is no conf file declare ELABCTL_CONF_FILE="using default values (no config file found)" @@ -58,7 +60,7 @@ function borg-backup export BORG_REMOTE_PATH="${BORG_REMOTE_PATH}" fi # we add to the borg the uploaded files (web directory) and also the backup dir containing dumps of MySQL - "${BORG_PATH}" create "::$(hostname)-$(date +%F_%H-%M)" "${DATA_DIR}/web" "${BACKUP_DIR}" + "${BORG_PATH}" create "::$(hostname)-$(date +%F_%H-%M)" "${UPLOAD_DIR}" "${BACKUP_DIR}" "${BORG_PATH}" prune --keep-daily="${BORG_KEEP_DAILY:-14}" --keep-monthly="${BORG_KEEP_MONTHLY:-6}" } @@ -179,6 +181,7 @@ function info { echo "Backup directory: ${BACKUP_DIR}" echo "Data directory: ${DATA_DIR}" + echo "Upload directory: ${UPLOAD_DIR}" echo "Web container name: ${ELAB_WEB_CONTAINER_NAME}" echo "MySQL container name: ${ELAB_MYSQL_CONTAINER_NAME}" echo "" @@ -228,7 +231,8 @@ function install dialog --colors --backtitle "$backtitle" --title "$title" --yes-label "Looks good to me" --no-label "Download example conf and quit" --yesno "\nHere is what will happen:\n The main configuration file will be created at: \Z4${CONF_FILE}\Zn\n - A directory holding elabftw data (mysql + uploaded files) will be created at: \Z4${DATA_DIR}\Zn\n + A directory holding elabftw MySQL data will be created at: \Z4${DATA_DIR}/mysql\Zn\n + A directory holding elabftw uploaded files will be created at: \Z4${UPLOAD_DIR}\Zn\n The backups will be created at: \Z4${BACKUP_DIR}\Zn\n\n If you wish to change these settings, quit now and edit the file \Z4elabctl.conf\Zn" 0 0 if [ $? -eq 1 ]; then @@ -302,12 +306,12 @@ function install set -e echo 40 | dialog --backtitle "$backtitle" --title "$title" --gauge "Creating folder structure. You will be asked for your password (bottom left of the screen)." 20 80 - sudo mkdir -pv ${DATA_DIR}/{web,mysql} - sudo chmod -Rv 700 ${DATA_DIR} + sudo mkdir -pv ${DATA_DIR}/mysql ${UPLOAD_DIR} + sudo chmod -Rv 700 ${DATA_DIR} ${UPLOAD_DIR} echo "Executing: sudo chown -v 999:999 ${DATA_DIR}/mysql" sudo chown -v 999:999 ${DATA_DIR}/mysql - echo "Executing: sudo chown -v 101:101 ${DATA_DIR}/web" - sudo chown -v 101:101 ${DATA_DIR}/web + echo "Executing: sudo chown -v 101:101 ${UPLOAD_DIR}" + sudo chown -v 101:101 ${UPLOAD_DIR} sleep 2 echo 50 | dialog --backtitle "$backtitle" --title "$title" --gauge "Grabbing the docker-compose configuration file" 20 80