bashrc fsck yosemite
Hey all I have a script in applescript that modifies the bashrc file in private/etc.
This works on every system I've tested except 10.10 yosemite.
What my script does is run various cleans on my systems, and in the end reboots the unit into single user mode and runs FSCK then reboots.
In Yosemite this does not happen. It reboots the unit in single user mode but then does not thing, sits at single user mode screen.
Please help. What Changed?
Part of my script.
set myname to do shell script ("whoami")
do shell script " sudo -v" with administrator privileges
try
do shell script "mkdir /Users/Shared/bash"
end try
try
do shell script "mkdir /Users/Shared/bash/original"
end try
try
do shell script "mkdir /Users/Shared/bash/modified"
end try
try
do shell script "cp Private/etc/bashrc /Users/Shared/bash/original/"
end try
try
do shell script "cp /Users/Shared/bash/original/bashrc /Users/Shared/bash/modified/"
end try
delay 1
do shell script "chmod 777 /Users/Shared/bash/modified/bashrc" with administrator privileges
delay 3
tell application "TextEdit"
open file "Users:Shared:bash:modified:bashrc"
end tell
delay 1
tell application "TextEdit"
activate
delay 5
repeat 40 times
tell application "System Events" to key code 125
end repeat
delay 1
tell application "System Events" to keystroke "singleuser=`sysctl -n kern.singleuser`"
tell application "System Events" to keystroke return
tell application "System Events" to keystroke "if [[ $singleuser -eq 1 ]]; then"
tell application "System Events" to keystroke return
tell application "System Events" to keystroke "nvram boot-args=\"\""
tell application "System Events" to keystroke return
tell application "System Events" to keystroke "echo Starting Process -- Repair disk"
tell application "System Events" to keystroke return
tell application "System Events" to keystroke "sleep 3"
tell application "System Events" to keystroke return
tell application "System Events" to keystroke "/sbin/fsck -fy"
tell application "System Events" to keystroke return
tell application "System Events" to keystroke "echo Starting Process -- Mounting the Drive"
tell application "System Events" to keystroke return
tell application "System Events" to keystroke "sleep 3"
tell application "System Events" to keystroke return
tell application "System Events" to keystroke "sbin/mount -uw /"
tell application "System Events" to keystroke return
tell application "System Events" to keystroke "echo Starting Process -- Begin moving proper files back into place"
tell application "System Events" to keystroke return
tell application "System Events" to keystroke "sleep 3"
tell application "System Events" to keystroke return
tell application "System Events" to keystroke "mv /Private/etc/bashrc /Users/Shared/bash/"
tell application "System Events" to keystroke return
tell application "System Events" to keystroke "mv /Users/Shared/bash/original/bashrc /Private/etc/"
tell application "System Events" to keystroke return
tell application "System Events" to keystroke "rm -rfv /Users/Shared/bash"
tell application "System Events" to keystroke return
tell application "System Events" to keystroke "echo Starting Process -- Boot Computer, Give me a min"
tell application "System Events" to keystroke return
tell application "System Events" to keystroke "exit"
tell application "System Events" to keystroke return
tell application "System Events" to keystroke "else"
tell application "System Events" to keystroke return
tell application "System Events" to keystroke "echo Not in single user mode"
tell application "System Events" to keystroke return
tell application "System Events" to keystroke "fi"
tell application "System Events" to keystroke "s" using command down
end tell
delay 10
do shell script "sudo rm -rfv Private/etc/bashrc" with administrator privileges
do shell script "sudo mv /Users/Shared/bash/modified/bashrc Private/etc/bashrc" with administrator privileges
do shell script "sudo nvram boot-args=\"-s\"" with administrator privileges
try
do shell script "killall Terminal"
end try
try
do shell script "killall TextEdit"
end try
try
tell applicat
end try
try
tell application "TextEdit" to quit
end try
try
tell application "Terminal" to quit
end try
delay 2
-- restarts machine disabling reopen windows on login. Had to use restart window because without it it always reopen windows.
do shell script "defaults write com.apple.loginwindow TALLogoutSavesState -bool False"
do shell script "osascript -e 'tell app \"loginwindow\" to «event aevtrrst»'"
delay 1
tell application "System Events" to keystroke return