root/HelpIM3_chi/tigase_setup.sh

Revision 731, 5.6 kB (checked in by winfried, 2 years ago)

- updating tigase setup for setting up tigase 4.3.1 (needed to fix delay in closing webchat)

  • Property svn:executable set to *
Line 
1#!/bin/sh
2
3TIGASEDIR="/usr/local/tigase"
4LOGDIR="/var/log/tigase"
5RUNDIR="/var/run/tigase"
6DYNSTORE="/var/lib/tigase"
7CONFDIR="/etc/tigase"
8TIGASEUSER=tigase
9TIGASEGROUP=tigase
10
11# Sanity check, can everything from tigase be found?
12
13for FILE in "$TIGASEDIR/etc/init.properties" \
14            "$TIGASEDIR/etc/tigase.conf" \
15            "$TIGASEDIR/scripts/tigase.sh"; do
16  if [ ! -f "$FILE" ]; then
17    echo "Aborting: $FILE not found (looking in: $TIGASEDIR)"
18    exit 1
19  fi
20done
21
22# first create /var/lib/tigase so it will be empty when creating user
23if [ ! -d "$DYNSTORE" ]; then
24  echo "creating $DYNSTORE"
25  mkdir "$DYNSTORE"
26fi
27
28if [ -z `id -un $TIGASEUSER` ]; then
29  echo "Creating tigase user: $TIGASEUSER (group: $TIGASEGROUP)"
30  addgroup --system $TIGASEGROUP
31  adduser --system --ingroup $TIGASEGROUP --home $DYNSTORE--disabled-password $TIGASEUSER
32fi
33
34# make sure permissions on /var/lib/tigase are correct
35chmod 700 "$DYNSTORE"
36chown tigase:tigase "$DYNSTORE"
37
38# give tigase write permissions in /usr/local/tigase/logs
39# this due to a bug in tigase 4.3.1, it shouldn't write there
40chgrp $TIGASEGROUP "$TIGASEDIR"/logs
41chgrp $TIGASEGROUP "$TIGASEDIR"/logs/*
42chmod g+wx "$TIGASEDIR"/logs
43chmod g+w "$TIGASEDIR"/logs/*
44
45# Make other dirs
46if [ ! -d "$LOGDIR" ]; then
47  echo "creating $LOGDIR"
48  mkdir "$LOGDIR"
49  chmod 750 "$LOGDIR"
50  chown $TIGASEUSER:adm "$LOGDIR"
51fi
52
53for DIR in "$RUNDIR" "$CONFDIR"; do
54  if [ ! -d "$DIR" ]; then
55    echo "creating $DIR"
56    mkdir "$DIR"
57    chmod 700 "$DIR"
58    chown $TIGASEUSER:$TIGASEGROUP "$DIR"
59  fi
60done
61
62# Move tigase.conf and init.properties to confdir:
63if [ ! -f "$CONFDIR/tigase.conf" ]; then
64  cp "$TIGASEDIR/etc/tigase.conf" "$CONFDIR/"
65  chown $TIGASEUSER:$TIGASEGROUP "$CONFDIR/tigase.conf"
66fi
67if [ ! -f "$CONFDIR/init.properties" ]; then
68  cp "$TIGASEDIR/etc/init.properties" "$CONFDIR/"
69  chown $TIGASEUSER:$TIGASEGROUP "$CONFDIR/init.properties"
70fi
71
72# And the needed lines to init.properties:
73
74if ! grep -q "\--comp-name-[0-9]*=muc" "$CONFDIR/init.properties"; then
75  echo "--comp-name-1=muc" >> "$CONFDIR/init.properties"
76fi
77
78if ! grep -q "\--comp-class-[0-9]*=tigase.muc.MUCComponent" "$CONFDIR/init.properties"; then
79  echo "--comp-class-1=tigase.muc.MUCComponent" >> "$CONFDIR/init.properties"
80fi
81
82if ! grep -q "muc/muc-allow-chat-states[B]=true" "$CONFDIR/init.properties"; then
83  echo "muc/muc-allow-chat-states[B]=true" >> "$CONFDIR/init.properties"
84fi
85
86if ! grep -q "muc/muc-lock-new-room[B]=false" "$CONFDIR/init.properties"; then
87  echo "muc/muc-lock-new-room[B]=false" >> "$CONFDIR/init.properties"
88fi
89
90if ! grep -q "message-router/components/msg-receivers/s2s.active[B]=false" "$CONFDIR/init.properties"; then
91  echo "message-router/components/msg-receivers/s2s.active[B]=false" >> "$CONFDIR/init.properties"
92fi
93
94if ! grep -q "basic-conf/logging/java.util.logging.FileHandler.pattern=$LOGDIR/tigase.log" "$CONFDIR/init.properties"; then
95  echo "basic-conf/logging/java.util.logging.FileHandler.pattern=$LOGDIR/tigase.log" >> "$CONFDIR/init.properties"
96fi
97
98# lower the loglevel:
99if grep -q "^--debug = server" "$CONFDIR/init.properties"; then
100  sed -i "s,^--debug = server,#--debug = server,g" "$CONFDIR/init.properties"
101fi
102
103
104# Change tigase.conf
105
106# sedding pathes goes wrong, needs escaping
107if grep -q "TIGASE_CONFIG" "$CONFDIR/tigase.conf"; then
108  sed -i "s,TIGASE_CONFIG=.*,TIGASE_CONFIG=\"$DYNSTORE\/tigase.xml\",g" "$CONFDIR/tigase.conf"
109else
110  echo "TIGASE_CONFIG=\"$DYNSTORE/tigase.xml\"" >> "$CONFDIR/tigase.conf"
111fi
112
113if grep -q "TIGASE_OPTIONS" "$CONFDIR/tigase.conf"; then
114  sed -i "s,TIGASE_OPTIONS=.*,TIGASE_OPTIONS=\" --property-file $CONFDIR\/init.properties\",g" "$CONFDIR/tigase.conf"
115else
116  echo "TIGASE_OPTIONS=\" --property-file $CONFDIR/init.properties\"" >> "$CONFDIR/tigase.conf"
117fi
118
119if grep -q "TIGASE_CONSOLE_LOG" "$CONFDIR/tigase.conf"; then
120  sed -i "s,TIGASE_CONSOLE_LOG=.*,TIGASE_CONSOLE_LOG=\"$LOGDIR\/console.log\",g" "$CONFDIR/tigase.conf"
121else
122  echo "TIGASE_CONSOLE_LOG=\"$LOGDIR/console.log\"" >> "$CONFDIR/tigase.conf"
123fi
124
125if grep -q "TIGASE_PID" "$CONFDIR/tigase.conf"; then
126  sed -i "s,TIGASE_PID=.*,TIGASE_PID=\"$RUNDIR\/tigase.pid\",g" "$CONFDIR/tigase.conf"
127else
128  echo "TIGASE_PID=\"$RUNDIR/tigase.pid\"" >> "$CONFDIR/tigase.conf"
129fi
130
131if grep -q "TIGASE_HOME" "$CONFDIR/tigase.conf"; then
132  sed -i "s,TIGASE_HOME=.*,TIGASE_HOME=\"$TIGASEDIR\",g" "$CONFDIR/tigase.conf"
133else
134  echo "TIGASE_HOME=\"$TIGASEDIR\"" >> "$CONFDIR/tigase.conf"
135fi
136
137if grep -q "HOME" "$CONFDIR/tigase.conf"; then
138  sed -i "s,HOME=.*,HOME=\"$TIGASEDIR\",g" "$CONFDIR/tigase.conf"
139else
140  echo "HOME=\"$TIGASEDIR\"" >> "$CONFDIR/tigase.conf"
141fi
142
143if [ ! -f "/etc/init.d/tigase" ]; then
144  cat > /etc/init.d/tigase <<EOF
145#!/bin/sh
146#
147# Quick and dirty tigase start/stop script
148#
149
150### BEGIN INIT INFO
151# Provides:          tigase
152# Required-Start:    \$remote_fs \$network
153# Required-Stop:     \$remote_fs \$network
154# Default-Start:     2 3 4 5
155# Default-Stop:      0 1 6
156# Short-Description: Starts tigase jabber server
157# Description:       Starts tigase jabber server, an high performance XMPP
158#                    compliant server written in Java.
159### END INIT INFO
160
161TIGASE=$TIGASEDIR/scripts/tigase.sh
162TIGASECONF=$CONFDIR/tigase.conf
163TIGASEUSER=$TIGASEUSER
164case "\$1" in
165    start)
166        sudo -u \$TIGASEUSER \$TIGASE start \$TIGASECONF
167    ;;
168    stop)
169        sudo -u \$TIGASEUSER \$TIGASE stop \$TIGASECONF
170    ;;
171    restart|force-reload)
172        sudo -u \$TIGASEUSER \$TIGASE restart \$TIGASECONF
173    ;;
174    *)
175        echo "Usage: \$0 {start|stop|restart|force-reload}" >&2
176        exit 1
177    ;;
178esac
179
180exit 0
181
182EOF
183  chmod 755 /etc/init.d/tigase
184  update-rc.d tigase defaults 80 10
185fi
186
187
188exit 0
Note: See TracBrowser for help on using the browser.