NextCloud Update: Difference between revisions

From WikiMLT
 
Line 24: Line 24:
</syntaxhighlight>
</syntaxhighlight>


Bring all together
=== Bring all together ===
<syntaxhighlight lang="shell" class="code-continue mlw-shell-gray">
/usr/local/bin/cloud-update-platform.sh
</syntaxhighlight>
<syntaxhighlight lang="bash" line="1" class="code-continue mlw-shell-gray">
#!/bin/bash
 
: ${NC_ROOT:="/var/www/cloud.metalevel.tech"} # The DocumentRoot directory of the wiki
: ${NC_OWNER:="www-data"}                    # The user that owns the $IP directory
 
LOG_FILE=$(cat "${NC_ROOT}/config/config.php" | grep -0 logfile | sed -r 's/^.*=>\s+['\''"](.*)['\''"].*$/\1/')


<syntaxhighlight lang="shell" line="1" class="code-continue mlw-shell-gray">
# Update the NextCloud platform itself
NC_ROOT="/var/www/cloud.metalevel.tech"
sudo -u "${NC_OWNER}" \
</syntaxhighlight>
php --define apc.enable_cli=1 "${NC_ROOT}/updater/updater.phar"
<syntaxhighlight lang="shell" line="1" class="code-continue mlw-shell-gray">
 
NC_OWNER="www-data"
# Update all apps
sudo -u "${NC_OWNER}" \
php --define apc.enable_cli=1 "${NC_ROOT}/occ" app:update --all
 
# Add the missing database indexes:
sudo -u "${NC_OWNER}" \
php --define apc.enable_cli=1 "${NC_ROOT}/occ" db:add-missing-indices
 
sudo -u "${NC_OWNER}" rm "$LOG_FILE"
</syntaxhighlight>
</syntaxhighlight>



Latest revision as of 12:21, 24 February 2024

Us­ing the com­mand line based up­dater

Up­date the NextCloud app it­self – the com­mand can al­so be used to com­plete a stuck web up­date.

NC_ROOT="/var/www/cloud.metalevel.tech"
NC_OWNER="www-data"
sudo -u "${NC_OWNER}" \
php --define apc.enable_cli=1 "${NC_ROOT}/updater/updater.phar"

In or­der to up­date all apps from CLI use:

sudo -u "${NC_OWNER}" \
php --define apc.enable_cli=1 "${NC_ROOT}/occ" app:update --all

Fur­ther you may need to add the miss­ing data­base in­dex­es:

sudo -u "${NC_OWNER}" \
php --define apc.enable_cli=1 "${NC_ROOT}/occ" db:add-missing-indices

Bring all to­geth­er

/usr/local/bin/cloud-update-platform.sh
#!/bin/bash

: ${NC_ROOT:="/var/www/cloud.metalevel.tech"} # The DocumentRoot directory of the wiki
: ${NC_OWNER:="www-data"}                     # The user that owns the $IP directory

LOG_FILE=$(cat "${NC_ROOT}/config/config.php" | grep -0 logfile | sed -r 's/^.*=>\s+['\''"](.*)['\''"].*$/\1/')

# Update the NextCloud platform itself
sudo -u "${NC_OWNER}" \
	php --define apc.enable_cli=1 "${NC_ROOT}/updater/updater.phar"

# Update all apps
sudo -u "${NC_OWNER}" \
	php --define apc.enable_cli=1 "${NC_ROOT}/occ" app:update --all

# Add the missing database indexes:
sudo -u "${NC_OWNER}" \
	php --define apc.enable_cli=1 "${NC_ROOT}/occ" db:add-missing-indices

sudo -u "${NC_OWNER}" rm "$LOG_FILE"

Ref­er­ences

Han­dle some is­sues

Helper scripts to de­bug a bro­ken ap­pli­ca­tion

Out­put the en­abled ap­pli­ca­tions to a file.

sudo -u "${NC_OWNER}" \
php --define apc.enable_cli=1 "${NC_ROOT}/occ" app:list | \
sed '/^Disabled:/,$d' | sed -E 's/^\s+-\s(.*):.*$/\1/' | sed '/^Enabled/d' \
> ~/tmp/nc.enabled-apps.txt

Dis­able (or at­tempt to) the en­abled apps.

while IFS= read -r EXT; \
do \
    sudo -u "${NC_OWNER}" php --define apc.enable_cli=1 "${NC_ROOT}/occ" app:disable "$EXT"; \
done < ~/tmp/nc.enabled-apps.txt

En­able (or at­tempt to) the pre­vi­ous­ly en­abled apps.

#!/usr/bin/zsh
while IFS= read -r EXT; \
do \
    read -s -k "?Press Enter to enable: ${EXT}"; echo; \
    sudo -u "${NC_OWNER}" php --define apc.enable_cli=1 "${NC_ROOT}/occ" app:enable "$EXT"; \
done < ~/tmp/nc.enabled-apps.txt

Web work­er is­sue tem­po­rary so­lu­tion