@@ -102,9 +102,9 @@ reply_error() {
102
102
}
103
103
104
104
wwprint () {
105
- MSG=$1
105
+ MSG=" $1 "
106
106
COLOR=$GRAY
107
- COMMAND=` basename $0 | sed -e ' s/^[0-9]*-\?//' | sed -e ' s/\.init$//' `
107
+ COMMAND=` basename -- $0 | sed -e ' s/^[0-9]*-\?//' | sed -e ' s/\.init$//' `
108
108
109
109
case $2 in
110
110
white|WHITE) COLOR=$WHITE ;;
@@ -117,6 +117,26 @@ wwprint() {
117
117
echo -ne " $WHITE$COMMAND$NORMAL :\\ 033[14G $COLOR$MSG$NORMAL "
118
118
}
119
119
120
+ wwprintf () {
121
+ FMT=" $1 "
122
+ shift
123
+
124
+ COLOR=$GRAY
125
+ COMMAND=` basename -- $0 | sed -e ' s/^[0-9]*-\?//' | sed -e ' s/\.init$//' `
126
+
127
+ case $1 in
128
+ white|WHITE) COLOR=$WHITE ; shift ;;
129
+ gray|GRAY|grey|GREY) COLOR=$GRAY ; shift ;;
130
+ red|RED|error) COLOR=$RED ; shift ;;
131
+ yellow|YELLOW|warn) COLOR=$YELLOW ; shift ;;
132
+ blue|BLUE) COLOR=$BLUE ; shift ;;
133
+ esac
134
+
135
+ echo -ne " $WHITE$COMMAND$NORMAL :\\ 033[14G $COLOR "
136
+ printf " $FMT " " $@ "
137
+ echo -ne " $NORMAL "
138
+ }
139
+
120
140
wwaction () {
121
141
TMPFILE=` mktemp`
122
142
" $@ " > $TMPFILE 2>&1
@@ -127,7 +147,7 @@ wwaction() {
127
147
reply_error
128
148
wwprint " + $* \n" RED
129
149
cat $TMPFILE | while read i; do
130
- wwprint " $i \n" YELLOW
150
+ wwprintf " %s \n" YELLOW " $i "
131
151
done
132
152
fi
133
153
rm -f $TMPFILE
@@ -155,7 +175,7 @@ wwrun() {
155
175
else
156
176
reply_error
157
177
cat $TMPFILE | while read i; do
158
- wwprint " $i \n" YELLOW
178
+ wwprintf " %s \n" YELLOW " $i "
159
179
done
160
180
fi
161
181
rm -f $TMPFILE
@@ -212,16 +232,19 @@ wwpackage_check() {
212
232
# that have different service names for the same service (e.g. ntp and
213
233
# ntpd).
214
234
wwservice_activate () {
215
- if test -x " /bin/initctl" || test -x " /usr/sbin/update-rc.d" ; then
216
- # We need to add entries for initctl and update-rc.d below! HELP!
217
- wwprint " You will need to manually enable and (re)start: $@ \n" warn
218
- fi
219
235
for SERVICE in " $@ " ; do
220
- if [ -e " /etc/xinetd.d/$SERVICE " ]; then
221
- wwprint " Activating xinetd service: $1 \n"
222
- wwrun sed -ie ' s@\(disable\s*=\s*\)\S*@\1no@' /etc/xinetd.d/$SERVICE
223
- wwservice_activate xinetd
224
- return 0
236
+ if [ -x " /bin/systemctl" ]; then
237
+ if ! echo $SERVICE | egrep -q ' \.service$|\.socket$' ; then
238
+ SERVICE=" ${SERVICE} .service"
239
+ fi
240
+ if systemctl list-unit-files --type=service,socket | egrep -q " ^$SERVICE " ; then
241
+ wwprint " Activating Systemd unit: $1 \n"
242
+ if wwrun /bin/systemctl -q enable $SERVICE ; then
243
+ if wwrun /bin/systemctl -q restart $SERVICE ; then
244
+ return 0
245
+ fi
246
+ fi
247
+ fi
225
248
elif [ -x " /etc/rc.d/init.d/$SERVICE " ]; then
226
249
wwprint " Activating system service: $1 \n"
227
250
if [ -x " /sbin/chkconfig" ]; then
@@ -235,13 +258,11 @@ wwservice_activate() {
235
258
if wwrun /etc/init.d/$SERVICE restart; then
236
259
return 0
237
260
fi
238
- elif test -x " /bin/systemctl" && systemctl list-unit-files --type=service | egrep -q " ^$SERVICE .service" ; then
239
- wwprint " Activating Systemd service: $1 \n"
240
- if wwrun /bin/systemctl -q enable $SERVICE .service; then
241
- if wwrun /bin/systemctl -q restart $SERVICE .service; then
242
- return 0
243
- fi
244
- fi
261
+ elif [ -e " /etc/xinetd.d/$SERVICE " ]; then
262
+ wwprint " Activating xinetd service: $1 \n"
263
+ wwrun sed -ie ' s@\(disable\s*=\s*\)\S*@\1no@' /etc/xinetd.d/$SERVICE
264
+ wwservice_activate xinetd
265
+ return 0
245
266
fi
246
267
done
247
268
@@ -251,17 +272,17 @@ wwservice_activate() {
251
272
252
273
253
274
service_findname () {
254
- wwprint " service_findname() has been depricated " warn
275
+ wwprint " service_findname() has been deprecated " warn
255
276
return 0
256
277
}
257
278
258
279
service_enable () {
259
- wwprint " service_enable() has been depricated " warn
280
+ wwprint " service_enable() has been deprecated " warn
260
281
return 0
261
282
}
262
283
263
284
service_restart () {
264
- wwprint " service_restart() has been depricated " warn
285
+ wwprint " service_restart() has been deprecated " warn
265
286
return 0
266
287
}
267
288
0 commit comments