Files
shell_sequencer/seqs/nextcloud.sh

118 lines
3.4 KiB
Bash
Executable File

#!/bin/bash
# Dependency to other seqs
# - mysql.sh (soft; Missing informational output)
toolName="nextcloud"
# 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"
step_config() {
## or to use sequencer api:
initSeqConfig "$CONFIG_FILE_NAME" "$CONFIG_FILE_TEMPLATE"
if [ $? -eq 0 ] ; then
CONFIG=1
fi
}
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
echoerr " [E] No configuration found to determine installation directory"
return 1
fi
exe cd "$NC_INSTALL_DIR"
exe sudo -u www-data php "$ncInstaller"
}
ncInstaller="updater/updater.phar"
step_100_info() { echoinfoArgs "<NC DATABASE> <IPV4 ADDRESS>"; echo "Delete IP from bruteforce table"; }
step_100_alias() { ALIAS="bruteforceRemoveIP"; }
step_100() {
shift
local ncdb=
local ip=
local ipregex='^[0-2]*[0-9]{1,2}\.[0-2]*[0-9]{1,2}\.[0-2]*[0-9]{1,2}\.[0-2]*[0-9]{1,2}$'
if [ -z $1 ] ; then
echoerr " [E] No database provided"
if [ -f "${WDIR}/mysql.sh" ] ; then
echo " [I] Available mysql databases:"
"${WDIR}/mysql.sh" -qq listdb
fi
return 1
else
ncdb="$1"
fi
# Check if string looks like ipv4 address
if [[ "$2" =~ $ipregex ]] ; then
ip="$2"
else
echoerr " [E] No valid IP:PORT detected: $2"
return 1
fi
exe mysql -u root -D ${ncdb} -e 'delete FROM oc_bruteforce_attempts WHERE IP="'${ip}'";'
endReturn -o $? "Error deleting ip $ip"
}
step_102_info() { echoinfoArgs "<USER>"; echo "Reset and rescan the music library in the background for one user"; }
step_102_alias() { ALIAS="audioreset"; }
step_102() {
shift
local ncUser=$1
local lOcc="sudo -u www-data php $NC_INSTALL_DIR/occ"
if [ -z "$ncUser" ] ; then
echoerr " [E] Reset only for single user"
return 1
fi
exep "sudo -u www-data php \"$NC_INSTALL_DIR/occ\" audioplayer:reset $ncUser > /var/log/ncAudioRescan.log"
echoseq " [I] Rescan audioplayer database for user $ncUser"
exep "sudo -u www-data php \"$NC_INSTALL_DIR/occ\" audioplayer:scan -vvvv $ncUser >> /var/log/ncAudioRescan.log &"
}
step_104_info() { echo "Reset picture preview folder"; }
step_104_alias() { ALIAS="resetpreview"; }
step_104() {
local lOcc="sudo -u www-data php \"$NC_INSTALL_DIR/occ\""
if [ -e "${NC_DATA_DIR}" ]; then
exe rm -rf "${NC_DATA_DIR}/appdata_"*"/preview/"*
echoseq " [I] Rescan app data folder"
exep "$lOcc files:scan-app-data &"
else
echoerr " [E] Nextcloud data direcotry $NC_DATA_DIR not found"
return 1
fi
}
step_200_info() { echo "Notes"; }
step_200_alias() { ALIAS="notes"; }
step_200() {
outColor green
cat<<NOTES_END
# Recommended preview settings
[$NC_INSTALL_DIR/config/config.php]
occ config:app:set previewgenerator squareSizes --value="32 256"
occ config:app:set previewgenerator widthSizes --value="256 384"
occ config:app:set previewgenerator heightSizes --value="256"
occ config:system:set preview_max_x --value 2048
occ config:system:set preview_max_y --value 2048
occ config:system:set jpeg_quality --value 60
occ config:app:set preview jpeg_quality --value="60"
NOTES_END
}
VERSION_SEQREV=14
. /usr/local/bin/sequencer.sh