From: Josip Rodin Date: Sun, 13 Sep 2009 12:30:29 +0000 (+0200) Subject: prebacio OS-specific application start funkcije u appstart.tcl X-Git-Url: https://git.entuzijast.net/?a=commitdiff_plain;h=71d3c3af3963e2a4f1d129c97f5a11268fc270cc;p=imunes.git prebacio OS-specific application start funkcije u appstart.tcl --- diff --git a/appstart.tcl b/appstart.tcl new file mode 100644 index 0000000..f78f3b1 --- /dev/null +++ b/appstart.tcl @@ -0,0 +1,74 @@ +#****f* appstart.tcl/spawnShell +# NAME +# spawnShell -- spawn shell +# SYNOPSIS +# spawnShell $node $cmd +# FUNCTION +# This procedure spawns a new shell for a specified node. +# The shell is specified in cmd parameter. +# INPUTS +# * node -- node id of the node for which the shell +# is spawned. +# * cmd -- the path to the shell. +#**** +proc spawnShell { node cmd } { + upvar 0 ::cf::[set ::curcfg]::eid eid + global remote_exec exec_host gui_unix + + set node_id $eid\.$node + + if { $remote_exec } { + nexec vimageShellServer.sh $node_id 1234 $cmd & + if { $gui_unix } { + exec xterm -sb -rightbar \ + -T "IMUNES: [getNodeName $node] (console)" \ + -e "nc $exec_host 1234" & + } else { + exec cmd /c nc $exec_host 1234 & + } + } else { + nexec xterm -sb -rightbar \ + -T "IMUNES: [getNodeName $node] (console)" \ + -e "vimage $node_id $cmd" & + } +} + + +#****f* appstart.tcl/startethereal +# NAME +# startethereal -- start ethereal +# SYNOPSIS +# startethereal $node $iface +# FUNCTION +# This procedure starts ethereal for the specified node +# and the specified interface. +# INPUTS +# * node -- node id +# * iface -- interface name +#**** +proc startethereal { node iface } { + upvar 0 ::cf::[set ::curcfg]::eid eid + + set interface "$iface@$eid\.$node" + nexec wireshark -i $interface -f " " & +} + + +#****f* appstart.tcl/startopera +# NAME +# startopera -- start opera +# SYNOPSIS +# startopera $node +# FUNCTION +# This procedure starts opera on the specified node +# INPUTS +# * node -- node id +# * iface -- interface name +#**** +proc startopera { node } { + upvar 0 ::cf::[set ::curcfg]::eid eid + + # set interface "$iface@$eid\.$node" + nexec startopera $eid.$node & +} + diff --git a/editor.tcl b/editor.tcl index f3e2ade..5a5aec8 100755 --- a/editor.tcl +++ b/editor.tcl @@ -1275,97 +1275,6 @@ proc button3node { c x y } { } -#****f* editor.tcl/spawnShell -# NAME -# spawnShell -- spawn shell -# SYNOPSIS -# spawnShell $node $cmd -# FUNCTION -# This procedure spawns a new shell for a specified node. -# The shell is specified in cmd parameter. -# INPUTS -# * node -- node id of the node for which the shell -# is spawned. -# * cmd -- the path to the shell. -#**** -proc spawnShell { node cmd } { - upvar 0 ::cf::[set ::curcfg]::eid eid - global remote_exec exec_host gui_unix gui_freebsd gui_linux - - set node_id $eid\.$node - - if { $remote_exec } { - nexec vimageShellServer.sh $node_id 1234 $cmd & - if { $gui_unix } { - exec xterm -sb -rightbar \ - -T "IMUNES: [getNodeName $node] (console)" \ - -e "nc $exec_host 1234" & - } else { - exec cmd /c nc $exec_host 1234 & - } - } else { - if { $gui_freebsd } { - set shellcommand "vimage $node_id $cmd" - } elseif { $gui_linux } { - if { $cmd == "enter" } { - set shellcommand "vzctl enter $node" - } else { - set shellcommand "vzctl exec $node $cmd" - } - } - nexec xterm -sb -rightbar \ - -T "IMUNES: [getNodeName $node] (console)" \ - -e "$shellcommand" & - } -} - - -#****f* editor.tcl/startethereal -# NAME -# startethereal -- start ethereal -# SYNOPSIS -# startethereal $node $iface -# FUNCTION -# This procedure starts ethereal for the specified node -# and the specified interface. -# INPUTS -# * node -- node id -# * iface -- interface name -#**** -proc startethereal { node iface } { - upvar 0 ::cf::[set ::curcfg]::eid eid - global gui_unix gui_linux - - #OpenVZ - lokalni interface-i za VE-ve, imaju drukciju nomenklaturu - if { $gui_unix && $gui_linux } { - set interface "to_[set node]_[set iface]" - } else { - set interface "$iface@$eid\.$node" - } - - nexec wireshark -i $interface -f " " & -} - - -#****f* editor.tcl/startopera -# NAME -# startopera -- start opera -# SYNOPSIS -# startopera $node -# FUNCTION -# This procedure starts opera on the specified node -# INPUTS -# * node -- node id -# * iface -- interface name -#**** -proc startopera { node } { - upvar 0 ::cf::[set ::curcfg]::eid eid - - # set interface "$iface@$eid\.$node" - nexec startopera $eid.$node & -} - - #****f* editor.tcl/button1 # NAME # button1 diff --git a/imunes.tcl b/imunes.tcl index 308ae6a..29a3377 100755 --- a/imunes.tcl +++ b/imunes.tcl @@ -166,6 +166,13 @@ if { $gui_unix && $gui_linux } { } source "$ROOTDIR/$LIBDIR/editor.tcl" + +if { $gui_unix && $gui_linux } { + source "$ROOTDIR/$LIBDIR/linux/appstart.tcl" +} else { + source "$ROOTDIR/$LIBDIR/appstart.tcl" +} + source "$ROOTDIR/$LIBDIR/copypaste.tcl" source "$ROOTDIR/$LIBDIR/annotations.tcl" diff --git a/install.sh b/install.sh index f38cacc..924a96c 100755 --- a/install.sh +++ b/install.sh @@ -23,7 +23,7 @@ sed -e "s,LIBDIR=\"\",LIBDIR=$LIBDIR," \ chmod 755 $ROOTDIR/$BINDIR/imunes lib_files="nodecfg.tcl linkcfg.tcl cfgparse.tcl ipv4.tcl ipv6.tcl exec.tcl \ - canvas.tcl editor.tcl filemgmt.tcl help.tcl initgui.tcl \ + canvas.tcl editor.tcl appstart.tcl filemgmt.tcl help.tcl initgui.tcl \ copypaste.tcl quagga.tcl xorp.tcl static.tcl pc.tcl host.tcl \ lanswitch.tcl rj45.tcl hub.tcl ns2imunes.tcl ipsec.tcl \ topogen.tcl annotations.tcl gpgui.tcl graph_partitioning.tcl \ diff --git a/linux/appstart.tcl b/linux/appstart.tcl new file mode 100644 index 0000000..3666e01 --- /dev/null +++ b/linux/appstart.tcl @@ -0,0 +1,91 @@ +#****f* appstart.tcl/spawnShell +# NAME +# spawnShell -- spawn shell +# SYNOPSIS +# spawnShell $node $cmd +# FUNCTION +# This procedure spawns a new shell for a specified node. +# The shell is specified in cmd parameter. +# INPUTS +# * node -- node id of the node for which the shell +# is spawned. +# * cmd -- the path to the shell. +#**** +proc spawnShell { node cmd } { + upvar 0 ::cf::[set ::curcfg]::eid eid + global remote_exec exec_host gui_unix gui_freebsd gui_linux + + set node_id $eid\.$node + + if { $remote_exec } { + nexec vimageShellServer.sh $node_id 1234 $cmd & + if { $gui_unix } { + exec xterm -sb -rightbar \ + -T "IMUNES: [getNodeName $node] (console)" \ + -e "nc $exec_host 1234" & + } else { + exec cmd /c nc $exec_host 1234 & + } + } else { + if { $gui_freebsd } { + set shellcommand "vimage $node_id $cmd" + } elseif { $gui_linux } { + if { $cmd == "enter" } { + set shellcommand "vzctl enter $node" + } else { + set shellcommand "vzctl exec $node $cmd" + } + } + nexec xterm -sb -rightbar \ + -T "IMUNES: [getNodeName $node] (console)" \ + -e "$shellcommand" & + } +} + + + +#****f* appstart.tcl/startethereal +# NAME +# startethereal -- start ethereal +# SYNOPSIS +# startethereal $node $iface +# FUNCTION +# This procedure starts ethereal for the specified node +# and the specified interface. +# INPUTS +# * node -- node id +# * iface -- interface name +#**** +proc startethereal { node iface } { + upvar 0 ::cf::[set ::curcfg]::eid eid + global gui_unix gui_linux + + #OpenVZ - lokalni interface-i za VE-ve, imaju drukciju nomenklaturu + if { $gui_unix && $gui_linux } { + set interface "to_[set node]_[set iface]" + } else { + set interface "$iface@$eid\.$node" + } + + nexec wireshark -i $interface -f " " & +} + + +#****f* appstart.tcl/startopera +# NAME +# startopera -- start opera +# SYNOPSIS +# startopera $node +# FUNCTION +# This procedure starts opera on the specified node +# INPUTS +# * node -- node id +# * iface -- interface name +#**** +proc startopera { node } { + upvar 0 ::cf::[set ::curcfg]::eid eid + + # set interface "$iface@$eid\.$node" + nexec startopera $eid.$node & +} +