From b30253ecb183f8419cffef4ac28dbba114d8815c Mon Sep 17 00:00:00 2001 From: Thierry Parmentelat Date: Thu, 12 Mar 2015 21:23:47 +0100 Subject: [PATCH] minor tweaks, and revert on forcing refresh_slice_vinit, this is not the problem --- initscript.py | 12 ++++++------ sliver-systemd/vinit.service | 5 +++-- sliver_lxc.py | 2 +- 3 files changed, 10 insertions(+), 9 deletions(-) diff --git a/initscript.py b/initscript.py index 0a3b17b..adeaa71 100644 --- a/initscript.py +++ b/initscript.py @@ -39,8 +39,8 @@ class Initscript: suitable for init-based VMs """ vinit_source = "/usr/share/NodeManager/sliver-initscripts/vinit" - vinit_script = "/vservers/%s/etc/rc.d/init.d/vinit"%self.name - enable_link = "/vservers/%s/etc/rc.d/rc3.d/S99vinit"%self.name + vinit_script = "/vservers/%s/etc/rc.d/init.d/vinit" % self.name + enable_link = "/vservers/%s/etc/rc.d/rc3.d/S99vinit" % self.name enable_target = "../init.d/vinit" # install in sliver code = file(vinit_source).read() @@ -60,8 +60,8 @@ class Initscript: suitable for systemd-based VMs """ vinit_source = "/usr/share/NodeManager/sliver-systemd/vinit.service" - vinit_unit_file = "/vservers/%s/usr/lib/systemd/system/vinit.service"%self.name - enable_link = "/vservers/%s/etc/systemd/system/multi-user.target.wants/vinit.service"%self.name + vinit_unit_file = "/vservers/%s/usr/lib/systemd/system/vinit.service" % self.name + enable_link = "/vservers/%s/etc/systemd/system/multi-user.target.wants/vinit.service" % self.name enable_target = "/usr/lib/systemd/system/vinit.service" # install in sliver code = file(vinit_source).read() @@ -77,11 +77,11 @@ class Initscript: # install or remove the slice inistscript, as instructed by the initscript tag - def refresh_slice_vinit(self, force=False): + def refresh_slice_vinit(self): logger.log("initscript.refresh_slice_vinit {}".format(self.name)) code = self.initscript sliver_initscript="/vservers/%s/etc/rc.d/init.d/vinit.slice" % self.name - if tools.replace_file_with_string(sliver_initscript, code, remove_if_empty=True, chmod=0755) or force: + if tools.replace_file_with_string(sliver_initscript, code, remove_if_empty=True, chmod=0755): if code: logger.log("Initscript: %s: Installed new initscript in %s" % (self.name, sliver_initscript)) if self.is_running(): diff --git a/sliver-systemd/vinit.service b/sliver-systemd/vinit.service index 744897e..c6adc2c 100644 --- a/sliver-systemd/vinit.service +++ b/sliver-systemd/vinit.service @@ -1,6 +1,7 @@ [Unit] Description=User-defined initscript launcher After=network-online.target +Requires=network-online.target # inspired from # http://www.freedesktop.org/software/systemd/man/systemd.service.html @@ -8,8 +9,8 @@ After=network-online.target [Service] Type=oneshot RemainAfterExit=yes -ExecStart=/bin/bash -c ' /etc/rc.d/init.d/vinit.slice start $(cat /etc/slicename) 2>&1 >> /var/log/vinit & ' -ExecStop=/bin/bash -c ' /etc/rc.d/init.d/vinit.slice stop $(cat /etc/slicename) 2>&1 >> /var/log/vinit & ' +ExecStart=/bin/bash -c ' [ -f /etc/rc.d/init.d/vinit.slice ] && /etc/rc.d/init.d/vinit.slice start $(cat /etc/slicename) 2>&1 >> /var/log/vinit & ' +ExecStop= /bin/bash -c ' [ -f /etc/rc.d/init.d/vinit.slice ] && /etc/rc.d/init.d/vinit.slice stop $(cat /etc/slicename) 2>&1 >> /var/log/vinit & ' [Install] WantedBy=multi-user.target diff --git a/sliver_lxc.py b/sliver_lxc.py index 518f291..babac35 100644 --- a/sliver_lxc.py +++ b/sliver_lxc.py @@ -62,7 +62,7 @@ class Sliver_LXC(Sliver_Libvirt, Initscript): Account.mount_ssh_dir(self.name) Sliver_Libvirt.start(self, delay) # if a change has occured in the slice initscript, reflect this in /etc/init.d/vinit.slice - self.refresh_slice_vinit(force=True) + self.refresh_slice_vinit() def rerun_slice_vinit(self): """This is called at startup, and whenever the initscript code changes""" -- 2.43.0