-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathinstall.bash
executable file
·63 lines (51 loc) · 1.96 KB
/
install.bash
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
#!/bin/bash
## created using the PlexConnect bash files for installing the daemon
InstallerPath=$(PWD)
CurrentUser=$(USERS)
findme="forever-agent"
echo
echo
## check if NPM Forever agent is installed
file=$(npm list | grep $findme)
if [ -z "$file" ]
then
echo "$findme not found."
echo Installing Forever agent
npm install -g forever
else
echo "Forever agent found"
fi
echo -------------------------------
## create autostart plist for next boot
echo 'Installing Homebridge-Daemon...'
echo Install from: $InstallerPath
echo -------------------------------
echo
## Copy the bash file used in the PList file to launch Homebridge through Forever
##cp ${InstallerPath}/homebridge-daemon.bash /usr/local/bin/homebridge-daemon.bash
## Modify the VAR names in the PList file and save it in the Library directory
sed -e "s/__CURRENTUSER__/${CurrentUser}/" "${InstallerPath}/org.homebridge.daemon.plist" > ~/Library/LaunchAgents/org.homebridge.daemon.plist
## Copy directly to the /Library/LaunchDameons folder
##cp ${InstallerPath}/org.homebridge.daemon.plist ~/Library/LaunchAgents/org.homebridge.daemon.plist
## change ownership and permissions of the plist file to make it launchctl compatible
##chmod 755 /usr/local/bin/homebridge-daemon.bash
chmod 0600 ~/Library/LaunchAgents/org.homebridge.daemon.plist
chown root ~/Library/LaunchAgents/org.homebridge.daemon.plist
## start Homebridge-Daemon for this session
echo 'Starting Homebridge-Daemon...'
echo
## launch the plist so that we can use it without a reboot
launchctl load ~/Library/LaunchAgents/org.homebridge.daemon.plist
## sh /usr/local/bin/forever-homebridge.bash
## wait a couple seconds to allow Homebridge to load
sleep 5
## display the running status of Homebridge
echo - below the running status of Homebridge-daemon.
echo - if nothing appears, the daemon is not launched
echo
launchctl list | grep org.homebridge.daemon
echo
echo display if Homebridge has been started with Forever:
forever list | grep "Homebridge"
echo
## end