Commit a2d26de6 authored by Heinz N. Gies's avatar Heinz N. Gies

Add halted step

parent f0509399
Pipeline #12374748 passed with stage
in 4 minutes and 2 seconds
...@@ -32,7 +32,12 @@ args=["{brand_root}", "{jail_uuid}", "{hostname}"] ...@@ -32,7 +32,12 @@ args=["{brand_root}", "{jail_uuid}", "{hostname}"]
# jail is then shut downb # jail is then shut downb
[halt] [halt]
cmd="{brand_root}/halt" cmd="{brand_root}/halt"
args=["{brand_root}", "{jail_root}", "{inner_id}"] args=["{inner_id}"]
## called after the outer jail has been stopped
[halted]
cmd="{brand_root}/halted"
args=["{brand_root}", "{jail_root}"]
[login] [login]
cmd="/usr/sbin/jexec" cmd="/usr/sbin/jexec"
......
#!/bin/sh #!/bin/sh
# include shared utility functions # include shared utility functions
brand_root="$1"
jail_root="$2"
inner_id="$3" inner_id="$3"
. ${brand_root}/../shared/utils.sh
validate_root "${jail_root}"
# cleanly shut down the inner jail (should this be run inside the outer jail?) # cleanly shut down the inner jail (should this be run inside the outer jail?)
if [ ! -z "${inner_id}" ] if [ ! -z "${inner_id}" ]
then then
jexec ${inner_id} /bin/sh /etc/rc.shutdown jexec ${inner_id} /bin/sh /etc/rc.shutdown
fi fi
# outer jail
umount ${jail_root}/root/dev
# inner jail
umount ${jail_root}/root/jail/dev
#!/bin/sh
# include shared utility functions
brand_root="$1"
jail_root="$2"
. ${brand_root}/../shared/utils.sh
validate_root "${jail_root}"
# outer jail
umount ${jail_root}/root/dev
# inner jail
umount ${jail_root}/root/jail/dev
...@@ -34,6 +34,11 @@ args=["{jail_uuid}", "{hostname}"] ...@@ -34,6 +34,11 @@ args=["{jail_uuid}", "{hostname}"]
cmd="{brand_root}/halt" cmd="{brand_root}/halt"
args=["{jail_root}", "{inner_id}"] args=["{jail_root}", "{inner_id}"]
## called after the outer jail has been stopped
[halted]
cmd="{brand_root}/halted"
args=["{brand_root}", "{jail_root}"]
[login] [login]
cmd="/usr/sbin/jexec" cmd="/usr/sbin/jexec"
args=["{jail_id}", "/bin/sh"] args=["{jail_id}", "/bin/sh"]
\ No newline at end of file
#!/bin/sh
# include shared utility functions
brand_root="$1"
jail_root="$2"
. ${brand_root}/../shared/utils.sh
validate_root "${jail_root}"
# outer jail
umount ${jail_root}/root/dev
# inner jail
umount ${jail_root}/root/jail/dev
...@@ -108,6 +108,7 @@ pub struct Brand { ...@@ -108,6 +108,7 @@ pub struct Brand {
pub init: Step, pub init: Step,
pub boot: Step, pub boot: Step,
pub halt: Step, pub halt: Step,
pub halted: Step,
pub login: Step, pub login: Step,
} }
......
...@@ -33,7 +33,6 @@ static JAIL: &'static str = "jail"; ...@@ -33,7 +33,6 @@ static JAIL: &'static str = "jail";
static RCTL: &'static str = "echo"; static RCTL: &'static str = "echo";
#[cfg(not(target_os = "freebsd"))] #[cfg(not(target_os = "freebsd"))]
static JAIL: &'static str = "echo"; static JAIL: &'static str = "echo";
#[cfg(target_os = "freebsd")] #[cfg(target_os = "freebsd")]
static IFCONFIG: &'static str = "/sbin/ifconfig"; static IFCONFIG: &'static str = "/sbin/ifconfig";
#[cfg(not(target_os = "freebsd"))] #[cfg(not(target_os = "freebsd"))]
...@@ -63,10 +62,6 @@ impl<'a> Jail<'a> { ...@@ -63,10 +62,6 @@ impl<'a> Jail<'a> {
let brand = self.brand(config)?; let brand = self.brand(config)?;
brand.init.output(self, config).expect("brand init failed"); brand.init.output(self, config).expect("brand init failed");
// self.mount_devfs()?;
// if self.config.brand == "lx-jail" {
// self.mount_lxfs()?;
// }
let CreateArgs { args, ifs } = self.create_args(config)?; let CreateArgs { args, ifs } = self.create_args(config)?;
debug!("Start jail"; "vm" => self.idx.uuid.hyphenated().to_string(), "args" => args.clone().join(" ")); debug!("Start jail"; "vm" => self.idx.uuid.hyphenated().to_string(), "args" => args.clone().join(" "));
...@@ -109,6 +104,8 @@ impl<'a> Jail<'a> { ...@@ -109,6 +104,8 @@ 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");;
let _ = self.remove_rctl(); let _ = self.remove_rctl();
match self.outer { match self.outer {
Some(outer) => { Some(outer) => {
...@@ -224,8 +221,6 @@ impl<'a> Jail<'a> { ...@@ -224,8 +221,6 @@ impl<'a> Jail<'a> {
exec_start.push_str("/sbin/ifconfig lo0 127.0.0.1 up; "); exec_start.push_str("/sbin/ifconfig lo0 127.0.0.1 up; ");
}; };
brand.init.output(self, config).expect("brand init failed");
// inner jail configuration // inner jail configuration
exec_start.push_str(brand.boot.to_string(self, config).as_str()); exec_start.push_str(brand.boot.to_string(self, config).as_str());
args.push(exec_start); args.push(exec_start);
......
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