#!/bin/sh TIGASEDIR="/usr/local/tigase" LOGDIR="/var/log/tigase" RUNDIR="/var/run/tigase" DYNSTORE="/var/lib/tigase" CONFDIR="/etc/tigase" TIGASEUSER=tigase TIGASEGROUP=tigase # Sanity check, can everything from tigase be found? for FILE in "$TIGASEDIR/etc/init.properties" \ "$TIGASEDIR/etc/tigase.conf" \ "$TIGASEDIR/scripts/tigase.sh"; do if [ ! -f "$FILE" ]; then echo "Aborting: $FILE not found (looking in: $TIGASEDIR)" exit 1 fi done # first create /var/lib/tigase so it will be empty when creating user if [ ! -d "$DYNSTORE" ]; then echo "creating $DYNSTORE" mkdir "$DYNSTORE" fi if [ -z `id -un $TIGASEUSER` ]; then echo "Creating tigase user: $TIGASEUSER (group: $TIGASEGROUP)" addgroup --system $TIGASEGROUP adduser --system --ingroup $TIGASEGROUP --home $DYNSTORE--disabled-password $TIGASEUSER fi # make sure permissions on /var/lib/tigase are correct chmod 700 "$DYNSTORE" chown tigase:tigase "$DYNSTORE" # give tigase write permissions in /usr/local/tigase/logs # this due to a bug in tigase 4.3.1, it shouldn't write there chgrp $TIGASEGROUP "$TIGASEDIR"/logs chgrp $TIGASEGROUP "$TIGASEDIR"/logs/* chmod g+wx "$TIGASEDIR"/logs chmod g+w "$TIGASEDIR"/logs/* # Make other dirs if [ ! -d "$LOGDIR" ]; then echo "creating $LOGDIR" mkdir "$LOGDIR" chmod 750 "$LOGDIR" chown $TIGASEUSER:adm "$LOGDIR" fi for DIR in "$RUNDIR" "$CONFDIR"; do if [ ! -d "$DIR" ]; then echo "creating $DIR" mkdir "$DIR" chmod 700 "$DIR" chown $TIGASEUSER:$TIGASEGROUP "$DIR" fi done # Move tigase.conf and init.properties to confdir: if [ ! -f "$CONFDIR/tigase.conf" ]; then cp "$TIGASEDIR/etc/tigase.conf" "$CONFDIR/" chown $TIGASEUSER:$TIGASEGROUP "$CONFDIR/tigase.conf" fi if [ ! -f "$CONFDIR/init.properties" ]; then cp "$TIGASEDIR/etc/init.properties" "$CONFDIR/" chown $TIGASEUSER:$TIGASEGROUP "$CONFDIR/init.properties" fi # And the needed lines to init.properties: if ! grep -q "\--comp-name-[0-9]*=muc" "$CONFDIR/init.properties"; then echo "--comp-name-1=muc" >> "$CONFDIR/init.properties" fi if ! grep -q "\--comp-class-[0-9]*=tigase.muc.MUCComponent" "$CONFDIR/init.properties"; then echo "--comp-class-1=tigase.muc.MUCComponent" >> "$CONFDIR/init.properties" fi if ! grep -q "muc/muc-allow-chat-states[B]=true" "$CONFDIR/init.properties"; then echo "muc/muc-allow-chat-states[B]=true" >> "$CONFDIR/init.properties" fi if ! grep -q "muc/muc-lock-new-room[B]=false" "$CONFDIR/init.properties"; then echo "muc/muc-lock-new-room[B]=false" >> "$CONFDIR/init.properties" fi if ! grep -q "message-router/components/msg-receivers/s2s.active[B]=false" "$CONFDIR/init.properties"; then echo "message-router/components/msg-receivers/s2s.active[B]=false" >> "$CONFDIR/init.properties" fi if ! grep -q "basic-conf/logging/java.util.logging.FileHandler.pattern=$LOGDIR/tigase.log" "$CONFDIR/init.properties"; then echo "basic-conf/logging/java.util.logging.FileHandler.pattern=$LOGDIR/tigase.log" >> "$CONFDIR/init.properties" fi # lower the loglevel: if grep -q "^--debug = server" "$CONFDIR/init.properties"; then sed -i "s,^--debug = server,#--debug = server,g" "$CONFDIR/init.properties" fi # Change tigase.conf # sedding pathes goes wrong, needs escaping if grep -q "TIGASE_CONFIG" "$CONFDIR/tigase.conf"; then sed -i "s,TIGASE_CONFIG=.*,TIGASE_CONFIG=\"$DYNSTORE\/tigase.xml\",g" "$CONFDIR/tigase.conf" else echo "TIGASE_CONFIG=\"$DYNSTORE/tigase.xml\"" >> "$CONFDIR/tigase.conf" fi if grep -q "TIGASE_OPTIONS" "$CONFDIR/tigase.conf"; then sed -i "s,TIGASE_OPTIONS=.*,TIGASE_OPTIONS=\" --property-file $CONFDIR\/init.properties\",g" "$CONFDIR/tigase.conf" else echo "TIGASE_OPTIONS=\" --property-file $CONFDIR/init.properties\"" >> "$CONFDIR/tigase.conf" fi if grep -q "TIGASE_CONSOLE_LOG" "$CONFDIR/tigase.conf"; then sed -i "s,TIGASE_CONSOLE_LOG=.*,TIGASE_CONSOLE_LOG=\"$LOGDIR\/console.log\",g" "$CONFDIR/tigase.conf" else echo "TIGASE_CONSOLE_LOG=\"$LOGDIR/console.log\"" >> "$CONFDIR/tigase.conf" fi if grep -q "TIGASE_PID" "$CONFDIR/tigase.conf"; then sed -i "s,TIGASE_PID=.*,TIGASE_PID=\"$RUNDIR\/tigase.pid\",g" "$CONFDIR/tigase.conf" else echo "TIGASE_PID=\"$RUNDIR/tigase.pid\"" >> "$CONFDIR/tigase.conf" fi if grep -q "TIGASE_HOME" "$CONFDIR/tigase.conf"; then sed -i "s,TIGASE_HOME=.*,TIGASE_HOME=\"$TIGASEDIR\",g" "$CONFDIR/tigase.conf" else echo "TIGASE_HOME=\"$TIGASEDIR\"" >> "$CONFDIR/tigase.conf" fi if grep -q "HOME" "$CONFDIR/tigase.conf"; then sed -i "s,HOME=.*,HOME=\"$TIGASEDIR\",g" "$CONFDIR/tigase.conf" else echo "HOME=\"$TIGASEDIR\"" >> "$CONFDIR/tigase.conf" fi if [ ! -f "/etc/init.d/tigase" ]; then cat > /etc/init.d/tigase <&2 exit 1 ;; esac exit 0 EOF chmod 755 /etc/init.d/tigase update-rc.d tigase defaults 80 10 fi exit 0