vm
vm copied to clipboard
Update crontab for everyone using iNotify
This piece of code would update the crontab for everyone using the SMB mount app. Problem is that it's not fail proof to get the actual MOUNT_IDs so it's better to do it manually.
source /var/scripts/fetch_lib.sh
# Replace iNotify checker with a script instead
if crontab -u www-data -l | grep -q "files_external:notify -v"
then
download_script ADDONS notify-crontab
chmod +x "$SCRIPTS"/notify-crontab.sh
chown root:root "$SCRIPTS"/notify-crontab.sh
MOUNT_ID=$(sudo -u postgres psql nextcloud_db -c "select mount_id from oc_external_config")
crontab -u www-data -l | grep -v "files_external:notify -v" | crontab -u www-data -
crontab -u root -l | { cat; echo "@reboot $SCRIPTS/notify-crontab.sh $(echo "${MOUNT_ID##* }" | head -1)"; } | crontab -u root -
print_text_in_color "$ICyan" "Replaced iNotify with a script instead of command."
fi
tested and works on a customers instance, but it only added the last mount_id. Maybe a for loop would work here? :thinking: