Created
August 4, 2016 14:35
-
-
Save MichalMMac/96478c84dd16ca63687ae258be9d5056 to your computer and use it in GitHub Desktop.
DS disable finalize
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/sh | |
SCRIPT_NAME=`basename "${0}"` | |
SCRIPT_PATH=`dirname "${0}"` | |
/bin/echo "${SCRIPT_NAME} - v1.0 ("`date`")" | |
custom_logger() { | |
/bin/echo "${SCRIPT_NAME} - $1" | |
} | |
restore_initial_config() { | |
custom_logger "restoring initial config" | |
# restoring default login password | |
AUTO_LOGIN_USER=$(defaults read "/Volumes/${DS_LAST_RESTORED_VOLUME}/etc/deploystudio/etc/autoLoginUser" autoLoginUser 2>/dev/null) | |
if [ -n "${AUTO_LOGIN_USER}" ] | |
then | |
if [ -e "/Volumes/${DS_LAST_RESTORED_VOLUME}/etc/deploystudio/etc/kcpassword" ] | |
then | |
/bin/mv "/Volumes/${DS_LAST_RESTORED_VOLUME}/etc/deploystudio/etc/kcpassword" "/Volumes/${DS_LAST_RESTORED_VOLUME}/etc/" | |
fi | |
defaults write "/Volumes/${DS_LAST_RESTORED_VOLUME}/Library/Preferences/com.apple.loginwindow" autoLoginUser "${AUTO_LOGIN_USER}" | |
chmod 644 "/Volumes/${DS_LAST_RESTORED_VOLUME}/Library/Preferences/com.apple.loginwindow.plist" | |
chown root:wheel "/Volumes/${DS_LAST_RESTORED_VOLUME}/Library/Preferences/com.apple.loginwindow.plist" | |
fi | |
} | |
# launchd configuration files removal | |
custom_logger "removing launchd configuration files" | |
# restore_initial_config | |
restore_initial_config | |
if [ -e "/Volumes/${DS_LAST_RESTORED_VOLUME}/Library/LaunchDaemons/com.deploystudio.finalizeScript.plist" ] | |
then | |
/bin/rm -f "/Volumes/${DS_LAST_RESTORED_VOLUME}/Library/LaunchDaemons/com.deploystudio.finalizeScript.plist" 2>/dev/null | |
custom_logger "removing /Volumes/${DS_LAST_RESTORED_VOLUME}/Library/LaunchDaemons/com.deploystudio.finalizeScript.plist" | |
else | |
/bin/rm -f "/Volumes/${DS_LAST_RESTORED_VOLUME}/Library/LaunchAgents/com.deploystudio.finalizeScript.plist" 2>/dev/null | |
/bin/rm -f "/Volumes/${DS_LAST_RESTORED_VOLUME}/Library/LaunchAgents/com.deploystudio.FinalizeApp.plist" 2>/dev/null | |
custom_logger "removing /Volumes/${DS_LAST_RESTORED_VOLUME}/Library/LaunchAgents/com.deploystudio.FinalizeApp.plist" | |
fi | |
/bin/rm -f "/Volumes/${DS_LAST_RESTORED_VOLUME}/Library/LaunchDaemons/com.deploystudio.finalizeCleanup.plist" 2>/dev/null | |
custom_logger "/Volumes/removing ${DS_LAST_RESTORED_VOLUME}/Library/LaunchDaemons/com.deploystudio.finalizeCleanup.plist" | |
# Self-removal | |
/bin/rm -rf "/Volumes/${DS_LAST_RESTORED_VOLUME}/etc/deploystudio" | |
custom_logger "removing /Volumes/${DS_LAST_RESTORED_VOLUME}/etc/deploystudio" | |
custom_logger "end" | |
exit 0 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment