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.

88 lines
2.3 KiB

#!/bin/bash
DB_ROOT=postgres
CONFIG_FILE=/etc/omero/omero.properties
ICEGRID_PIDFILE=/opt/omero/var/master/master.pid
OMERO_WEB_ENABLED=no
case "$1" in
init)
if [ ! -f $CONFIG_FILE ]; then
echo Configuration file $CONFIG_FILE not found! Aborting...
exit 1
fi
echo Reseting previous configuration
rm -f ${CONFIG_FILE%/omero.properties}/grid/config.xml
echo Reading configuration from $CONFIG_FILE...
DATADIR=$(sed -nre 's/^omero\.data\.dir=(.*)$/\1/p' $CONFIG_FILE)
DB_HOST=$(sed -nre 's/^omero\.db\.host=(.*)$/\1/p' $CONFIG_FILE)
DB_PORT=$(sed -nre 's/^omero\.db\.port=(.*)$/\1/p' $CONFIG_FILE)
[ -n "$DB_PORT" ] || DB_PORT=5432
DB_NAME=$(sed -nre 's/^omero\.db\.name=(.*)$/\1/p' $CONFIG_FILE)
DB_USER=$(sed -nre 's/^omero\.db\.user=(.*)$/\1/p' $CONFIG_FILE)
PGOPTS="-h $DB_HOST -p $DB_PORT -U $DB_ROOT"
echo Applying configuration...
sudo -H -u omero -i omero config load $CONFIG_FILE
if [ ! -d $DATADIR ]; then
echo Creating data repository...
mkdir -p $DATADIR
chown omero $DATADIR
fi
if ! psql $PGOPTS -c '\du' | grep -q $DB_USER ; then
echo Creating database user...
createuser $PGOPTS -P -D -R -S $DB_USER
fi
if ! psql $PGOPTS -l | grep -q $DB_NAME ; then
echo Creating database...
createdb $PGOPTS -O $DB_USER $DB_NAME
createlang $PGOPTS plpgsql $DB_NAME
sudo -H -u omero -i omero db script
psql -h $DB_HOST -p $DB_PORT -U $DB_USER $DB_NAME < /var/lib/omero/OMERO5.0__0.sql
rm -rf /var/lib/omero/OMERO5.0__0.sql
fi
;;
start)
sudo -H -u omero -i omero admin start
if [ "x$OMERO_WEB_ENABLED" = xyes ]; then
sudo -H -u omero -i omero web start
fi
;;
stop)
if [ -f $ICEGRID_PIDFILE ] && kill -0 $(< $ICEGRID_PIDFILE) 2>/dev/null ; then
if [ "x$OMERO_WEB_ENABLED" = xyes ]; then
sudo -H -u omero -i omero web stop
fi
sudo -H -u omero -i omero admin stop
rm -f $ICEGRID_PIDFILE
fi
;;
restart)
$0 stop
sleep 5
$0 start
;;
status)
if [ -f $ICEGRID_PIDFILE ] && kill -0 $(< $ICEGRID_PIDFILE) 2>/dev/null; then
echo "Omero is running"
else
echo "Omero is not running"
fi
;;
*)
echo "Usage: ${1##.*/} {init|start|stop|restart}"
exit 1
;;
esac
exit 0