-
Notifications
You must be signed in to change notification settings - Fork 0
/
install-pi-server-32bit.bash
127 lines (87 loc) · 3.58 KB
/
install-pi-server-32bit.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
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
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
#!/usr/bin/env bash
# Copyright (c) 2018-2021 AnimatedLEDStrip
#
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to deal
# in the Software without restriction, including without limitation the rights
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
# copies of the Software, and to permit persons to whom the Software is
# furnished to do so, subject to the following conditions:
#
# The above copyright notice and this permission notice shall be included in
# all copies or substantial portions of the Software.
#
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
# THE SOFTWARE.
if [ "$EUID" -ne 0 ]; then
echo "Please run as root"
exit 1
fi
echo -n "Determining latest version..."
PI_SERVER_VERSION=$(curl -s https://api.github.com/repos/AnimatedLEDStrip/server-pi/releases/latest | grep --color="never" -P '"tag_name":' | cut -d '"' -f 4)
if [[ -z "$PI_SERVER_VERSION" ]]; then
echo "Could not determine latest version of AnimatedLEDStrip Pi server library, aborting"
exit 1
else
echo "$PI_SERVER_VERSION"
fi
echo -n "Checking for java..."
if ! command -v java &>/dev/null; then
echo "not found"
echo "Please install java"
exit 1
else
echo "found"
fi
rm -rf /tmp/ledserver-download
mkdir /tmp/ledserver-download
cd /tmp/ledserver-download || exit 1
echo -n "Creating /usr/local/leds..."
if [[ -d /usr/local/leds ]]; then
echo "exists"
else
install -d /usr/local/leds
echo "done"
fi
echo -n "Installing ledserver..."
wget "https://github.com/AnimatedLEDStrip/server-pi/releases/download/${PI_SERVER_VERSION}/animatedledstrip-server-pi-${PI_SERVER_VERSION}-32bit.jar"
install -m 755 "animatedledstrip-server-pi-${PI_SERVER_VERSION}-32bit.jar" /usr/local/leds/ledserver.jar
wget -q https://raw.githubusercontent.com/AnimatedLEDStrip/server-pi/master/install/ledserver.sh
install -m 755 ledserver.sh /usr/local/leds/ledserver.sh
chmod 755 /usr/local/leds/ledserver.sh
ln -f -s /usr/local/leds/ledserver.sh /usr/bin/ledserver
echo "done"
echo -n "Creating /etc/leds..."
if [[ -d /etc/leds ]]; then
echo "exists"
else
install -d /etc/leds
echo "done"
fi
echo -n "Downloading config script..."
wget -q https://raw.githubusercontent.com/AnimatedLEDStrip/server-pi/master/install/ledconfig.bash
echo "done"
echo -n "Installing config script..."
install -m 755 ledconfig.bash /usr/local/leds/ledconfig.bash
ln -f -s /usr/local/leds/ledconfig.bash /usr/bin/ledconfig
echo "done"
echo -n "Installing led.config..."
wget -q https://raw.githubusercontent.com/AnimatedLEDStrip/server-pi/master/install/led.config
install -m 644 led.config /etc/leds/led.config
echo "done"
#echo "Configuring server..."
#
#ledconfig
echo -n "Creating ledserver systemd service..."
wget -q https://raw.githubusercontent.com/AnimatedLEDStrip/server-pi/master/install/ledserver.service
install -m 644 ledserver.service /etc/systemd/system/ledserver.service
systemctl enable ledserver &>/dev/null
systemctl daemon-reload
echo "done"
rm -rf /tmp/ledserver-download
echo "AnimatedLEDStrip LED Server for Raspberry Pi installed successfully"