Some SlackBuild scripts for Slackware.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
slackbuilds/ap/omero/rc.omero

87 lines
2.1 KiB

#!/bin/bash
CONFIG_FILE=/etc/omero.conf
ICEGRID_PIDFILE=/opt/omero/var/master/master.pid
omero_initialize()
{
# Read settings
OMERO_DATADIR=$(sed -nre 's/^omero.data.dir=(.*)$/\1/p' $CONFIG_FILE)
OMERO_DB_HOST=$(sed -nre 's/^omero.db.host=(.*)$/\1/p' $CONFIG_FILE)
OMERO_DB_NAME=$(sed -nre 's/^omero.db.name=(.*)$/\1/p' $CONFIG_FILE)
OMERO_DB_USER=$(sed -nre 's/^omero.db.user=(.*)$/\1/p' $CONFIG_FILE)
PGOPTS="-h $OMERO_DB_HOST -U postgres"
# Create compiled settings file
echo Compile settings...
cp $CONFIG_FILE /opt/omero/lib/server/blitz/omero.properties
jar cmf \
/opt/omero/lib/server/blitz/META-INF/MANIFEST.MF \
/opt/omero/lib/server/blitz.jar \
-C /opt/omero/lib/server/blitz .
# Create data repository
echo Ensure data repository exists...
if [ ! -d $OMERO_DATADIR ]; then
mkdir -p $OMERO_DATADIR
chown omero $OMERO_DATADIR
fi
# Create database user
echo Ensure database user exists...
if ! psql $PGOPTS -c '\du' | grep -q $OMERO_DB_USER ; then
createuser $PGOPTS -P -D -R -S $OMERO_DB_USER
fi
# Create and fill database
echo Ensure database is ready to use...
if ! psql $PGOPTS -l | grep -q $OMERO_DB_NAME ; then
createdb $PGOPTS -O $OMERO_DB_USER $OMERO_DB_NAME
createlang $PGOPTS plpgsql $OMERO_DB_NAME
(
cd /opt/omero
sudo -u omero omero db script
psql -h $OMERO_DB_HOST -U $OMERO_DB_USER $OMERO_DB_NAME < \
OMERO4__0.sql
rm -rf OMERO4__0.sql .java
)
fi
}
omero_start()
{
if [ ! -f /opt/omero/lib/server/blitz.jar ]; then
omero_initialize
fi
sudo -u omero omero admin start
}
omero_stop()
{
su -u omero omero admin stop
[ -f $ICEGRID_PIDFILE ] && kill -TERM $(< $ICEGRID_PIDFILE)
}
case "$1" in
init)
omero_initialize
;;
start)
omero_start
;;
stop)
omero_stop
;;
restart)
omero_stop
sleep 5
omero_start
;;
*)
echo "Usage: ${1##.*/} {init|start|stop|restart}"
exit 1
;;
esac
exit 0