-
Notifications
You must be signed in to change notification settings - Fork 0
/
install-systemd-service.sh
60 lines (48 loc) · 1.44 KB
/
install-systemd-service.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
#!/bin/sh
echo "Checking..."
ok=1
if [ ! -d "/etc/systemd/system" ]; then
echo "Could not find /etc/systemd/system"
ok=0
fi
if [ ! -e "Rwb.Luxopus.Systemc/unit" ]; then
echo "Could not find Rwb.Luxopus.Systemc/unit"
ok=0
fi
if [ ! -d "/etc" ]; then
echo "Could not find /etc"
ok=0
fi
if [ ! -d "/var" ]; then
echo "Could not find /var"
ok=0
fi
if [ $ok -eq 0 ]; then
echo "Checks failed. Quitting."
exit 1
fi
# Proceed to install.
# Get the install location.
luxopus_dir=$(dirname "$0")
if [ "luxopus_dir" != "/opt/luxopus"]; then
echo "WARING: install directory is $pwd but the recommended location is /opt/luxopus."
# update the unit file
sed -i -e "s!ExecStart=/opt/luxopus!ExecStart=$luxopus_dir" "$luxopus_dir/Rwb.Luxopus.Systemd/unit" > "$luxopus_dir/Rwb.Luxopus.Systemd/unit"
fi
echo "Copying unit file to /etc/systemd/system/luxopus and systemctl reload-daemon."
cp "$luxopus_dir/Rwb.Luxopus.Systemd/unit" /etc/systemd/system/luxopus
systemctl reload-daemon
if [ ! -f /etc/lusopus ]; then
echo "/etc/luxopus does not exists; copying from defualt configuration."
echo " WARNING! You need to edit /etc/luxopus!"
cp "$luxopus_dir/Rwb.Luxopus.Console/appsettings.json" /etc/luxopus
fi
if [ ! -d "/var/opt/luxopus" ]; then
if [ ! -d "/var/opt" ]; then
echo "Making runtime storage directory at /var/opt"
mkdir /var/opt
fi
echo "Making runtime storage directory at /var/opt/luxopus"
mkdir /var/opt/luxopus
fi
# idea: run.sh 2>&1 | logger