#!/sbin/sh
#
# Copyright 2011, 2016, Oracle and/or its affiliates. All rights reserved.
#
. /lib/svc/share/smf_include.sh
case "$1" in
'start')
FMRI=svc:/system/consolekit
arg=`eval "echo \`svcprop -p consolekit/args $FMRI\`"`
SEATFILE=/etc/ConsoleKit/seats.d/00-primary.seat
rep=`eval "echo \`svcprop -p consolekit/sessions $FMRI\`"`
curline=`sed -n "/Sessions=/p" $SEATFILE`
cur=`expr $curline : "Sessions=\(.*\);"`
if [[ $cur != $rep ]]; then
/usr/bin/ex $SEATFILE << EOF
/$curline
s/$curline/Sessions=$rep;/
w
q
EOF
fi
/usr/sbin/console-kit-daemon $arg
rc=$?
if [ $rc -ne 0 ]; then
echo "$0: consolekit failed with $rc"
exit $SMF_EXIT_ERR_FATAL
fi
;;
*)
echo "Usage: $0 { start }"
exit $SMF_EXIT_ERR_FATAL
;;
esac
exit $SMF_EXIT_OK