2
# ARC cache index cache server
5
# description: The ARC cache server collects cache information which \
6
# can be pulled by a cache index.
10
# Required-Start: $network
11
# Required-Stop: $network
16
# Short-Description: ARC cacheindex, cache server
17
# Description: The ARC cache server collects cache information which
18
# can be pulled by a cache index.
21
# source function library
22
if [ -f /etc/init.d/functions ]; then
23
. /etc/init.d/functions
39
elif [ -f /lib/lsb/init-functions ]; then
40
. /lib/lsb/init-functions
42
echo "Error: Cannot source neither init.d nor lsb functions"
46
PIDFILE=/var/run/acix-cache.pid
47
DEFAULT_LOGFILE=/var/log/arc/acix-cache.log
53
if [ -r /etc/sysconfig/nordugrid ]; then
54
. /etc/sysconfig/nordugrid
55
elif [ -r /etc/default/nordugrid ]; then
56
. /etc/default/nordugrid
58
if [ -r /etc/sysconfig/acix-cache ]; then
59
. /etc/sysconfig/acix-cache
60
elif [ -r /etc/default/acix-cache ]; then
61
. /etc/default/acix-cache
64
if [ `id -u` = 0 ] ; then
65
# Debian does not have /var/lock/subsys
66
if [ -d /var/lock/subsys ]; then
67
LOCKFILE=/var/lock/subsys/acix-cache
69
LOCKFILE=/var/lock/acix-cache
72
LOCKFILE=$HOME/acix-cache.lock
75
APPSTART="from acix import cacheserver ; application = cacheserver.createApplication()"
79
if [ "$RUN" != "yes" ] ; then
80
echo "acix-cache service is disabled, please adjust the configuration to your"
81
echo "needs and then set RUN to 'yes' in /etc/default/acix-cache to enable it."
86
if [ "x$ARC_CONFIG" = "x" ] && [ -r /etc/arc.conf ]; then
87
ARC_CONFIG=/etc/arc.conf
89
if [ ! -r "$ARC_CONFIG" ]; then
90
log_failure_msg "ARC configuration not found (usually /etc/arc.conf)"
94
echo -n "Starting ARC cache server..."
96
# Check if we are already running
97
if [ -f $PIDFILE ]; then
99
if [ "x$pid" != "x" ]; then
100
ps -p "$pid" -o comm 2>/dev/null | grep "^$prog$" 1>/dev/null 2>/dev/null
101
if [ $? -eq 0 ] ; then
102
log_success_msg "already running (pid $pid)"
106
rm -f "$PIDFILE" "$LOCKFILE"
109
CONFIG_SECTION=acix\\/cacheserver
110
# read in cacheserver section from arc.conf
111
# this will put the read values into the environment, e.g., $logfile
112
eval `sed -e 's/[[:space:]]*\=[[:space:]]*/=/g' \
114
-e 's/[[:space:]]*$//' \
115
-e 's/^[[:space:]]*//' \
116
-e "s/^\(.*\)=\([^\"']*\)$/\1=\"\2\"/" \
118
| sed -n -e "/^\[$CONFIG_SECTION\]/,/^\s*\[/{/^[^;].*\=.*/p;}" `
119
LOGFILE=${logfile:-$DEFAULT_LOGFILE}
120
if [ ! -d `dirname $LOGFILE` ]; then
121
mkdir -p `dirname $LOGFILE`
124
TACFILE=`mktemp` || exit 1
125
echo $APPSTART > $TACFILE
127
$prog --pidfile $PIDFILE -l $LOGFILE -y $TACFILE
130
if [ $RETVAL -eq 0 ]; then
141
echo -n "Stopping ARC cache server..."
143
if [ -f "$PIDFILE" ]; then
144
read pid < "$PIDFILE"
145
if [ ! -z "$pid" ] ; then
148
if [ $RETVAL -eq 0 ]; then
154
timeout=2; # for stopping nicely
156
while ( ps -p "$pid" -o comm 2>/dev/null | grep "^$prog$" 1>/dev/null 2>/dev/null ) && [ $timeout -ge 1 ] ; do
158
timeout=$(($timeout - 1))
161
[ $timeout -lt 1 ] && kill -9 "$pid" 1>/dev/null 2>&1
162
rm -f "$PIDFILE" "$LOCKFILE"
165
log_failure_msg "$prog shutdown - pidfile is empty"
169
log_success_msg "$prog shutdown - already stopped"
176
if [ -f "$PIDFILE" ]; then
177
read pid < "$PIDFILE"
178
if [ "$pid" != "" ]; then
179
if ps -p "$pid" > /dev/null; then
180
echo "$1 (pid $pid) is running..."
183
echo "$1 stopped but pid file exists"
187
if [ -f $LOCKFILE ]; then
188
echo "$1 stopped but lockfile exists"
207
restart|reload|force-reload)
210
condrestart|try-restart)
211
[ -f $LOCKFILE ] && do_restart || :
217
echo "Usage: $0 {start|stop|restart|status|reload|condrestart|try-restart}"