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
04d656d2
Commit
04d656d2
authored
Nov 02, 2000
by
Mac Newbold
Browse files
fixed for sshtb
parent
8d8baac3
Changes
1
Hide whitespace changes
Inline
Side-by-side
tbsetup/mkacct
View file @
04d656d2
#!/usr/local/bin/perl -w
#!/usr/local/bin/perl -w
###
###
### $Id: mkacct,v 1.1
5
2000-
09-22 22:06:02 kwright
Exp $
### $Id: mkacct,v 1.1
6
2000-
11-02 17:26:21 newbold
Exp $
###
###
### Address 'lkw' comments:
### Address 'lkw' comments:
### Break up into subroutines, possibly libraries. We'll
### Break up into subroutines, possibly libraries. We'll
...
@@ -151,7 +151,7 @@ $cmd =
...
@@ -151,7 +151,7 @@ $cmd =
"
select IP from interfaces as ip
"
.
"
select IP from interfaces as ip
"
.
"
left join reserved as r on r.node_id=ip.node_id
"
.
"
left join reserved as r on r.node_id=ip.node_id
"
.
"
left join experiments as e on r.eid = e.eid
"
.
"
left join experiments as e on r.eid = e.eid
"
.
"
where e.eid = '
$eid
'
";
"
where e.eid = '
$eid
'
and card=4
";
$sth
=
$dbh
->
query
(
$cmd
);
$sth
=
$dbh
->
query
(
$cmd
);
my
@nodes
=
();
my
@nodes
=
();
while
(
@row
=
$sth
->
fetchrow_array
)
{
while
(
@row
=
$sth
->
fetchrow_array
)
{
...
@@ -192,20 +192,26 @@ foreach $IP (@nodes) {
...
@@ -192,20 +192,26 @@ foreach $IP (@nodes) {
}
else
{
}
else
{
print
"
Checking OS on
$IP
...
";
print
"
Checking OS on
$IP
...
";
open
(
UNAME
,"
/usr/local/bin/ssh
$IP
uname 2>&1 |
");
open
(
UNAME
,"
/usr/local/bin/ssh
tb
$IP
uname 2>&1 |
");
$_
=
<
UNAME
>
;
$_
=
<
UNAME
>
;
print
$_
;
print
$_
;
close
(
UNAME
);
## FreeBSD says "155.99.214.129: Connection refused"
## FreeBSD says "155.99.214.129: Connection refused"
## and can also say "Host key doesn't match..."
## and can also say "Host key doesn't match..."
## and can also say "@@@@@@... WARNING HOST ID CHANGED..."
## and can also say "@@@@@@... WARNING HOST ID CHANGED..."
if
(
(
$_
=~
/^Sorry/
)
||
(
$_
=~
/^$IP/
)
||
(
$_
=~
/^Host key/
)
if
(
(
$_
=~
/^Sorry/
)
||
(
$_
=~
/^$IP/
)
||
(
$_
=~
/^Host key/
)
||
(
$_
=~
/^@+/
)
)
{
||
(
$_
=~
/^@+/
)
)
{
die
("
Uname failed on
$IP
:
$_
\n
");
print
"
Uname failed on
$IP
:
$_
";
while
(
<
UNAME
>
)
{
print
;
}
close
(
UNAME
);
die
("
\n
");
}
else
{
}
else
{
$OS
=
$_
;
$OS
=
$_
;
}
}
close
(
UNAME
);
}
}
...
@@ -221,14 +227,14 @@ foreach $IP (@nodes) {
...
@@ -221,14 +227,14 @@ foreach $IP (@nodes) {
## will report it and move on.
## will report it and move on.
print
"
Creating group
$unix_gid
on
$IP
.
\n
";
print
"
Creating group
$unix_gid
on
$IP
.
\n
";
open
(
GROUPADD
,
"
/usr/local/bin/ssh
$IP
/usr/sbin/groupadd -g
$unix_gid
$eid
2>&1 |
");
open
(
GROUPADD
,
"
/usr/local/bin/ssh
tb
$IP
/usr/sbin/groupadd -g
$unix_gid
$eid
2>&1 |
");
while
(
<
GROUPADD
>
)
{
print
"
$_
";
}
while
(
<
GROUPADD
>
)
{
print
"
$_
";
}
close
(
GROUPADD
);
close
(
GROUPADD
);
my
$i
=
1
;
my
$i
=
1
;
foreach
my
$user
(
keys
%passwd
)
{
foreach
my
$user
(
keys
%passwd
)
{
print
"
Creating user
$user
on
$IP
.
\n
";
print
"
Creating user
$user
on
$IP
.
\n
";
open
(
USERADD
,
"
/usr/local/bin/ssh
$IP
/usr/sbin/useradd -c
\"
$fullname
{
$user
}
\"
-d /users/
$user
-g
$unix_gid
-m -p
$passwd
{
$user
} -s /bin/tcsh -u
$unix_uid
{
$user
}
$user
2>&1 |
");
open
(
USERADD
,
"
/usr/local/bin/ssh
tb
$IP
/usr/sbin/useradd -c
\"
$fullname
{
$user
}
\"
-d /users/
$user
-g
$unix_gid
-m -p
$passwd
{
$user
} -s /bin/tcsh -u
$unix_uid
{
$user
}
$user
2>&1 |
");
while
(
<
USERADD
>
)
{
print
"
$_
";
}
while
(
<
USERADD
>
)
{
print
"
$_
";
}
close
(
USERADD
);
close
(
USERADD
);
}
}
...
@@ -264,7 +270,7 @@ foreach $IP (@nodes) {
...
@@ -264,7 +270,7 @@ foreach $IP (@nodes) {
$addon
=
"
$user
:
$passwd
{
$user
}:
$unix_uid
{
$user
}:
"
.
$addon
=
"
$user
:
$passwd
{
$user
}:
$unix_uid
{
$user
}:
"
.
"
$unix_gid
:
\
:0:0:
$fullname
{
$user
}:/users/
$user
:
"
.
"
$unix_gid
:
\
:0:0:
$fullname
{
$user
}:/users/
$user
:
"
.
"
/bin/tcsh
\n
";
"
/bin/tcsh
\n
";
open
(
CHPASS
,
"
/usr/local/bin/ssh
$IP
/usr/bin/chpass -a '
$addon
' 2>&1 |
");
open
(
CHPASS
,
"
/usr/local/bin/ssh
tb
$IP
/usr/bin/chpass -a '
$addon
' 2>&1 |
");
while
(
<
CHPASS
>
)
{
print
"
$_
";
}
while
(
<
CHPASS
>
)
{
print
"
$_
";
}
close
(
CHPASS
)
close
(
CHPASS
)
}
}
...
...
Write
Preview
Markdown
is supported
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