From 1914f83128d86ae45082c76c0d568a20df50c466 Mon Sep 17 00:00:00 2001 From: Martin Winkler Date: Fri, 22 Apr 2022 12:54:05 +0200 Subject: [PATCH] nextcloud - refactor variable names --- seqs/nextcloud.cfg.example | 5 ++-- seqs/nextcloud.sh | 55 +++++++++++++++++++------------------- 2 files changed, 30 insertions(+), 30 deletions(-) diff --git a/seqs/nextcloud.cfg.example b/seqs/nextcloud.cfg.example index 4df1d9f..bea9dda 100644 --- a/seqs/nextcloud.cfg.example +++ b/seqs/nextcloud.cfg.example @@ -1,4 +1,5 @@ # Configuration file for nextcloud sequence -NC_INSTALL_DIR="/var/www/nextcloud" -NC_DATA_DIR="${NC_INSTALL_DIR}/data" +sc_ncServerUser="www-data" +sc_ncInstallDir="/var/www/nextcloud" +sc_ncDataDir="${sc_ncInstallDir}/data" diff --git a/seqs/nextcloud.sh b/seqs/nextcloud.sh index 101251c..4213058 100755 --- a/seqs/nextcloud.sh +++ b/seqs/nextcloud.sh @@ -1,4 +1,4 @@ -#!/bin/bash +#!/usr/bin/env bash # Dependency to other seqs # - mysql.sh (soft; Missing informational output) @@ -8,43 +8,43 @@ localOcc=("echo" "occ not found!") # Get script working directory # (when called from a different directory) -WDIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >>/dev/null 2>&1 && pwd )" -CONFIG=0 -CONFIG_FILE_NAME="${toolName}.cfg" -CONFIG_FILE_TEMPLATE="$WDIR/${CONFIG_FILE_NAME}.example" +sq_dir="$( cd "$( dirname -- "$(realpath "${BASH_SOURCE[0]}")")" >>/dev/null 2>&1 && pwd )" +sq_config=0 +sq_configFileName="${toolName}.cfg" +sq_configFileTemplate="$sq_dir/${sq_configFileName}.example" step_config() { ## or to use sequencer api: - initSeqConfig "$CONFIG_FILE_NAME" "$CONFIG_FILE_TEMPLATE" + initSeqConfig "$sq_configFileName" "$sq_configFileTemplate" if [ $? -eq 0 ] ; then - CONFIG=1 + sq_config=1 fi - localOcc=( sudo -u www-data php "$(escpath "$NC_INSTALL_DIR/occ")" ) + localOcc=( sudo -u $sc_ncServerUser php "$(escpath "$sc_ncInstallDir/occ")" ) +} + +step_1_info() { + echoinfoArgs "[OCC ARGS]" + echo "Execute occ command" +} +step_1_alias() { ALIAS="occ"; } +step_1() { + shift + + exe "${localOcc[@]}" "$@" } step_20_info() { echo "Upgrade $toolName on command line to latest version of selected release channel"; } step_20_alias() { ALIAS="upgrade"; } step_20() { - if [ $CONFIG -eq 0 ] ; then + if [ $sq_config -eq 0 ] ; then echoerr " [E] No configuration found to determine installation directory" return 1 fi - exe cd "$NC_INSTALL_DIR" + exe cd "$sc_ncInstallDir" exe sudo -u www-data php "$ncInstaller" } ncInstaller="updater/updater.phar" -step_100_info() { - echoinfoArgs "[OCC ARGS]" - echo "Execute occ command" -} -step_100_alias() { ALIAS="occ"; } -step_100() { - shift - - exe "${localOcc[@]}" "$@" -} - step_102_info() { echoinfoArgs " "; echo "Delete IP from bruteforce table"; } step_102_alias() { ALIAS="bruteforceRemoveIP"; } step_102() { @@ -55,9 +55,9 @@ step_102() { if [ -z $1 ] ; then echoerr " [E] No database provided" - if [ -f "${WDIR}/mysql.sh" ] ; then + if [ -f "${sq_dir}/mysql.sh" ] ; then echo " [I] Available mysql databases:" - "${WDIR}/mysql.sh" -qq listdb + "${sq_dir}/mysql.sh" -qq listdb fi return 1 else @@ -108,24 +108,23 @@ step_106() { step_110_info() { echo "Reset picture preview folder"; } step_110_alias() { ALIAS="resetpreview"; } step_110() { - if [ -e "${NC_DATA_DIR}" ]; then - exe rm -rf "${NC_DATA_DIR}/appdata_"*"/preview/"* + if [ -e "${sc_ncDataDir}" ]; then + exe rm -rf "${sc_ncDataDir}/appdata_"*"/preview/"* echoseq " [I] Rescan app data folder" exep "${localOcc[@]} files:scan-app-data &" else - echoerr " [E] Nextcloud data direcotry $NC_DATA_DIR not found" + echoerr " [E] Nextcloud data direcotry $sc_ncDataDir not found" return 1 fi } -step_200_info() { echo "Notes"; } step_200_alias() { ALIAS="notes"; } step_200() { outColor green cat<