forked from SimpleHomelab/AtoMiC-ToolKit
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathapp-start.sh
executable file
·58 lines (52 loc) · 1.73 KB
/
app-start.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
#!/bin/bash
echo
echo -e "$YELLOW--->Starting $APPTITLE...$ENDCOLOR"
if IsSystemdSupported; then
if [[ -f /etc/systemd/system/$APPSYSTEMD ]] || \
[[ -f /lib/systemd/system/$APPSYSTEMD ]] || \
[[ -f /usr/lib/systemd/system/$APPSYSTEMD ]] || \
[[ -L /etc/systemd/system/multi-user.target.wants/$APPSYSTEMD ]] ; then
FOUND=1
sudo systemctl start "$APPSYSTEMD"
sleep 5
STATUS=$(systemctl is-active "$APPSYSTEMD")
if [[ $STATUS = 'active' ]]; then
echo -e "$APPSYSTEMD is now: ${GREEN}$STATUS$ENDCOLOR"
else
echo -e "$APPSYSTEMD is now: ${RED}$STATUS$ENDCOLOR"
exit 1
fi
fi
if [[ -n $APPSYSTEMD2 ]]; then
if [[ -f /etc/systemd/system/$APPSYSTEMD2 ]] || \
[[ -f /lib/systemd/system/$APPSYSTEMD2 ]] || \
[[ -f /usr/lib/systemd/system/$APPSYSTEMD2 ]] || \
[[ -L /etc/systemd/system/multi-user.target.wants/$APPSYSTEMD2 ]]; then
FOUND=2
sudo systemctl start "$APPSYSTEMD2"
sleep 5
STATUS=$(systemctl is-active "$APPSYSTEMD2")
if [[ $STATUS = 'active' ]]; then
echo -e "$APPSYSTEMD2 is now: ${GREEN}$STATUS$ENDCOLOR"
else
echo -e "$APPSYSTEMD2 is now: ${RED}$STATUS$ENDCOLOR"
exit 1
fi
fi
fi
elif [[ -f /etc/init.d/$APPINITD ]]; then
FOUND=3
sudo service "$APPINITD" start
sleep 10
if [[ $(pgrep -f "$APPINITD" | wc -l) != 0 ]]; then
echo "$APPINITD is running"
else
echo "$APPINITD is not running"
exit 1
fi
fi
if [[ -z $FOUND ]]; then
echo -e "${RED}Startup file not found.$ENDCOLOR"
else
FOUND=''
fi