-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmk_systemd.sh
executable file
·61 lines (44 loc) · 1016 Bytes
/
mk_systemd.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
#!/usr/bin/bash
set -e
BASE=${HOME}/atlassian-tools
. ${BASE}/conf/config.sh
. ${BASE}/lib/utils.sh
PID_FILE="$APP_INSTALL_DIR"/work/catalina.pid
STARTER="$APP_INSTALL_DIR"/bin/start-${APP_NAME}.sh
STOPPER="$APP_INSTALL_DIR"/bin/stop-${APP_NAME}.sh
# USER=$APP_NAME
INSTALL_DIR=/etc/systemd/system
REFERENCE=$(find $INSTALL_DIR -type f -print -quit)
[[ $VERBOSE -eq $YES ]] && set -x
###
# FUNCTIONS
###
mk_service_file() {
[[ $VERBOSE -eq $YES ]] && set -x
local _fn="${INSTALL_DIR}/${APP_NAME}.service"
[[ -f "$_fn" ]] && return 0
>$_fn cat <<ENDHERE
[Unit]
Description=$APP_NAME
Wants=postgresql.service
After=postgresql.service
[Service]
Type=forking
PIDFile=$PID_FILE
ExecStart=$STARTER
ExecStop=$STOPPER
[Install]
WantedBy=multi-user.target
ENDHERE
chown --reference="$REFERENCE" "$_fn"
chmod --reference="$REFERENCE" "$_fn"
systemctl daemon-reload
}
enable_service() {
systemctl enable ${APP_NAME}.service
}
###
# MAIN
###
mk_service_file
enable_service