3.mfrisbeed-ops.sh.in 3.36 KB
Newer Older
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
#!/bin/sh

# PROVIDE: mfrisbeed
# REQUIRE: DAEMON ntpd
# BEFORE: testbed
# KEYWORD: shutdown

#
# Start up the frisbee upload-only master server on ops (fs).
#
# We run it under the daemon wrapper if available so that it will get
# automatically restarted.
#

#
# Default values for configuration variables.
# XXX Not synchronized with sitevars right now.
#
# BASEPORT: base multicast port number.
#     Zero means any ephemeral port.
#     Unset to use mfrisbeed default.
# NUMPORT: number of ports to allow.
#     Range will be BASEPORT to BASEPORT+NUMPORT.
#     Zero means any ephemeral port above the base.
#     Unset to use mfrisbeed default.
# MAXSIZE: maximum size of an uploaded image in GB.
#     Unset to use mfrisbeed default.
# MAXWAIT: maximum time to allow for an upload to finish in minutes.
#     Zero means wait forever.
#     Unset to use mfrisbeed default.
# MAXIDLE: maximum idle time to allow during an active upload in minutes
#     Zero means wait forever.
#     Constrainted by the MAXWAIT timeout.
#     Unset to use mfrisbeed default.
# DEBUG: set to run with debugging enabled.
#
37 38
BASEPORT="@FRISEBEEMCASTPORT@"
NUMPORT="@FRISEBEENUMPORTS@"
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 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140
MAXSIZE=20
MAXWAIT=60
MAXIDLE=5
DEBUG=true

. /etc/rc.subr

if [ "@IMAGEUPLOADTOFS@" != "1" ]; then
    exit 0
fi

bindir=@prefix@/sbin
if [ ! -x $bindir/mfrisbeed -o ! -x $bindir/frisuploadd ]; then
    echo "*** mfrisbeed.sh: $bindir/mfrisbeed or frisuploadd not installed"
    exit 1
fi

case "$1" in
start|faststart|quietstart|onestart|forcestart)
    ;;
restart|fastrestart|quietrestart|onerestart|forcerestart)
    if [ -f /var/run/mfrisbeed_wrapper.pid ]; then
	kill `cat /var/run/mfrisbeed_wrapper.pid` >/dev/null 2>&1
	rm -f /var/run/mfrisbeed_wrapper.pid
    fi
    if [ -f /var/run/mfrisbeed.pid ]; then
	kill `cat /var/run/mfrisbeed.pid` >/dev/null 2>&1
	rm -f /var/run/mfrisbeed.pid
    fi
    ;;
stop|faststop|quietstop|onestop|forcestop)
    echo -n ' mfrisbeed'
    if [ -f /var/run/mfrisbeed_wrapper.pid ]; then
	kill `cat /var/run/mfrisbeed_wrapper.pid` >/dev/null 2>&1
	rm -f /var/run/mfrisbeed_wrapper.pid
    fi
    if [ -f /var/run/mfrisbeed.pid ]; then
	kill `cat /var/run/mfrisbeed.pid` >/dev/null 2>&1
	rm -f /var/run/mfrisbeed.pid
    fi
    rm -f /var/run/frisbeed-*.pid
    exit 0
    ;;
*)
    echo "Usage: $0 {start|stop|restart}" >&2
    exit 1
    ;;
esac

echo -n " mfrisbeed"
rm -f /var/run/frisbeed-*.pid

args="-C upload-only -r put -S @BOSSNODE_IP@ -A -M"
if [ "$DEBUG" = "true" ]; then
   args="-ddD $args"
fi

opts=""
if [ -n "$BASEPORT" ]; then
    if [ -z "$opts" ]; then
	opts="-O portbase=$BASEPORT"
    else
	opts="$opts,mcportbase=$BASEPORT"
    fi
fi
if [ -n "$NUMPORT" ]; then
    if [ -z "$opts" ]; then
	opts="-O portnum=$NUMPORT"
    else
	opts="$opts,portnum=$NUMPORT"
    fi
fi
if [ -n "$MAXSIZE" ]; then
    if [ -z "$opts" ]; then
	opts="-O maxsize=$MAXSIZE"
    else
	opts="$opts,maxsize=$MAXSIZE"
    fi
fi
if [ -n "$MAXWAIT" ]; then
    if [ -z "$opts" ]; then
	opts="-O maxwait=$MAXWAIT"
    else
	opts="$opts,maxwait=$MAXWAIT"
    fi
fi
if [ -n "$MAXIDLE" ]; then
    if [ -z "$opts" ]; then
	opts="-O maxidle=$MAXIDLE"
    else
	opts="$opts,maxidle=$MAXIDLE"
    fi
fi

if [ "$DEBUG" != "true" -a -x @prefix@/sbin/daemon_wrapper ]; then
    @prefix@/sbin/daemon_wrapper -i 30 -l @prefix@/log/mfrisbeed_wrapper.log \
	@prefix@/sbin/mfrisbeed -d $args $opts
else
    @prefix@/sbin/mfrisbeed $args $opts
fi

exit $?