How to force trailing slash in lighttpd

How to force trailing slash in lighttpd

$SERVER["socket"] == "xxx.xxx.xxx.xxx:80" {
        server.name = "ashishnepal.com"
server.document-root = "/www-root/"
accesslog.filename = "/logs/www/access_log"
server.errorlog = "/logs/www/error_log"
url.redirect = ("^(.*[^/])$" => "$1/") }

######################################
# exclude .ext
#######################################

$HTTP["url"] !~ “^(.*)(..{3}|/)$” {
url.redirect = (
“.*” => “%1/”
)

#####################################
# everything redirect
#####################################

url.redirect = (“^(.*[^/])$” => “$1/”)

Installing Skype on Linux (centos 5.6) and sending message using zabbix

Subject itself sounds crazy, yet intresting.

Installing Skype on Linux (centos 5.6) and sending message using zabbix

Installing skype on Linux 5.6
Installing skype 2.2 on linux 6.2 is easy peasy :D

Download static version of skype for linux, if you are installing skype on linux 5.6 you better pick, older skype version

Download skype of version that suits you.
skype_static-2.1.0.81.tar
skypeAPI (Skype4Py – i have been using 1.0.31.0)

Skype would need to install either GUI or Use vnc server in order to be able to accept terms and condition (checkbox) and to accept skypeAPI integration.

1) If you follow to do with GUI (easiest just install KDE, GNOME according to your suit and install x windows)

2) If you follow to do with VNC (you would need to install Xvfb, fluxbox, x11vnc, dbus and modules according to need all problem i faced during the process is mentioned below).

Simply extract skype_static tarball and cp skype to /usr/bin/skype.

Install skype4Py with following command:

cd Skype4Py-1.0.31.0/
python setup.py install

Implementing skype on zabbix to send message

You will need to setup Media type and user profile.
which is pretty much simple for those user who has used zabbix.
And Action on configuration, which will define how to treat on alert and choose skype and user to alert.

with the given script (sendim.sh and sendim.py)

skype message on the server as skype user: ./sendim.sh ‘tikejhya’ ‘test this’

Script:
Sendim.sh

#!/bin/bash
DISPLAY=localhost:0.0
export DISPLAY
my_arg="${@:2:6}"
python ./sendim.py "$1" "$my_arg"

[Note: I used Display localhost to ensure tranporting display which can be in bash_profile]
[Note: Zabbix sends message as script username message so i wanted to use all message apart from username
this will allow you to send multiple macros.]

./sendim.py

import Skype4Py
import sys

# Create an instance of the Skype class.
skype = Skype4Py.Skype()

# Connect the Skype object to the Skype client.
skype.Attach()
user = sys.argv[1]
msg = ' '.join(sys.argv[2:])
message = skype.SendMessage(user, msg)

[This script imports skype4py which you might have installed already in above given tips.]

./skype_login.sh

#!/bin/bash
echo tikejhya password | skype --pipelogin&

[this is how you can login to skype from CLI]

Did i miss anything?

This link was really helpful to get me going

http://www.qxs.ch/2011/01/07/skype-instant-messages-from-zabbix/

###########################################################
Problem i faced during installation.

Install Skype in EL6

yum install skype

If you do not have my repo installed:

wget http://li.nux.ro/download/nux/dextop/el6/x86_64/skype-2.2.0.35-3.el6.nux.i586.rpm
yum localinstall --nogpgcheck ./skype-2.2.0.35-3.el6.nux.i586.rpm

All of the above needs to be done as root, obviously.

#############################################################

rpm -Uvh http://ftp.ntua.gr/pub/linux/fedora-epel/6/x86_64/epel-release-6-6.noarch.rpm

(if unable to open web, and search for which epel-release version is available)

yum install wine

############################################################

/usr/bin/python2.5: bad interpreter: No such file or directory

To get around this, open skysentials.py with your favourite text editor and change the very first line from:

  #!/usr/bin/python2.5

to:

#!/usr/bin/python

###########################################################

Changing dbus to x11 (BTW you dont need to change build one but compile again)

vi skype4py/build/lib/Skype4Py/api/posix.py	
vi skype4py/Skype4Py/api/posix.py

def SkypeAPI(opts):
trans = opts.pop(‘Transport’, ‘x11′)
if trans == ‘dbus’:
from posix_dbus import SkypeAPI
elif trans == ‘x11′:
from posix_x11 import SkypeAPI
else:
raise SkypeAPIError(‘Unknown transport: %s’ % trans)
############################################################

How to setup Skype headless on centos 5.6

Download Skype Static Package version:
skype_static-2.1.0.81.tar

tar -xvf skype_static-2.1.0.81.tar
cd skype_static-2.1.0.81

############################################################
Problem: libstdc++ GLIBC error
Solution: Older Skype version
############################################################

[root@ashishnepal Skype4Py-1.0.32.0]# Xvfb :1 -screen 0 800x600x24
Couldn’t open RGB_DB ‘/usr/share/X11/rgb’
_XSERVTransSocketOpenCOTSServer: Unable to open socket for inet6
_XSERVTransOpen: transport open failed for inet6/ashishnepal:1
_XSERVTransMakeAllCOTSServerListeners: failed to open listener for inet6
error opening security policy file /usr/lib64/xserver/SecurityPolicy
Could not init font path element unix/:7100, removing from list!
FreeFontPath: FPE “built-ins” refcount is 2, should be 1; fixing.

solution: Comment out ipv6 , disable = 1

[root@ashishnepal Skype4Py]# cat /etc/modprobe.conf
alias scsi_hostadapter mptbase
alias scsi_hostadapter1 mptspi
alias scsi_hostadapter2 ata_piix
alias net-pf-10 off
# alias ipv6 off
# options ipv6 disable=1
# Added by VMware Tools
install pciehp /sbin/modprobe -q --ignore-install acpiphp; /bin/true
install pcnet32 (/sbin/modprobe -q --ignore-install vmxnet || /sbin/modprobe -q --ignore-install pcnet32 $CMDLINE_OPTS);/bin/true
alias eth0 e1000

###########################################################

Xvfb :1 -screen 0 800x600x24

export Display
DISPLAY=localhost:0.0
export DISPLAY

Pipe Login.
echo tikejhya Password | skype --pipelogin

###########################################################
If you are willing to run zabbix in diff server and have centos with skype in diff server this may totally make sense.

sudo: no tty present and no askpass program specified

# %users  localhost=/sbin/shutdown -h now
%tikejhya    ALL=(ALL)      NOPASSWD: ALL

#########################################################
[root@ashishnepal skype4py]# sudo /root/sendim.sh tikejhya “Ok this is it”
Xlib: connection to “localhost:0.0″ refused by server
Xlib: No protocol specified

Traceback (most recent call last):
File “/root/sendim.py”, line 4, in ?
skype = Skype4Py.Skype()
File “/usr/lib/python2.4/site-packages/Skype4Py/skype.py”, line 250, in __init__
self._Api = SkypeAPI(Options)
File “/usr/lib/python2.4/site-packages/Skype4Py/api/posix.py”, line 40, in SkypeAPI
return SkypeAPI(opts)
File “/usr/lib/python2.4/site-packages/Skype4Py/api/posix_x11.py”, line 254, in __init__
raise SkypeAPIError(‘Could not open XDisplay’)
Skype4Py.errors.SkypeAPIError: Could not open XDisplay
/root/sendim.sh: line 6: 5816 Segmentation fault python /root/sendim.py “$1″ “$2″

Solution:

[root@ashishnepal skype4py]# su -
[root@ashishnepal ~]# /root/sendim.sh tikejhya "Ok this is it"

[environmental variable plus exporting display is sometimes tricky]

Also if you want to make more certain

[root@ashishnepal.com Skype4Py]# echo tikejhya password | skype –pipelogin
Xlib: connection to “localhost:0.0″ refused by server
Xlib: No protocol specified

this is becuase of .xauthority file…

su -
and it should be fine…

or need to find way to use .xauthority file..

/usr/bin/mkxauth [-q] [-u ] -m 

-u     create/merge .Xauthority for user 

Best practice: mkxauth -u skype -m root

###############################################################
skype not snyncing

http://www.mydigitallife.info/how-to-disable-upnp-in-skype-to-remove-open-tcp-and-udp-ports-in-firewall/

Its all in all upnp play.
###############################################################

Debugging shell script arguments.

While implementing skype in zabbix we normally dont see any logs so it was important for me to see weather message were being passed or not.

Simple script.

#!/bin/bash
KEY="/home/zabbix/id_rsa"
PORT=2222
USER="skype@ashishnepal.com"
SCRIPT="/home/skype/sendim.sh"
# my_arg="${@:2:6}"

echo "..............">>skypelog.txt

echo "Total Arguments: $#" >> skypelog.txt
i=1;
echo ".........................">>skypelog.txt
for var in "$@"
        do
          echo "Argument $i is $var" >> skypelog.txt
          let i=$i+1;
        done

ssh -p${PORT} -i $KEY $USER "$SCRIPT "$1" "$2""

Delay on message arrival : Firewall
Skype message not delivered yet?

Allways allow from the SKYPEAPI Server IP (from port) 1024 (to port) 65535.

This should solve issue.

##########################################################

GUI for sending skype message

Sending Skype Message from Web: