Commit 4b62c057 authored by Heinz N. Gies's avatar Heinz N. Gies

merge

parents 9c2e3947 91998a36
Pipeline #16250596 passed with stages
in 7 minutes and 56 seconds
[root] [root]
name = "vmadm" name = "vmadm"
version = "0.3.7" version = "0.3.8"
dependencies = [ dependencies = [
"aud 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)", "aud 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)",
"bzip2 0.3.2 (registry+https://github.com/rust-lang/crates.io-index)", "bzip2 0.3.2 (registry+https://github.com/rust-lang/crates.io-index)",
......
[package] [package]
name = "vmadm" name = "vmadm"
version = "0.3.7" version = "0.3.8"
authors = ["Heinz N. Gies <heinz@project-fifo.net>"] authors = ["Heinz N. Gies <heinz@project-fifo.net>"]
[dependencies] [dependencies]
......
VERSION=0.3.7 VERSION=0.3.8
COMPONENT_INTERNAL=rvmadm COMPONENT_INTERNAL=rvmadm
COMPONENT=vmadm COMPONENT=vmadm
...@@ -5,21 +5,12 @@ then ...@@ -5,21 +5,12 @@ then
mkdir -p /usr/local/etc/vmadm mkdir -p /usr/local/etc/vmadm
fi fi
if [ ! -d /var/imgadm/images ] if [ ! -f /usr/local/etc/vmadm.toml ]
then then
mkdir -p /var/imgadm/images cp /usr/local/lib/vmadm/vmadm.toml.example /usr/local/etc/vmadm.toml
fi fi
if [ ! -d /var/imgadm/images ]
CONFFILE="/usr/local/etc/vmadm.toml"
if [ ! -f $CONFFILE ]
then then
echo "Creating new configuration from example file." mkdir -p /var/imgadm/images
cat <<EOF > $CONFFILE
pool = "zroot/jails"
[networks]
admin = "bridge0"
EOF
else
echo "Please make sure you update your config according to the update manual!"
fi fi
...@@ -97,10 +97,24 @@ expand_linked() { ...@@ -97,10 +97,24 @@ expand_linked() {
} }
read_routes() { read_routes() {
# we run the interface routes first
while read route gw while read route gw
do do
/sbin/route add "$route" -gateway "$gw" if ifconfig "${gw}" 2> /dev/null
then
/sbin/route add "${route}" -iface "${gw}"
echo "route: $route" echo "route: $route"
echo "gw: $gw" echo "gw: $gw"
fi
done < "/config/routes"
# now we use network routes
while read route gw
do
if ! ifconfig "${gw}" 2> /dev/null
then
/sbin/route add "${route}" "${gw}"
fi
done < "/config/routes" done < "/config/routes"
} }
...@@ -131,10 +131,6 @@ impl NIC { ...@@ -131,10 +131,6 @@ impl NIC {
iface = self.interface iface = self.interface
) )
}; };
if self.primary {
let route = format!("/sbin/route add default -gateway {}; ", self.gateway);
script.push_str(route.as_str())
}
let mut desc = String::from("VNic from jail "); let mut desc = String::from("VNic from jail ");
desc.push_str(uuid.hyphenated().to_string().as_str()); desc.push_str(uuid.hyphenated().to_string().as_str());
let output = Command::new(IFCONFIG) let output = Command::new(IFCONFIG)
......
...@@ -76,13 +76,23 @@ impl<'a> Jail<'a> { ...@@ -76,13 +76,23 @@ impl<'a> Jail<'a> {
let mut config = self.jail_root(); let mut config = self.jail_root();
config.push("config"); config.push("config");
if ! self.config.routes.is_empty() { {
let mut routes = config.clone(); let mut routes = config.clone();
routes.push("routes"); routes.push("routes");
debug!("preparing routes file"; debug!("preparing routes file";
"vm" => self.idx.uuid.hyphenated().to_string(), "vm" => self.idx.uuid.hyphenated().to_string(),
"file" => routes.to_str()); "file" => routes.to_str());
let mut routes_file = File::create(routes)?; let mut routes_file = File::create(routes)?;
for nic in self.config.nics.clone() {
if nic.primary {
routes_file.write_all(b"default")?;
routes_file.write_all(b"\t")?;
routes_file.write_all(nic.gateway.as_bytes())?;
routes_file.write_all(b"\n")?;
}
}
if !self.config.routes.is_empty() {
for (dest, gw) in self.config.routes.iter() { for (dest, gw) in self.config.routes.iter() {
routes_file.write_all(dest.as_bytes())?; routes_file.write_all(dest.as_bytes())?;
routes_file.write_all(b"\t")?; routes_file.write_all(b"\t")?;
...@@ -91,10 +101,12 @@ impl<'a> Jail<'a> { ...@@ -91,10 +101,12 @@ impl<'a> Jail<'a> {
} }
} }
}
let id = start_jail(&self.idx.uuid, args)?; let id = start_jail(&self.idx.uuid, args)?;
let id_str = id.to_string(); let id_str = id.to_string();
let mut jprefix = String::from("j"); let mut jprefix = String::from("j");
jprefix.push_str(id_str.as_str()); jprefix.push_str(id_str.as_str());
jprefix.push(':'); jprefix.push(':');
for iface in ifs.iter() { for iface in ifs.iter() {
...@@ -103,14 +115,14 @@ impl<'a> Jail<'a> { ...@@ -103,14 +115,14 @@ impl<'a> Jail<'a> {
let mut target_name = jprefix.clone(); let mut target_name = jprefix.clone();
target_name.push_str(iface.iface.as_str()); target_name.push_str(iface.iface.as_str());
let args = vec![epair, String::from("name"), target_name]; let args = vec![epair, String::from("name"), target_name];
debug!("destroying epair"; debug!("renaming epair";
"vm" => self.idx.uuid.hyphenated().to_string(), "vm" => self.idx.uuid.hyphenated().to_string(),
"args" => args.clone().join(" ")); "args" => args.clone().join(" "));
let output = Command::new(IFCONFIG).args(args.clone()).output().expect( let output = Command::new(IFCONFIG).args(args.clone()).output().expect(
"ifconfig failed", "ifconfig failed",
); );
if !output.status.success() { if !output.status.success() {
crit!("failed to destroy interface"; "vm" => self.idx.uuid.hyphenated().to_string()); crit!("failed to rename interface"; "vm" => self.idx.uuid.hyphenated().to_string());
} }
} }
Ok(0) Ok(0)
...@@ -123,7 +135,7 @@ impl<'a> Jail<'a> { ...@@ -123,7 +135,7 @@ impl<'a> Jail<'a> {
"dir" => config.to_str(), "dir" => config.to_str(),
"vm" => self.idx.uuid.hyphenated().to_string()); "vm" => self.idx.uuid.hyphenated().to_string());
fs::create_dir(config.clone())?; fs::create_dir(config.clone())?;
if ! self.config.resolvers.is_empty() { if !self.config.resolvers.is_empty() {
let mut resolvers = config.clone(); let mut resolvers = config.clone();
resolvers.push("resolvers"); resolvers.push("resolvers");
debug!("preparing resolver file"; debug!("preparing resolver file";
...@@ -180,7 +192,9 @@ impl<'a> Jail<'a> { ...@@ -180,7 +192,9 @@ impl<'a> Jail<'a> {
return Err(GenericError::bx("Could not stop jail")); return Err(GenericError::bx("Could not stop jail"));
} }
brand.halted.output(self, config).expect("brand halted failed");; brand.halted.output(self, config).expect(
"brand halted failed",
);;
let _ = self.remove_rctl(); let _ = self.remove_rctl();
match self.outer { match self.outer {
......
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