Skip to content
Navigation Menu
Toggle navigation
Sign in
In this repository
All GitHub Enterprise
↵
Jump to
↵
No suggested jump to results
In this repository
All GitHub Enterprise
↵
Jump to
↵
In this organization
All GitHub Enterprise
↵
Jump to
↵
In this repository
All GitHub Enterprise
↵
Jump to
↵
Sign in
Reseting focus
You signed in with another tab or window.
Reload
to refresh your session.
You signed out in another tab or window.
Reload
to refresh your session.
You switched accounts on another tab or window.
Reload
to refresh your session.
Dismiss alert
{{ message }}
mariux64
/
mxstartup
Public
Notifications
You must be signed in to change notification settings
Fork
2
Star
0
Code
Issues
1
Pull requests
0
Actions
Projects
0
Security
Insights
Additional navigation options
Code
Issues
Pull requests
Actions
Projects
Security
Insights
Files
1a73b59
Makefile
mxservicectl
mxstartup.service
mxstartup2mxconfig
mxstartupctl
mxvipctl
Breadcrumbs
mxstartup
/
mxservicectl
Blame
Blame
Latest commit
History
History
executable file
·
150 lines (109 loc) · 2.71 KB
Breadcrumbs
mxstartup
/
mxservicectl
Top
File metadata and controls
Code
Blame
executable file
·
150 lines (109 loc) · 2.71 KB
Raw
#!/bin/bash CMD_IP="/sbin/ip" CMD_MXS2MXSRV="/usr/sbin/mxstartup2mxconfig" RUNDIR="/run/mariux" # expands *-pattern in pathnames to null if no matching files are found.. shopt -s nullglob # exit on any error set -e function mxsrv_start_one() { local cfg=$1 local -i i mip mfwd echo "starting ${cfg} .." . ${cfg} test "$MX_SRV_USER" = "-" && MX_SRV_USER="root" case "${MX_SRV_SCRIPT}" in *.service) systemctl start "${MX_SRV_SCRIPT}" || true ;; *) su - ${MX_SRV_USER} -c "${MX_SRV_SCRIPT} start" & ;; esac mv ${cfg}{,.r} unset -v MX_SRV_USER MX_SRV_SCRIPT } function mxsrv_stop_one() { local cfg=$1 local -i i mip mfwd echo "stopping ${cfg} .." . ${cfg} test "$MX_SRV_USER" = "-" && MX_SRV_USER="root" case "${MX_SRV_SCRIPT}" in *.service) systemctl stop "${MX_SRV_SCRIPT}" || true ;; *) su - ${MX_SRV_USER} -c "${MX_SRV_SCRIPT} stop" & ;; esac rm ${cfg} unset -v MX_SRV_USER MX_SRV_SCRIPT } function mxsrv_start() { local cfg local pattern=$1 : ${pattern:=*} for cfg in ${RUNDIR}/mxservice.${pattern}.cfg ; do if [ -e ${cfg}.r ] ; then echo >&2 "skipping $cfg: already running.." continue fi if [ ! -r ${cfg} ] ; then echo >&2 "skipping $cfg: can't read file" continue fi if [ ! -O ${cfg} ] ; then echo >&2 "skipping $cfg: possible hack attempt?" continue fi mxsrv_start_one ${cfg} done } function mxsrv_stop() { local cfg local pattern=$1 : ${pattern:=*} for cfg in ${RUNDIR}/mxservice.${pattern}.cfg.r ; do if [ ! -r ${cfg} ] ; then echo >&2 "skipping $cfg: can't read file" continue fi if [ ! -O ${cfg} ] ; then echo >&2 "skipping $cfg: possible hack attempt?" continue fi mxsrv_stop_one ${cfg} done } function create_run_dir_if_not_exists() { if [ ! -d ${RUNDIR} ] ; then mkdir -m 0700 ${RUNDIR} fi if [ ! -O ${RUNDIR} ] ; then echo >&2 "${RUNDIR}: wrong owner: possible hack attempt? exiting.." exit 1 fi } function create_mxservice() { ${CMD_MXS2MXSRV} ${RUNDIR} >/dev/null } ############################################################################## create_run_dir_if_not_exists case "${1}" in start) create_mxservice mxsrv_start $2 ;; stop) mxsrv_stop $2 ;; restart) mxsrv_stop $2 create_mxservice mxsrv_start $2 ;; *) echo >&2 "$0 start|stop" ;; esac
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
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
You can’t perform that action at this time.