Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
emulab
emulab-devel
Commits
7c481b95
Commit
7c481b95
authored
May 11, 2004
by
Leigh B. Stoller
Browse files
New rc script to start up the link agent on non-ethernet (okay,
wireless) nodes.
parent
9149eed0
Changes
3
Hide whitespace changes
Inline
Side-by-side
tmcd/common/config/GNUmakefile.in
View file @
7c481b95
...
...
@@ -19,7 +19,8 @@ SUBDIR = tmcd/common/config
SCRIPTS = $(addprefix $(SRCDIR)/, \
rc.config rc.misc rc.mounts rc.accounts rc.route \
rc.tunnels rc.ifconfig rc.delays rc.hostnames rc.syncserver \
rc.tunnels rc.ifconfig rc.delays rc.hostnames \
rc.syncserver rc.linkagent \
rc.keys rc.trafgen rc.tarfiles rc.rpms rc.progagent \
rc.startcmd rc.simulator)
...
...
tmcd/common/config/rc.config
View file @
7c481b95
...
...
@@ -87,8 +87,8 @@ else {
@
bootscripts
= (
"rc.misc"
,
"rc.keys"
,
"rc.mounts"
,
"rc.accounts"
,
"rc.route"
,
"rc.tunnels"
,
"rc.ifconfig"
,
"rc.delays"
,
"rc.hostnames"
,
"rc.syncserver"
,
"rc.trafgen"
,
"rc.tarfiles"
,
"rc.rpms"
,
"rc.progagent"
,
"rc.
startcmd
"
,
"rc.simulator"
);
"rc.tarfiles"
,
"rc.rpms"
,
"rc.progagent"
,
"rc.
linkagent
"
,
"rc.startcmd"
,
"rc.simulator"
);
}
# Execute the action.
...
...
tmcd/common/config/rc.linkagent
0 → 100755
View file @
7c481b95
#!/usr/bin/perl -w
#
# EMULAB-COPYRIGHT
# Copyright (c) 2004 University of Utah and the Flux Group.
# All rights reserved.
#
use
English
;
use
Getopt::
Std
;
sub
usage
()
{
print
"
Usage:
"
.
scriptname
()
.
"
[-j vnodeid] boot|shutdown|reconfig|reset
\n
";
exit
(
1
);
}
my
$optlist
=
"
j:
";
my
$action
=
"
boot
";
# Turn off line buffering on output
$|
=
1
;
# Drag in path stuff so we can find emulab stuff.
BEGIN
{
require
"
/etc/emulab/paths.pm
";
import
emulabpaths
;
}
# Only root.
if
(
$EUID
!=
0
)
{
die
("
*** $0:
\n
"
.
"
Must be root to run this script!
\n
");
}
# Script specific goo
my
$LOGFILE
=
"
$LOGDIR
/linkagent.debug
";
my
$PIDFILE
=
"
/var/run/linkagent.pid
";
my
$LAGENT
=
"
$BINDIR
/link-agent
";
#
# Load the OS independent support library. It will load the OS dependent
# library and initialize itself.
#
use
libsetup
;
use
libtmcc
;
use
librc
;
#
# Not all clients support this.
#
exit
(
0
)
if
(
MFS
()
||
JAILED
()
||
REMOTE
());
# Protos.
sub
doboot
();
sub
doshutdown
();
sub
doreconfig
();
sub
docleanup
();
# Parse command line.
if
(
!
getopts
(
$optlist
,
\
%options
))
{
usage
();
}
if
(
defined
(
$options
{'
j
'}))
{
my
$vnodeid
=
$options
{'
j
'};
libsetup_setvnodeid
(
$vnodeid
);
}
# Allow default above.
if
(
@ARGV
)
{
$action
=
$ARGV
[
0
];
}
# Execute the action.
SWITCH:
for
(
$action
)
{
/^boot$/i
&&
do
{
doboot
();
last
SWITCH
;
};
/^shutdown$/i
&&
do
{
doshutdown
();
last
SWITCH
;
};
/^reconfig$/i
&&
do
{
doreconfig
();
last
SWITCH
;
};
/^reset$/i
&&
do
{
docleanup
();
last
SWITCH
;
};
fatal
("
Invalid action:
$action
\n
");
}
exit
(
0
);
#
# Boot Action.
#
sub
doboot
()
{
my
@ifacelist
=
();
my
$args
=
"";
#
# Get the iface list from libsetup, which handles parsing the stuff
# we get back from tmcd.
#
if
(
getifconfig
(
\
@ifacelist
)
!=
0
)
{
fatal
("
Could not get ifconfig from libsetup!
");
}
return
0
if
(
!
@ifacelist
);
#
# Need the pid/eid and nickname.
#
my
(
$pid
,
$eid
,
$vname
)
=
check_nickname
();
$vname
=
$vnodeid
if
(
defined
(
$vnodeid
));
foreach
my
$ifconfig
(
@ifacelist
)
{
my
$lan
=
$ifconfig
->
{"
LAN
"};
my
$iface
=
$ifconfig
->
{"
IFACE
"};
my
$mac
=
$ifconfig
->
{"
MAC
"};
my
$protocol
=
$ifconfig
->
{"
SETTINGS
"}
->
{"
protocol
"};
# We want to run this for non-ethernet links only since eth links
# are handled by the delay agent.
next
if
(
!
defined
(
$protocol
)
||
$protocol
eq
"
ethernet
");
$args
.=
"
$lan
,
$vname
,
$iface
,
$mac
";
}
return
0
if
(
$args
eq
"");
print
"
Starting Link Agent ...
\n
";
system
("
$LAGENT
-v -e
$pid
/
$eid
-s localhost -l
$LOGFILE
"
.
"
-i
$PIDFILE
-k
"
.
TMEVENTKEY
()
.
"
$args
\n
");
if
(
$?
)
{
fatal
("
Could not start program agent!
");
}
return
;
}
#
# Shutdown Action.
#
sub
doshutdown
()
{
#
# Kill the process.
#
if
(
-
e
$PIDFILE
)
{
system
("
kill `cat
$PIDFILE
`
");
# Does not unlink its own pidfile.
unlink
$PIDFILE
;
}
return
;
}
#
# Node Reconfig Action (without rebooting).
#
sub
doreconfig
()
{
# Same as booting
doshutdown
();
return
doboot
();
}
#
# Node cleanup action (node is reset to clean state, as if just allocated).
#
sub
docleanup
()
{
# Remove config file; will be regenerated at next boot.
if
(
-
e
$CONFIG
)
{
unlink
$CONFIG
;
}
}
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment