This repository has been archived by the owner on Jul 15, 2019. It is now read-only.
/
plReloadManager
95 lines (72 loc) · 1.88 KB
/
plReloadManager
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
#! /bin/sh
# This script abstracts the reload function so that service
# installs do not need to know the nitty gritty of how the
# plutonManager is managed.
# This script (mostly) only exists because you cannot nest yinst
# commands with yinst (This is a Yahoo-ism that is otherwise
# irrelevant).
args=`getopt a $*`
if [ $? != 0 ]
then
echo 'Usage: plReloadManager [-a]'
exit 2
fi
reloadAll=n
set -- $args
for f
do
case "$f" in
-a)
reloadAll=y
shift;;
*)
shift;;
--)
break;;
esac
done
# Check that the user can issue the svc command
id=`id -un`
if [ $id != 'yahoo' -a $id != 'root' ]; then
cat <<EOF
WARNING: You are running as user $id but normally this command is only
WARNING: effective when running as 'yahoo' or 'root'. It is likely
WARNING: this command will fail, but we're proceeding anyway, just in
WARNING: case you know something we don't...
EOF
fi
# Find that pesky service directory containing the plutonManager
foundit=
for d in /service /etc/service /var/service /usr/local/var/service
do
p=$p/plutonManager
if [ -d $p ]; then
echo Manager service found at $p
foundit=$p
if [ $reloadAll = 'y' ]; then
echo Reload All
svc -i $p
else
echo Reload Changed
svc -h $p
fi
break;
fi
done
# Bug. svc doesn't exit non-zero on failure! Bah humbug djb - a rare
# oversight on your part.
if [ "$foundit" ]; then
cat <<EOF
The plutonManager at $foundit has been notified to reload its configuration.
Do not expect configuration changes to be instantaneous as the
plutonManager patiently waits for active services to finish. In the
worst case, the plutonManager can wait for over twelve seconds before
uncremoniously evicting a recalcitrant service.
EOF
exit
fi
cat <<EOF
ERROR: Could not find the service path for the plutonManager. Reload
ERROR: not performed.
EOF
exit 1