#!/usr/bin/env bash # Dependency to other seqs # - mysql.sh (soft; Missing informational output) toolName="nextcloud" localOcc=("echo" "occ not found!") # Get script working directory # (when called from a different directory) 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" seq_config() { ## or to use sequencer api: initSeqConfig "$sq_configFileName" "$sq_configFileTemplate" if [ $? -eq 0 ] ; then sq_config=1 fi localOcc=( sudo -u $sc_ncServerUser php "$(escpath "$sc_ncInstallDir/occ")" ) } step_1_info() { echoinfoArgs "[OCC ARGS]" echo "Execute occ command" } 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 -eq 0 ] ; 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() { echoinfoArgs " "; echo "Delete IP from bruteforce table"; } 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 "${sq_dir}/mysql.sh" ] ; then echo " [I] Available mysql databases:" "${sq_dir}/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() { echoinfoArgs ""; echo "Reset and rescan the music library in the background for one 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() { echoinfoArgs ""; echo "Scan the music library"; } 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<