2011-09-26 18:03:33 +00:00
|
|
|
#! /bin/sh
|
|
|
|
### BEGIN INIT INFO
|
2011-10-03 22:02:24 +00:00
|
|
|
# Provides: radosgw
|
2011-09-26 18:03:33 +00:00
|
|
|
# Required-Start: $remote_fs $named $network $time
|
|
|
|
# Required-Stop: $remote_fs $named $network $time
|
2012-04-11 17:51:16 +00:00
|
|
|
# Default-Start: 2 3 4 5
|
2011-09-26 18:03:33 +00:00
|
|
|
# Default-Stop: 0 1 6
|
2011-10-03 22:02:24 +00:00
|
|
|
# Short-Description: radosgw RESTful rados gateway
|
2011-09-26 18:03:33 +00:00
|
|
|
### END INIT INFO
|
|
|
|
|
|
|
|
PATH=/sbin:/bin:/usr/bin
|
|
|
|
|
|
|
|
. /lib/lsb/init-functions
|
|
|
|
|
2013-11-05 16:40:31 +00:00
|
|
|
daemon_is_running() {
|
|
|
|
daemon=$1
|
|
|
|
if pidof $daemon >/dev/null; then
|
|
|
|
echo "$daemon is running."
|
|
|
|
exit 0
|
|
|
|
else
|
|
|
|
echo "$daemon is not running."
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
}
|
|
|
|
|
2013-11-05 17:02:47 +00:00
|
|
|
VERBOSE=0
|
|
|
|
for opt in $*; do
|
|
|
|
if [ "$opt" = "-v" ] || [ "$opt" = "--verbose" ]; then
|
|
|
|
VERBOSE=1
|
|
|
|
fi
|
|
|
|
done
|
|
|
|
|
2011-09-26 18:03:33 +00:00
|
|
|
# prefix for radosgw instances in ceph.conf
|
|
|
|
PREFIX='client.radosgw.'
|
|
|
|
|
2011-10-03 22:13:31 +00:00
|
|
|
# user to run radosgw as (it not specified in ceph.conf)
|
|
|
|
DEFAULT_USER='www-data'
|
2011-09-26 18:03:33 +00:00
|
|
|
|
|
|
|
RADOSGW=`which radosgw`
|
|
|
|
if [ ! -x "$RADOSGW" ]; then
|
2013-11-05 17:02:47 +00:00
|
|
|
[ $VERBOSE -eq 1 ] && echo "$RADOSGW could not start, it is not executable."
|
2013-11-05 16:32:58 +00:00
|
|
|
exit 1
|
2011-09-26 18:03:33 +00:00
|
|
|
fi
|
|
|
|
|
|
|
|
case "$1" in
|
|
|
|
start)
|
2013-06-06 13:21:30 +00:00
|
|
|
for name in `ceph-conf --list-sections $PREFIX`;
|
|
|
|
do
|
|
|
|
auto_start=`ceph-conf -n $name 'auto start'`
|
|
|
|
if [ "$auto_start" = "no" ] || [ "$auto_start" = "false" ] || [ "$auto_start" = "0" ]; then
|
|
|
|
continue
|
|
|
|
fi
|
2011-09-26 18:03:33 +00:00
|
|
|
|
|
|
|
# is the socket defined? if it's not, this instance shouldn't run as a daemon.
|
2013-06-20 02:38:17 +00:00
|
|
|
rgw_socket=`$RADOSGW -n $name --show-config-value rgw_socket_path`
|
2013-06-06 13:21:30 +00:00
|
|
|
if [ -z "$rgw_socket" ]; then
|
|
|
|
continue
|
|
|
|
fi
|
2011-09-26 18:03:33 +00:00
|
|
|
|
|
|
|
# mapped to this host?
|
2013-06-06 13:21:30 +00:00
|
|
|
host=`ceph-conf -n $name host`
|
2013-11-05 17:02:47 +00:00
|
|
|
hostname=`hostname -s`
|
|
|
|
if [ "$host" != "$hostname" ]; then
|
|
|
|
[ $VERBOSE -eq 1 ] && echo "hostname $hostname could not be found in ceph.conf:[$name], not starting."
|
2013-06-06 13:21:30 +00:00
|
|
|
continue
|
|
|
|
fi
|
2011-09-26 18:03:33 +00:00
|
|
|
|
2013-06-06 13:21:30 +00:00
|
|
|
user=`ceph-conf -n $name user`
|
|
|
|
if [ -z "$user" ]; then
|
|
|
|
user="$DEFAULT_USER"
|
|
|
|
fi
|
2011-10-03 22:13:31 +00:00
|
|
|
|
2013-06-20 02:38:17 +00:00
|
|
|
log_file=`$RADOSGW -n $name --show-config-value log_file`
|
2013-06-06 13:21:30 +00:00
|
|
|
if [ -n "$log_file" ] && [ ! -e "$log_file" ]; then
|
|
|
|
touch "$log_file"
|
|
|
|
chown $user $log_file
|
|
|
|
fi
|
2011-10-05 20:37:10 +00:00
|
|
|
|
2011-09-26 18:03:33 +00:00
|
|
|
echo "Starting $name..."
|
2013-06-06 13:21:30 +00:00
|
|
|
start-stop-daemon --start -u $user -x $RADOSGW -- -n $name
|
|
|
|
done
|
2013-11-05 16:40:31 +00:00
|
|
|
daemon_is_running $RADOSGW
|
2011-09-26 18:03:33 +00:00
|
|
|
;;
|
2012-02-29 17:23:22 +00:00
|
|
|
reload)
|
2013-06-06 13:21:30 +00:00
|
|
|
echo "Reloading $name..."
|
|
|
|
start-stop-daemon --stop --signal HUP -x $RADOSGW --oknodo
|
|
|
|
;;
|
2012-02-29 17:23:22 +00:00
|
|
|
restart|force-reload)
|
2011-09-26 18:03:33 +00:00
|
|
|
$0 stop
|
|
|
|
$0 start
|
|
|
|
;;
|
|
|
|
stop)
|
2011-10-03 22:23:15 +00:00
|
|
|
start-stop-daemon --stop -x $RADOSGW --oknodo
|
2011-09-26 18:03:33 +00:00
|
|
|
;;
|
2013-06-06 13:33:23 +00:00
|
|
|
status)
|
2013-11-05 16:40:31 +00:00
|
|
|
daemon_is_running $RADOSGW
|
2013-06-06 13:33:23 +00:00
|
|
|
;;
|
2011-09-26 18:03:33 +00:00
|
|
|
*)
|
2013-11-05 17:02:47 +00:00
|
|
|
echo "Usage: $0 {start|stop|restart|force-reload|reload|status} [-v|--verbose]" >&2
|
2011-09-26 18:03:33 +00:00
|
|
|
exit 3
|
|
|
|
;;
|
|
|
|
esac
|
|
|
|
|