File: localapp

package info (click to toggle)
controlaula 1.3-4
  • links: PTS
  • area: main
  • in suites: lenny
  • size: 2,720 kB
  • ctags: 102
  • sloc: sh: 3,839; ansic: 483; makefile: 206
file content (54 lines) | stat: -rw-r--r-- 1,652 bytes parent folder | download
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
52
53
54
#!/bin/sh
# Copyright (C) 2008 José L. Redrejo Rodríguez, jredrejo at-no-spam debian.org.
# This file is free software; you can redistribute it and/or modify it
# under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful, but
# WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
# General Public License for more details.
#
# This example implements local apps in ltsp
# For it to work, it should be placed at /usr/bin in the ltsp chroot
# with execution permissions
#
launch()
{	
	ISFIREFOX=$(echo "${1}"|grep firefox)$(echo "${1}"|grep iceweasel)$(echo "${1}"|grep www-browser)
	if [ ! -z "$ISFIREFOX" ]; then
		param=""
	   	for var in $1; do
	   		ISFIREFOX=$(echo "${var}"|grep firefox)$(echo "${var}"|grep iceweasel)$(echo "${var}"|grep www-browser)
          	if [  -z "$ISFIREFOX" ]; then
          	 	param=$param" "$var
          	fi
      	done
		if [ -e /usr/local/bin/iceweasel ]; then
		  	/usr/local/bin/iceweasel $param &
		fi
	else
		su -c "cd /var/tmp/${LOGIN};DISPLAY=:7.0  PULSE_SERVER=127.0.0.1:4713  ESPEAKER=127.0.0.1:16001  ${1}" ${LOGIN} &
	fi

}


LOGIN=$(cat $(ls -1 /var/run/ltsplogin*|head -1))

if [ ! -z "$1" ]; then
	launch "${1}"
	exit 0
fi

while [ -d  /var/tmp/${LOGIN} ] ; do

	if [ -f /var/tmp/${LOGIN}/local.exec ]; then
		COMMAND=$(head -1 /var/tmp/${LOGIN}/local.exec)
		rm -f /var/tmp/${LOGIN}/local.exec
		launch "${COMMAND}"
	fi
	
	sleep 1     
done