~edubuntu-italc-devel/italc/italc-intrepid

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
#!/bin/sh
# iTalc client launcher using avahi
# Written by Stéphane Graber <stgraber@ubuntu.com>

ICA_LTSP=`xprop -root ica_ltsp | sed 's/^.* //' 2> /dev/zero`
if [ "$ICA_LTSP" = "1" ]
then
	echo "ICA already running on the thin client."
	exit 0
fi

ISDPORT=5800
IVSPORT=5900
HOSTNAME=`hostname`
MD5_3=`md5sum /etc/italc/keys/public/teacher/key | awk '{print \$1}'`
MD5_2=`md5sum /etc/italc/keys/public/admin/key | awk '{print \$1}'`
MD5_1=`md5sum /etc/italc/keys/public/supporter/key | awk '{print \$1}'`

if [ "$LTSP_CLIENT" ];
then
	echo LTSP environement detected
	PORT=`echo $LTSP_CLIENT | awk -F . '{print \$4}'`
	ISDPORT=$((11000 + $PORT))
	IVSPORT=$((10000 + $PORT))
fi

if [ -f /etc/ltsp_chroot ]
then
	IP=`ip addr show | grep " inet " | grep -v 127.0.0.1 | head -n1 | awk '{print \$2}' | sed "s/\/.*//"`
	HOSTNAME="$IP ($USER)"
fi

RUNNING_ICA=`ps ux | awk '{print \$2" "\$11}' | grep -E "^[0-9]* ica" | awk '{print \$1}'`
if [ "$RUNNING_ICA" ]
then
	for processus in $RUNNING_ICA
	do
		kill $processus
	done
	echo ICA already running, killing it.
	sleep 1s
fi

echo Announce the service on avahi
avahi-publish-service "italc $HOSTNAME" _italc._tcp $IVSPORT $MD5_1 $MD5_2 $MD5_3 "$HOSTNAME" > /dev/zero &

echo Starting ICA
ica -noshm -isdport $ISDPORT -ivsport $IVSPORT

echo Stopping avahi
kill `ps ux | grep avahi-publish-service | grep italc | grep $IVSPORT | grep $HOSTNAME | awk '{print \$2}'`