Fix: nextcloud notify script issues

This commit is contained in:
coolnsx
2025-09-17 16:22:20 +05:30
parent 269f944dd2
commit 8ca1d21f51
2 changed files with 18 additions and 19 deletions

View File

@@ -1,5 +1,4 @@
#!/bin/sh #!/bin/sh
set -e
NC_PATH="/var/www/html" NC_PATH="/var/www/html"
CONFIG="$NC_PATH/config/config.php" CONFIG="$NC_PATH/config/config.php"
@@ -8,33 +7,32 @@ SOCKET_PATH="${SOCKET_PATH:-/tmp/docker/notify_push.sock}"
# Clean shutdown handler # Clean shutdown handler
cleanup() { cleanup() {
echo "[*] Stopping notify_push..." echo "[*] Stopping notify_push..."
kill -TERM "$NOTIFY_PID" 2>/dev/null || true kill -TERM "$NOTIFY_PID" 2>/dev/null && echo "[*] notify push stopped.." || echo "Unable to Kill Notify Push.."
wait "$NOTIFY_PID" 2>/dev/null || true echo "[*] Bye"
} }
trap 'cleanup' TERM INT trap 'cleanup' TERM INT
echo "[*] Ensuring notify_push app is installed/updated..." echo "[*] Ensuring notify_push app is installed and enabled..."
php occ app:install notify_push 2>/dev/null || true php occ app:install notify_push || true
php occ app:update notify_push 2>/dev/null || true php occ app:enable notify_push || true
echo "[*] Starting notify_push binary..." echo "[*] Starting notify_push binary..."
"$NOTIFY_BIN" "$CONFIG" & "$NOTIFY_BIN" "$CONFIG" &
NOTIFY_PID=$! NOTIFY_PID=$!
# Wait for the socket to appear, max 30 seconds # Wait for the socket to appear, max 30 seconds
echo "[*] Waiting for notify_push to be ready..."
i=0 i=0
while [ $i -lt 30 ]; do while [ $i -lt 6 ]; do
if [ -S "$SOCKET_PATH" ]; then echo "[*] Waiting 5 seconds for notify_push to be ready... (try $i/6)"
echo "[*] Socket found, running occ notify_push:setup" sleep 5
php occ notify_push:setup "${NEXTCLOUD_URL}/push" || true if [ -S "$SOCKET_PATH" ]; then
break echo "[*] Socket found, running occ notify_push:setup"
fi php occ notify_push:setup "${NEXTCLOUD_URL}/push" || true
i=$((i+1)) break
sleep 1 fi
: $((i += 1))
done done
# Keep container alive while notify_push runs # Keep container alive while notify_push runs
wait "$NOTIFY_PID" wait

View File

@@ -7,8 +7,9 @@ After=nextcloud_db.service nextcloud_valkey.service nextcloud.service
Pod=nextcloud.pod Pod=nextcloud.pod
ContainerName=nextcloud_push ContainerName=nextcloud_push
Image=docker.io/library/nextcloud:fpm-alpine Image=docker.io/library/nextcloud:fpm-alpine
Exec=/nextcloud-notify-push-entrypoint.sh Entrypoint=/nextcloud-notify-push-entrypoint.sh
User=1000 User=1000
Group=1000
# Enable auto-update container # Enable auto-update container
AutoUpdate=registry AutoUpdate=registry