2006-01-26 00:37:29 -05:00
|
|
|
#!/bin/bash
|
|
|
|
#
|
2006-03-21 15:25:41 -05:00
|
|
|
# Copyright 2006 The Apache Software Foundation
|
|
|
|
#
|
|
|
|
# Licensed under the Apache License, Version 2.0 (the "License");
|
|
|
|
# you may not use this file except in compliance with the License.
|
|
|
|
# You may obtain a copy of the License at
|
|
|
|
#
|
|
|
|
# http://www.apache.org/licenses/LICENSE-2.0
|
|
|
|
#
|
|
|
|
# Unless required by applicable law or agreed to in writing, software
|
|
|
|
# distributed under the License is distributed on an "AS IS" BASIS,
|
|
|
|
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
|
|
# See the License for the specific language governing permissions and
|
|
|
|
# limitations under the License.
|
2006-01-26 00:37:29 -05:00
|
|
|
#
|
2006-03-02 23:33:24 -05:00
|
|
|
# Shell script to stop rsyncd on master Solr server
|
2006-01-26 00:37:29 -05:00
|
|
|
|
2006-03-21 15:25:41 -05:00
|
|
|
orig_dir=$(pwd)
|
|
|
|
cd ${0%/*}/..
|
|
|
|
solr_root=$(pwd)
|
|
|
|
cd ${orig_dir}
|
2006-01-26 00:37:29 -05:00
|
|
|
|
2006-07-06 15:14:40 -04:00
|
|
|
unset user verbose debug
|
2006-03-21 15:25:41 -05:00
|
|
|
. ${solr_root}/bin/scripts-util
|
2006-01-26 00:37:29 -05:00
|
|
|
|
2006-03-21 15:25:41 -05:00
|
|
|
# set up variables
|
2006-01-26 00:37:29 -05:00
|
|
|
prog=${0##*/}
|
2006-03-21 15:25:41 -05:00
|
|
|
log=${solr_root}/logs/rsyncd.log
|
2006-01-26 00:37:29 -05:00
|
|
|
|
|
|
|
# define usage string
|
|
|
|
USAGE="\
|
2006-03-21 15:25:41 -05:00
|
|
|
usage: $prog [-u username] [-v]
|
|
|
|
-u specify user to sudo to before running script
|
2006-01-26 00:37:29 -05:00
|
|
|
-v increase verbosity
|
2006-07-06 15:14:40 -04:00
|
|
|
-V output debugging info
|
2006-01-26 00:37:29 -05:00
|
|
|
"
|
|
|
|
|
|
|
|
# parse args
|
2006-07-06 15:14:40 -04:00
|
|
|
while getopts u:vV OPTION
|
2006-01-26 00:37:29 -05:00
|
|
|
do
|
|
|
|
case $OPTION in
|
2006-03-21 15:25:41 -05:00
|
|
|
u)
|
|
|
|
user="$OPTARG"
|
|
|
|
;;
|
2006-01-26 00:37:29 -05:00
|
|
|
v)
|
|
|
|
verbose="v"
|
|
|
|
;;
|
2006-07-06 15:14:40 -04:00
|
|
|
V)
|
|
|
|
debug="V"
|
|
|
|
;;
|
2006-01-26 00:37:29 -05:00
|
|
|
*)
|
|
|
|
echo "$USAGE"
|
|
|
|
exit 1
|
|
|
|
esac
|
|
|
|
done
|
|
|
|
|
2006-07-06 15:14:40 -04:00
|
|
|
[[ -n $debug ]] && set -x
|
|
|
|
|
2006-03-21 15:25:41 -05:00
|
|
|
fixUser "$@"
|
2006-01-26 00:37:29 -05:00
|
|
|
|
|
|
|
logMessage stopped by $oldwhoami
|
2006-03-21 15:25:41 -05:00
|
|
|
logMessage command: $0 $@
|
|
|
|
|
|
|
|
# look for pid file
|
|
|
|
if [[ ! -f ${solr_root}/logs/rsyncd.pid ]]
|
|
|
|
then
|
|
|
|
logMessage "missing rsyncd pid file ${solr_root}/logs/rsyncd.pid"
|
|
|
|
exit 2
|
|
|
|
fi
|
2006-01-26 00:37:29 -05:00
|
|
|
|
|
|
|
# get PID from file
|
2006-03-21 15:25:41 -05:00
|
|
|
pid=$(<${solr_root}/logs/rsyncd.pid)
|
2006-01-26 00:37:29 -05:00
|
|
|
if [[ -z $pid ]]
|
|
|
|
then
|
|
|
|
logMessage "unable to get rsyncd's PID"
|
|
|
|
exit 2
|
|
|
|
fi
|
|
|
|
|
|
|
|
kill $pid
|
|
|
|
|
|
|
|
# wait until rsyncd dies or we time out
|
|
|
|
dead=0
|
|
|
|
timer=0
|
|
|
|
timeout=300
|
|
|
|
while (( ! dead && timer < timeout ))
|
|
|
|
do
|
2006-02-27 20:18:40 -05:00
|
|
|
if ps -eo pid | grep -qw $pid
|
2006-01-26 00:37:29 -05:00
|
|
|
then
|
|
|
|
kill $pid
|
|
|
|
(( timer++ ))
|
|
|
|
sleep 1
|
|
|
|
else
|
|
|
|
dead=1
|
|
|
|
fi
|
|
|
|
done
|
2006-02-27 20:18:40 -05:00
|
|
|
if ps -eo pid | grep -qw $pid
|
2006-01-26 00:37:29 -05:00
|
|
|
then
|
|
|
|
logMessage rsyncd failed to stop after $timeout seconds
|
|
|
|
exit 3
|
|
|
|
fi
|
2006-03-21 15:25:41 -05:00
|
|
|
|
|
|
|
# remove rsyncd.conf
|
2006-07-06 15:14:40 -04:00
|
|
|
/bin/rm -f ${solr_root}/conf/rsyncd.conf
|