Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

Added volumed. If you want it to auto-start whenever it's needed, `/p…

…ath/to/volumecontrol/volumed start --double-check` should do the trick (does a check that's not reliable enough for me to like enabling by default)
  • Loading branch information...
commit 093273f41602099443b4d75206155a956acf3afc 1 parent dbbc36f
Nik Markwell authored May 23, 2011

Showing 1 changed file with 69 additions and 0 deletions. Show diff stats Hide diff stats

  1. 69  volumed
69  volumed
... ...
@@ -0,0 +1,69 @@
  1
+#!/usr/bin/env bash
  2
+
  3
+DIR=$(dirname $(readlink -f $0)) # Directory script is in
  4
+
  5
+function running(){
  6
+  if [ -f "$DIR/pidfile" ]; then
  7
+    if [ "$(ps aux | grep -i $(cat pidfile) | grep -v grep)" != "" ]; then
  8
+      true
  9
+    else
  10
+      rm $DIR/pidfile
  11
+      status
  12
+    fi
  13
+  else
  14
+    false
  15
+  fi
  16
+}
  17
+
  18
+function status(){
  19
+  echo -n "volume daemon is ";
  20
+  if [ !running ]; then
  21
+    echo -n "not ";
  22
+  fi
  23
+  echo "running."
  24
+}
  25
+
  26
+function finish(){
  27
+  if [ "$?" == "0" ]; then
  28
+    echo "[DONE]"
  29
+  else
  30
+    echo "[FAIL]"
  31
+  fi
  32
+}
  33
+
  34
+case "$1" in
  35
+  "stop")
  36
+    if running; then
  37
+      echo -n "Stopping volume daemon..."
  38
+      kill $(cat pidfile)
  39
+      rm pidfile
  40
+      finish
  41
+    else
  42
+      echo "Volume daemon not running."
  43
+    fi
  44
+  ;;
  45
+  "start")
  46
+    if [ "$2" == "--double-check" ] && [ -z "$(ps aux | grep -i volumecontrol | grep -v grep)" ]; then
  47
+      rm $DIR/pidfile
  48
+    fi
  49
+    
  50
+    if [ -f "$DIR/pidfile" ]; then
  51
+      echo "Volume daemon already running, perhaps you meant \`$0 restart\`?"
  52
+    else
  53
+      echo -n "Starting volume daemon..."
  54
+      $DIR/server.rb &> /dev/null &
  55
+      echo $! > $DIR/pidfile
  56
+      finish
  57
+    fi
  58
+  ;;
  59
+  "restart")
  60
+    $0 stop --silent
  61
+    $0 start --silent
  62
+  ;;
  63
+  "status")
  64
+    status
  65
+  ;;
  66
+  *)
  67
+    echo "Usage: $0 (start|stop|restart|status|help)"
  68
+  ;;
  69
+esac

0 notes on commit 093273f

Please sign in to comment.
Something went wrong with that request. Please try again.