Busco un script que pueda ejecutar en un ordenador Mavericks o Yosemite recién instalado, que instale todas las actualizaciones, reiniciando cuando sea necesario y volviendo a empezar automáticamente.
Por ejemplo, me gustaría:
sudo curl https://gist.githubusercontent.com/ChristopherA/0ddc4c27f8ec7d5a0aed/raw/2e694c616c728593c2af155d18aeeff68b25a222/gistfile1.txt | sh
Esto entonces va a mi esencia, envía el contenido a mi shell, y luego es lo siguiente script (que actualmente existe en mi esencia):
#!/bin/bash
# Installs all system updates, reboot and does it again if necessary.
# Execute on a new mac via:
# sudo curl https://gist.githubusercontent.com/ChristopherA/0ddc4c27f8ec7d5a0aed/raw/2e694c616c728593c2af155d18aeeff68b25a222/gistfile1.txt | sh
# Initially, based on https://jamfnation.jamfsoftware.com/discussion.html?id=7827 which works on 10.8 and untested on 10.9 or 10.10
SWUL=`/usr/sbin/softwareupdate -l | /usr/bin/awk '{printf "%s", $0}'`
SWULER=`/usr/sbin/softwareupdate -l 2>&1 | /usr/bin/head -1`
NoRestartUpdates=`/usr/sbin/softwareupdate -l | /usr/bin/grep -v restart | /usr/bin/grep -B1 recommended | /usr/bin/grep -v recommended | /usr/bin/awk '{print $2}' | /usr/bin/awk '{printf "%s ", $0}'`
osvers=`sw_vers -productVersion | awk -F. '{print $2}'`
if [[ $osvers -lt 8 ]]; then
/bin/echo "Script only for 10.8+ ONLY"
exit 1
elif [ "$SWULER" == "No new software available." ]; then
/bin/echo "$SWULER"
exit 1
elif [[ "$SWUL" == *"[restart]"* ]]; then
echo "Installing Updates that require Restart"
/usr/bin/sudo /usr/sbin/softwareupdate -d -a
/usr/libexec/PListBuddy -c "Copy CompletedProducts InstallAtLogout" /Library/Updates/index.plist
/usr/bin/touch /var/db/.SoftwareUpdateAtLogout
/bin/chmod og-r /var/db/.SoftwareUpdateAtLogout
/usr/libexec/PListBuddy -c "Add -RootInstallMode STRING YES" /var/db/.SoftwareUpdateOptions
/usr/libexec/PListBuddy -c "Add -SkipConfirm STRING YES" /var/db/.SoftwareUpdateOptions
/bin/chmod og-r /var/db/.SoftwareUpdateOptions
elif [[ "$SWUL" == *"[recommended]"* ]]; then
/bin/echo "Installing Updates that does not require Restart"
/usr/bin/sudo /usr/sbin/softwareupdate -i $NoRestartUpdates
fi
exit 0
```
Desafortunadamente este script de https://jamfnation.jamfsoftware.com/discussion.html?id=7827 no funciona en 10.9 o 10.10.
Los resultados:
Installing Updates that require Restart
Software Update Tool
Copyright 2002-2012 Apple Inc.
Finding available software
Downloaded iTunes
Downloaded iTunes
Downloaded OS X Yosemite Developer Preview 8
Downloading Yosemite Recovery Update
Downloaded Yosemite Recovery Update
Done.
Copy: Entry, "CompletedProducts", Does Not Exist
touch: /var/db/.SoftwareUpdateAtLogout: Permission denied
chmod: /var/db/.SoftwareUpdateAtLogout: No such file or directory
File Doesn't Exist, Will Create: /var/db/.SoftwareUpdateOptions
File Doesn't Exist, Will Create: /var/db/.SoftwareUpdateOptions
chmod: /var/db/.SoftwareUpdateOptions: No such file or directory
$
Hay algunas pistas en los comentarios de ese post, y también en http://hints.macworld.com/article.php?story=20080916220249270
Sin embargo, no soy capaz de encontrar algo que pueda ser sólo un golpe script.
- Christopher Allen