Exemplo n.º 1
0
	def doBackup(self):
		self.save_shutdownOK = config.usage.shutdownOK.value
		config.usage.shutdownOK.setValue(True)
		config.usage.shutdownOK.save()
		configfile.save()
		try:
			if config.plugins.softwaremanager.epgcache.value:
				eEPGCache.getInstance().save()
		except:
			pass
		try:
			if path.exists(self.backuppath) == False:
				makedirs(self.backuppath)
			InitConfig()
			self.backupdirs=" ".join(f.strip("/") for f in config.plugins.configurationbackup.backupdirs_default.value)
			for f in config.plugins.configurationbackup.backupdirs.value:
				if not f.strip("/") in self.backupdirs:
					self.backupdirs += " " + f.strip("/")
			if not "tmp/installed-list.txt" in self.backupdirs:
				self.backupdirs += " tmp/installed-list.txt"
			if not "tmp/changed-configfiles.txt" in self.backupdirs:
				self.backupdirs += " tmp/changed-configfiles.txt"
			if not "tmp/passwd.txt" in self.backupdirs:
				self.backupdirs += " tmp/passwd.txt"
			if not "tmp/groups.txt" in self.backupdirs:
				self.backupdirs += " tmp/groups.txt"

			ShellCompatibleFunctions.backupUserDB()
			pkgs=ShellCompatibleFunctions.listpkg(type="user")
			installed = open("/tmp/installed-list.txt", "w")
			installed.write('\n'.join(pkgs))
			installed.close()
			cmd2 = "opkg list-changed-conffiles > /tmp/changed-configfiles.txt"
			cmd3 = "tar -C / -czvf " + self.fullbackupfilename + " " + self.backupdirs
			for f in config.plugins.configurationbackup.backupdirs_exclude.value:
				cmd3 = cmd3 + " --exclude " + f.strip("/")
			for f in BLACKLISTED:
				cmd3 = cmd3 + " --exclude " + f.strip("/")
			cmd = [cmd2, cmd3]
			if path.exists(self.fullbackupfilename):
				dt = str(date.fromtimestamp(stat(self.fullbackupfilename).st_ctime))
				self.newfilename = self.backuppath + "/" + dt + '-' + self.backupfile
				if path.exists(self.newfilename):
					remove(self.newfilename)
				rename(self.fullbackupfilename,self.newfilename)
			if self.finished_cb:
				self.session.openWithCallback(self.finished_cb, Console, title = _("Backup is running..."), cmdlist = cmd,finishedCallback = self.backupFinishedCB,closeOnSuccess = True)
			else:
				self.session.open(Console, title = _("Backup is running..."), cmdlist = cmd,finishedCallback = self.backupFinishedCB, closeOnSuccess = True)
		except OSError:
			if self.finished_cb:
				self.session.openWithCallback(self.finished_cb, MessageBox, _("Sorry, your backup destination is not writeable.\nPlease select a different one."), MessageBox.TYPE_INFO, timeout = 10 )
			else:
				self.session.openWithCallback(self.backupErrorCB,MessageBox, _("Sorry, your backup destination is not writeable.\nPlease select a different one."), MessageBox.TYPE_INFO, timeout = 10 )
Exemplo n.º 2
0
	def doBackup(self):
		self.save_shutdownOK = config.usage.shutdownOK.value
		config.usage.shutdownOK.setValue(True)
		config.usage.shutdownOK.save()
		configfile.save()
		try:
			if config.plugins.softwaremanager.epgcache.value:
				eEPGCache.getInstance().save()
		except:
			pass
		try:
			if path.exists(self.backuppath) == False:
				makedirs(self.backuppath)
			InitConfig()
			self.backupdirs=" ".join(f.strip("/") for f in config.plugins.configurationbackup.backupdirs_default.value)
			for f in config.plugins.configurationbackup.backupdirs.value:
				if not f.strip("/") in self.backupdirs:
					self.backupdirs += " " + f.strip("/")
			if not "tmp/installed-list.txt" in self.backupdirs:
				self.backupdirs += " tmp/installed-list.txt"
			if not "tmp/changed-configfiles.txt" in self.backupdirs:
				self.backupdirs += " tmp/changed-configfiles.txt"
			if not "tmp/passwd.txt" in self.backupdirs:
				self.backupdirs += " tmp/passwd.txt"
			if not "tmp/groups.txt" in self.backupdirs:
				self.backupdirs += " tmp/groups.txt"

			ShellCompatibleFunctions.backupUserDB()
			pkgs=ShellCompatibleFunctions.listpkg(type="user")
			installed = open("/tmp/installed-list.txt", "w")
			installed.write('\n'.join(pkgs))
			installed.close()
			cmd2 = "opkg list-changed-conffiles > /tmp/changed-configfiles.txt"
			cmd3 = "tar -C / -czvf " + self.fullbackupfilename + " " + self.backupdirs
			for f in config.plugins.configurationbackup.backupdirs_exclude.value:
				cmd3 = cmd3 + " --exclude " + f.strip("/")
			for f in BLACKLISTED:
				cmd3 = cmd3 + " --exclude " + f.strip("/")
			cmd = [cmd2, cmd3]
			if path.exists(self.fullbackupfilename):
				dt = str(date.fromtimestamp(stat(self.fullbackupfilename).st_ctime))
				self.newfilename = self.backuppath + "/" + dt + '-' + self.backupfile
				if path.exists(self.newfilename):
					remove(self.newfilename)
				rename(self.fullbackupfilename,self.newfilename)
			if self.finished_cb:
				self.session.openWithCallback(self.finished_cb, Console, title = _("Backup is running..."), cmdlist = cmd,finishedCallback = self.backupFinishedCB,closeOnSuccess = True)
			else:
				self.session.open(Console, title = _("Backup is running..."), cmdlist = cmd,finishedCallback = self.backupFinishedCB, closeOnSuccess = True)
		except OSError:
			if self.finished_cb:
				self.session.openWithCallback(self.finished_cb, MessageBox, _("Sorry, your backup destination is not writeable.\nPlease select a different one."), MessageBox.TYPE_INFO, timeout = 10 )
			else:
				self.session.openWithCallback(self.backupErrorCB,MessageBox, _("Sorry, your backup destination is not writeable.\nPlease select a different one."), MessageBox.TYPE_INFO, timeout = 10 )
Exemplo n.º 3
0
 def readPluginList(self):
     installedpkgs = ShellCompatibleFunctions.listpkg(type="installed")
     self.PluginList = []
     with open('/tmp/installed-list.txt') as f:
         for line in f:
             if line.strip() not in installedpkgs:
                 self.PluginList.append(line.strip())
     f.close()
     self.createMenuList()
Exemplo n.º 4
0
	def readPluginList(self):
		installedpkgs=ShellCompatibleFunctions.listpkg(type="installed")
		self.PluginList = []
		with open('/tmp/installed-list.txt') as f:
			for line in f:
				if line.strip() not in installedpkgs:
					self.PluginList.append(line.strip())
		f.close()
		self.createMenuList()
Exemplo n.º 5
0
 def restoreFinishedCB(self, retval=None):
     ShellCompatibleFunctions.restoreUserDB()
     self.session.openWithCallback(self.checkPlugins, RestartNetwork)
Exemplo n.º 6
0
	def restoreFinishedCB(self,retval = None):
		ShellCompatibleFunctions.restoreUserDB()
		self.session.openWithCallback(self.checkPlugins, RestartNetwork)