Module: xenomai-3
Branch: master
Commit: 9cacfdae4735f6d9964053ea1f65a15cbdc5b629
URL:    
http://git.xenomai.org/?p=xenomai-3.git;a=commit;h=9cacfdae4735f6d9964053ea1f65a15cbdc5b629

Author: Jan Kiszka <jan.kis...@siemens.com>
Date:   Thu Jan  8 17:08:46 2015 +0100

scripts: Add multi-user service setup scripts

This script can be hooked up with the system in order to allow
unprivileged members of the xenomai group to access real-time services
as well. It configures the module parameter, creates the registry root
directory with the appropriate access rights and ensures that a sysreg
daemon for the anon session is running.

Signed-off-by: Jan Kiszka <jan.kis...@siemens.com>

---

 scripts/xeno-multiuser |   91 ++++++++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 91 insertions(+)

diff --git a/scripts/xeno-multiuser b/scripts/xeno-multiuser
new file mode 100755
index 0000000..5f4d380
--- /dev/null
+++ b/scripts/xeno-multiuser
@@ -0,0 +1,91 @@
+#! /bin/sh
+#
+# Copyright (C) 2015 Siemens AG
+#
+# Authors:
+#  Jan Kiszka <jan.kis...@siemens.com>
+#
+# Released under the terms of the GPLv2.
+#
+
+### BEGIN INIT INFO
+# Provides:          xeno-multiuser
+# Required-Start:    $syslog
+# Required-Stop:     $syslog
+# Default-Start:     2 3 4 5
+# Default-Stop:      0 1 6
+# Short-Description: Xenomai multi-user setup
+### END INIT INFO
+
+PATH=/sbin:/usr/sbin:/bin:/usr/bin
+DESC="Xenomai multi-user setup"
+NAME=xenomai
+DAEMON=/usr/sbin/sysregd
+DAEMON_ARGS="--linger --shared"
+PIDFILE=/var/run/$NAME.pid
+SCRIPTNAME=/etc/init.d/$NAME
+
+SYSREG_ROOT=/var/run/xenomai
+XENOMAI_GROUP=xenomai
+
+# Exit if the package is not installed
+[ -x "$DAEMON" ] || exit 0
+
+. /lib/lsb/init-functions
+
+do_start()
+{
+       pidofproc -p $PIDFILE "$DAEMON" >/dev/null && return 0
+
+       echo `getent group $XENOMAI_GROUP | cut -d: -f3` > 
/sys/module/xenomai/parameters/allowed_group
+
+       mkdir -p $SYSREG_ROOT
+       chgrp $XENOMAI_GROUP $SYSREG_ROOT
+       chmod g+rwxs $SYSREG_ROOT
+
+       sg $XENOMAI_GROUP -c "
+               $DAEMON $DAEMON_ARGS --root=$SYSREG_ROOT/anon &
+               [ \$? == 0 ] || return 1;
+               echo \$! > $PIDFILE
+               "
+       return $?
+}
+
+do_stop()
+{
+       killproc -p $PIDFILE $DAEMON
+       RETVAL="$?"
+       rm -f $PIDFILE
+       # Clean up mountpoint root dir
+       rm -rf $SYSREG_ROOT
+
+       [ "$RETVAL" == 0 ] || return 1
+       return 0
+}
+
+case "$1" in
+  start)
+       do_start
+       ;;
+  stop)
+       do_stop
+       ;;
+  status)
+       pidofproc -p $PIDFILE "$DAEMON" >/dev/null && exit 0 || exit $?
+       ;;
+  restart|force-reload)
+       do_stop
+       case "$?" in
+         0|1)
+               do_start
+               ;;
+         *)
+               # Failed to stop
+               ;;
+       esac
+       ;;
+  *)
+       echo "Usage: $SCRIPTNAME {start|stop|status|restart|force-reload}" >&2
+       exit 3
+       ;;
+esac


_______________________________________________
Xenomai-git mailing list
Xenomai-git@xenomai.org
http://www.xenomai.org/mailman/listinfo/xenomai-git

Reply via email to