Configure Chat system (optional)
Places of config information
The node-based chat server has its config files here:
/opt/iliasdata/clientname/chatroom
(Note: you need to replace “clientname” here with the client you used in the JSON file. In our case, it is “Ilias”)
client.cfg
- Can be configured and with this created in ILIAS->Administration->Repository and Objects->Chat Room
server.cfg
- Since ILIAS 7, there is no way to change or create this file via ILIAS->Administration->Repository and Objects->Chat Room. That means that the information has to be added to server.cfg manually
NOTE: In case you need to edit/update your chat settings in the JSON file, you can use the following commands:
nano /opt/iliasdata/scripts/clients/clientname1.json
cd /var/www/html/ilias
php setup/setup.php update /opt/iliasdata/scripts/clients/clientname1.json
Creation of client.cfg
- Login as root in ILIAS
- Go to Administration->Repository and Objects->Chatroom
- Fill out the form in General Settings:
- Click "Save"
- You now have a fresh client.cfg in the directory /opt/iliasdata/clientname/chatroom (again, instead of “clientname” here, you would have the client ID you used in the JSON file)
- If you get an error while saving, check the file permissions (write must be allowed for www-data).
Creating server.cfg
cd /opt/iliasdata/clientname/chatroom
(replace “clientname” here with the client ID you used in the JSON file)
nano server.cfg
Paste this code in:
{
"protocol": "http",
"port": "8080",
"address": "127.0.0.1",
"cert": "",
"key": "",
"dhparam": "",
"log": "\/opt\/iliasdata\/log\/chat.log",
"error_log": "\/opt\/iliasdata\/log\/chaterror.log",
"sub_directory": "",
"deletion_mode": "1",
"deletion_unit": "days",
"deletion_value": "10",
"deletion_time": "22:30"
}
Create Startscripts
nano /etc/init.d/ilchat
Fill in the following code:
#!/bin/bash
### BEGIN INIT INFO
# Provides: ilchat3
# Author: Wolfgang Hubesch wolfgang.huebsch@gmx.de
# Required-Start: $remote_fs $syslog
# Required-Stop: $remote_fs $syslog
# Default-Start: 2 3 4 5
# Default-Stop: 0 1 6
# Short-Description: ILIAS-Chatserver nodebased
### END INIT INFO
# Do NOT "set -e"
PATH=/sbin:/usr/sbin:/bin:/usr/bin
DESC="ilchat"
NAME=ilchat
#DAEMON=/usr/sbin/$NAME
#DAEMON_ARGS="--options args"
SCRIPTNAME=/etc/init.d/$NAME
ilroot=/var/www/html/ilias
ildata=/opt/iliasdata
client=Ilias
url=127.0.0.1
chatport=8080
code="404"
USER=www-data
node_path=/usr/bin/node
#################################################
status=$(curl -s --head ${url}:${chatport} | head -n 1)
case "$1" in
start)
if [[ $status == *${code}* ]];
then
echo "Chat-Server for client ${client} on port ${chatport} seems to be running"
else
echo "Chat-Server for client ${client} on port ${chatport} seems to be DOWN. Try to start..."
sudo -H -u $USER bash -c "${node_path} ${ilroot}/Modules/Chatroom/chat/chat.js ${ildata}/${client}/chatroom/server.cfg ${ildata}/${client}/chatroom/client.cfg" &
sleep 5
status=$(curl -s --head ${url}:${chatport} | head -n 1)
if [[ $status == *${code}* ]];
then
echo "Chatserver for client ${client} on port ${chatport} is up!"
exit
else
echo "Sorry, I was not able to start the Chatserver for client ${client} on port ${chatport}. Try user root instead of ${USER} (edit line 28 of this script)"
exit
fi
fi
;;
stop)
if [[ $status == *${code}* ]];
then
echo "Chatserver for client ${client} on port ${chatport} is running...try to stop..."
kill $(ps aux | grep chat.js | awk '{print $2}') > /dev/null 2>&1
exit
else
echo "Chatserver for client ${client} on port ${chatport} is already down..."
exit
fi
;;
status)
if [[ $status == *${code}* ]];
then
echo "Chatserver is running...exit now..."
exit
else
echo "Chatserver is down...exit now..."
exit
fi
;;
*)
echo "Usage: $0 {start|stop|status}"
exit 1
esac
exit 0
- NOTE: Make sure you have the client name fits your installation and client in line 23 (in our case, it is Ilias)
- Exit nano with CTR+x
chmod +x /etc/init.d/ilchat
Start the server
- Check if Node is installed.
- That's enough to start the chat server. You can do this manually:
/etc/init.d/ilchat start|stop|status
- Check if any messages in the error log would indicate an incorrect configuration:
nano /opt/iliasdata/log/chaterror.log
Crontab settings
Crontab shall check if the chat server runs every 5 minutes:
nano /etc/crontab
- Add a line like this:
#Line for Chat-Server: checks every 5 minutes if sevice is up
*/5 * * * * root /etc/init.d/ilchat start >/dev/null 2>&1