-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathinstall.sh
executable file
·112 lines (85 loc) · 1.9 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
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
#!/bin/sh
MAC=false
LINUX=false
case "$(uname -s)" in
Darwin)
echo 'Mac OS X'
MAC=true
;;
Linux)
echo 'Linux'
LINUX=true
;;
# Add here more strings to compare
# See correspondence table at the bottom of this answer
*)
echo 'Unknown OS, aborting install.'
exit
;;
esac
STARTUP=$(pwd)/startup.sh
APP=$(pwd)/node-app
AUTOSTART=$HOME/.config/autostart/NightTimes.desktop
cat <<EOM >startup.sh
#!/bin/sh
cd $APP
/usr/local/bin/node app.js
EOM
chmod 755 $STARTUP
mkdir -p 'db-backups'
echo 'Copying settings file for local customization...'
rsync -u -p node-app/settingsDefault.js node-app/settings.js
if [ $MAC == true ]; then
read -p "Install autostart script? (y/n)" -n 1 -r
echo
if [[ ! $REPLY =~ ^[Yy]$ ]]
then
echo "Skipping autostart script. You can run using ./startup.sh"
else
echo "Installing autostart script..."
cat <<EOM >~/Library/LaunchAgents/considerthebelvedere.plist
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>Label</key>
<string>com.considerthebelvedere</string>
<key>ProgramArguments</key>
<array>
<string>/bin/sh</string>
<string>$STARTUP</string>
</array>
<key>RunAtLoad</key>
<true/>
</dict>
</plist>
EOM
fi
fi
if [ $LINUX == true ]; then
read -p "Install autostart script? (y/n)" -n 1 -r
echo
if [[ ! $REPLY =~ ^[Yy]$ ]]
then
echo "Skipping autostart script. You can run using ./startup.sh"
else
echo "Installing autostart script..."
mkdir -p "$(dirname "$AUTOSTART")"
cat <<EOM >$AUTOSTART
#!/usr/bin/env xdg-open
[Desktop Entry]
Version=1.0
Name=Night Times startup
Comment=Remember the Belvedere
Exec=$STARTUP
Type=Application
Categories=Startup
EOM
chmod 755 $AUTOSTART
fi
fi
echo "Installing node dependencies..."
cd node-app
npm install
cd ..
echo "Ready!"