Beispiel #1
0
    def updateService(self, result=None, retval=None, extra_args=None):
        import process
        p = process.ProcessList()
        sabnzbd_process = str(p.named('SABnzbd.py')).strip('[]')
        self['labrun'].hide()
        self['labstop'].hide()
        self['labactive'].setText(_("Disabled"))
        self.my_sabnzbd_active = False
        self.my_sabnzbd_run = False
        if fileExists('/etc/rc2.d/S20sabnzbd'):
            self['labactive'].setText(_("Enabled"))
            self['labactive'].show()
            self.my_sabnzbd_active = True
        if sabnzbd_process:
            self.my_sabnzbd_run = True
        if self.my_sabnzbd_run:
            self['labstop'].hide()
            self['labactive'].show()
            self['labrun'].show()
            self['key_green'].setText(_("Stop"))
            status_summary = self['lab2'].text + ' ' + self['labrun'].text
        else:
            self['labrun'].hide()
            self['labstop'].show()
            self['labactive'].show()
            self['key_green'].setText(_("Start"))
            status_summary = self['lab2'].text + ' ' + self['labstop'].text
        title = _("SABnzbd Setup")
        autostartstatus_summary = self['lab1'].text + ' ' + self[
            'labactive'].text

        for cb in self.onChangedEntry:
            cb(title, status_summary, autostartstatus_summary)
Beispiel #2
0
    def updateService(self):
        import process
        p = process.ProcessList()
        nfs_process = str(p.named('nfsd')).strip('[]')
        self['labrun'].hide()
        self['labstop'].hide()
        self['labactive'].setText(_("Disabled"))
        self.my_nfs_active = False
        self.my_nfs_run = False
        if fileExists('/etc/rc2.d/S20nfsserver'):
            self['labactive'].setText(_("Enabled"))
            self['labactive'].show()
            self.my_nfs_active = True
        if nfs_process:
            self.my_nfs_run = True
        if self.my_nfs_run:
            self['labstop'].hide()
            self['labrun'].show()
            self['key_green'].setText(_("Stop"))
            status_summary = self['lab2'].text + ' ' + self['labrun'].text
        else:
            self['labstop'].show()
            self['labrun'].hide()
            self['key_green'].setText(_("Start"))
            status_summary = self['lab2'].text + ' ' + self['labstop'].text
        title = _("NFS Setup")
        autostartstatus_summary = self['lab1'].text + ' ' + self[
            'labactive'].text

        for cb in self.onChangedEntry:
            cb(title, status_summary, autostartstatus_summary)
Beispiel #3
0
 def updateService(self):
     import process
     p = process.ProcessList()
     pcscd_process = str(p.named('pcscd')).strip('[]')
     self['labrun'].hide()
     self['labstop'].hide()
     self['labactive'].setText(_('Disabled'))
     self.my_Pcscd_active = False
     self.my_pcscd_run = False
     if fileExists('/etc/rc2.d/S20pcscd'):
         self['labactive'].setText(_('Enabled'))
         self['labactive'].show()
         self.my_Pcscd_active = True
     if pcscd_process:
         self.my_pcscd_run = True
     if self.my_pcscd_run:
         self['labstop'].hide()
         self['labrun'].show()
         self['key_green'].setText(_('Stop'))
         status_summary = self['lab2'].text + ' ' + self['labrun'].text
     else:
         self['labstop'].show()
         self['labrun'].hide()
         self['key_green'].setText(_('Start'))
         status_summary = self['lab2'].text + ' ' + self['labstop'].text
     title = _('Pcscd USB cardreader setup')
     autostartstatus_summary = self['lab1'].text + ' ' + self[
         'labactive'].text
     for cb in self.onChangedEntry:
         cb(title, status_summary, autostartstatus_summary)
	def getBoolean(self):
		p = process.ProcessList()
		name = ""
		if self.type == 'samba':
			name = str(p.named('smbd')).strip('[]')
		elif self.type == 'vpn':
			name = str(p.named('openvpn')).strip('[]')
			country, ip = get_myipdata()
			if name and country and ip:
				ip = ip.split('.')[0] + '.'
				if os.path.exists(novpnfile):
					novpn = open(novpnfile,'r').readlines()
					for line in novpn:
						if not line.startswith('#') and (country in line or line.startswith(ip)):
							name = ""
							break
				if os.path.exists(isvpnfile):
					isvpn = open(isvpnfile,'r').readlines()
					for line in isvpn:
						if not line.startswith('#') and (country in line or line.startswith(ip)):
							name = "ok"
							break
		if name:
			return True
		return False
Beispiel #5
0
	def updateVpn(self):

		self["labrun"].hide()
		self["labstop"].hide()
		self["labactive"].setText(_("Inactive"))
		self["key_yellow"].setText(_("Set Active"))
		self.my_vpn_active = False
		self.my_vpn_run = False

		if fileExists("/etc/rc3.d/S20openvpn"):
			self["labactive"].setText(_("Active/Autostart enabled"))
			self["key_yellow"].setText(_("Deactivate"))
			self.my_vpn_active = True

		p = process.ProcessList()
		openvpn_process = str(p.named('openvpn')).strip('[]')
		if openvpn_process:
			self.my_vpn_run = True

		if self.my_vpn_run == True:
			self["labstop"].hide()
			self["labrun"].show()
			self["key_green"].setText(_("Restart"))
		else:
			self["labstop"].show()
			self["labrun"].hide()
			self["key_green"].setText(_("Start"))
Beispiel #6
0
	def updateService(self):
		import process
		p = process.ProcessList()
		cihelper_process = str(p.named('cihelper')).strip('[]')
		self['labrun'].hide()
		self['labstop'].hide()
		self['labactive'].hide()
		self['labdisabled'].hide()
		self.my_cihelper_active = False
		self.my_cihelper_run = False
		if fileExists('/etc/rcS.d/S50cihelper.sh') or fileExists('/etc/rc4.d/S50cihelper.sh'):
			self['labdisabled'].hide()
			self['labactive'].show()
			self.my_cihelper_active = True
			autostartstatus_summary = self['autostart'].text + ' ' + self['labactive'].text
		else:
			self['labactive'].hide()
			self['labdisabled'].show()
			autostartstatus_summary = self['autostart'].text + ' ' + self['labdisabled'].text
		if cihelper_process:
			self.my_cihelper_run = True
		if self.my_cihelper_run:
			self['labstop'].hide()
			self['labrun'].show()
			self['key_green'].setText(_("Stop"))
			status_summary= self['status'].text + ' ' + self['labstop'].text
		else:
			self['labstop'].show()
			self['labrun'].hide()
			self['key_green'].setText(_("Start"))
			status_summary= self['status'].text + ' ' + self['labstop'].text

		if fileExists('/etc/cihelper.conf'):
			f = open('/etc/cihelper.conf', 'r')
			for line in f.readlines():
				line = line.strip()
				if line.startswith('ENABLE_CI0='):
					if line[11:] == 'no':
						self['ci0active'].hide()
						self['ci0inactive'].show()
					else:
						self['ci0active'].show()
						self['ci0inactive'].hide()
				elif fileExists('/dev/ci1'):
					if line.startswith('ENABLE_CI1='):
						if line[11:] == 'no':
							self['ci1active'].hide()
							self['ci1inactive'].show()
						else:
							self['ci1active'].show()
							self['ci1inactive'].hide()
				else:
					self['ci1active'].hide()
					self['ci1inactive'].hide()
					self['ci1'].hide()
				f.close()
		title = _("CIHelper Setup")

		for cb in self.onChangedEntry:
			cb(title, status_summary, autostartstatus_summary)
