summaryrefslogtreecommitdiff
path: root/share
diff options
context:
space:
mode:
authorbnewbold <bnewbold@robocracy.org>2012-07-12 17:21:54 -0400
committerbnewbold <bnewbold@robocracy.org>2012-07-12 22:25:50 -0400
commitf1e764f2e5728113f191456236d02fdae6e7680a (patch)
tree46484b2871311fd213c1df2e2b228a0db8635903 /share
parent337560b0d197fb3d1b4fd7cb1fdecc687c9f9758 (diff)
integrate exmachina configuration management layer
- add exmachina code and test code - modify plinth.py to listen for shared secret on stdin at start (if appropriate flag is set) and try to connect to exmachina daemon - use exmachina to read and set /etc/hostname as a demo - update plinth init.d script to start exmachina and share keys - update docs with new deps and run instructions
Diffstat (limited to 'share')
-rwxr-xr-xshare/init.d/plinth45
1 files changed, 41 insertions, 4 deletions
diff --git a/share/init.d/plinth b/share/init.d/plinth
index e364fc1..8cf88a9 100755
--- a/share/init.d/plinth
+++ b/share/init.d/plinth
@@ -12,23 +12,53 @@
# This file is /etc/init.d/plinth
DAEMON=/usr/local/bin/plinth.py
+EXMACHINA_DAEMON=/usr/local/bin/exmachina.py
PID_FILE=/var/run/plinth.pid
-
+EXMACHINA_PID_FILE=/var/run/exmachina.pid
+
+PLINTH_USER=www-data
+PLINTH_GROUP=www-data
+
+test -x $DAEMON || exit 0
+test -x $EXMACHINA_DAEMON || exit 0
+
+set -e
+
+. /lib/lsb/init-functions
+
start_plinth (){
if [ -f $PID_FILE ]; then
- echo Already running with a pid of `cat $PID_FILE`.
+ echo Already running with a pid of `cat $PID_FILE`.
else
- $DAEMON --pidfile=$PID_FILE
+ if [ -f $EXMACHINA_PID_FILE ]; then
+ echo exmachina was already running with a pid of `cat $EXMACHINA_PID_FILE`.
+ kill -15 `cat $EXMACHINA_PID_FILE`
+ rm -rf $EXMACHINA_PID_FILE
+ fi
+ SHAREDKEY=`$EXMACHINA_DAEMON --random-key`
+ touch $PID_FILE
+ chown $PLINTH_USER:$PLINTH_GROUP $PID_FILE
+ echo $SHAREDKEY | $EXMACHINA_DAEMON --pidfile=$EXMACHINA_PID_FILE || rm $PID_FILE
+ sleep 0.5
+ echo $SHAREDKEY | sudo -u $PLINTH_USER -g $PLINTH_GROUP $DAEMON --pidfile=$PID_FILE
fi
}
stop_plinth () {
if [ -f $PID_FILE ]; then
- kill -15 `cat $PID_FILE`
+ kill -15 `cat $PID_FILE` || true
rm -rf $PID_FILE
+ echo "killed plinth"
else
echo "No pid file at $PID_FILE suggests plinth is not running."
fi
+ if [ -f $EXMACHINA_PID_FILE ]; then
+ kill -15 `cat $EXMACHINA_PID_FILE` || true
+ rm -rf $EXMACHINA_PID_FILE
+ echo "killed exmachina"
+ else
+ echo "No pid file at $EXMACHINA_PID_FILE suggests exmachina is not running."
+ fi
}
test -x $DAEMON || exit 0
@@ -45,5 +75,12 @@ case "$1" in
$0 stop
$0 start
;;
+ status)
+ status_of_proc -p $PID_FILE "$DAEMON" plinth && exit 0 || exit $?
+ ;;
+ *)
+ echo "Usage: $NAME {start|stop|restart|status}" >&2
+ exit 1
+ ;;
esac