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]
name = "vmadm"
version = "0.3.7"
version = "0.3.8"
dependencies = [
"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)",
......
[package]
name = "vmadm"
version = "0.3.7"
version = "0.3.8"
authors = ["Heinz N. Gies <heinz@project-fifo.net>"]
[dependencies]
......
VERSION=0.3.7
VERSION=0.3.8
COMPONENT_INTERNAL=rvmadm
COMPONENT=vmadm
......@@ -5,21 +5,12 @@ then
mkdir -p /usr/local/etc/vmadm
fi
if [ ! -d /var/imgadm/images ]
if [ ! -f /usr/local/etc/vmadm.toml ]
then
mkdir -p /var/imgadm/images
cp /usr/local/lib/vmadm/vmadm.toml.example /usr/local/etc/vmadm.toml
fi
CONFFILE="/usr/local/etc/vmadm.toml"
if [ ! -f $CONFFILE ]
if [ ! -d /var/imgadm/images ]
then
echo "Creating new configuration from example file."
cat <<EOF > $CONFFILE
pool = "zroot/jails"
[networks]
admin = "bridge0"
EOF
else
echo "Please make sure you update your config according to the update manual!"
mkdir -p /var/imgadm/images
fi
......@@ -97,10 +97,24 @@ expand_linked() {
}
read_routes() {
# we run the interface routes first
while read route gw
do
/sbin/route add "$route" -gateway "$gw"
if ifconfig "${gw}" 2> /dev/null
then
/sbin/route add "${route}" -iface "${gw}"
echo "route: $route"
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"
}
......@@ -131,10 +131,6 @@ impl NIC {
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 ");
desc.push_str(uuid.hyphenated().to_string().as_str());
let output = Command::new(IFCONFIG)
......
......@@ -76,13 +76,23 @@ impl<'a> Jail<'a> {
let mut config = self.jail_root();
config.push("config");
if ! self.config.routes.is_empty() {
{
let mut routes = config.clone();
routes.push("routes");
debug!("preparing routes file";
"vm" => self.idx.uuid.hyphenated().to_string(),
"file" => routes.to_str());
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() {
routes_file.write_all(dest.as_bytes())?;
routes_file.write_all(b"\t")?;
......@@ -91,10 +101,12 @@ impl<'a> Jail<'a> {
}
}
}
let id = start_jail(&self.idx.uuid, args)?;
let id_str = id.to_string();
let mut jprefix = String::from("j");
jprefix.push_str(id_str.as_str());
jprefix.push(':');
for iface in ifs.iter() {
......@@ -103,14 +115,14 @@ impl<'a> Jail<'a> {
let mut target_name = jprefix.clone();
target_name.push_str(iface.iface.as_str());
let args = vec![epair, String::from("name"), target_name];
debug!("destroying epair";
debug!("renaming epair";
"vm" => self.idx.uuid.hyphenated().to_string(),
"args" => args.clone().join(" "));
let output = Command::new(IFCONFIG).args(args.clone()).output().expect(
"ifconfig failed",
);
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)
......@@ -123,7 +135,7 @@ impl<'a> Jail<'a> {
"dir" => config.to_str(),
"vm" => self.idx.uuid.hyphenated().to_string());
fs::create_dir(config.clone())?;
if ! self.config.resolvers.is_empty() {
if !self.config.resolvers.is_empty() {
let mut resolvers = config.clone();
resolvers.push("resolvers");
debug!("preparing resolver file";
......@@ -180,7 +192,9 @@ impl<'a> Jail<'a> {
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();
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