diff --git a/share/scripts/one b/share/scripts/one index 24135ebdc9..658fb235e6 100755 --- a/share/scripts/one +++ b/share/scripts/one @@ -45,44 +45,44 @@ setup() PORT=$(sed -n '/^[ \t]*PORT/s/^.*PORT\s*=\s*\([0-9]\+\)\s*.*$/\1/p' \ $ONE_CONF) - if [ $? -ne 0 ]; then - echo "Can not find PORT in $ONE_CONF." - exit 1 - fi + if [ $? -ne 0 ]; then + echo "Can not find PORT in $ONE_CONF." + exit 1 + fi - if [ -f $LOCK_FILE ]; then - if [ -f $ONE_PID ]; then - ONEPID=`cat $ONE_PID` - ps $ONEPID > /dev/null 2>&1 - if [ $? -eq 0 ]; then - echo "ONE is still running (PID:$ONEPID). Please try 'one stop' first." - exit 1 - fi - fi - if [ -f $ONE_SCHEDPID ]; then - ONESCHEDPID=`cat $ONE_SCHEDPID` - ps $ONESCHEDPID > /dev/null 2>&1 - if [ $? -eq 0 ]; then - echo "The scheduler is still running (PID:$ONEPID). Please try 'one stop' first." - exit 1 - fi - fi - echo "Stale .lock detected. Erasing it." - rm $LOCK_FILE - fi + if [ -f $LOCK_FILE ]; then + if [ -f $ONE_PID ]; then + ONEPID=`cat $ONE_PID` + ps $ONEPID > /dev/null 2>&1 + if [ $? -eq 0 ]; then + echo "ONE is still running (PID:$ONEPID). Please try 'one stop' first." + exit 1 + fi + fi + if [ -f $ONE_SCHEDPID ]; then + ONESCHEDPID=`cat $ONE_SCHEDPID` + ps $ONESCHEDPID > /dev/null 2>&1 + if [ $? -eq 0 ]; then + echo "The scheduler is still running (PID:$ONEPID). Please try 'one stop' first." + exit 1 + fi + fi + echo "Stale .lock detected. Erasing it." + rm $LOCK_FILE + fi } start() { - if [ ! -x "$ONED" ]; then - echo "Can not find $ONED." - exit 1 - fi + if [ ! -x "$ONED" ]; then + echo "Can not find $ONED." + exit 1 + fi - if [ ! -x "$ONE_SCHEDULER" ]; then - echo "Can not find $ONE_SCHEDULER." - exit 1 - fi + if [ ! -x "$ONE_SCHEDULER" ]; then + echo "Can not find $ONE_SCHEDULER." + exit 1 + fi if [ ! -f "$ONE_DB" ]; then if [ ! -f "$HOME/.one/one_auth" ]; then @@ -101,28 +101,28 @@ start() [ -f "$ONE_LOG" ] && cp $ONE_LOG{,.$(date '+%Y%m%d%H%M')} fi - # Start the one daemon - $ONED -f 2>&1 & + # Start the one daemon + $ONED -f 2>&1 & - LASTRC=$? - LASTPID=$! + LASTRC=$? + LASTPID=$! - if [ $LASTRC -ne 0 ]; then - echo "Error executing $ONED" - exit 1 - else - echo $LASTPID > $ONE_PID - fi + if [ $LASTRC -ne 0 ]; then + echo "Error executing $ONED" + exit 1 + else + echo $LASTPID > $ONE_PID + fi - sleep 1 - ps $LASTPID > /dev/null 2>&1 + sleep 1 + ps $LASTPID > /dev/null 2>&1 - if [ $? -ne 0 ]; then - echo "Error executing $ONED." - exit 1 - fi + if [ $? -ne 0 ]; then + echo "Error executing $ONED." + exit 1 + fi - # Start the scheduler + # Start the scheduler # The following command line arguments are supported by mm_shed: # [-p port] to connect to oned - default: 2633 # [-t timer] seconds between two scheduling actions - default: 30 @@ -133,19 +133,19 @@ start() # [-h host dispatch] max number of VMs dispatched to a given host in each # scheduling action - default: 1 - $ONE_SCHEDULER -p $PORT -t 30 -m 300 -d 30 -h 1& + $ONE_SCHEDULER -p $PORT -t 30 -m 300 -d 30 -h 1& - LASTRC=$? - LASTPID=$! + LASTRC=$? + LASTPID=$! - if [ $LASTRC -ne 0 ]; then - echo "Error executing $ONE_SCHEDULER" - exit 1 - else - echo $LASTPID > $ONE_SCHEDPID - fi + if [ $LASTRC -ne 0 ]; then + echo "Error executing $ONE_SCHEDULER" + exit 1 + else + echo $LASTPID > $ONE_SCHEDPID + fi - echo "oned and scheduler started" + echo "oned and scheduler started" } # @@ -153,30 +153,30 @@ start() # stop() { - if [ ! -f $ONE_PID ]; then - echo "Couldn't find oned process pid." - exit 1 - fi + if [ ! -f $ONE_PID ]; then + echo "Couldn't find oned process pid." + exit 1 + fi - if [ ! -f $ONE_SCHEDPID ]; then - echo "Couldn't find scheduler process pid." - exit 1 - fi + if [ ! -f $ONE_SCHEDPID ]; then + echo "Couldn't find scheduler process pid." + exit 1 + fi - # Kill the one daemon + # Kill the one daemon - kill `cat $ONE_PID` > /dev/null 2>&1 + kill `cat $ONE_PID` > /dev/null 2>&1 - # Kill the scheduler + # Kill the scheduler - kill `cat $ONE_SCHEDPID` > /dev/null 2>&1 + kill `cat $ONE_SCHEDPID` > /dev/null 2>&1 - # Remove pid files + # Remove pid files - rm -f $ONE_PID > /dev/null 2>&1 - rm -f $ONE_SCHEDPID > /dev/null 2>&1 + rm -f $ONE_PID > /dev/null 2>&1 + rm -f $ONE_SCHEDPID > /dev/null 2>&1 - echo "oned and scheduler stopped" + echo "oned and scheduler stopped" } if [ "$1" = "-b" ]; then @@ -185,18 +185,18 @@ if [ "$1" = "-b" ]; then fi case "$1" in - start) - setup - start - ;; - stop) - stop - ;; - *) - echo "Usage: one [-b] {start|stop}" >&2 - echo "Options:" >&2 - echo " -b Backup log file." >&2 - exit 3 - ;; + start) + setup + start + ;; + stop) + stop + ;; + *) + echo "Usage: one [-b] {start|stop}" >&2 + echo "Options:" >&2 + echo " -b Backup log file." >&2 + exit 3 + ;; esac