summaryrefslogtreecommitdiffstats
path: root/system/bees/rc.bees
diff options
context:
space:
mode:
Diffstat (limited to 'system/bees/rc.bees')
-rw-r--r--system/bees/rc.bees69
1 files changed, 69 insertions, 0 deletions
diff --git a/system/bees/rc.bees b/system/bees/rc.bees
new file mode 100644
index 0000000000..e28122e496
--- /dev/null
+++ b/system/bees/rc.bees
@@ -0,0 +1,69 @@
+#!/bin/bash
+
+declare -a UUIDS
+declare -a LOGFILES
+
+. /etc/rc.d/rc.bees.conf
+
+umount_uuid()
+{
+ UUID="$1"
+ MNT="/run/bees/mnt/$UUID"
+ # Try for up to 10 seconds and then bail out
+ for _ in {1..10} ; do
+ umount "$MNT" > /dev/null 2>&1
+ if mountpoint -q "$MNT" ; then
+ sleep 1
+ else
+ break
+ fi
+ done
+}
+
+bees_start()
+{
+ for i in "${!UUIDS[@]}" ; do
+ UUID="${UUIDS[$i]}"
+ LOGFILE="${LOGFILES[$i]}"
+ umount_uuid "$UUID"
+ nice -n 15 ionice -c 3 daemon --name="bees.$UUID" --output="$LOGFILE" -- beesd "$UUID"
+ done
+}
+
+bees_stop()
+{
+ for UUID in "${UUIDS[@]}" ; do
+ daemon --name="bees.$UUID" --stop
+ umount_uuid "$UUID"
+ done
+}
+
+bees_status()
+{
+ for UUID in "${UUIDS[@]}" ; do
+ daemon --name="bees.$UUID" --running --verbose
+ done
+}
+
+bees_forcestop()
+{
+ killall bees
+}
+
+case "$1" in
+ 'start')
+ bees_start
+ ;;
+ 'stop')
+ bees_stop
+ ;;
+ 'status')
+ bees_status
+ ;;
+ 'forcestop')
+ bees_forcestop
+ ;;
+ *)
+ echo "usage $0 start|stop|status|forcestop"
+ ;;
+esac