I want to run a script at shutdown, and a far as I can tell I've followed the proper procedures. The script (close) is supposed to launch another script (gdrive) in a terminal which prompts me to sync my Google drive folder.
Here's what I've done:
Copied files "close" and and "gdrive" into /etc/init.d and made them executable.
Then I run the command
update-rc.d close start 0 0 .from the command line. As expected this creates a link in
S00closewhich points to the file
close. Manually testing this link from the command line runs
gdrivein a terminal and generally behaves as expected.
Unfortunately, nothing happens when I shutdown my machine.
Here is the code from
close. In the first line I delay shutdown because I think the sync will take about 5 minutes or so:
#!/bin/sh echo "PASSWORD" | sudo -S shutdown -c xterm -e '/etc/init.d/gdrive'
Here is the code from gdrive (although, close doesn't run on shutdown, so I'm not sure how relevant this is):
#!/bin/sh echo "Sync Gdrive?" read response if [ $response = "y" ]; then cd ~/Gdrive drive push -ignore-name-clashes -quiet -ignore-conflict drive pull -ignore-name-clashes -quiet -ignore-conflict echo "Drive successfully synced" echo "PASSWORD" | sudo -S shutdown -h now exit 1 else echo "Ok, maybe next time" echo "PASSWORD" | sudo -S shutdown -h now exit 1 fi
I'm not super knowledgeable with this stuff, so any advice is appreciated. Even if someone could tell me how I can see what is happening at shutdown (what log files to look at etc.) that would be great.