146 lines
3.9 KiB
Bash
Executable File
146 lines
3.9 KiB
Bash
Executable File
#!/usr/bin/env bash
|
|
|
|
# Dependency to other seqs
|
|
# - mysql.sh (soft; Missing informational output)
|
|
|
|
readonly toolName="nextcloud"
|
|
localOcc=("echo" "occ not found!")
|
|
sq_config=0
|
|
|
|
seq_config() {
|
|
if initSeqConfig "${seq_configName:?}" "${seq_configTemplate:?}" ; then
|
|
sq_config=1
|
|
fi
|
|
localOcc=( sudo -u $sc_ncServerUser php "$(escpath "$sc_ncInstallDir/occ")" )
|
|
}
|
|
|
|
step_1_info() { echo "Execute occ command"; }
|
|
step_1_options() { echo "[OCC ARGS]"; }
|
|
step_1_alias() { echo "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() { echo "upgrade"; }
|
|
step_20() {
|
|
if (( ! sq_config )) ; then
|
|
error -e "No configuration found to determine installation directory"
|
|
return 1
|
|
fi
|
|
exe cd "$sc_ncInstallDir"
|
|
exe sudo -u www-data php "$ncInstaller"
|
|
}
|
|
ncInstaller="updater/updater.phar"
|
|
|
|
step_21_info() { echo "Running recommended post upgrade procedure"; }
|
|
step_21_alias() { echo "postupgrade"; }
|
|
step_21() {
|
|
step occ db:convert-filecache-bigint
|
|
step occ db:add-missing-indices
|
|
step occ db:add-missing-columns
|
|
step occ db:add-missing-primary-keys
|
|
step occ app:update --all
|
|
}
|
|
|
|
step_102_info() { echo "Delete IP from bruteforce table"; }
|
|
step_102_options() { echo "<NC DATABASE> <IPV4 ADDRESS>"; }
|
|
step_102_alias() { echo "bruteforceRemoveIP"; }
|
|
step_102() {
|
|
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
|
|
error -e "No database provided"
|
|
if [ -f "${seq_origin}/mysql.sh" ] ; then
|
|
echo " [I] Available mysql databases:"
|
|
"${seq_origin}/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
|
|
error -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_104_info() { echo "Reset and rescan the music library in the background for one user"; }
|
|
step_104_options() { echo "<USER>"; }
|
|
step_104_alias() { echo "audioreset"; }
|
|
step_104() {
|
|
shift
|
|
local ncUser=$1
|
|
|
|
if [ -z "$ncUser" ] ; then
|
|
error -e "Reset only for single user"
|
|
return 1
|
|
fi
|
|
|
|
exep "${localOcc[@]} audioplayer:reset $ncUser > /var/log/ncAudioRescan.log"
|
|
info "Rescan audioplayer database for user $ncUser"
|
|
exep "${localOcc[@]} audioplayer:scan -vvvv $ncUser >> /var/log/ncAudioRescan.log &"
|
|
}
|
|
|
|
step_106_info() { echo "Scan the music library"; }
|
|
step_106_options() { echo "<USER>"; }
|
|
step_106_alias() { echo "audioscan"; }
|
|
step_106() {
|
|
shift
|
|
local ncUser="${1:-}"
|
|
|
|
if [ -z "$ncUser" ] ; then
|
|
error -e "Reset only for single user"
|
|
return 1
|
|
fi
|
|
|
|
exe "${localOcc[@]}" audioplayer:scan -vvvv $ncUser
|
|
}
|
|
|
|
step_110_info() { echo "Reset picture preview folder"; }
|
|
step_110_alias() { echo "resetpreview"; }
|
|
step_110() {
|
|
if [ -e "${sc_ncDataDir}" ]; then
|
|
exe rm -rf "${sc_ncDataDir}/appdata_"*"/preview/"*
|
|
|
|
info "Rescan app data folder"
|
|
exep "${localOcc[@]} files:scan-app-data &"
|
|
else
|
|
error -e "Nextcloud data direcotry $sc_ncDataDir not found"
|
|
return 1
|
|
fi
|
|
}
|
|
|
|
step_200_alias() { echo "notes"; }
|
|
step_200() {
|
|
color green
|
|
cat<<NOTES_END
|
|
# Recommended preview settings
|
|
[$sc_ncInstallDir/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
|
|
}
|
|
|
|
# shellcheck disable=SC2034 # Appears unused
|
|
readonly sqr_minVersion=16
|
|
# shellcheck disable=SC1091 # Don't follow this source
|
|
. /usr/local/bin/sequencer.sh
|