Skip to content
Snippets Groups Projects
Verified Commit 6dc7f53d authored by Maarten de Waard's avatar Maarten de Waard :angel:
Browse files

improve setup apps script

parent faf93653
No related branches found
No related tags found
1 merge request!300Resolve "Migrate jobs to postStartCommand"
Pipeline #31444 canceled with stages
in 39 minutes
......@@ -83,11 +83,11 @@ This chart adds a "postStart" command to the Nextcloud pod, that installs apps
integration with ONLYOFFICE as well as the Stackspin OIDC provider.
Kubernetes postStart commands do not log to the pod log. Instead, the script
creates its own log in `/var/www/html/data/postStart.log`. This means that even
if you can't `exec` into the pod (because something is failing), you can see the
logs inside the `data` folder in the PVC. Often, if the `postStart` command
fails, you can also see the problem by running `kubectl describe pod <nextcloud
pod>`.
creates its own log in `/var/www/html/tmp/postStart<date>.log`. This means that
even if you can't `exec` into the pod (because something is failing), you can
see the logs inside the `data` folder in the PVC. Often, if the `postStart`
command fails, you can also see the problem by running `kubectl describe pod
<nextcloud pod>`.
## Apps
......
......@@ -26,7 +26,9 @@ data:
# * Persists and loads the config.json config file
# * Updates database indices, columns, keys, etc needed after NC upgrade
# * Writes a log to /var/www/html/data/postStart.log
exec 1>/var/www/html/data/postStart.log
exec > /var/www/tmp/postStart-$(date +"%s").log
exec 2> /var/www/tmp/postStart-$(date +"%s")_error.log
# Copied from the NC docker entrypoint to run OCC commands
run_as() {
......@@ -39,32 +41,41 @@ data:
echo "STARTING SETUP-APPS.SH"
set -ev
# Debug: place the json file in a persistent location for reuse
cp /var/local/config.json /var/www/html/
occ="/var/www/html/occ"
count=0
limit=10
# There's a nextcloud setup process. First, wait for `occ` to exist
until [ -e $occ ]; do
echo "$occ doesn't exist yet..."
sleep 1
until [ -f "$occ" ] || [ "$count" -gt "$limit" ]
do
count=$((count+1))
wait=$((count*10))
echo "$occ doesn't exist yet, waiting $wait seconds"
sleep $wait
done
echo "$occ now exists!!!"
lock=/var/www/html/nextcloud-init-sync.lock
# If Nextcloud is still installing files at this point, a "lock file" will
# exist, wait until that's gone too before running our own setup:
until [ ! -f "$lock" ]
count=0
# As soon as the $occ command exist, we know that we can run occ, but
# Nextcloud might still be initializing, a "lock file" will exist, wait
# until that's gone before running our own setup:
until run_as "php occ status --output json" | grep '"installed":true' || [ "$count" -gt "$limit" ]
do
echo "Nextcloud lock file $lock still exists..."
sleep 1
count=$((count+1))
wait=$((count*10))
echo "Nextcloud is not installed yet. Waiting $wait seconds..."
sleep $wait
done
echo "Nextcloud lock file $lock is gone, we can do our thing!"
set -e
# Enable app store so we can run `install` and `enable` commands
run_as "php $occ config:system:set appstoreenabled --type boolean --value true"
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment