-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathinstall.sh
More file actions
executable file
·80 lines (65 loc) · 1.76 KB
/
install.sh
File metadata and controls
executable file
·80 lines (65 loc) · 1.76 KB
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
#!/usr/bin/sh
SVCNAME='boot-notify'
# Template file locations
SVCTEMP="$PWD/template/boot-notify.service.template"
INITEMP="$PWD/template/BotSettings.ini.template"
# Template installation locations
SERVICE="/etc/systemd/system/boot-notify.service"
NOTIFY_INI="$PWD/src/BotSettings.ini"
DEFLT_LOGS_PATH="$PWD/logs"
# Location of boot-notify script
NOTIFY_SCRIPT="$PWD/src/boot-notify.py"
# Validate that the service template exists
if [ ! -f $SVCTEMP ]; then
echo $SVCTEMP not found!
exit
fi
# Validate that the INI template exists
if [ ! -f $INITEMP ]; then
echo $INITEMP not found!
exit
fi
# Validate that the boot-notify script exists
if [ ! -f $NOTIFY_SCRIPT ]; then
echo $NOTIFY_SCRIPT not found!
exit
fi
echo Generating INI ...
# Generate INI from template with correct logs path
if sed "s|<path>|$DEFLT_LOGS_PATH|g" $INITEMP > $NOTIFY_INI; then
echo Created $NOTIFY_INI
else
echo Failed to create $NOTIFY_INI
exit
fi
# Update permissions on the INI
if chmod 0666 $NOTIFY_INI; then
echo Updated permissions for $NOTIFY_INI
echo
else
echo Failed to update permissions for $NOTIFY_INI. Please execute \'chmod 0666 $NOTIFY_INI\'.
echo
fi
echo Installing service ...
# Generate service from template with correct path to notify.py
if sed "s|<notify>|$NOTIFY_SCRIPT -i $NOTIFY_INI|g" $SVCTEMP > $SERVICE; then
echo Created $SERVICE
else
echo Failed to create $SERVICE
exit
fi
# Update permissions on the service
if chmod 0644 $SERVICE; then
echo Updated permissions for $SERVICE
else
echo Failed to update permissions for $SERVICE. Please execute \'chmod 0644 $SERVICE\'.
fi
# Enable the service
if systemctl enable $SVCNAME; then
echo Enabled $SVCNAME
else
echo Error enabling $SVCNAME
exit
fi
echo
echo $SVCNAME installed successfully!