Beispiel #7
0
 def updateList(self):
     import process
     p = process.ProcessList()
     mediatomb_process = str(p.named('mediatomb')).strip('[]')
     self['labrun'].hide()
     self['labstop'].hide()
     self['labactive'].hide()
     self['labdisabled'].hide()
     self.my_mediatomb_active = False
     self.my_mediatomb_run = False
     if path.exists('/etc/rc3.d/S90mediatomb'):
         self['labdisabled'].hide()
         self['labactive'].show()
         self.my_mediatomb_active = True
     else:
         self['labactive'].hide()
         self['labdisabled'].show()
     if mediatomb_process:
         self.my_mediatomb_run = True
     if self.my_mediatomb_run == True:
         self['labstop'].hide()
         self['labrun'].show()
         self['key_yellow'].setText(_('Stop'))
     else:
         self['labstop'].show()
         self['labrun'].hide()
         self['key_yellow'].setText(_('Start'))
     self.list = []
Beispiel #8
0
    def updateIna(self):
        self["lactive"].hide()
        self["linactive"].hide()
        self["sactive"].hide()
        self["sinactive"].hide()
        self["labrun"].hide()
        self["labstop"].hide()

        self.my_nabina_state = False

        if fileExists("/etc/rc3.d/S20inadyn-mt"):
            self["lactive"].show()
            self.my_nabina_state = True
        else:
            self["linactive"].show()

        if fileExists("/etc/inadyn.conf"):
            f = open("/etc/inadyn.conf", 'r')
            for line in f.readlines():
                line = line.strip()
                if line.startswith('username '):
                    line = line[9:]
                    self["labuser"].setText(line)
                elif line.startswith('password '):
                    line = line[9:]
                    self["labpass"].setText(line)
                elif line.startswith('alias '):
                    line = line[6:]
                    self["labalias"].setText(line)
                elif line.startswith('update_period_sec '):
                    line = int(line[18:])
                    line = (line / 60)
                    self["labtime"].setText(str(line))
                elif line.startswith('dyndns_system ') or line.startswith(
                        '#dyndns_system '):
                    if line.startswith('#'):
                        line = line[15:]
                        self["sinactive"].show()
                    else:
                        line = line[14:]
                        self["sactive"].show()
                        self["labsys"].setText(line)

            f.close()

        p = process.ProcessList()
        check = False
        inadyn_process = str(p.named('inadyn-mt')).strip('[]')
        if inadyn_process:
            check = True

        if check == True:
            self["labstop"].hide()
            self["labrun"].show()
            self["key_red"].setText(_("Restart"))
        else:
            self["labstop"].show()
            self["labrun"].hide()
            self["key_red"].setText(_("Start"))
Beispiel #9
0
    def updateService(self):
        import process
        p = process.ProcessList()
        samba_process = str(p.named('smbd')).strip('[]')
        self['labrun'].hide()
        self['labstop'].hide()
        self['labactive'].setText(_("Disabled"))
        self.my_Samba_active = False
        self.my_Samba_run = False
        if fileExists('/etc/rc2.d/S20samba'):
            self['labactive'].setText(_("Enabled"))
            self['labactive'].show()
            self.my_Samba_active = True

        if access('/etc/network/if-up.d/01samba-start', X_OK):
            self['labactive'].setText(_("Enabled"))
            self['labactive'].show()
            self.my_Samba_active = True

        if samba_process:
            self.my_Samba_run = True
        if self.my_Samba_run:
            self['labstop'].hide()
            self['labactive'].show()
            self['labrun'].show()
            self['key_green'].setText(_("Stop"))
            status_summary = self['lab2'].text + ' ' + self['labrun'].text
        else:
            self['labrun'].hide()
            self['labstop'].show()
            self['labactive'].show()
            self['key_green'].setText(_("Start"))
            status_summary = self['lab2'].text + ' ' + self['labstop'].text
        title = _("Samba Setup")
        autostartstatus_summary = self['lab1'].text + ' ' + self[
            'labactive'].text

        for cb in self.onChangedEntry:
            cb(title, status_summary, autostartstatus_summary)
Beispiel #10
0
    def updateList(self, result=None, retval=None, extra_args=None):
        import process
        p = process.ProcessList()
        crond_process = str(p.named('crond')).strip('[]')
        self['labrun'].hide()
        self['labstop'].hide()
        self['labactive'].hide()
        self['labdisabled'].hide()
        self.my_crond_active = False
        self.my_crond_run = False
        if path.exists('/etc/rc3.d/S90crond'):
            self['labdisabled'].hide()
            self['labactive'].show()
            self.my_crond_active = True
        else:
            self['labactive'].hide()
            self['labdisabled'].show()
        if crond_process:
            self.my_crond_run = True
        if self.my_crond_run:
            self['labstop'].hide()
            self['labrun'].show()
            self['key_yellow'].setText(_("Stop"))
            self.summary_running = _("Running")
        else:
            self['labstop'].show()
            self['labrun'].hide()
            self['key_yellow'].setText(_("Start"))
            self.summary_running = _("Stopped")

        self.list = []
        if path.exists('/etc/cron/crontabs/root'):
            f = open('/etc/cron/crontabs/root', 'r')
            for line in f.readlines():
                parts = line.strip().split()
                if parts:
                    if parts[1] == '*':
                        try:
                            line2 = 'H: 00:' + parts[0].zfill(
                                2) + '\t' + parts[5] + parts[6] + parts[
                                    7] + parts[8] + parts[9]
                        except:
                            try:
                                line2 = 'H: 00:' + parts[0].zfill(
                                    2) + '\t' + parts[5] + parts[6] + parts[
                                        7] + parts[8]
                            except:
                                try:
                                    line2 = 'H: 00:' + parts[0].zfill(
                                        2
                                    ) + '\t' + parts[5] + parts[6] + parts[7]
                                except:
                                    try:
                                        line2 = 'H: 00:' + parts[0].zfill(
                                            2) + '\t' + parts[5] + parts[6]
                                    except:
                                        line2 = 'H: 00:' + parts[0].zfill(
                                            2) + '\t' + parts[5]
                        res = (line2, line)
                        self.list.append(res)
                    elif parts[2] == '*' and parts[4] == '*':
                        try:
                            line2 = 'D: ' + parts[1].zfill(2) + ':' + parts[
                                0].zfill(2) + '\t' + parts[5] + parts[
                                    6] + parts[7] + parts[8] + parts[9]
                        except:
                            try:
                                line2 = 'D: ' + parts[1].zfill(
                                    2) + ':' + parts[0].zfill(
                                        2) + '\t' + parts[5] + parts[
                                            6] + parts[7] + parts[8]
                            except:
                                try:
                                    line2 = 'D: ' + parts[1].zfill(
                                        2) + ':' + parts[0].zfill(
                                            2) + '\t' + parts[5] + parts[
                                                6] + parts[7]
                                except:
                                    try:
                                        line2 = 'D: ' + parts[1].zfill(
                                            2) + ':' + parts[0].zfill(
                                                2) + '\t' + parts[5] + parts[6]
                                    except:
                                        line2 = 'D: ' + parts[1].zfill(
                                            2) + ':' + parts[0].zfill(
                                                2) + '\t' + parts[5]
                        res = (line2, line)
                        self.list.append(res)
                    elif parts[3] == '*':
                        if parts[4] == "*":
                            try:
                                line2 = 'M:  Day ' + parts[2] + '  ' + parts[
                                    1].zfill(2) + ':' + parts[0].zfill(
                                        2) + '\t' + parts[5] + parts[
                                            6] + parts[7] + parts[8] + parts[9]
                            except:
                                try:
                                    line2 = 'M:  Day ' + parts[
                                        2] + '  ' + parts[1].zfill(
                                            2) + ':' + parts[0].zfill(
                                                2) + '\t' + parts[5] + parts[
                                                    6] + parts[7] + parts[8]
                                except:
                                    try:
                                        line2 = 'M:  Day ' + parts[
                                            2] + '  ' + parts[1].zfill(
                                                2) + ':' + parts[0].zfill(
                                                    2
                                                ) + '\t' + parts[5] + parts[
                                                    6] + parts[7]
                                    except:
                                        try:
                                            line2 = 'M:  Day ' + parts[
                                                2] + '  ' + parts[1].zfill(
                                                    2) + ':' + parts[0].zfill(
                                                        2) + '\t' + parts[
                                                            5] + parts[6]
                                        except:
                                            line2 = 'M:  Day ' + parts[
                                                2] + '  ' + parts[1].zfill(
                                                    2) + ':' + parts[0].zfill(
                                                        2) + '\t' + parts[5]
                        header = 'W:  '
                        day = ""
                        if str(parts[4]).find('0') >= 0:
                            day = 'Sun '
                        if str(parts[4]).find('1') >= 0:
                            day += 'Mon '
                        if str(parts[4]).find('2') >= 0:
                            day += 'Tues '
                        if str(parts[4]).find('3') >= 0:
                            day += 'Wed '
                        if str(parts[4]).find('4') >= 0:
                            day += 'Thurs '
                        if str(parts[4]).find('5') >= 0:
                            day += 'Fri '
                        if str(parts[4]).find('6') >= 0:
                            day += 'Sat '

                        if day:
                            try:
                                line2 = header + day + parts[1].zfill(
                                    2) + ':' + parts[0].zfill(
                                        2) + '\t' + parts[5] + parts[
                                            6] + parts[7] + parts[8] + parts[9]
                            except:
                                try:
                                    line2 = header + day + parts[1].zfill(
                                        2) + ':' + parts[0].zfill(
                                            2) + '\t' + parts[5] + parts[
                                                6] + parts[7] + parts[8]
                                except:
                                    try:
                                        line2 = header + day + parts[1].zfill(
                                            2) + ':' + parts[0].zfill(
                                                2) + '\t' + parts[5] + parts[
                                                    6] + parts[7]
                                    except:
                                        try:
                                            line2 = header + day + parts[
                                                1].zfill(2) + ':' + parts[
                                                    0].zfill(2) + '\t' + parts[
                                                        5] + parts[6]
                                        except:
                                            line2 = header + day + parts[
                                                1].zfill(
                                                    2) + ':' + parts[0].zfill(
                                                        2) + '\t' + parts[5]
                        res = (line2, line)
                        self.list.append(res)
            f.close()
        self['list'].list = self.list
        self["actions"].setEnabled(True)
