aboutsummaryrefslogtreecommitdiff
path: root/vo/java/app.hub
blob: 6abc85623e3b3b939540055b144ed00d2bb34eda (plain) (blame)
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
#!/bin/csh -f

unalias ps egrep java

set dir   = `dirname $0`
set me    = `whoami`
set pid   = `ps -fwu $me | egrep -i hub | egrep -i jsamp` 	#  MACHDEP
set npid  = $#pid
if ($npid == 0) then
    #  No JSAMP running, check for a Topcat/Aladin Hub.
    set pid   = `ps -fwu $me | egrep -i hub | egrep -i "topcat|aladin"`
    set npid  = $#pid
    set is_jsamp = 0
else
    set is_jsamp = 1
endif

set jar   = jsamp-1.3-2.jar

set mode  = "-mode client-gui"

if ($#argv > 0) then
    if ("$2" == "-no-gui") then
	set mode = "-mode no-gui"
        if (! ($?DISPLAY)) then
            setenv DISPLAY :0
        endif
    endif

    if ("$1" == "-bg") then
        if ($npid == 0 && $is_jsamp == 0) then
            /bin/rm -rf ~/.samp
        endif
        exec java -jar ${dir}/$jar hub ${mode} &

    else if ("$1" == "-kill") then
        kill -9 $pid[2]

    else if ("$1" == "-status") then
        if ($npid == 0 && $is_jsamp == 0) then
	    echo "off"
        else
	    echo "on"
        endif

    endif
else
    if ($npid == 0 && $is_jsamp == 0) then
        /bin/rm -rf ~/.samp
    endif
    exec java -jar ${dir}/$jar hub ${mode}
endif