Commit | Line | Data |
4536f655 |
1 | #!/usr/local/bin/perl -s |
2 | |
3 | $line_cnt = 10 ; |
4 | $offset = 175 ; |
5 | $base_off = 0 ; |
6 | $xskip = ( $^O eq 'solaris' ) ? 600 : 500 ; |
7 | |
8 | my @children ; |
9 | |
10 | print "INETD: $ENV{PATH}\n" ; |
11 | |
3104a1f1 |
12 | use File::Basename qw( basename ); |
13 | $ENV{PATH} .= ':' . basename( $0 ) . ':.'; |
14 | for my $prog qw( run_stem xterm telnet ) { |
15 | die "Can't find $prog in PATH\n" if |
16 | system( "which $prog >/dev/null 2>&1" ) != 0; |
17 | } |
18 | |
4536f655 |
19 | $SIG{ 'INT' } = \&cleanup ; |
20 | |
21 | if ( $s ) { |
22 | |
23 | $ssfe = 'ssfe' ; |
24 | $prompt = '-prompt Stem:' ; |
25 | $echo = 'console_echo=1' |
26 | # $prompt2 = '-prompt Chat:' ; |
27 | } |
28 | |
29 | foreach $cmd ( split /\n/, <<EOT ) { |
30 | xterm -T Stem -n Stem -geometry 80x40+XSKIP+0 -e $ssfe $prompt run_stem $echo inetd |
31 | xterm -T A -n A -geometry 80xLINE+0+OFF -e $ssfe $prompt2 telnet localhost 6666 |
32 | xterm -T B -n B -geometry 80xLINE+0+OFF -e $ssfe $prompt2 telnet localhost 6667 |
33 | xterm -T C -n C -geometry 80xLINE+0+OFF -e $ssfe $prompt2 telnet localhost 6666 |
34 | xterm -T D -n D -geometry 80xLINE+0+OFF -e $ssfe $prompt2 telnet localhost 6667 |
35 | EOT |
36 | |
37 | $cmd =~ s/XSKIP/$xskip/ ; |
38 | |
39 | $cmd =~ s/LINE/$line_cnt/ ; |
40 | $cmd =~ s/OFF/$base_off/ and $base_off += $offset ; |
41 | |
42 | print "CMD $cmd\n" ; |
43 | |
44 | @cmd = split ' ', $cmd ; |
45 | |
46 | s/:/: / for @cmd ; |
47 | |
48 | fork_exec( @cmd ) ; |
49 | sleep 4 unless $cmd =~ /localhost/ ; |
50 | } |
51 | |
3104a1f1 |
52 | 1 while wait() != -1; |
4536f655 |
53 | |
3104a1f1 |
54 | exit; |
4536f655 |
55 | |
4536f655 |
56 | |
4536f655 |
57 | |
58 | sub cleanup { |
59 | |
60 | print "clean up\n" ; |
61 | |
62 | kill 9, @children ; |
63 | |
64 | wait ; |
65 | exit ; |
66 | |
67 | } |
68 | |
69 | sub fork_exec { |
70 | |
71 | my( @exec ) = @_ ; |
72 | |
73 | if ( $pid = fork() ) { |
74 | |
75 | push @children, $pid ; |
76 | return ; |
77 | } |
78 | |
79 | exec @exec ; |
80 | } |