Beispiel #11
0
	def JobStart(self):
		self.autostartcams = config.softcammanager.softcams_autostart.value
		self.Console = Console()
		if path.exists("/tmp/cam.check.log"):
			if path.getsize("/tmp/cam.check.log") > 40000:
				fh = open("/tmp/cam.check.log", "rb+")
				fh.seek(-40000, 2)
				data = fh.read()
				fh.seek(0)  # rewind
				fh.write(data)
				fh.truncate()
				fh.close()

		if path.exists("/etc/CCcam.cfg"):
			f = open("/etc/CCcam.cfg", "r")
			logwarn = ""
			for line in f.readlines():
				if line.find("LOG WARNINGS") != -1:
					parts = line.strip().split()
					logwarn = parts[2]
					if logwarn.find(":") >= 0:
						logwarn = logwarn.replace(":", "")
					if logwarn == "":
						logwarn = parts[3]
				else:
					logwarn = ""
			if path.exists(logwarn):
				if path.getsize(logwarn) > 40000:
					fh = open(logwarn, "rb+")
					fh.seek(-40000, 2)
					data = fh.read()
					fh.seek(0)  # rewind
					fh.write(data)
					fh.truncate()
					fh.close()
			f.close()

		for softcamcheck in self.autostartcams:
			softcamcheck = softcamcheck.replace("/usr/softcams/", "")
			softcamcheck = softcamcheck.replace("\n", "")
			if softcamcheck.endswith(".sh"):
				if path.exists("/tmp/SoftcamsDisableCheck"):
					file = open("/tmp/SoftcamsDisableCheck")
					data = file.read()
					file.close()
				else:
					data = ""
				if data.find(softcamcheck) < 0:
					if path.exists("/tmp/SoftcamsScriptsRunning"):
						file = open("/tmp/SoftcamsScriptsRunning")
						data = file.read()
						file.close()
						if data.find(softcamcheck) < 0:
							fileout = open("/tmp/SoftcamsScriptsRunning", "a")
							line = softcamcheck + "\n"
							fileout.write(line)
							fileout.close()
							print("[SoftcamManager] Starting " + softcamcheck)
							self.Console.ePopen("/usr/softcams/" + softcamcheck + " start")
					else:
						fileout = open("/tmp/SoftcamsScriptsRunning", "w")
						line = softcamcheck + "\n"
						fileout.write(line)
						fileout.close()
						print("[SoftcamManager] Starting " + softcamcheck)
						self.Console.ePopen("/usr/softcams/" + softcamcheck + " start")
			else:
				if path.exists("/tmp/SoftcamsDisableCheck"):
					file = open("/tmp/SoftcamsDisableCheck")
					data = file.read()
					file.close()
				else:
					data = ""
				if data.find(softcamcheck) < 0:
					import process

					p = process.ProcessList()
					softcamcheck_process = str(p.named(softcamcheck)).strip("[]")
					if softcamcheck_process != "":
						if path.exists("/tmp/frozen"):
							remove("/tmp/frozen")
						if path.exists("/tmp/status.html"):
							remove("/tmp/status.html")
						if path.exists("/tmp/index.html"):
							remove("/tmp/index.html")
						print("[SoftcamManager] " + softcamcheck + " already running")
						output = open("/tmp/cam.check.log", "a")
						now = datetime.now()
						output.write(now.strftime("%Y-%m-%d %H:%M") + ": " + softcamcheck + " running OK\n")
						output.close()
						if softcamcheck.lower().startswith("oscam") or softcamcheck.lower().startswith("ncam"):
							if path.exists("/tmp/status.html"):
								remove("/tmp/status.html")
							port = ""
							if softcamcheck.lower().startswith("oscam"):
								if path.exists("/etc/tuxbox/config/oscam.conf"):
									camconf = "/etc/tuxbox/config/oscam.conf"
							elif softcamcheck.lower().startswith("ncam"):
								if path.exists("/etc/tuxbox/config/ncam.conf"):
									camconf = "/etc/tuxbox/config/ncam.conf"
							f = open(camconf, "r")
							for line in f.readlines():
								if line.find("httpport") != -1:
									port = re.sub("\D", "", line)
							f.close()
							print("[SoftcamManager] Checking if " + softcamcheck + " is frozen")
							if port == "":
								port = "16000"
							self.Console.ePopen("wget -T 1 http://127.0.0.1:" + port + "/status.html -O /tmp/status.html &> /tmp/frozen")
							sleep(2)
							f = open("/tmp/frozen")
							frozen = f.read()
							f.close()
							if frozen.find("Unauthorized") != -1 or frozen.find("Authorization Required") != -1 or frozen.find("Forbidden") != -1 or frozen.find("Connection refused") != -1 or frozen.find("100%") != -1 or path.exists("/tmp/status.html"):
								print("[SoftcamManager] " + softcamcheck + " is responding like it should")
								output = open("/tmp/cam.check.log", "a")
								now = datetime.now()
								output.write(now.strftime("%Y-%m-%d %H:%M") + ": " + softcamcheck + " is responding like it should\n")
								output.close()
							else:
								print("[SoftcamManager] " + softcamcheck + " is frozen, Restarting...")
								output = open("/tmp/cam.check.log", "a")
								now = datetime.now()
								output.write(now.strftime("%Y-%m-%d %H:%M") + ": " + softcamcheck + " is frozen, Restarting...\n")
								output.close()
								print("[SoftcamManager] Stopping " + softcamcheck)
								output = open("/tmp/cam.check.log", "a")
								now = datetime.now()
								output.write(now.strftime("%Y-%m-%d %H:%M") + ": AutoStopping: " + softcamcheck + "\n")
								output.close()
								self.Console.ePopen("killall -9 " + softcamcheck)
								sleep(1)
								if softcamcheck.lower().startswith("oscam"):
									self.Console.ePopen("ps.procps | grep softcams | grep -v grep | awk 'NR==1' | awk '{print $5}'| awk  -F'[/]' '{print $4}' > /tmp/oscamRuningCheck.tmp")
									sleep(2)
									file = open("/tmp/oscamRuningCheck.tmp")
								elif softcamcheck.lower().startswith("ncam"):
									self.Console.ePopen("ps.procps | grep softcams | grep -v grep | awk 'NR==1' | awk '{print $5}'| awk  -F'[/]' '{print $4}' > /tmp/ncamRuningCheck.tmp")
									sleep(2)
									file = open("/tmp/ncamRuningCheck.tmp")
								cccamcheck_process = file.read()
								file.close()
								cccamcheck_process = cccamcheck_process.replace("\n", "")
								if cccamcheck_process.lower().find("cccam") != -1:
									try:
										print("[SoftcamManager] Stopping ", cccamcheck_process)
										output = open("/tmp/cam.check.log", "a")
										now = datetime.now()
										output.write(now.strftime("%Y-%m-%d %H:%M") + ": AutoStopping: " + cccamcheck_process + "\n")
										output.close()
										self.Console.ePopen("killall -9 /usr/softcams/" + str(cccamcheck_process))
									except:
										pass
								print("[SoftcamManager] Starting " + softcamcheck)
								output = open("/tmp/cam.check.log", "a")
								now = datetime.now()
								output.write(now.strftime("%Y-%m-%d %H:%M") + ": AutoStarting: " + softcamcheck + "\n")
								output.close()
								self.Console.ePopen("ulimit -s 1024;/usr/softcams/" + softcamcheck + " -b")
								sleep(10)

						elif softcamcheck.lower().startswith("cccam"):
							if path.exists("/tmp/index.html"):
								remove("/tmp/index.html")
							allow = "no"
							port = ""
							f = open("/etc/CCcam.cfg", "r")
							for line in f.readlines():
								if line.find("ALLOW WEBINFO") != -1:
									if not line.startswith("#"):
										parts = line.replace("ALLOW WEBINFO", "")
										parts = parts.replace(":", "")
										parts = parts.replace(" ", "")
										parts = parts.strip().split()
										if parts[0].startswith("yes"):
											allow = parts[0]
								if line.find("WEBINFO LISTEN PORT") != -1:
									port = re.sub("\D", "", line)
							f.close()
							if allow.lower().find("yes") != -1:
								print("[SoftcamManager] Checking if " + softcamcheck + " is frozen")
								if port == "":
									port = "16001"
								self.Console.ePopen("wget -T 1 http://127.0.0.1:" + port + " -O /tmp/index.html &> /tmp/frozen")
								sleep(2)
								f = open("/tmp/frozen")
								frozen = f.read()
								f.close()
								if frozen.find("Unauthorized") != -1 or frozen.find("Authorization Required") != -1 or frozen.find("Forbidden") != -1 or frozen.find("Connection refused") != -1 or frozen.find("100%") != -1 or path.exists("/tmp/index.html"):
									print("[SoftcamManager] " + softcamcheck + " is responding like it should")
									output = open("/tmp/cam.check.log", "a")
									now = datetime.now()
									output.write(now.strftime("%Y-%m-%d %H:%M") + ": ' + softcamcheck + ' is responding like it should\n")
									output.close()
								else:
									print("[SoftcamManager] " + softcamcheck + " is frozen, Restarting...")
									output = open("/tmp/cam.check.log", "a")
									now = datetime.now()
									output.write(now.strftime("%Y-%m-%d %H:%M") + ": " + softcamcheck + " is frozen, Restarting...\n")
									output.close()
									print("[SoftcamManager] Stopping " + softcamcheck)
									self.Console.ePopen("killall -9 " + softcamcheck)
									sleep(1)
									print("[SoftcamManager] Starting " + softcamcheck)
									self.Console.ePopen("ulimit -s 1024;/usr/softcams/" + softcamcheck)
							elif allow.lower().find("no") != -1:
								print("[SoftcamManager] Telnet info not allowed, can not check if frozen")
								output = open("/tmp/cam.check.log", "a")
								now = datetime.now()
								output.write(now.strftime("%Y-%m-%d %H:%M") + ":  Webinfo info not allowed, can not check if frozen,\n\tplease enable 'ALLOW WEBINFO: YES'\n")
								output.close()
							else:
								print("[SoftcamManager] Webinfo info not setup, please enable 'ALLOW WEBINFO= YES'")
								output = open("/tmp/cam.check.log", "a")
								now = datetime.now()
								output.write(now.strftime("%Y-%m-%d %H:%M") + ":  Telnet info not setup, can not check if frozen,\n\tplease enable 'ALLOW WEBINFO: YES'\n")
								output.close()

					elif softcamcheck_process == "":
						print("[SoftcamManager] Couldn't find " + softcamcheck + " running, Starting " + softcamcheck)
						output = open("/tmp/cam.check.log", "a")
						now = datetime.now()
						output.write(now.strftime("%Y-%m-%d %H:%M") + ": Couldn't find " + softcamcheck + " running, Starting " + softcamcheck + "\n")
						output.close()
						if softcamcheck.lower().startswith("oscam") or softcamcheck.lower().startswith("ncam"):
							self.Console.ePopen("ps.procps | grep softcams | grep -v grep | awk 'NR==1' | awk '{print $5}'| awk  -F'[/]' '{print $4}' > /tmp/softcamRuningCheck.tmp")
							sleep(2)
							file = open("/tmp/softcamRuningCheck.tmp")
							cccamcheck_process = file.read()
							cccamcheck_process = cccamcheck_process.replace("\n", "")
							file.close()
							if cccamcheck_process.find("cccam") >= 0 or cccamcheck_process.find("CCcam") >= 0:
								try:
									print("[SoftcamManager] Stopping ", cccamcheck_process)
									output = open("/tmp/cam.check.log", "a")
									now = datetime.now()
									output.write(now.strftime("%Y-%m-%d %H:%M") + ": AutoStopping: " + cccamcheck_process + "\n")
									output.close()
									self.Console.ePopen("killall -9 /usr/softcams/" + str(cccamcheck_process))
								except:
									pass
							self.Console.ePopen("ulimit -s 1024;/usr/softcams/" + softcamcheck + " -b")
							sleep(10)
							remove("/tmp/softcamRuningCheck.tmp")
						elif softcamcheck.lower().startswith("sbox"):
							self.Console.ePopen("ulimit -s 1024;/usr/softcams/" + softcamcheck)
							sleep(7)
						elif softcamcheck.lower().startswith("gbox"):
							self.Console.ePopen("ulimit -s 1024;/usr/softcams/" + softcamcheck)
							sleep(3)
							self.Console.ePopen("start-stop-daemon --start --quiet --background --exec /usr/bin/gbox")
						else:
							self.Console.ePopen("ulimit -s 1024;/usr/softcams/" + softcamcheck)
