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.

90 lines
2.5 KiB

#!/bin/bash
DB_ROOT=postgres
CONFIG_FILE=/etc/omero.conf
ICEGRID_PIDFILE=/opt/omero/var/master/master.pid
OMERO_WEB_ENABLED=no
case "$1" in
init)
if [ -f $CONFIG_FILE ]; then
echo Loading configuration
sudo -H -u omero -i omero config load $CONFIG_FILE
fi
CONFIG=$(sudo -H -u omero -i omero config get)
DATADIR=$(echo "$CONFIG" | sed -nre 's/^omero\.data\.dir=(.*)$/\1/p')
DB_HOST=$(echo "$CONFIG" | sed -nre 's/^omero\.db\.host=(.*)$/\1/p')
DB_PORT=$(echo "$CONFIG" | sed -nre 's/^omero\.db\.port=(.*)$/\1/p')
DB_NAME=$(echo "$CONFIG" | sed -nre 's/^omero\.db\.name=(.*)$/\1/p')
DB_USER=$(echo "$CONFIG" | sed -nre 's/^omero\.db\.user=(.*)$/\1/p')
DB_PASS=$(echo "$CONFIG" | sed -nre 's/^omero\.db\.pass=(.*)$/\1/p')
[ -n "$DATADIR" ] || DATADIR=/OMERO
[ -n "$DB_HOST" ] || DB_HOST=localhost
[ -n "$DB_PORT" ] || DB_PORT=5432
[ -n "$DB_NAME" ] || DB_NAME=omero
[ -n "$DB_USER" ] || DB_USER=omero
[ -n "$DB_PASS" ] || DB_PASS=omero
PGOPTS="-h $DB_HOST -p $DB_PORT -U $DB_ROOT"
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...
psql $PGOPTS -c "CREATE ROLE $DB_USER WITH LOGIN PASSWORD '$DB_PASS'"
fi
if ! psql $PGOPTS -l | grep -q $DB_NAME ; then
echo Creating database...
createdb $PGOPTS -E UTF8 -l en_US.UTF-8 -T template0 -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.3__0.sql
rm -rf /var/lib/omero/OMERO5.3__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