Created
July 24, 2015 22:19
-
-
Save dderusha/7ebc81facd3f020c3841 to your computer and use it in GitHub Desktop.
Remove Illustrator Creative Cloud User preferences
This file contains hidden or 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 | |
set -euo pipefail # "e" and "o pipefail" let the script exit immediately on errors, "u" exits on undefined variables | |
###### Standard Variables ##### | |
### You should not normally need to edit these | |
### If you need to modify one for your own script, | |
### move the line to the script variable section and rename for consistancy | |
### This contains more variable than are used to serve better as a template | |
### Remove unused variables in this section before merging to remote module branch | |
startTime=$(date "+%Y-%m-%d_%H:%M:%S") | |
scriptName=$(basename -- "$0") # $0 is the full path to the script. basename removes the path. dirname would return only the path (see scriptDir below) | |
# scriptName="${0##*/}" # I've seen this mentioned as a better version of the above, but I don't understand what's better. | |
# scriptDir=$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd ) | |
logDate=$(date "+%Y-%m-%d") | |
# logDir=$(echo "/var/log/$scriptName" | cut -d . -f 1) | |
logDir=/var/log # must run as root to write /var/log | |
logName="$(echo "$scriptName" | cut -d . -f 1).$logDate.log" | |
logPath="$logDir/$logName" | |
### Script - Edit these to fit your envirnoment and needs | |
## uncomment these log variables as needed to override the standard versions above for convenient testing | |
# logDir="$(cd "$scriptDir/../" && pwd)/logs" # log to "module-root/logs" | |
# logDir=$slimerPath/logs/$(echo "$scriptName" | cut -d . -f 1) # log to "path-to-slimer/logs/module-name/" | |
# logName="TESTING-$(echo "$scriptName" | cut -d . -f 1)-$logDate.log" # prefix logfile with TESTING tag | |
# logPath="$logDir/$logName" # if you modify logDir or logName, you must redefine logPath here | |
# logPath=/dev/null # logs to nothing | |
# touchPath will touch one or more files and create the path if it does not exist | |
# USAGE: touchPath "/path/to/file.1" "/new/folder/for/file.2" "$pathInVariable" | |
touchPath() { | |
argT=${1:-} | |
if [ -z "$argT" ]; then | |
echo "no argument provided to touchPath"; | |
exit 1; | |
fi | |
for path in "$@"; do | |
if [ ! -d "$(dirname -- "$path")" ]; then | |
mkdir -p -- "$(dirname -- "$path")" | |
fi | |
touch -m -- "$path" | |
done | |
} | |
# echoLog writes an argument or piped data to a syslog-style line in stdout and a logfile | |
# USAGE: echoLog "Text Here" "Optional second line of text" OR command 2>&1 | echoLog (this will add the logtag to all lines) OR echoLog $(command) (this can be flakey, but should only add the logtag to the first line of output) | |
echoLog(){ | |
logTime=$(date "+%Y-%m-%d_%H:%M:%S") # set date and time here to update on each write | |
printLogLine(){ | |
printf "\n %s \n" "$logTime $(hostname -s) $scriptName [$$] -- $logMessage" 2>&1 | tee -a "$logPath" | |
logger -t "$scriptName" -- "$logMessage" # also write to syslog | |
} | |
argE=${1:-} | |
if [ -n "$argE" ] | |
then | |
logMessage="$argE" | |
printLogLine | |
else | |
while read -r logMessage; do printLogLine; done | |
fi | |
} | |
### START FIRST SECTION BLOCK ### | |
touchPath "$logPath" # check/create log path, touch logfile | |
echoLog "##### STARTING $scriptName - $startTime #####" | |
echoLog "### STARTING FIRST TASK ###" | |
### START FIRST SECTION | |
echoLog "Preparing $scriptName" | |
rm -Rv /Users/"$(who | grep console | awk '{print $1}')"/Library/Preferences/Adobe\ Illustrator\ 17\ Settings/en_US/* 2>&1 | echoLog | |
echoLog "Illustrator CC User Prefs removed" | |
exit 0 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
this script will also add a log file in your console under /var/log -name you give the script.sh