Beispiel #12
0
    def JobStart(self):
        self.autostartcams = config.softcammanager.softcams_autostart.value
        self.Console = Console()
        if path.exists('/tmp/cam.check.log'):
            if path.getsize('/tmp/cam.check.log') > 40000:
                fh = open('/tmp/cam.check.log', 'rb+')
                fh.seek(-40000, 2)
                data = fh.read()
                fh.seek(0)  # rewind
                fh.write(data)
                fh.truncate()
                fh.close()

        if path.exists('/etc/CCcam.cfg'):
            f = open('/etc/CCcam.cfg', 'r')
            logwarn = ""
            for line in f.readlines():
                if line.find('LOG WARNINGS') != -1:
                    parts = line.strip().split()
                    logwarn = parts[2]
                    if logwarn.find(':') >= 0:
                        logwarn = logwarn.replace(':', '')
                    if logwarn == '':
                        logwarn = parts[3]
                else:
                    logwarn = ""
            if path.exists(logwarn):
                if path.getsize(logwarn) > 40000:
                    fh = open(logwarn, 'rb+')
                    fh.seek(-40000, 2)
                    data = fh.read()
                    fh.seek(0)  # rewind
                    fh.write(data)
                    fh.truncate()
                    fh.close()
            f.close()

        for softcamcheck in self.autostartcams:
            softcamcheck = softcamcheck.replace("/usr/softcams/", "")
            softcamcheck = softcamcheck.replace("\n", "")
            if softcamcheck.endswith('.sh'):
                if path.exists('/tmp/SoftcamsDisableCheck'):
                    file = open('/tmp/SoftcamsDisableCheck')
                    data = file.read()
                    file.close()
                else:
                    data = ''
                if data.find(softcamcheck) < 0:
                    if path.exists('/tmp/SoftcamsScriptsRunning'):
                        file = open('/tmp/SoftcamsScriptsRunning')
                        data = file.read()
                        file.close()
                        if data.find(softcamcheck) < 0:
                            fileout = open('/tmp/SoftcamsScriptsRunning', 'a')
                            line = softcamcheck + '\n'
                            fileout.write(line)
                            fileout.close()
                            print '[SoftcamManager] Starting ' + softcamcheck
                            self.Console.ePopen('/usr/softcams/' +
                                                softcamcheck + ' start')
                    else:
                        fileout = open('/tmp/SoftcamsScriptsRunning', 'w')
                        line = softcamcheck + '\n'
                        fileout.write(line)
                        fileout.close()
                        print '[SoftcamManager] Starting ' + softcamcheck
                        self.Console.ePopen('/usr/softcams/' + softcamcheck +
                                            ' start')
            else:
                if path.exists('/tmp/SoftcamsDisableCheck'):
                    file = open('/tmp/SoftcamsDisableCheck')
                    data = file.read()
                    file.close()
                else:
                    data = ''
                if data.find(softcamcheck) < 0:
                    import process

                    p = process.ProcessList()
                    softcamcheck_process = str(
                        p.named(softcamcheck)).strip('[]')
                    if softcamcheck_process != "":
                        if path.exists('/tmp/frozen'):
                            remove('/tmp/frozen')
                        if path.exists('/tmp/status.html'):
                            remove('/tmp/status.html')
                        if path.exists('/tmp/index.html'):
                            remove('/tmp/index.html')
                        print '[SoftcamManager] ' + softcamcheck + ' already running'
                        output = open('/tmp/cam.check.log', 'a')
                        now = datetime.now()
                        output.write(
                            now.strftime("%Y-%m-%d %H:%M") + ": " +
                            softcamcheck + " running OK\n")
                        output.close()
                        if softcamcheck.lower().startswith('oscam'):
                            if path.exists('/tmp/status.html'):
                                remove('/tmp/status.html')
                            port = ''
                            f = open('/etc/tuxbox/config/oscam.conf', 'r')
                            for line in f.readlines():
                                if line.find('httpport') != -1:
                                    port = re.sub("\D", "", line)
                            f.close()
                            print '[SoftcamManager] Checking if ' + softcamcheck + ' is frozen'
                            if port == "":
                                port = "16000"
                            self.Console.ePopen(
                                "wget -T 1 http://127.0.0.1:" + port +
                                "/status.html -O /tmp/status.html &> /tmp/frozen"
                            )
                            sleep(2)
                            f = open('/tmp/frozen')
                            frozen = f.read()
                            f.close()
                            if frozen.find(
                                    'Unauthorized') != -1 or frozen.find(
                                        'Authorization Required'
                                    ) != -1 or frozen.find(
                                        'Forbidden') != -1 or frozen.find(
                                            'Connection refused'
                                        ) != -1 or frozen.find(
                                            '100%') != -1 or path.exists(
                                                '/tmp/status.html'):
                                print '[SoftcamManager] ' + softcamcheck + ' is responding like it should'
                                output = open('/tmp/cam.check.log', 'a')
                                now = datetime.now()
                                output.write(
                                    now.strftime("%Y-%m-%d %H:%M") + ": " +
                                    softcamcheck +
                                    " is responding like it should\n")
                                output.close()
                            else:
                                print '[SoftcamManager] ' + softcamcheck + ' is frozen, Restarting...'
                                output = open('/tmp/cam.check.log', 'a')
                                now = datetime.now()
                                output.write(
                                    now.strftime("%Y-%m-%d %H:%M") + ": " +
                                    softcamcheck +
                                    " is frozen, Restarting...\n")
                                output.close()
                                print '[SoftcamManager] Stopping ' + softcamcheck
                                output = open('/tmp/cam.check.log', 'a')
                                now = datetime.now()
                                output.write(
                                    now.strftime("%Y-%m-%d %H:%M") +
                                    ": AutoStopping: " + softcamcheck + "\n")
                                output.close()
                                self.Console.ePopen("killall -9 " +
                                                    softcamcheck)
                                sleep(1)
                                self.Console.ePopen(
                                    "ps | grep softcams | grep -v grep | awk 'NR==1' | awk '{print $5}'| awk  -F'[/]' '{print $4}' > /tmp/oscamRuningCheck.tmp"
                                )
                                sleep(2)
                                file = open('/tmp/oscamRuningCheck.tmp')
                                cccamcheck_process = file.read()
                                file.close()
                                cccamcheck_process = cccamcheck_process.replace(
                                    "\n", "")
                                if cccamcheck_process.lower().find(
                                        'cccam') != -1:
                                    try:
                                        print '[SoftcamManager] Stopping ', cccamcheck_process
                                        output = open('/tmp/cam.check.log',
                                                      'a')
                                        now = datetime.now()
                                        output.write(
                                            now.strftime("%Y-%m-%d %H:%M") +
                                            ": AutoStopping: " +
                                            cccamcheck_process + "\n")
                                        output.close()
                                        self.Console.ePopen(
                                            "killall -9 /usr/softcams/" +
                                            str(cccamcheck_process))
                                    except:
                                        pass
                                print '[SoftcamManager] Starting ' + softcamcheck
                                output = open('/tmp/cam.check.log', 'a')
                                now = datetime.now()
                                output.write(
                                    now.strftime("%Y-%m-%d %H:%M") +
                                    ": AutoStarting: " + softcamcheck + "\n")
                                output.close()
                                self.Console.ePopen(
                                    'ulimit -s 512;/usr/softcams/' +
                                    softcamcheck + ' -b')
                                sleep(10)

                        elif softcamcheck.lower().startswith('cccam'):
                            if path.exists('/tmp/index.html'):
                                remove('/tmp/index.html')
                            allow = 'no'
                            port = ''
                            f = open('/etc/CCcam.cfg', 'r')
                            for line in f.readlines():
                                if line.find('ALLOW WEBINFO') != -1:
                                    if not line.startswith('#'):
                                        parts = line.replace(
                                            'ALLOW WEBINFO', '')
                                        parts = parts.replace(':', '')
                                        parts = parts.replace(' ', '')
                                        parts = parts.strip().split()
                                        if parts[0].startswith('yes'):
                                            allow = parts[0]
                                if line.find('WEBINFO LISTEN PORT') != -1:
                                    port = re.sub("\D", "", line)
                            f.close()
                            if allow.lower().find('yes') != -1:
                                print '[SoftcamManager] Checking if ' + softcamcheck + ' is frozen'
                                if port == "":
                                    port = "16001"
                                self.Console.ePopen(
                                    "wget -T 1 http://127.0.0.1:" + port +
                                    " -O /tmp/index.html &> /tmp/frozen")
                                sleep(2)
                                f = open('/tmp/frozen')
                                frozen = f.read()
                                f.close()
                                if frozen.find(
                                        'Unauthorized') != -1 or frozen.find(
                                            'Authorization Required'
                                        ) != -1 or frozen.find(
                                            'Forbidden') != -1 or frozen.find(
                                                'Connection refused'
                                            ) != -1 or frozen.find(
                                                '100%') != -1 or path.exists(
                                                    '/tmp/index.html'):
                                    print '[SoftcamManager] ' + softcamcheck + ' is responding like it should'
                                    output = open('/tmp/cam.check.log', 'a')
                                    now = datetime.now()
                                    output.write(
                                        now.strftime("%Y-%m-%d %H:%M") + ": " +
                                        softcamcheck +
                                        " is responding like it should\n")
                                    output.close()
                                else:
                                    print '[SoftcamManager] ' + softcamcheck + ' is frozen, Restarting...'
                                    output = open('/tmp/cam.check.log', 'a')
                                    now = datetime.now()
                                    output.write(
                                        now.strftime("%Y-%m-%d %H:%M") + ": " +
                                        softcamcheck +
                                        " is frozen, Restarting...\n")
                                    output.close()
                                    print '[SoftcamManager] Stopping ' + softcamcheck
                                    self.Console.ePopen("killall -9 " +
                                                        softcamcheck)
                                    sleep(1)
                                    print '[SoftcamManager] Starting ' + softcamcheck
                                    self.Console.ePopen(
                                        'ulimit -s 512;/usr/softcams/' +
                                        softcamcheck)
                            elif allow.lower().find('no') != -1:
                                print '[SoftcamManager] Telnet info not allowed, can not check if frozen'
                                output = open('/tmp/cam.check.log', 'a')
                                now = datetime.now()
                                output.write(
                                    now.strftime("%Y-%m-%d %H:%M") +
                                    ":  Webinfo info not allowed, can not check if frozen,\n\tplease enable 'ALLOW WEBINFO: YES'\n"
                                )
                                output.close()
                            else:
                                print "[SoftcamManager] Webinfo info not setup, please enable 'ALLOW WEBINFO= YES'"
                                output = open('/tmp/cam.check.log', 'a')
                                now = datetime.now()
                                output.write(
                                    now.strftime("%Y-%m-%d %H:%M") +
                                    ":  Telnet info not setup, can not check if frozen,\n\tplease enable 'ALLOW WEBINFO: YES'\n"
                                )
                                output.close()

                    elif softcamcheck_process == "":
                        print "[SoftcamManager] Couldn't find " + softcamcheck + " running, Starting " + softcamcheck
                        output = open('/tmp/cam.check.log', 'a')
                        now = datetime.now()
                        output.write(
                            now.strftime("%Y-%m-%d %H:%M") +
                            ": Couldn't find " + softcamcheck +
                            " running, Starting " + softcamcheck + "\n")
                        output.close()
                        if softcamcheck.lower().startswith('oscam'):
                            self.Console.ePopen(
                                "ps | grep softcams | grep -v grep | awk 'NR==1' | awk '{print $5}'| awk  -F'[/]' '{print $4}' > /tmp/softcamRuningCheck.tmp"
                            )
                            sleep(2)
                            file = open('/tmp/softcamRuningCheck.tmp')
                            cccamcheck_process = file.read()
                            cccamcheck_process = cccamcheck_process.replace(
                                "\n", "")
                            file.close()
                            if cccamcheck_process.find(
                                    'cccam') >= 0 or cccamcheck_process.find(
                                        'CCcam') >= 0:
                                try:
                                    print '[SoftcamManager] Stopping ', cccamcheck_process
                                    output = open('/tmp/cam.check.log', 'a')
                                    now = datetime.now()
                                    output.write(
                                        now.strftime("%Y-%m-%d %H:%M") +
                                        ": AutoStopping: " +
                                        cccamcheck_process + "\n")
                                    output.close()
                                    self.Console.ePopen(
                                        "killall -9 /usr/softcams/" +
                                        str(cccamcheck_process))
                                except:
                                    pass
                            self.Console.ePopen(
                                'ulimit -s 512;/usr/softcams/' + softcamcheck +
                                " -b")
                            sleep(10)
                            remove('/tmp/softcamRuningCheck.tmp')
                        elif softcamcheck.lower().startswith('sbox'):
                            self.Console.ePopen(
                                'ulimit -s 512;/usr/softcams/' + softcamcheck)
                            sleep(7)
                        elif softcamcheck.lower().startswith('gbox'):
                            self.Console.ePopen(
                                'ulimit -s 512;/usr/softcams/' + softcamcheck)
                            sleep(3)
                            self.Console.ePopen(
                                'start-stop-daemon --start --quiet --background --exec /usr/bin/gbox'
                            )
                        else:
                            self.Console.ePopen(
                                'ulimit -s 512;/usr/softcams/' + softcamcheck)
Beispiel #13
0
    def JobStart(self):
        self.autostartcams = config.softcammanager.softcams_autostart.value
        self.Console = Console()
        if SystemInfo["OScamInstalled"] and not path.exists(
                "/usr/softcams/oscam"):
            self.Console.ePopen('ln -s /usr/bin/*oscam* /usr/softcams/')
        if SystemInfo["NCamInstalled"] and not path.exists(
                "/usr/softcams/ncam"):
            self.Console.ePopen('ln -s /usr/bin/ncam /usr/softcams/')
        if path.exists('/tmp/cam.check.log'):
            if path.getsize('/tmp/cam.check.log') > 40000:
                fh = open('/tmp/cam.check.log', 'rb+')
                fh.seek(-40000, 2)
                data = fh.read()
                fh.seek(0)  # rewind
                fh.write(data)
                fh.truncate()
                fh.close()

        for softcamcheck in self.autostartcams:
            softcamcheck = softcamcheck.replace("/usr/softcams/", "")
            softcamcheck = softcamcheck.replace("\n", "")
            if softcamcheck.endswith('.sh'):
                if path.exists('/tmp/SoftcamsDisableCheck'):
                    data = open('/tmp/SoftcamsDisableCheck').read()
                else:
                    data = ''
                if data.find(softcamcheck) < 0:
                    if path.exists('/tmp/SoftcamsScriptsRunning'):
                        data = open('/tmp/SoftcamsScriptsRunning').read()
                        if data.find(softcamcheck) < 0:
                            open('/tmp/SoftcamsScriptsRunning',
                                 'a').write(softcamcheck + '\n')
                            print('[SoftcamManager] Starting ' + softcamcheck)
                            self.Console.ePopen('/usr/softcams/' +
                                                softcamcheck + ' start')
                    else:
                        open('/tmp/SoftcamsScriptsRunning',
                             'w').write(softcamcheck + '\n')
                        print('[SoftcamManager] Starting ' + softcamcheck)
                        self.Console.ePopen('/usr/softcams/' + softcamcheck +
                                            ' start')
            else:
                if path.exists('/tmp/SoftcamsDisableCheck'):
                    data = open('/tmp/SoftcamsDisableCheck').read()
                else:
                    data = ''
                if data.find(softcamcheck) < 0:
                    import process

                    p = process.ProcessList()
                    softcamcheck_process = str(
                        p.named(softcamcheck)).strip('[]')
                    if softcamcheck_process != "":
                        if path.exists('/tmp/frozen'):
                            remove('/tmp/frozen')
                        if path.exists('/tmp/status.html'):
                            remove('/tmp/status.html')
                        if path.exists('/tmp/index.html'):
                            remove('/tmp/index.html')
                        print('[SoftcamManager] ' + softcamcheck +
                              ' already running')
                        now = datetime.now()
                        open('/tmp/cam.check.log', 'a').write(
                            now.strftime("%Y-%m-%d %H:%M") + ": " +
                            softcamcheck + " running OK\n")
                        if softcamcheck.lower().startswith(
                                'oscam') or softcamcheck.lower().startswith(
                                    'oscam'):
                            if path.exists('/tmp/status.html'):
                                remove('/tmp/status.html')
                            port = ''
                            if path.exists(
                                    '/etc/tuxbox/config/oscam/oscam.conf'):
                                oscamconf = '/etc/tuxbox/config/oscam/oscam.conf'
                            elif path.exists(
                                    '/etc/tuxbox/config/ncam/ncam.conf'):
                                oscamconf = '/etc/tuxbox/config/ncam/ncam.conf'
                            elif path.exists(
                                    '/etc/tuxbox/config/oscam-emu/oscam.conf'):
                                oscamconf = '/etc/tuxbox/config/oscam-emu/oscam.conf'
                            elif path.exists(
                                    '/etc/tuxbox/config/oscam-smod/oscam.conf'
                            ):
                                oscamconf = '/etc/tuxbox/config/oscam-smod/oscam.conf'
                            f = open(oscamconf, 'r')
                            for line in f.readlines():
                                if line.find('httpport') != -1:
                                    port = re.sub("\D", "", line)
                            f.close()
                            print('[SoftcamManager] Checking if ' +
                                  softcamcheck + ' is frozen')
                            if port == "":
                                port = "16000"
                            self.Console.ePopen(
                                "wget -T 1 http://127.0.0.1:" + port +
                                "/status.html -O /tmp/status.html &> /tmp/frozen"
                            )
                            sleep(2)
                            frozen = open('/tmp/frozen').read()
                            if frozen.find(
                                    'Unauthorized') != -1 or frozen.find(
                                        'Authorization Required'
                                    ) != -1 or frozen.find(
                                        'Forbidden') != -1 or frozen.find(
                                            'Connection refused'
                                        ) != -1 or frozen.find(
                                            '100%') != -1 or path.exists(
                                                '/tmp/status.html'):
                                print('[SoftcamManager] ' + softcamcheck +
                                      ' is responding like it should')
                                now = datetime.now()
                                open('/tmp/cam.check.log', 'a').write(
                                    now.strftime("%Y-%m-%d %H:%M") + ": " +
                                    softcamcheck +
                                    " is responding like it should\n")
                            else:
                                print('[SoftcamManager] ' + softcamcheck +
                                      ' is frozen, restarting...')
                                now = datetime.now()
                                open('/tmp/cam.check.log', 'a').write(
                                    now.strftime("%Y-%m-%d %H:%M") + ": " +
                                    softcamcheck +
                                    " is frozen, Restarting...\n")
                                print('[SoftcamManager] Stopping ' +
                                      softcamcheck)
                                now = datetime.now()
                                open('/tmp/cam.check.log', 'a').write(
                                    now.strftime("%Y-%m-%d %H:%M") +
                                    ": AutoStopping: " + softcamcheck + "\n")
                                self.Console.ePopen("killall -9 " +
                                                    softcamcheck)
                                sleep(1)
                                print('[SoftcamManager] Starting ' +
                                      softcamcheck)
                                now = datetime.now()
                                open('/tmp/cam.check.log', 'a').write(
                                    now.strftime("%Y-%m-%d %H:%M") +
                                    ": AutoStarting: " + softcamcheck + "\n")
                                self.Console.ePopen(
                                    'ulimit -s 1024;/usr/softcams/' +
                                    softcamcheck + ' -b')
                                sleep(10)

                    elif softcamcheck_process == "":
                        print("[SoftcamManager] Couldn't find " +
                              softcamcheck + " running, starting " +
                              softcamcheck)
                        now = datetime.now()
                        open('/tmp/cam.check.log', 'a').write(
                            now.strftime("%Y-%m-%d %H:%M") +
                            ": Couldn't find " + softcamcheck +
                            " running, Starting " + softcamcheck + "\n")
                        if softcamcheck.lower().startswith(
                                'oscam') or softcamcheck.lower().startswith(
                                    'ncam'):
                            self.Console.ePopen(
                                "ps.procps | grep softcams | grep -v grep | awk 'NR==1' | awk '{print $5}'| awk  -F'[/]' '{print $4}' > /tmp/softcamRuningCheck.tmp"
                            )
                            sleep(2)

                            #							open('/tmp/softcamRuningCheck.tmp')
                            self.Console.ePopen(
                                'ulimit -s 1024;/usr/softcams/' +
                                softcamcheck + " -b")
                            sleep(10)
                            remove('/tmp/softcamRuningCheck.tmp')
                        else:
                            self.Console.ePopen(
                                'ulimit -s 1024;/usr/softcams/' + softcamcheck)
Beispiel #14
0
    def updateList(self, result=None, retval=None, extra_args=None):
        import process
        p = process.ProcessList()
        crond_process = str(p.named('crond')).strip('[]')
        self['labrun'].hide()
        self['labstop'].hide()
        self['labactive'].hide()
        self['labdisabled'].hide()
        self.my_crond_active = False
        self.my_crond_run = False
        if path.exists('/etc/rc3.d/S20busybox-cron'):
            self['labdisabled'].hide()
            self['labactive'].show()
            self.my_crond_active = True
        else:
            self['labactive'].hide()
            self['labdisabled'].show()
        if crond_process:
            self.my_crond_run = True
        if self.my_crond_run:
            self['labstop'].hide()
            self['labrun'].show()
            self['key_yellow'].setText(_('Stop'))
            self.summary_running = _('Running')
        else:
            self['labstop'].show()
            self['labrun'].hide()
            self['key_yellow'].setText(_('Start'))
            self.summary_running = _('Stopped')
        self.list = []
        if path.exists('/etc/cron/crontabs/root'):
            f = open('/etc/cron/crontabs/root', 'r')
            for line in f.readlines():
                parts = line.strip().split()
                if len(parts) > 5 and not parts[0].startswith('#'):
                    if parts[1] == '*':
                        line2 = 'H: 00:' + parts[0].zfill(2) + '\t'
                        for i in range(5, len(parts) - 1):
                            line2 = line2 + parts[i] + ' '

                        res = (line2, line)
                        self.list.append(res)
                    elif parts[2] == '*' and parts[4] == '*':
                        line2 = 'D: ' + parts[1].zfill(
                            2) + ':' + parts[0].zfill(2) + '\t'
                        for i in range(5, len(parts) - 1):
                            line2 = line2 + parts[i] + ' '

                        res = (line2, line)
                        self.list.append(res)
                    elif parts[3] == '*':
                        if parts[4] == '*':
                            line2 = 'M:  Day ' + parts[2] + '  ' + parts[
                                1].zfill(2) + ':' + parts[0].zfill(2) + '\t'
                            for i in range(5, len(parts) - 1):
                                line2 = line2 + parts[i] + ' '

                        header = 'W:  '
                        day = ''
                        if str(parts[4]).find('0') >= 0:
                            day = 'Sun '
                        if str(parts[4]).find('1') >= 0:
                            day += 'Mon '
                        if str(parts[4]).find('2') >= 0:
                            day += 'Tues '
                        if str(parts[4]).find('3') >= 0:
                            day += 'Wed '
                        if str(parts[4]).find('4') >= 0:
                            day += 'Thurs '
                        if str(parts[4]).find('5') >= 0:
                            day += 'Fri '
                        if str(parts[4]).find('6') >= 0:
                            day += 'Sat '
                        if day:
                            line2 = header + day + parts[1].zfill(
                                2) + ':' + parts[0].zfill(2) + '\t'
                            for i in range(5, len(parts) - 1):
                                line2 = line2 + parts[i] + ' '

                        res = (line2, line)
                        self.list.append(res)

            f.close()
        self['list'].list = self.list
        self['actions'].setEnabled(True)
