-
Notifications
You must be signed in to change notification settings - Fork 56
/
Copy pathAppleUserLibraryAgent.sh
executable file
·38 lines (32 loc) · 1.1 KB
/
AppleUserLibraryAgent.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
#!/bin/sh
#* AppleUserLibrary
#+
#+ Description: Payload free. Unhide ~/Library.
#+
#+ Version: 1.0
#+
#+ History:
#+ 1.0: Script.
#+
#+ TODO:
#+ * Add error checking?
ME=$0
SCRIPT_DIR="$1/Contents/Resources"
TARGET_DIR="$3"
#+ // fix
if [ -z "${TARGET_DIR}" ] || [ "${TARGET_DIR}" = "/" ]; then
TARGET_DIR=""
fi
#+ LaunchAgent
sudo /usr/bin/defaults write "${TARGET_DIR}/Library/LaunchAgents/AppleUserLibrary" Label "com.cg.AppleUserLibrary"
sudo /usr/bin/defaults write "${TARGET_DIR}/Library/LaunchAgents/AppleUserLibrary" RunAtLoad -bool TRUE
sudo /usr/bin/defaults write "${TARGET_DIR}/Library/LaunchAgents/AppleUserLibrary" ProgramArguments -array "/bin/sh" "-c" "/bin/sleep 10; /usr/bin/chflags nohidden ~/Library"
#+ Permissions
sudo /usr/sbin/chown root:wheel "${TARGET_DIR}/Library/LaunchAgents/AppleUserLibrary.plist"
sudo /bin/chmod 644 "${TARGET_DIR}/Library/LaunchAgents/AppleUserLibrary.plist"
#+ Load if booted
if [ -z "${TARGET_DIR}" ] || [ "${TARGET_DIR}" = "" ]; then
sudo /bin/launchctl load -w "${TARGET_DIR}/Library/LaunchAgents/AppleUserLibrary.plist"
fi
exit 0