Submit Hint Search The Forums LinksStatsPollsHeadlinesRSS
14,000 hints and counting!


Click here to return to the 'Force fsck on headless servers and remote macs' hint
The following comments are owned by whoever posted them. This site is not responsible for what they say.
Force fsck on headless servers and remote macs
Authored by: chuckadile on Oct 03, '12 01:35:50PM

I have found this extremely useful. I want to write this into an applescript that can run on a local machine like this:

tell application "Terminal" to do shell script "sudo echo 'if [ $HOSTNAME = localhost ] || [ -z $SECURITYSESSIONID ]; then clear; echo "Checking File System. The Computer will reboot in 1 minute..."; /bin/sleep 6; fsckResult=$(/sbin/fsck -fy); echo "$fsckResult"; /sbin/mount -uw /; echo "$fsckResult" >> /var/log/fsck.log; /bin/rm /var/root/.profile;cd /Library/Preferences; plutil -s *.plist; rm `plutil -s *.plist | grep "plist:" | sed "s/://g"`; nvram boot-args=""; echo "Rebooting in 10 seconds."; /bin/sleep 10; /sbin/shutdown -r now; fi' > /var/root/.profile " with administrator privileges

However since the whole command needs to be inside quotations the the quotations inside the command prevent it from compiling
I have gotten this to work:

tell application "Terminal" to do shell script "sudo echo 'if [ $HOSTNAME = localhost ] || [ -z $SECURITYSESSIONID ]; then clear; /bin/sleep 6; fsckResult=$(/sbin/fsck -fy); /sbin/mount -uw /;/var/log/fsck.log; /bin/rm /var/root/.profile; nvram boot-args=; /bin/sleep 10; /sbin/shutdown -r now; fi' > /var/root/.profile " with administrator privileges

But not as nice without messages to let the user know what's going on.

Any suggestions?



[ Reply to This | # ]