forked from brl/citadel
more properly coordinate the launch of desktopd
This commit is contained in:
parent
5222830626
commit
7bd693f9dc
@ -14,6 +14,8 @@ lazy_static!{
|
||||
static ref APPIMG_RUN_PATH: PathBuf = PathBuf::from("/run/appimg");
|
||||
}
|
||||
|
||||
const DESKTOPD_SERVICE: &str = "citadel-desktopd.service";
|
||||
|
||||
|
||||
pub struct ImageManager {
|
||||
images: HashMap<String, AppImg>,
|
||||
@ -79,19 +81,25 @@ impl ImageManager {
|
||||
}
|
||||
|
||||
pub fn start_image(&mut self, name: &str) -> Result<()> {
|
||||
// if current is not set, set it to this instance
|
||||
let set_as_current = self.current.is_none();
|
||||
if set_as_current {
|
||||
self.set_current(name)?;
|
||||
}
|
||||
|
||||
match self.images.get(name) {
|
||||
Some(img) => {
|
||||
img.start()?;
|
||||
},
|
||||
None => {
|
||||
// XXX if set_as_current do something here to undo what set_current has done
|
||||
warn!("Cannot start '{}'. Image does not exist");
|
||||
return Ok(())
|
||||
},
|
||||
}
|
||||
// if current is not set, set it to this one
|
||||
if self.current.is_none() {
|
||||
self.set_current(name)?;
|
||||
systemd::systemctl_restart("desktopd");
|
||||
|
||||
if set_as_current {
|
||||
systemd::systemctl_restart(DESKTOPD_SERVICE);
|
||||
}
|
||||
Ok(())
|
||||
}
|
||||
@ -109,14 +117,14 @@ impl ImageManager {
|
||||
None => return Ok(()),
|
||||
};
|
||||
if current == name {
|
||||
systemd::systemctl_stop("desktopd");
|
||||
systemd::systemctl_stop(DESKTOPD_SERVICE);
|
||||
let path = APPIMG_RUN_PATH.join("current.appimg");
|
||||
if path.exists() {
|
||||
fs::remove_file(&path)?;
|
||||
}
|
||||
if let Some(img_name) = self.find_running_image_name() {
|
||||
self.set_current(&img_name)?;
|
||||
systemd::systemctl_start("desktopd");
|
||||
systemd::systemctl_start(DESKTOPD_SERVICE);
|
||||
}
|
||||
}
|
||||
Ok(())
|
||||
|
@ -100,7 +100,7 @@ Zone=clear
|
||||
pub const APPIMG_SERVICE_TEMPLATE: &str = r###"
|
||||
[Unit]
|
||||
Description=Application Image $APPIMG_NAME instance
|
||||
Wants=desktopd.service
|
||||
Wants=citadel-desktopd.service
|
||||
|
||||
[Service]
|
||||
Environment=SYSTEMD_NSPAWN_SHARE_NS_IPC=1
|
||||
|
@ -3,6 +3,3 @@ Description=Desktop Integration Manager
|
||||
|
||||
[Service]
|
||||
ExecStart=/usr/libexec/citadel-desktopd /usr/share/citadel/citadel-desktopd.conf
|
||||
|
||||
[Install]
|
||||
WantedBy=graphical.target
|
||||
|
@ -56,9 +56,7 @@ crate://crates.io/winapi/0.3.4 \
|
||||
crate://crates.io/wincolor/0.1.5 \
|
||||
"
|
||||
|
||||
inherit cargo systemd
|
||||
|
||||
SYSTEMD_SERVICE_${PN} = "citadel-desktopd.service"
|
||||
inherit cargo
|
||||
|
||||
do_install() {
|
||||
install -d ${D}${libexecdir}
|
||||
@ -70,6 +68,6 @@ do_install() {
|
||||
install -m 644 ${B}/conf/citadel-desktopd.service ${D}${systemd_system_unitdir}
|
||||
}
|
||||
|
||||
FILES_${PN} += "${datadir}/citadel"
|
||||
FILES_${PN} += "${datadir}/citadel ${systemd_system_unitdir}"
|
||||
|
||||
require citadel-tools.inc
|
||||
|
Loading…
Reference in New Issue
Block a user