Commit 7fdb8351 authored by Elijah Grubb's avatar Elijah Grubb

Reorganizing user account support for cmd/entrypoint

parent 608afa03
......@@ -4803,25 +4803,31 @@ sub emulabizeImage($;$$$$$$$$)
my $dockerentrypoint;
my $dockercmd;
my $dockeruser;
my $dockerworkingdir;
if ($iattrs{DOCKER_WORKINGDIR} ne "") {
$dockerworkingdir = $iattrs{DOCKER_WORKINGDIR};
print $runitfile "cd ";
print $runitfile $dockerworkingdir;
print $runitfile "\n\n";
}
$dockeruser = $iattrs{DOCKER_USER};
print $runitfile "if [ ! -f /etc/emulab/docker/dockercmd ]; then\n";
print $runitfile "exec ";
# if the user for the container is specified otherwise
# need to run it as that user
if ($dockeruser ne "") {
print $runitfile "sudo -u ";
print $runitfile $dockeruser;
print $runitfile " bash -c '";
}
if (exists($iattrs{DOCKER_ENTRYPOINT})) {
$dockerentrypoint = $iattrs{DOCKER_ENTRYPOINT};
# check if first arg is /bin/sh
if ($dockerentrypoint->[0] ne "/bin/sh") {
print $runitfile "exec ";
}
# if the user for the container is specified otherwise
# need to run it as that user
if ($dockeruser ne "") {
print $runitfile "sudo -u ";
print $runitfile $dockeruser;
print $runitfile " bash -c '";
}
# print whole thing to file
# need to be careful about variables to be expanded
......@@ -4831,25 +4837,10 @@ sub emulabizeImage($;$$$$$$$$)
print $runitfile "\"";
print $runitfile " ";
}
if ($dockeruser ne "") {
print $runitfile "'";
}
}
if (exists($iattrs{DOCKER_CMD})) {
$dockercmd = $iattrs{DOCKER_CMD};
if ($dockercmd->[0] ne "/bin/sh" and !defined($dockerentrypoint)) {
print $runitfile "exec ";
}
# if the user for the container is specified otherwise
# need to run it as that user
if ($dockeruser ne "") {
print $runitfile "sudo -u ";
print $runitfile $dockeruser;
print $runitfile " bash -c '";
}
foreach my $elem (@$dockercmd) {
print $runitfile "\"";
......@@ -4857,10 +4848,10 @@ sub emulabizeImage($;$$$$$$$$)
print $runitfile "\"";
print $runitfile " ";
}
}
if ($dockeruser ne "") {
print $runitfile "'";
}
if ($dockeruser ne "") {
print $runitfile "'";
}
print $runitfile "\n";
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment