feat: nextcloud notify-push script verbose logging

This commit is contained in:
coolnsx
2025-10-02 14:34:04 +05:30
parent 412d29f6ee
commit 9c484f553f

View File

@@ -9,16 +9,18 @@ export DATABASE_PREFIX="oc_"
# Clean shutdown handler # Clean shutdown handler
cleanup() { cleanup() {
echo "[*] Stopping notify_push..." echo "[*] Stopping notify_push..."
kill -TERM "$NOTIFY_PID" 2>/dev/null && echo "[*] notify push stopped.." || echo "Unable to Kill Notify Push.." kill -TERM "$NOTIFY_PID" 2>/dev/null && echo "[] notify push stopped.." || echo "Unable to Kill Notify Push.."
echo "[*] Bye" echo "[] Bye..."
} }
trap 'cleanup' TERM INT trap 'cleanup' TERM INT
echo "[*] Checking Nextcloud Host Presence..."
while ! curl -s --fail --max-time 15 "$NEXTCLOUD_URL/status.php" >/dev/null; do while ! curl -s --fail --max-time 15 "$NEXTCLOUD_URL/status.php" >/dev/null; do
echo "[*] Waiting for Nextcloud to start..." echo "[*] Waiting for Nextcloud to start..."
sleep 5 sleep 5
done done
echo "[✓] Nextcloud Host is UP and Serving."
echo "[*] Ensuring notify_push app is installed and enabled..." echo "[*] Ensuring notify_push app is installed and enabled..."
php occ app:install notify_push || true php occ app:install notify_push || true
php occ app:enable notify_push || true php occ app:enable notify_push || true
@@ -27,13 +29,21 @@ echo "[*] Starting notify_push binary..."
/var/www/html/custom_apps/notify_push/bin/x86_64/notify_push & /var/www/html/custom_apps/notify_push/bin/x86_64/notify_push &
NOTIFY_PID=$! NOTIFY_PID=$!
# Posix compliance check to ensure notify_push is running
if kill -0 "$PID" 2>/dev/null; then
echo "[✓] Notify Push is UP and running."
else
echo "[X] Notify Push is not Running!! Exiting.."
exit 1
fi
# Wait for the socket to active and respond, max 30 seconds # Wait for the socket to active and respond, max 30 seconds
i=1 i=1
while [ $i -le 6 ]; do while [ $i -le 6 ]; do
if [ -S "$SOCKET_PATH" ]; then if [ -S "$SOCKET_PATH" ]; then
echo "[*] Socket file exists, testing HTTP response..." echo "[*] Socket file exists, testing HTTP response..."
if curl -s --max-time 5 --unix-socket "$SOCKET_PATH" http://localhost/ -o /dev/null; then if curl -s --max-time 5 --unix-socket "$SOCKET_PATH" http://localhost/ -o /dev/null; then
echo "[*] notify_push is ready, running occ notify_push:setup" echo "[*] Running occ notify_push:setup"
php occ notify_push:setup "${NEXTCLOUD_URL}/push" || true php occ notify_push:setup "${NEXTCLOUD_URL}/push" || true
break break
else else