Sybase SMF scripts

/etc/sybase_config contains:
# Sybase config
#run_user;sybase_home;config;db_user;db_pass
syb_run_user;/sybserver/sybase_instance_home;instance_name;none;none

Sybase_to_smf.sh
is for creation of SMF manifests:

#!/sbin/sh

SYBASE_CONFIG=./sybase_config

if [ ! -s $SYBASE_CONFIG ] ; then
echo "The Sybase configuration-file $SYBASE_CONFIG does not exist or is empty!"
fi



for DATASERVER_ENTRY in ` grep -v "^#" $SYBASE_CONFIG ` ; do
RUN_USER=`echo $DATASERVER_ENTRY | cut -f1 -d\;`
SERVER_HOME=`echo $DATASERVER_ENTRY | cut -f2 -d\;`
CONFIG_NAME=`echo $DATASERVER_ENTRY | cut -f3 -d\;`

cat<<EOF >$CONFIG_NAME.xml
<?xml version='1.0'?>
<!DOCTYPE service_bundle SYSTEM '/usr/share/lib/xml/dtd/service_bundle.dtd.1'>
<service_bundle type='manifest' name='export'>
<service name='database/sybase' type='service' version='0'>
<dependency name='network-service' grouping='require_all' restart_on='none' type='service'>
<service_fmri value='svc:/network/service'/>
</dependency>
<exec_method name='start' type='method' exec='/lib/svc/method/sybase start' timeout_seconds='600'>
<method_context/>
</exec_method>
<exec_method name='stop' type='method' exec='/lib/svc/method/sybase stop' timeout_seconds='3'>
<method_context/>
</exec_method>
<instance name='$CONFIG_NAME' enabled='false'>
<property_group name='vars' type='framework'>
<propval name='run_user' type='astring' value='$RUN_USER'/>
<propval name='server_home' type='astring' value='$SERVER_HOME'/>
<propval name='config_name' type='astring' value='RUN_$CONFIG_NAME'/>
<propval name='server_name' type='astring' value='$CONFIG_NAME'/>
</property_group>
</instance>
<stability value='Unstable'/>
<template>
<common_name>
<loctext xml:lang='C'>layered network services</loctext>
</common_name>
<description>
<loctext xml:lang='C'>Network infrastructure services
requiring name service availability.</loctext>
</description>
<documentation>
<manpage title='ifconfig' section='1M' manpath='/usr/share/man'/>
</documentation>
</template>
</service>
</service_bundle>
EOF

done

This one put into /lib/svc/method:
#!/sbin/sh -x

. /lib/svc/share/smf_include.sh
getproparg() {
val=`svcprop -p $1 $SMF_FMRI`
[ -n "$val" ] && echo $val
}
RUN_USER=`getproparg vars/run_user`
RUN_USER_HOME=`getproparg vars/server_home`
CONFIG_NAME=`getproparg vars/config_name`
SERVER_NAME=`getproparg vars/server_name`


STARTSERVER=$RUN_USER_HOME/system/ASE-15_0/install/startserver
STARTSERVER_CONF=$RUN_USER_HOME/cfg/$CONFIG_NAME
STOPSERVER="pkill -u $RUN_USER"

SYBASE_CONFIG=/etc/sybase_config
if [ ! -s $SYBASE_CONFIG ] ; then
echo "The Sybase configuration-file $SYBASE_CONFIG does not exist or is empty!"
fi

for DATASERVER_ENTRY in ` grep -v "^#" $SYBASE_CONFIG ` ; do
DB_USER=`echo $DATASERVER_ENTRY | cut -f4 -d\;`
DB_PASS=`echo $DATASERVER_ENTRY | cut -f5 -d\;`
done


case "$1" in
'start')
if [ -x $STARTSERVER ]; then
umask 022
su - $RUN_USER -c ".profile; $STARTSERVER -f $STARTSERVER_CONF" 2>&1
else
echo "$0: $STARTSERVER does not exist or is not executable."
fi
;;

'restart')
if [ -x $STARTSERVER ]; then
umask 022
$STOPSERVER
su - $RUN_USER -c ".profile; $STARTSERVER -f $STARTSERVER_CONF" 2>&1
else
echo "$0: $STARTSERVER does not exist or is not executable."
fi
;;

'stop')
#su - $RUN_USER -c "isql -S$SERVER_NAME -U$DB_USER -P$DB_PASS<<EOF
#shutdown syb_backup
#go
#shutdown
#go
#EOF"
su - $RUN_USER -c "printf 'shutdown syb_backup\ngo\nshutdown\ngo' |isql -S$SERVER_NAME -U$DB_USER -P$DB_PASS"
;;

*)
echo "Usage: $0 { start | stop }"
exit 1
;;

esac
exit 0

#svccfg validate file.xml
#svccfg import file.xml

Comments