Beispiel #15
0
	def updateList(self, result=None, retval=None, extra_args=None):
		import process
		p = process.ProcessList()
		crond_process = str(p.named("crond")).strip("[]")
		self["labrun"].hide()
		self["labstop"].hide()
		self["labactive"].hide()
		self["labdisabled"].hide()
		self.my_crond_active = False
		self.my_crond_run = False
		if exists("/etc/rc3.d/S90crond"):
			self["labdisabled"].hide()
			self["labactive"].show()
			self.my_crond_active = True
		else:
			self["labactive"].hide()
			self["labdisabled"].show()
		if crond_process:
			self.my_crond_run = True
		if self.my_crond_run:
			self["labstop"].hide()
			self["labrun"].show()
			self["key_yellow"].setText(_("Stop"))
			self.summary_running = _("Running")
		else:
			self["labstop"].show()
			self["labrun"].hide()
			self["key_yellow"].setText(_("Start"))
			self.summary_running = _("Stopped")

		self.list = []
		if exists("/etc/cron/crontabs/root"):
			f = open("/etc/cron/crontabs/root", "r")
			for line in f.readlines():
				parts = line.strip().split(maxsplit=5)
				if parts and len(parts) == 6 and not parts[0].startswith("#"):
					if parts[1] == "*":
						line2 = "H: 00:" + parts[0].zfill(2) + "\t" + parts[5]
						res = (line2, line)
						self.list.append(res)
					elif parts[2] == "*" and parts[4] == "*":
						line2 = "D: " + parts[1].zfill(2) + ":" + parts[0].zfill(2) + "\t" + parts[5]
						res = (line2, line)
						self.list.append(res)
					elif parts[3] == "*":
						if parts[4] == "*":
							line2 = "M:  Day " + parts[2] + "  " + parts[1].zfill(2) + ":" + parts[0].zfill(2) + "\t" + parts[5]
						header = "W:  "
						day = ""
						if str(parts[4]).find("0") >= 0:
							day = "Sun "
						if str(parts[4]).find("1") >= 0:
							day += "Mon "
						if str(parts[4]).find("2") >= 0:
							day += "Tues "
						if str(parts[4]).find("3") >= 0:
							day += "Wed "
						if str(parts[4]).find("4") >= 0:
							day += "Thurs "
						if str(parts[4]).find("5") >= 0:
							day += "Fri "
						if str(parts[4]).find("6") >= 0:
							day += "Sat "

						if day:
							line2 = header + day + parts[1].zfill(2) + ":" + parts[0].zfill(2) + "\t" + parts[5]
						res = (line2, line)
						self.list.append(res)
			f.close()
		self["list"].list = self.list
		self["actions"].setEnabled(True)
