Tweets from pichat
| I love refactoring, there should be a t-shirt. #softwareengineering About 14 hours, 21 mins ago from pichat (Mark Seuffert) |
Tweets from 600infos
| How agile are you? A short online test to find out how agile your software development team is http://bit.ly/cGoTNg #fb About 3 months, 1 week ago from 600infos (Wolf) |
Trace: » Webcam » Installer » Meine Adresse » Superman - Die Abenteuer von Lois und Clark » Beispiele/Examples » Install Pichat on a Linux System
You are here: Pichat Wiki (en) » Manuals » Install Pichat on a Linux System
Install Pichat on a Linux System
Requirements/Voraussetzung
- Linux 32-Bit
- glib version min. 2.4 (GLIBC_2.4)
- login into the Unix commandline with root-rights
Install Pichat
Create an own pichat user
login as a root user
adduser pichat
Adding user `pichat' …
Adding new group `pichat' (1000) …
Adding new user `pichat' (1000) with group `pichat' …
Creating home directory `/home/pichat' …
Copying files from `/etc/skel' …
Enter new UNIX password:
Retype new UNIX password:
passwd: password updated successfully
Changing the user information for pichat
Enter the new value, or press ENTER for the default
Full Name []: Pichat
Room Number []:
Work Phone []:
Home Phone []:
Other []:
Is the information correct? [Y/n] y
# cd /home/pichat/
Create an install/update Script
create this script-file in a text editor and edit it (e.g. vi update.sh)
touch update.sh chmod 750 update.sh chown pichat:pichat update.sh
- | update.sh
#!/bin/sh # update.sh # Script to install or update Pichat # please have a look to http://pichat-wiki.de # # Version 0.1.6 2010-03-16 Mark Wolfgruber # change default webport in the script and in the examples to tcp/8008 # # Version 0.1.5 2010-03-14 Mark Wolfgruber # now support zip download and decompress (using unzip) # check if a pichat_user_permissions.ini is present, if not it will be created # download of the pichat_sdk_tools.zip is now possible (e.g. for pipasswd) # # Version 0.1.4 2010-03-13 Mark Wolfgruber # new download URL and Filenames # Pichat Linux Plugins are now supported # # Version 0.1.3 2010-03-07 Mark Wolfgruber # add download function # now support tgz download and decompress (using tar) # add plugin support # add backup if update is available # restart pichat only if necessary # add support of cli arguments (needs to modify the init-script too) # Version 0.1.2 2010-03-04 Mark Wolfgruber # add Proxy support # Version 0.1.1 2010-02-24 Mark Wolfgruber # # modify the _pichatdir if it is installed in a other directory _pichatdir=/home/pichat # modify the _user and _group if you need it _user=pichat _group=pichat # name of the pichat-deamon _pichatd=pichatd # user defined pichat command line arguments # like -IniFile=/etc/pichat.ini -PluginsIniFile=/etc/pichat_plugins.ini _args= # where is the init-script placed to stop/start the pichat-deamon # default: _init=/etc/init.d/pichat _init=/etc/init.d/pichat # where is the permissions file placed # it will be created if not exist _permissions=$_pichatdir/pichat/pichat_user_permissions.ini # if using a Proxy activate following line with you Proxyname and Port # and set _proxy=on (default _proxy=off) # or use _proxy='on --bind-address=192.168.12.34' (where 192.168.12.34 is your IP) # export http_proxy='http://proxy.example.com:8080' _proxy=off # modify the _updateurl if you want do download from an other location _updateurl=http://www.pichat.net/downloads function download { ### Download Section # Download Plugins # activate Lines if needed # getupdates pichat_pluginlanguage.so # getupdates pichat_pluginlogbot.so # getupdates pichat_pluginquizbot.so # getupdates pichat_pluginwebstatus.so # Download Tools # getupdates pichat_sdk_tools.zip # Download Pichat Deamon Pack getupdates pichat_linux32.tgz } ##################################################### ###### --- END OF default user customizing --- ###### ##################################################### function readargs { shift until [ -z "$1" ] # Until all parameters used up . . . do _args+="$1 " shift done } function getupdates { _file=$1.$_timestamp.down _backup=$1.$_timestamp.backup echo `date` --- try to download for pichat update $1 ... # if using a Proxy add option --proxy=on to the wget command (default --proxy=off) # if download ended with error downloaded file will be deleted # wget --debug --verbose --proxy=$_proxy --no-cache --connect-timeout=2 --tries=2 --output-document=pichat_linux.tgz $_updateurl || rm $1 # display the command for logging echo wget --proxy=$_proxy --connect-timeout=2 --tries=2 --output-document=$_file $_updateurl/$1 wget --proxy=$_proxy --connect-timeout=2 --tries=2 --output-document=$_file $_updateurl/$1 || rm $_file # if files exist and it is empty delete it [ -f $_file ] && [ `stat -c%s "$_file"` -eq 0 ] && rm $_file [ -f $1 ] && [ `stat -c%s "$1"` -eq 0 ] && rm $1 # if downloaded file is the same delete it ... no update [ -f $_file ] && [ -f $1 ] && cmp -s $_file $1 && ( echo `date` --- "no Update of $1 available ... delete downloaded file $_file ..." rm $_file ) # if update/downgrade is available ... if [ -f $_file ]; then echo `date` --- "Update of $1 detected!" # if pichat is running - prepare to restart and stop pichatd ... if [ "$(pidof $_pichatd)" ]; then _restart=yes # read pichat cli arguments readargs `ps -e -o cmd= | grep $_pichatd | egrep -v grep` echo `date` --- Stop Pichat Deamon ... [ -f $_init ] && $_init stop || echo init-Script $_init not available fi # if old file exist backup old file if [ -f $1 ]; then echo `date` --- "old File $1 exists ... make a Backup to $_backup ..." mv $1 $_backup fi # new file becomes original Name now echo `date` --- "new File $_file will be activated now as $1 ..." mv $_file $1 # if new file is a .tgz file ... extract it [ -f $1 ] && echo $1 | grep .tgz > /dev/null && ( echo `date` --- extract the downloaded file $1 ... [ -f $1 ] && tar xfvz $1 ) # if new file is a .zip file ... extract it [ -f $1 ] && echo $1 | grep .zip > /dev/null && ( echo `date` --- extract the downloaded file $1 ... # needs to install unzip [ -f $1 ] && unzip $1 ) fi } # define internal vars _timestamp=`date +%y%m%d_%H%M%S` _restart=no echo `date` --- Start install/update Pichat cd $_pichatdir # create an empty permission file if [ ! -f $_permissions ]; then touch $_permissions echo [User Permissions] >> $_permissions echo '# THIS FILE CONTAINS PRIVATE USER INFORMATION, DO NOT SHARE!' >> $_permissions echo '# example to add an admin user (needs pipasswd from the pichat_sdk_tools.zip):' >> $_permissions echo '# ./pipasswd /home/pichat/pichat/pichat_user_permissions.ini USER_NORMAL NAME PASSWORD "*" "Description"' >> $_permissions echo '# ./pipasswd /home/pichat/pichat/pichat_user_permissions.ini USER_ADMIN NAME PASSWORD "*" "Description"' >> $_permissions chown pichat:pichat $_permissions chmod 660 $_permissions _restart=yes fi download # if user who runs the script is not $_user (default pichat-user) # change the owner and group to pichat of all files if [ "`whoami`" != "$_user" ]; then echo `date` --- change owner to $_user:$_group chown $_user:$_group * fi # if pichatd was stoped for update - start pichatd again if [ "$_restart" == "yes" ]; then echo `date` --- try to Start Pichat Deamon with the init-Script ... [ -f $_init ] && $_init start $_args || echo init-Script $_init not available else echo `date` --- no restart of the Pichat Deamon needed [ -f $_init ] && $_init status || echo init-Script $_init not available fi echo `date` --- display lastlines of pichat_chatserver.log in 5 seconds ... sleep 5 tail --lines=50 $_pichatdir/pichat/logfiles/pichat_chatserver.log echo "" echo `date` --- End install/update Pichat echo ""
step by step
login as user pichat
change directory to the programm dir
cd /home/pichat/
Download Pichat
Source from http://www.pichat.net
wget --output-document=pichat_linux.tgz http://www.pichat.net/downloads/pichat_linux.tgz
Extract the Archiv-File
tar xfvz pichat_linux.tgz
Start/Stop Pichat
login as user pichat (or root)
| with init-script | direct command | |
|---|---|---|
| Start | /etc/init.d/pichat start | cd /home/pichat ./pichatd |
| Stop | /etc/init.d/pichat stop | pkill pichatd |
| Restart | /etc/init.d/pichat restart | pkill pichatd && sleep 5 && /home/pichat/pichatd |
| Verify | /etc/init.d/pichat status | ps -ef | grep pichatd | egrep -v grep |
Autostart/Autorun Pichat
This script is for a debian vserver (lenny updated from etch)
create init-script to start-stop pichat
touch /etc/init.d/pichat chmod 755 /etc/init.d/pichat
Edit the start script
create this file in a text editor (e.g. vi /etc/init.d/pichat)
- pichat
#!/bin/sh # /etc/init.d/pichat # # init-Script pichat to start/stop/restart pichat or show the running state # please have a look to http://pichat-wiki.de # # Version 0.1.3 2010-03-07 Mark Wolfgruber # rearange functions # stop with root rights will delete existing port redirects too # vars more flexible configured # more infos in logfile # rename default logfile # open: external conf file # open: define pichat cli arguments as $_args # open: define webport as part of pichat cli arguments # # Version 0.1.2 2010-03-06 Mark Wolfgruber # rearange functions # better logfile with $_args # # Version 0.1.1 2010-03-06 Mark Wolfgruber # add support of pichat cli arguments (like -IniFile=/etc/pichat.ini) # support pichatd with other names # modified status ouput # # Version 0.1.0 2010-02-24 Mark Wolfgruber #------------------------------------------------------------------------------- # define username which runs the pichatd _user=pichat # define pichat deamon name _pichatd=pichatd # define webports _webport=8008 # define redirects ports - example: _redirports="80 81 8000 8008" _redirports="80 81" # define the complete path where pichatd is located _pichatdir=/home/pichat # define the logfile - to deactivate use /dev/null as destination or leave it empty ;D _logfile=$_pichatdir/init_pichat.log # define path where this script is located _initpath=/etc/init.d # define action var _action=$1 # Make sure only root or defined pichatd-user can run this script if ([ `id -u` != "0" ] && [ "`whoami`" != "$_user" ] ); then echo "$0 must be run as root or user $_user" 1>&2 exit 1 fi # check if path of logfile exist and logfile if it is writeable if [ "$_logfile" != "" ]; then if ( ! [ -w $_logfile ] ); then # check if logdir exist and create it if possible [ -d ${_logfile%/*} ] || ( mkdir ${_logfile%/*} || ( _logfile=&& echo ERROR creating path of logfile $_logfile )) fi # check logfile if it is touchable and if it not exist the logfile will be created touch $_logfile || ( _logfile=&& echo ERROR touching logfile $_logfile ) # check logfile if it is writeable [ -w $_logfile ] || ( _logfile=&& echo ERROR no writeable logfile $_logfile ) fi function readargs () { # read pichat cli arguments and set it to vars shift until [ -z "$1" ] # Until all parameters used up . . . do _args+="$1 " shift done } function redirect () { # root user redirects the tcp portnumber - usage: do_redirect PORTNUMBER # check if the port is redirected and exit iptables-save | grep -e "-A PREROUTING -p tcp -m tcp --dport $1 -j REDIRECT --to-ports $_webport" > /dev/null && return # if it is not a REDIRECT entry in the active IP-Tables echo -n iptables activate redirecting port tcp/$1 to tcp/$_webport ... [ $_logfile ] && echo "`date` --- iptables activate redirecting port tcp/$1 to tcp/$_webport " >> $_logfile iptables -t nat -A PREROUTING -p tcp --dport $1 -j REDIRECT --to-port $_webport # check if the port is redirected and write the result iptables-save | grep -e "-A PREROUTING -p tcp -m tcp --dport $1 -j REDIRECT --to-ports $_webport" > /dev/null && ( echo " done " ) || ( echo failed [ $_logfile ] && echo "`date` --- ERROR iptables failed to activate redirecting port tcp/$1 to tcp/$_webport ... " >> $_logfile ) } function do_redirports () { # until [ -z "$1" ] # Until all parameters used up . . . do if ( [ $1 -gt 0 ] && [ $1 -le 65535 ] ); then redirect $1 fi shift done } function delete_redirports () { _active_redirports=`iptables-save | egrep -e '-j REDIRECT --to-ports 8008' | cut -d " " -f 8` for dport in $_active_redirports do echo -n iptables delete redirecting port tcp/$dport to tcp/$_webport ... [ $_logfile ] && echo "`date` --- iptables delete redirecting port tcp/$dport to tcp/$_webport " >> $_logfile iptables -t nat -D PREROUTING -p tcp --dport $dport -j REDIRECT --to-port $_webport echo " done " done } function do_start () { echo -n "Starting Pichat $_pichatd ..." cd $_pichatdir if [ "`whoami`" == "$_user" ]; then [ $_logfile ] && echo "`date` ### Starting $_pichatdir/$_pichatd $_args " >> $_logfile $_pichatdir/$_pichatd $_args else [ $_logfile ] && su $_user -c "echo \"`date` ### Starting $_pichatdir/$_pichatd $_args \"" >> $_logfile su $_user -c "$_pichatdir/$_pichatd $_args" fi echo " done " cd - > /dev/null # if you are root and redirect ports are defined [ `id -u` == "0" ] && [ '$_redirports' ] && do_redirports $_redirports } function do_stop () { # if you are root user ... delete redirect ports [ `id -u` == "0" ] && delete_redirports # if the pichatd is runnig kill it if [ "$(pidof $_pichatd)" ]; then echo -n "Stopping Pichat $_pichatd ..." [ $_logfile ] && echo "`date` ### Stopping Pichatd $_pichatd `ps -e -o cmd= | grep $_pichatd | egrep -v grep`" >> $_logfile while [ "$(pidof $_pichatd)" ] do # use pkill or killall, whatever works for you pkill $_pichatd sleep 1 echo -n "." done echo " done " fi } function do_status () { if [ "$(pidof $_pichatd)" ]; then echo "Pichat is running: `ps -e -o cmd= | grep $_pichatd | egrep -v grep`" else echo "Pichat is not running" fi } # Main section case "$_action" in status) do_status ;; stop) do_stop do_status ;; start|restart|reload|force-reload) [ $2 ] && readargs $* if [ "$(pidof $_pichatd)" ]; then [ $2 ] || readargs `ps -e -o cmd= | grep $_pichatd | egrep -v grep` # if pichat is running stop it first do_stop fi do_start do_status ;; *) echo "Usage: $0 [start [Arguments]|stop|restart [Arguments]|status]" exit 1 ;; esac exit 0
create a logical link for the default Runlevels
ln -fs /etc/init.d/pichat /etc/rc0.d/K91pichat # runlevel 1 only singeluser ln -fs /etc/init.d/pichat /etc/rc2.d/S91pichat ln -fs /etc/init.d/pichat /etc/rc3.d/S91pichat # runlevel 4 normally not defined ln -fs /etc/init.d/pichat /etc/rc5.d/S91pichat ln -fs /etc/init.d/pichat /etc/rc6.d/K91pichat
- verify
ls -l /etc/rc2.d S91pichat -> /etc/init.d/pichat
Create Webserver Port
In some cases you need a workaround to use the normal http (cp/80) port for the Pichat-Webserver
Ports below 1024 can be opened only by root, so we need a workaround.
You can redirect connections on port 80 to some other port like 8008 you can open as normal user.
Here are some possible Workarounds:
Edit pichat.ini
and do not forgett to edit the pichat.ini with port 8008 as the webserverport after installation (first start of pichatd)
with a bash command
# stop pichat pkill pichatd cd /home/pichat/pichat mv pichat.ini pichat.ini.old sed -e 's/PortHttp=.*/PortHttp=8008/' pichat.ini.old > pichat.ini # start pichat again cd /home/pichat ./pichatd
with an editor
- vi home/pichat/pichat/pichat.ini
- goto to the line started with PortHttp=
- replace the value 8008
- save the pichat.ini
- restart the pichatd
using the iptables
if you have an own start script for the iptables, please add
iptables -t nat -A PREROUTING -p tcp --dport 80 -j REDIRECT --to-port 8008
Errormessages/Fehlermeldungen
version `GLIBC_2.4' not found
# ./pichatd ./pichatd: /lib/tls/libc.so.6: version `GLIBC_2.4' not found (required by ./pichatd) ./pichatd: /lib/tls/libc.so.6: version `GLIBC_2.4' not found (required by ./libpichatcore.so) ./pichatd: /lib/tls/libc.so.6: version `GLIBC_2.4' not found (required by ./libsharkengine.so)
Install a new version of glib
If you have a debian vserver, update from etch to lenny. A HowTo is here → Wie man ein Debian Etch System (Server & Desktop) zu Debian Lenny Upgradet
ServerDebugMode activate/deactivate
- ServerDebugMode_activate.sh
cd /home/pichat/pichat /bin/cp pichat.ini pichat.ini.old sed -e 's/ServerDebugMode=.*/ServerDebugMode=1/' pichat.ini.old > pichat.ini /etc/init.d/pichat restart
- ServerDebugMode_deactivate.sh
cd /home/pichat/pichat /bin/cp pichat.ini pichat.ini.old sed -e 's/ServerDebugMode=.*/ServerDebugMode=0/' pichat.ini.old > pichat.ini /etc/init.d/pichat restart