Last active
May 1, 2018 22:17
-
-
Save bryanheinz/07a42ec17d1e0b4c376a946708ac7f22 to your computer and use it in GitHub Desktop.
Resets Synology Cloud Station Backup client backup status.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
if [ $(sw_vers -productVersion | awk -F. '{print $2}') -lt "11" ]; then | |
echo "This script only works on macOS 10.11 or newer." | |
exit | |
fi | |
# 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/com.apple.loginwindow.plist lastUserName) | |
fi | |
# get the user's ID | |
user_id=$(/usr/bin/id -u $theUser) | |
# path to Cloud Station Backup sys.sqlite DB | |
csb_db="/Users/$theUser/.CloudStationBackup/data/db/sys.sqlite" | |
# path to Cloud Station Backup ui process ID | |
csb_ui="/Users/$theUser/.CloudStationBackup/ui.pid" | |
# path to the Cloud Station Backup user LaunchAgent | |
ula="/Users/$theUser/Library/LaunchAgents/com.synology.CloudStationBackup.plist" | |
# 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