Skip to content
GitLab
Menu
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
5647a0b5
Commit
5647a0b5
authored
Dec 01, 2000
by
Leigh B. Stoller
Browse files
A script to make an experiment directory hierarchy.
parent
63c9534a
Changes
1
Hide whitespace changes
Inline
Side-by-side
tbsetup/mkexpdir
0 → 100755
View file @
5647a0b5
#!/usr/bin/perl -wT
use
English
;
#
# This gets invoked from the Web interface. CD into the proper directory
# and do the tb stuff.
#
# usage: mkexpdir <pid> <eid>
#
my
$tbdir
=
"
/usr/testbed/bin/
";
my
$projroot
=
"
/proj
";
my
$tbdata
=
"
tbdata
";
my
@dirlist
=
(
$tbdata
,
"
bin
",
"
tmp
",
"
logs
");
#
# Untaint the path
#
$ENV
{'
PATH
'}
=
'
/bin:/usr/bin
';
delete
@ENV
{'
IFS
',
'
CDPATH
',
'
ENV
',
'
BASH_ENV
'};
#
# Check args.
#
if
(
@ARGV
!=
2
)
{
print
STDOUT
"
Usage: mkexpdir <pid> <eid>
\n
";
exit
(
-
1
);
}
my
$project
=
$ARGV
[
0
];
my
$eid
=
$ARGV
[
1
];
#
# Untaint the arguments.
#
if
(
$project
=~
/^([-\@\w.]+)$/
)
{
$project
=
$
1
;
}
if
(
$eid
=~
/^([-\@\w.]+)$/
)
{
$eid
=
$
1
;
}
my
$piddir
=
"
$projroot
/
$project
";
my
$expdir
=
"
$piddir
/exp
";
my
$eiddir
=
"
$expdir
/
$eid
";
#
# We create a directory structure for the experiment in the project directory.
#
if
(
!
chdir
(
$expdir
))
{
print
STDOUT
"
Could not chdir to
$expdir
: $!
\n
";
exit
(
-
1
);
}
if
(
!
mkdir
(
$eid
,
0770
))
{
print
STDOUT
"
Could not mkdir
$eid
in
$piddir
: $!
\n
";
exit
(
-
1
);
}
if
(
!
chmod
(
0770
,
"
$eid
"))
{
print
STDOUT
"
Could not chmod
$eid
to 0770 in
$piddir
: $!
\n
";
rmdir
(
$eid
);
exit
(
-
1
);
}
if
(
!
chdir
(
$eid
))
{
print
STDOUT
"
Could not chdir to
$eid
in
$piddir
: $!
\n
";
rmdir
(
$eid
);
exit
(
-
1
);
}
#
# Create the experiment directory list in the new directory.
#
foreach
$dir
(
@dirlist
)
{
if
(
!
mkdir
(
$dir
,
0770
))
{
print
STDOUT
"
Could not mkdir
$dir
in
$eiddir
: $!
\n
";
fatal
();
}
if
(
!
chmod
(
0770
,
"
$dir
"))
{
print
STDOUT
"
Could not chmod
$dir
to 0770 in
$eiddir
: $!
\n
";
fatal
();
}
}
exit
(
0
);
sub
fatal
()
{
if
(
!
chdir
(
$expdir
))
{
print
STDOUT
"
In Fatal: Could not chdir to
$expdir
!
\n
";
exit
(
-
1
);
}
system
("
rm -r
$eid
");
exit
(
-
1
);
}
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a 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