[go: up one dir, main page]

File: ivman-launch

package info (click to toggle)
ivman 0.6.12-5
  • links: PTS
  • area: main
  • in suites: etch, etch-m68k
  • size: 2,144 kB
  • ctags: 186
  • sloc: sh: 9,500; ansic: 2,951; makefile: 81; xml: 22; sed: 16
file content (96 lines) | stat: -rwxr-xr-x 2,059 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
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
#!/bin/bash
# This script was written by Daniele Favara <danjele@gmail.com>
# 
CMD=ivman
CONFDIR=  # the config dir | null
EXITWITH=
SESSION=
while [ ! -z "$1" ];do
    case "$1" in
      --help|-h)
	    echo "Usage: ivman-launch [OPTIONS]"
		echo "Please see 'man ivman-launch' for details."
        exit 
        ;;
      --confdir|-c)
        if [ "x$2" != "x" ];then
            CONFDIR=$2
            if [ -d "$CONFDIR" ]; then
                CMD="$CMD --confdir $CONFDIR"
                shift 2
            else
                echo "Error $CONFDIR: No such file or directory"
                exit
            fi
        else
            echo "Error: You must specify a directory"
            exit
        fi
        ;;
	  --debug|-d)
        CMD="$CMD --debug"
        shift 1
		;;
      --nofork)
        CMD="$CMD --nofork"
        shift 1
        ;;
      --system|-s)
        CMD="$CMD --system"
        shift 1
        ;;
      --exit-with-session)
	    # exit-with-session implies nofork.
		CMD="$CMD --nofork"
        SESSION=$2
        if [ "x$(which $SESSION)" = "x" ];then
            echo "Error $2: Not a session"
            exit
        else
            echo $(which $SESSION)
            EXITWITH=yes
            shift 2
        fi
        ;;
      *)
            SESSION=$@ ; shift $#
        ;;
    esac
  done
echo "$CMD"

if [ "x$SESSION" = "x" ]; then
    # start normally
	exec $CMD
	exit $?
else

    if [ "x$EXITWITH" = "x" ]; then
	# we were passed a session to start
	#
	$CMD & ivmanpid=$!
	$SESSION
	while ps $ivmanpid
	do
	    kill $ivmanpid || sleep 5
	done
	exit $?
    else
	# we were called with --exit-with-session, which means we
	# watch them and wait for them to die
	#
	exec $CMD & pid=$!
	KILLCMD="kill $pid && echo 'ivman killed' && exit"
	trap "eval $KILLCMD" ALRM HUP INT PIPE PROF TERM USR1 USR2 VTALRM ABRT

	while ps -C ivman -o pid --no-heading | grep -q $pid
	do
            if  ! ps -C $SESSION -o user | grep -q $USER
            then
		eval $KILLCMD
            fi
            sleep 5
	done
    fi
fi