Skip to content
20 changes: 20 additions & 0 deletions addons/notify-crontab.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
#!/bin/bash

true
SCRIPT_NAME="Notify Crontab Script"
# shellcheck source=lib.sh
source /var/scripts/fetch_lib.sh

# Check for errors + debug code and abort if something isn't right
# 1 = ON
# 0 = OFF
DEBUG=0
debug_mode

# Must be root
root_check

MOUNT_ID="$1"

# Add crontab for this external storage
nextcloud_occ files_external:notify -v "$MOUNT_ID" >> "$VMLOGS"/files_inotify.log
9 changes: 7 additions & 2 deletions apps/smbmount.sh
Original file line number Diff line number Diff line change
Expand Up @@ -408,9 +408,14 @@ files_inotify app and set up the cronjob for this external storage."
nextcloud_occ_no_check app:enable files_inotify
fi

# Add crontab for this external storage
# Download script
download_script ADDONS notify-crontab
chmod 700 "$SCRIPTS"/notify-crontab.sh
chown root:root "$SCRIPTS"/notify-crontab.sh

# Add crontab
print_text_in_color "$ICyan" "Generating crontab..."
crontab -u www-data -l | { cat; echo "@reboot sleep 20 && php -f $NCPATH/occ files_external:notify -v $MOUNT_ID >> $VMLOGS/files_inotify.log"; } | crontab -u www-data -
crontab -u root -l | { cat; echo "@reboot $SCRIPTS/notify-crontab.sh $MOUNT_ID"; } | crontab -u root

# Run the command in a subshell and don't exit if the smbmount script exits
nohup sudo -u www-data php "$NCPATH"/occ files_external:notify -v "$MOUNT_ID" >> $VMLOGS/files_inotify.log &
Expand Down