Creating a systemd script for Sybase ASE

This is what I did. No forking or pid file required and can be run as sybase user. ExecStop is not required if you are happy with the dataserver being stopped with a kill command.

unit file ... /etc/systemd/system/sybase-srvnane

Add a separate unit file for each sybase server.

[Unit]
Description=Sybase dataserver

[Service]
User=sybase
ExecStart=/home/sybase/bin/run-dataserver SRVNAME
ExecStop=/home/sybase/bin/stop-dataserver SRVNAME

[Install]
WantedBy=multi-user.target

start script ... /home/sybase/bin/run-dataserver

#!/bin/sh

[ $# -ne 1 ] && echo "Usage: $0 <SYB_SERVER>" && exit 1
_server=${1}
. /opt/sybase/SYBASE.sh
_run_file=${SYBROOT}/${SYBASE_ASE}/install/RUN_${_server}
if [ -x ${_run_file} ]
then
        echo "Starting Sybase server ... ${_server}"
        . ${_run_file}
else
        echo "Cannot find run file ${_run_server}"
        exit 1
fi

stop script ... /home/sybase/bin/stop-dataserver

#!/bin/bash

[ $# -ne 1 ] && echo "Usage: $0 <SYB_SERVER>" && exit 1
_server=${1}
. /opt/sybase/SYBASE.sh
_isql=${SYBROOT}/${SYBASE_OCS}/bin/isql
if [ -x ${_isql} ]
then
        echo "Stopping Sybase server .... ${_server}"
        ${_isql} -U sa -S ${_server} << EOF
$( cat /home/sybase/.sa_password )
shutdown
go
EOF

fi

For completeness I also have stop for a backup server ... /home/sybase/bin/start-backup-dataserver

#!/bin/bash

[ $# -ne 1 ] && echo "Usage: $0 <SYB_SERVER>" && exit 1
_server=${1}
. /opt/sybase/SYBASE.sh
_isql=${SYBROOT}/${SYBASE_OCS}/bin/isql
if [ -x ${_isql} ]
then
        echo "Stopping Sybase backup server .... ${_server}"
        ${_isql} -U sa -S ${_server} << EOF
$( cat /home/sybase/.sa_password )
shutdown SYB_BACKUP
go
EOF

fi

I have a user read-only file /home/sybase/.sa_password for the password.

sudo systemctl daemon-reload and you are done.

Tags:

Systemd