#!/bin/bash # Check if Syncthing service is enabled, abort if not. ENABLED_SERVICES="$(/usr/bin/knulli-settings-get system.services)" if [[ ${ENABLED_SERVICES} != *"syncthing"* ]];then echo "Syncthing not running. Aborting." exit 0 fi VAR_SYNC_PID="/var/run/knulli-sync.pid" # If script is already running, kill it before starting another if [ -f $VAR_SYNC_PID ]; then kill $(cat $VAR_SYNC_PID) echo "Script was already running - terminated other instance." rm $VAR_SYNC_PID fi # Register running script echo $$ > $VAR_SYNC_PID # Retrieve syncthing API key from config file. SYNCTHING_API_KEY=$(cat ~/configs/syncthing/config.xml | sed -n 's/.*\([^<]*\).*/\1/p') # Retrieve folder IDs from config file. FOLDER_ID_MULTILINE_STRING=$(cat ~/configs/syncthing/config.xml | sed -n 's/.*