#!/bin/sh
# Customise this file to start and stop your application as necessary.
. /lib/svc/share/smf_include.sh
getproparg() {
val=`svcprop -p $1 $SMF_FMRI`
[ -n "$val" ] && echo $val
}
VM=`getproparg vbox/VM`
if [ -z $SMF_FMRI ]; then
echo "Error: SMF framework variables are not initialized"
exit $SMF_EXIT_ERR
fi
case "$1" in
'start') /opt/VirtualBox/VBoxHeadless -s $VM &
;;
'stop') /opt/VirtualBox/VBoxManage controlvm $VM savestate
;;
'refresh') /opt/VirtualBox/VBoxManage controlvm $VM reset
;;
*) echo "Usage: $0 { start | stop | refresh }"
exit 1
;;
esac
exit $SMF_EXIT_OK
/var/svc/manifest/application/vboxheadless.xml:
<?xml version="1.0"?>
<!DOCTYPE service_bundle SYSTEM "/usr/share/lib/xml/dtd/service_bundle.dtd.1">
<service_bundle type='manifest' name='vboxheadless'>
<service name='application/vboxheadless' type='service' version='1'>
<method_context>
<method_credential user='root' group='root' />
</method_context>
<exec_method type='method' name='start'
exec='/lib/svc/method/vboxheadless start'
timeout_seconds="60" />
<exec_method type='method' name='stop'
exec='/lib/svc/method/vboxheadless stop'
timeout_seconds="60" />
<exec_method type='method' name='refresh'
exec='/lib/svc/method/vboxheadless refresh'
timeout_seconds="60" />
<property_group name="startd" type="framework">
<propval name="duration" type="astring" value="transient"/>
</property_group>
<instance name='w7' enabled='true'>
<property_group name='vbox' type='application'>
<propval name='VM' type='astring'
value='w7' />
</property_group>
</instance>
<stability value='Unstable' />
<template>
<common_name>
<loctext xml:lang='C'>VirtualBox Headless</loctext>
</common_name>
<documentation>
<manpage title='VBoxManage' section='1m' manpath='/usr/share/man' />
<doc_link name='homepage' uri='http://sgpit.com/smf' />
</documentation>
</template>
</service>
</service_bundle>
No comments:
Post a Comment