-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathinstall
executable file
·48 lines (38 loc) · 1.51 KB
/
install
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
39
40
41
42
43
44
45
46
47
48
#!/bin/bash
echo -e '\n\033[0;32mSANDBOX LAUNCHD\033[0m\n'
# Install Sleepwatcher using Homebrew if not installed
INSTALLED=$(brew list | grep sleepwatcher)
if [ -z "$INSTALLED" ]; then
echo '✔ Installing Sleepwatcher using Homebrew'
brew install sleepwatcher
fi
# Create Launch Daemon
echo '✔ Creating Launch Agents'
mkdir -p $HOME/Library/LaunchAgents
cp launchd/*.plist $HOME/Library/LaunchAgents/
# Copy Wake & Sleep files to home directory acording to instructions
echo '✔ Copying Program Files'
mkdir -p $HOME/.opensfcc
cp bin/boot-shutdown $HOME/.opensfcc/boot-shutdown
cp bin/sdx-stop $HOME/.opensfcc/sdx-stop
cp bin/sdx-start $HOME/.opensfcc/sdx-start
# Replace Relative Path with Absolute Path
sed -i '' "s|~|$HOME|" $HOME/Library/LaunchAgents/com.opensfcc.*.plist
sed -i '' "s|~|$HOME|" $HOME/.opensfcc/boot-shutdown
# Unload Launch Daemon if Loaded
LOADED=$(launchctl list | grep com.opensfcc)
if [ -n "$LOADED" ]; then
launchctl unload -w $HOME/Library/LaunchAgents/com.opensfcc.sleepwatcher.plist
launchctl unload -w $HOME/Library/LaunchAgents/com.opensfcc.sandbox.plist
fi
# Load Launch Daemon
echo '✔ Loading Launch Agents'
launchctl load -w $HOME/Library/LaunchAgents/com.opensfcc.sleepwatcher.plist
launchctl load -w $HOME/Library/LaunchAgents/com.opensfcc.sandbox.plist
# Set Permissions on Program Files
chmod u+x $HOME/.opensfcc/boot-shutdown
chmod u+x $HOME/.opensfcc/sdx-*
# Reset Log File
cat /dev/null > $HOME/.opensfcc/sandbox.log
# All Done :)
echo -e '\n✅ Installation Complete!\n'