def do_apply(self): if not self.netconf.locked("dhcp") or self.netconf.ip4_changed: if self.netconf.ip4_changed: self.do_remove() config_file, config_path = mkstemp(prefix="udhcpd-") os.write(config_file, self._generate_config().encode('UTF-8')) os.close(config_file) dprint("Running udhcpd with config file %s" % config_path) cmd = [have("udhcpd"), "-S", config_path] p = Popen(cmd) p.wait() # udhcpd takes time to create pid file sleep(0.1) pid = read_pid_file("/var/run/udhcpd.pan1.pid") if p.pid and is_running("udhcpd", pid): dprint("udhcpd started correctly") self.pid = pid dprint("pid", self.pid) self.netconf.lock("dhcp") else: raise Exception("udhcpd failed to start. Check the system log for errors") os.remove(config_path)
def do_apply(self): if not self.netconf.locked("dhcp") or self.netconf.ip4_changed: if self.netconf.ip4_changed: self.do_remove() config_file, config_path = mkstemp(prefix="udhcpd-") os.write(config_file, self._generate_config().encode('UTF-8')) os.close(config_file) logging.info("Running udhcpd with config file %s" % config_path) cmd = [have("udhcpd"), "-S", config_path] p = Popen(cmd, stderr=PIPE) error = p.communicate()[1] # udhcpd takes time to create pid file sleep(0.1) pid = read_pid_file("/var/run/udhcpd.pan1.pid") if p.pid and is_running("udhcpd", pid): logging.info("udhcpd started correctly") self.pid = pid logging.info("pid %s" % self.pid) self.netconf.lock("dhcp") else: error_msg = error.decode("UTF-8").strip() logging.info(error_msg) raise NetworkSetupError("udhcpd failed to start: %s" % error_msg) os.remove(config_path)
def on_devices(self, menu_item): lockfile = get_lockfile('blueman-manager') pid = get_pid(lockfile) if lockfile and pid and is_running('blueman-manager', pid): os.kill(pid, signal.SIGTERM) else: launch("blueman-manager", None, False, "blueman", _("Device Manager"))
def do_apply(self): if not self.netconf.locked("dhcp") or self.netconf.ip4_changed: if self.netconf.ip4_changed: self.do_remove() config_file, config_path = mkstemp(prefix="udhcpd-") os.write(config_file, self._generate_config().encode('UTF-8')) os.close(config_file) logging.info("Running udhcpd with config file %s" % config_path) cmd = [have("udhcpd"), "-S", config_path] p = Popen(cmd) p.wait() # udhcpd takes time to create pid file sleep(0.1) pid = read_pid_file("/var/run/udhcpd.pan1.pid") if p.pid and is_running("udhcpd", pid): logging.info("udhcpd started correctly") self.pid = pid logging.info("pid %s" % self.pid) self.netconf.lock("dhcp") else: raise Exception( "udhcpd failed to start. Check the system log for errors") os.remove(config_path)
def do_remove(self): dhcp_config, existing_subnet = self._read_dhcp_config() f = open(DHCP_CONFIG_FILE, "w") f.write(dhcp_config) f.close() if self.netconf.locked("dhcp"): if not self.pid: pid = read_pid_file("/var/run/dhcpd.pan1.pid") else: pid = self.pid if pid and (is_running("dhcpd3", pid) or is_running("dhcpd", pid)): os.kill(pid, signal.SIGTERM) self.netconf.unlock("dhcp") else: dprint("Stale dhcp lockfile found") self.netconf.unlock("dhcp")
def do_remove(self): dhcp_config, existing_subnet = self._read_dhcp_config() f = open(DHCP_CONFIG_FILE, "w") f.write(dhcp_config) f.close() if self.netconf.locked("dhcp"): if not self.pid: pid = read_pid_file("/var/run/dhcpd.pan1.pid") else: pid = self.pid if pid and (is_running("dhcpd3", pid) or is_running("dhcpd", pid)): os.kill(pid, signal.SIGTERM) self.netconf.unlock("dhcp") else: logging.info("Stale dhcp lockfile found") self.netconf.unlock("dhcp")
def do_remove(self): if self.netconf.locked("dhcp"): if not self.pid: pid = read_pid_file("/var/run/dnsmasq.pan1.pid") else: pid = self.pid if pid and is_running("dnsmasq", pid): os.kill(pid, signal.SIGTERM) self.netconf.unlock("dhcp") else: dprint("Stale dhcp lockfile found") self.netconf.unlock("dhcp")
def do_remove(self): if self.netconf.locked("dhcp"): if not self.pid: pid = read_pid_file("/var/run/udhcpd.pan1.pid") else: pid = self.pid if pid and is_running("udhcpd", pid): os.kill(pid, signal.SIGTERM) self.netconf.unlock("dhcp") else: logging.info("Stale dhcp lockfile found") self.netconf.unlock("dhcp")
def do_remove(self): if self.netconf.locked("dhcp"): if not self.pid: pid = read_pid_file("/var/run/dnsmasq.pan1.pid") else: pid = self.pid if pid and is_running("dnsmasq", pid): os.kill(pid, signal.SIGTERM) self.netconf.unlock("dhcp") else: logging.info("Stale dhcp lockfile found") self.netconf.unlock("dhcp")
def do_remove(self): if self.netconf.locked("dhcp"): if not self.pid: pid = read_pid_file("/var/run/dnsmasq.pan1.pid") else: pid = self.pid running = is_running("dnsmasq", pid) if pid else False if running: os.kill(pid, signal.SIGTERM) self.netconf.unlock("dhcp") else: dprint("Stale dhcp lockfile found") self.netconf.unlock("dhcp")
def do_remove(self): if self.netconf.locked("dhcp"): if not self.pid: pid = read_pid_file("/var/run/dnsmasq.pan1.pid") else: pid = self.pid running = is_running("dnsmasq", pid) if pid else False if running: os.kill(pid, signal.SIGTERM) self.netconf.unlock("dhcp") else: logging.info("Stale dhcp lockfile found") self.netconf.unlock("dhcp")
def do_remove(self): dhcp_config, existing_subnet = self._read_dhcp_config() f = open(DHCP_CONFIG_FILE, "w") f.write(dhcp_config) f.close() if self.netconf.locked("dhcp"): if not self.pid: pid = read_pid_file("/var/run/dhcpd-server/dhcp.pan1.pid") else: pid = self.pid running = is_running("dnsmasq", pid) if pid else False if running: os.kill(pid, signal.SIGTERM) self.netconf.unlock("dhcp") else: dprint("Stale dhcp lockfile found") self.netconf.unlock("dhcp")
def do_remove(self): dhcp_config, existing_subnet = self._read_dhcp_config() f = open(DHCP_CONFIG_FILE, "w") f.write(dhcp_config) f.close() if self.netconf.locked("dhcp"): if not self.pid: pid = read_pid_file("/var/run/dhcpd-server/dhcp.pan1.pid") else: pid = self.pid running = is_running("dnsmasq", pid) if pid else False if running: os.kill(pid, signal.SIGTERM) self.netconf.unlock("dhcp") else: logging.info("Stale dhcp lockfile found") self.netconf.unlock("dhcp")