

#MAC OS X SHELL SCRIPT IF ELSE MAC#
Need Mac support for a business in the Philadelphia, PA metro area? Contact me. If they do defer it, I plan to make it nag them periodically (either just before a shutdown, or just after the next reboot) until they let it happen.

I have some plans to improve it, like having it pop up a dialog box in the GUI and let the user know what's about to happen and warn them to save their work, and give them the option to defer it. It was created with the intent of being either remotely executed on machines where the user is logged out, or manually kicked off by me when I'm rebuilding a machine- so it's not particularly polite. When you run it it will immediately reboot the machine, so make sure you save any open files before you try it out. I could not duplicate what you were seeing on my test system. "sudo /Library/Management/initswupdater.sh". You don't launch it by double-clicking, you execute it in Terminal with root privileges, i.e. More complete instructions are in another of my replies in this thread. plistfile='\n\n\n\nLabel\\nProgramArguments\n\n/bin/sh/Library/Management/initswupdater.sh\n\nRunAtLoad\n\n\n' # Writing the LaunchDaemon plist file must be done differently in Tiger than Leopard osversionlong=`sw_vers -productVersion` osvers=$ if then # Tiger echo -e $plistfile > "/Library/LaunchDaemons/" else # Leopard echo $plistfile > "/Library/LaunchDaemons/" fifi# Rebootshutdown -r now Please do not attempt to log in until this message is gone." #Put the daemon in the LaunchDaemons folder, so the script runs again after reboot. defaults write /Library/Preferences/ LoginwindowText "Software updates are currently being installed on this computer. touch /Users/Shared/.initswupd_inprog #Set the loginwindow banner to warn people not to use the machine. # Create the marker file so the script knows to keep going. rm /Users/Shared/.initswupd_inprog rm /Library/LaunchDaemons/ defaults delete /Library/Preferences/ LoginwindowText fielse # If the 'updates in progress' marker is not there, prep the machine. if then # If there are no more updates available, clean up the marker, launchdaemon and login window text. # Softwareupdate returns 3 lines if there are no updates. softwareupdate -ai # Run softwareupdate again to see if there's anything left.
#MAC OS X SHELL SCRIPT IF ELSE INSTALL#
pmset -a sleep 0 force # Install all available software updates. # Temporarily prevent machine from sleeping. It must be run as root.# To use in its current form, name the script initswupdater.sh and put it in /Library/Management.# Tested in both Tiger and Leopard.if then # If the 'updates in progress' marker is there, run the updates. I tried a few variants but I didn't manage to set 'R' which is probably the variable containing the new location to a fixed value.#!/bin/sh# This script will run softwareupdate, install all available updates, reboot and repeat# until no more updates are available. I would then just create two or three scripts for my most frequently used locations. to just put in the name of the location that I want to switch to and not display a selection box. In fact I would prefer the script to run without user interaction, i.e. eScriptX/Concepts/work withas.html I found a way to call an AppleScript from the shell (using the #!/usr/bin/osascript interpreter) - but if I run the script you sent I getġ42:166: execution error: No user interaction allowed.

While this works, ideally I would like to have one script that does both the changes to the shell (for this I already have a shell script) and the changes to Mac OS. Now I have marked the question as "answered").

(I actually wanted to mark your message as "solved".