Beispiel #16
0
    def updateService(self):
        import process
        p = process.ProcessList()
        cihelper_process = str(p.named("cihelper")).strip("[]")
        self["labrun"].hide()
        self["labstop"].hide()
        self["labactive"].hide()
        self["labdisabled"].hide()
        self.my_cihelper_active = False
        self.my_cihelper_run = False
        if isfile("/etc/rcS.d/S50cihelper.sh") or isfile(
                "/etc/rc4.d/S50cihelper.sh"):
            self["labdisabled"].hide()
            self["labactive"].show()
            self.my_cihelper_active = True
            autostartstatus_summary = self["autostart"].text + " " + self[
                "labactive"].text
        else:
            self["labactive"].hide()
            self["labdisabled"].show()
            autostartstatus_summary = self["autostart"].text + " " + self[
                "labdisabled"].text
        if cihelper_process:
            self.my_cihelper_run = True
        if self.my_cihelper_run:
            self["labstop"].hide()
            self["labrun"].show()
            self["key_green"].setText(_("Stop"))
            status_summary = self["status"].text + " " + self["labstop"].text
        else:
            self["labstop"].show()
            self["labrun"].hide()
            self["key_green"].setText(_("Start"))
            status_summary = self["status"].text + " " + self["labstop"].text

        if isfile(CI_HELPER_CONF):
            helperConfig = fileReadLines(CI_HELPER_CONF)
            helperConfig = [
                x.strip() for x in helperConfig
                if x.strip().startswith("ENABLE_CI")
            ]
            self["ci1active"].hide()
            self["ci1inactive"].hide()
            self["ci1"].hide()
            for line in helperConfig:
                if line.startswith("ENABLE_CI0="):
                    if line[11:] == "no":
                        self["ci0active"].hide()
                        self["ci0inactive"].show()
                    else:
                        self["ci0active"].show()
                        self["ci0inactive"].hide()
                elif line.startswith("ENABLE_CI1=") and access(
                        "/dev/ci1", R_OK):
                    self["ci1"].show()
                    if line[11:] == "no":
                        self["ci1active"].hide()
                        self["ci1inactive"].show()
                    else:
                        self["ci1active"].show()
                        self["ci1inactive"].hide()
        title = _("CI Helper Settings")

        for cb in self.onChangedEntry:
            cb(title, status_summary, autostartstatus_summary)