Skip to content

Instantly share code, notes, and snippets.

@cfoster
Last active August 29, 2015 14:07
Show Gist options
  • Save cfoster/0ed242236749af2b63c5 to your computer and use it in GitHub Desktop.
Save cfoster/0ed242236749af2b63c5 to your computer and use it in GitHub Desktop.
Sedna XML Database - Linux Service CentOS / Fedora / RedHat
#!/bin/bash
############################################################
# Sedna Database Service
# Copyright (c) 2008-2014 Charles Foster
# http://www.cfoster.net/
#
# Start, stop, restart or query the status
# of the Sedna XML Database.
#
# This service manages the both the Sedna Governor Server
# as well as loading/unloading child database instances.
#
# You are free to modify and redistribute this script,
# providing you leave the copyright message in tact.
#
# Tested on CentOS 6.5, should work on Fedora and RedHat
############################################################
# Home of The Sedna Installation
SEDNA_HOME=/opt/sedna
# The user account which will run Sedna
USER=sedna
# Database instances to start/stop, separated by spaces
DBLIST="mydbname1 mydbname2 mydbname3"
############################################################
# Don't edit below here, unless you know what you are doing.
############################################################
SPIDX="pidof se_gov"
DESC="Sedna XML Database Server"
IDESC="Sedna DB"
SEGOV="/etc/init.d/sedna"
RETVAL=0
# . /lib/lsb/init-functions
. /etc/rc.d/init.d/functions
do_start()
{
if [ `$SPIDX` ]; then
echo "$DESC already running."
else
echo -n $"Starting $DESC"
daemon --user="$USER" $SEDNA_HOME/bin/se_gov >> /dev/null
RETVAL=$?
if [ $RETVAL -eq 0 ]; then
success
else
failure
fi
fi
echo
}
do_start_dbs()
{
for n in $DBLIST;\
do\
echo -n $"Starting $IDESC \"$n\""
if [ ! -d $SEDNA_HOME/data/"$n"_files ]; then
failure
else
if daemon --user="$USER" $SEDNA_HOME/bin/se_sm $n >> /dev/null; then
success
else
failure
fi
fi
echo
done
}
do_stop_dbs()
{
if [ ! `$SPIDX` ]; then
return
fi
for n in $DBLIST;\
do\
echo -n $"Stopping $IDESC \"$n\""
if [ ! -d $SEDNA_HOME/data/"$n"_files ]; then
failure
else
daemon --user="$USER" $SEDNA_HOME/bin/se_smsd $n >> /dev/null
RETVAL=$?
if [ $RETVAL -eq 0 ]; then
success
else
failure
fi
fi
echo
done
}
get_status()
{
if [ `$SPIDX` ]; then
$SEDNA_HOME/bin/se_rc
else
echo $"$DESC not running."
fi
}
do_stop()
{
echo -n $"Stopping $DESC"
if [ ! `$SPIDX` ]; then
echo -n $"$DESC was not running in the first place."
failure
else
daemon --user="$USER" $SEDNA_HOME/bin/se_stop >> /dev/null
if [ ! `$SPIDX` ]; then
success
else
failure
fi
fi
echo
}
case "$1" in
start)
do_start
do_start_dbs
;;
status)
get_status
;;
stop)
do_stop_dbs
do_stop
;;
restart)
do_stop_dbs
do_stop
do_start
do_start_dbs
;;
*)
echo "Usage: $SEGOV {start|stop|status|restart}" >&2
exit 1
esac
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment