aboutsummaryrefslogtreecommitdiff
path: root/src/partimage/partimaged
diff options
context:
space:
mode:
authorAdrian C. (anrxc) <anrxc@sysphere.org>2012-11-25 21:24:58 +0100
committerAdrian C. (anrxc) <anrxc@sysphere.org>2012-11-25 21:24:58 +0100
commit16262790cb6ddacf6c632625cc865e03b1b8671f (patch)
tree09898d65deef518380915ecdc7575756c9ca8595 /src/partimage/partimaged
parent7bb1499a7cd539f714bb7f603d7fc0a38fd8a963 (diff)
downloadrcdscripts-16262790cb6ddacf6c632625cc865e03b1b8671f.tar.xz
rcdscripts: import first snapshot of rc.d scripts as of 11.25.20122012.11.25
In 30 days these scripts will start dissapearing from official Arch Linux packages. This is an attempt to conserve them, and keep sysvinit usable.
Diffstat (limited to 'src/partimage/partimaged')
-rwxr-xr-xsrc/partimage/partimaged64
1 files changed, 64 insertions, 0 deletions
diff --git a/src/partimage/partimaged b/src/partimage/partimaged
new file mode 100755
index 0000000..da810cb
--- /dev/null
+++ b/src/partimage/partimaged
@@ -0,0 +1,64 @@
+#!/bin/bash
+# This file belongs in /etc/rc.d
+#
+###############################################################################
+
+#inserting certain functions (like stat_busy)
+. /etc/rc.conf
+. /etc/rc.d/functions
+
+PARTIMAGE=/usr/sbin/
+
+# Check the file is there and is executable.
+[ -x $PARTIMAGE/partimaged ] || exit 0
+
+PID=`pidof -o %PPID /usr/sbin/partimaged`
+
+# See how we were called.
+case "$1" in
+ start)
+ stat_busy "Starting Partimage Daemon "
+ if [ -z "$PID" ]; then
+ /usr/sbin/partimaged -D &>/dev/null
+ RETVAL=$? #storing the status of the last command to RETVAL
+ if [ $? -gt 0 ]; then #if the status was other than 0, the command failed
+ stat_fail
+ exit 1
+ else
+ add_daemon partimaged
+ stat_done
+ fi
+ else
+ stat_fail
+ echo ":: Daemon already started as pid $PID"
+ exit 1
+ fi
+ ;;
+ stop)
+ stat_busy "Stopping Partimage Daemon "
+ if [ "$PID" != "" ]; then #if PID exists
+ kill -KILL $PID &>/dev/null
+ stat_done
+ if [ $? -gt 0 ]; then
+ stat_fail
+ exit 1
+ else
+ RETVAL=$?
+ rm_daemon partimaged
+ fi
+ else
+ stat_fail
+ echo ":: Daemon already stopped"
+ exit 1
+ fi
+ ;;
+ restart|reload)
+ $0 stop
+ $0 start
+ RETVAL=$?
+ ;;
+ *)
+ echo "Usage: partimaged {start|stop|restart|reload}"
+ exit 1
+esac
+exit $RETVAL