Skip to content

Instantly share code, notes, and snippets.

Last active May 1, 2018 22:17
What would you like to do?
Resets Synology Cloud Station Backup client backup status.
if [ $(sw_vers -productVersion | awk -F. '{print $2}') -lt "11" ]; then
echo "This script only works on macOS 10.11 or newer."
# get user
theUser=$(/usr/bin/stat -f "%Su" /dev/console)
# fall back to get user
if [[ $theUser == "root" ]]; then
theUser=$(/usr/bin/defaults read /Library/Preferences/ lastUserName)
# get the user's ID
user_id=$(/usr/bin/id -u $theUser)
# path to Cloud Station Backup sys.sqlite DB
# path to Cloud Station Backup ui process ID
# path to the Cloud Station Backup user LaunchAgent
# unload the CSB LaunchAgent
/bin/launchctl bootout gui/$user_id $ula # not 10.10 safe
# get the CSB PID
ui_pid=$(/bin/cat $csb_ui | /usr/bin/awk -F\" '{print $2}')
# kill CSB to shut it down
/bin/kill $ui_pid
# wait for it to be closed
/bin/sleep 5
# change the status to 0 -- shutdown
/usr/bin/sqlite3 $csb_db "update session_table set status=0 where id=1;"
# start CSB
/bin/launchctl bootstrap gui/$user_id $ula # not 10.10 safe
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment