epe Asesor espaņol


Joined: 27 Aug 2005 Posts: 132 Location: Quito - Ecuador
|
Posted: Sun Jan 24, 2010 1:36 pm Post subject: FAQ: Using <on-connect>, an easy way |
|
|
hi
today I woke up early, and having nothing to do, decided to put <on-connect> working inside my chrooted icecast. The server is CentOS-5
For a person with knowledge of linux shell, it will be quite easy. I expect you to have a moderate knowledge of Linux sysadmin in order to know exactly what we will be dong
Actually I saw little documentation on this TAG, therefore it took me a little, but here is how:
install busybox, as busybox has a very simple but functional shell similar to bash called: ash, also because busybox is statically compiled and then we avoid copying 10's of libraries, and because busybox has several shell commands included in it, then we also avoid copying these commands and libraries inside the chroot
| Code: |
| yum install busybox |
My icecast is installed under:
/usr/share/icecast
So I will create a bin directory inside that dir:
| Code: |
cd /usr/share/icecast
mkdir sbin
ln -s sbin bin
cp /sbin/busybox /usr/share/icecast/sbin/
cd sbin
ln -s busybox touch
ln -s busybox ash
ln -s busybox wget
ln -s busybox ls
ln -s busybox echo
|
as you can see, we are softlinking some known commands to busybox, busybox works like this, if we invoke from within the jail one of these commands, then busybox will know from $0 the purpose and act accordingly.
you can see a list of compiled commands inside busybox by simply calling it:
Of course you are free to ln -s any other commands you might need
ok, our jail is ready, let's test it:
| Code: |
| chroot /usr/share/icecast /bin/ash |
we are chrooting inside /usr/share/icecast and then invoking /bin/ash.
you should get a funny shell, something like:
You are inside the jail, try using ls for example:
you should invoke the command with the full path in order for it to work.
Now exit the jail by pressing CONTROL D
If you wish, now you can create a script inside /usr/share/icecast for example let's call it: on-connect:
| Code: |
| vi /usr/share/icecast/on-connect |
put the following code inside:
| Code: |
#!/bin/ash
/bin/echo $1 >> /log/example |
Then chmod it to +x:
| Code: |
| chmod +x /usr/share/icecast/on-connect |
you can then modify a mount-point adding the following line;
<on-connect>/on-connect</on-connect>
reload icecast
and every time this mount-point connect, the script will be invoked and it will write to /usr/share/icecat/log/example the name of the radio (it is the only parameter that is passed to the script, $1 = /radioname )
In case of trouble:
try chrooting into the icecast dir, and invoke the command(s) from within the shell and of course with the full path. Usually you will forget invoking with the full path
It should work, I hope it gets easier for you to use on-connect _________________ --
http://www.NuestroServer.com
USA: +1 305 359 4495, Espaņa: +34 911 877 602
Ecuador: +593 2 600 4454
Se habla espaņol |
|