def main():
    print("Blink Container Main script")

    #Change the working directory to the Shared folder
    os.chdir(Container.homeFolder)

    if os.path.isfile(Container.updateFile):
        #We update the container
        subprocess.call(["python3","/home/blink/updateContainer.py"])
    else :
        #We create an instance of Container
        blink = Container()

        #We check the Data file with the complete user profile
        blink.checkDataFile()

        #We chose the fonts and the plugins
        blink.selectFonts()
        blink.selectPlugins()

        if blink.selectBrowser() == 'chrome':
            browser = Chrome()
        else :
            browser = Firefox()
        #We import the user profile inside the browser
        browser.importData()

        #We initialise a boolean to indicate if the
        #VM must be shutdown
        shutdown = False

        while not shutdown :
            #We launch the browser
            browserProcess = browser.runBrowser()
            signal.signal(signal.SIGINT, sigint_handler)
            #We wait for either the browsing session to be finished
            while not isinstance(browserProcess.poll(),int):
                time.sleep(1)


            encryption = browser.exportData()

            #Encrypt file if the encryption is activated
            if encryption :
                done = False
                while not done :
                    res = subprocess.getstatusoutput("gpg2 -c --cipher-algo=AES256 "+Container.dataFile)
                    if res[0] == 0 :
                        #If the encryption went well, we removed the unencrypted file
                        subprocess.call("rm "+Container.dataFile,shell=True)
                        done = True
                    elif "cancelled" in res[1]:
                        #If the user cancelled the encryption operation, we do nothing
                        done = True

            #We finish the execution of the script
            shutdown = True
Example #2
0
def main():
    print("Blink Container Main script")

    #Change the working directory to the Shared folder
    os.chdir(Container.homeFolder)

    if os.path.isfile(Container.updateFile):
        #We update the container
        subprocess.call(["python3", "/home/blink/updateContainer.py"])
    else:
        #We create an instance of Container
        blink = Container()

        #We check the Data file with the complete user profile
        blink.checkDataFile()

        #We chose the fonts and the plugins
        blink.selectFonts()
        blink.selectPlugins()

        if blink.selectBrowser() == 'chrome':
            browser = Chrome()
        else:
            browser = Firefox()
        #We import the user profile inside the browser
        browser.importData()

        #We initialise a boolean to indicate if the
        #VM must be shutdown
        shutdown = False

        while not shutdown:
            #We launch the browser
            browserProcess = browser.runBrowser()
            signal.signal(signal.SIGINT, sigint_handler)
            #We wait for either the browsing session to be finished
            while not isinstance(browserProcess.poll(), int):
                time.sleep(1)

            encryption = browser.exportData()

            #Encrypt file if the encryption is activated
            if encryption:
                done = False
                while not done:
                    res = subprocess.getstatusoutput(
                        "gpg2 -c --cipher-algo=AES256 " + Container.dataFile)
                    if res[0] == 0:
                        #If the encryption went well, we removed the unencrypted file
                        subprocess.call("rm " + Container.dataFile, shell=True)
                        done = True
                    elif "cancelled" in res[1]:
                        #If the user cancelled the encryption operation, we do nothing
                        done = True

            #We finish the execution of the script
            shutdown = True
Example #3
0
def main():
	print("Blink VM Main script")

	#Change the working directory to the Shared folder
	os.chdir(VM.sharedFolder)

	#We create an instance of a VM
	machine = VM()

	#We chose the fonts and the plugins
	machine.selectFonts()
	machine.selectPlugins()

	#We look for the JSON data file
	dataPath = VM.jsonDataFile
	encryptedDataPath = dataPath+".gpg"

	#Decrypt file if encrypted
	if os.path.isfile(encryptedDataPath):
		cancelled = False
		while not os.path.isfile(dataPath) and not cancelled:
			res = subprocess.getstatusoutput("gpg2 -d -o "+dataPath+" "+encryptedDataPath)
			if res[0] != 0 and "cancelled" in res[1]:
				cancelled = True
		subprocess.call("rm "+encryptedDataPath,shell=True)

	#Look in the browser folder for the browser but
	#Execute a different command according to the browser used
	if os.path.isfile(VM.sharedFolder+"chrome.browser"):
		browser = Chrome()
	else :
		browser = Firefox()

	#We import the user profile inside the browser
	browser.importData()

	#We initialise a boolean to indicate if the
	#VM must be shutdown
	shutdown = False

	while not shutdown :
		#We launch the browser
		browserProcess = browser.runBrowser()

		#We wait for either the browsing session to be finished or the computer to be locked
		while not isinstance(browserProcess.poll(),int) and not os.path.isfile(VM.sharedFolder+"browser.switch"):
			time.sleep(10)

		encryption = browser.exportData()

		#If the browsing session is finished
		if isinstance(browserProcess.poll(),int) :
			#Encrypt file if the encryption is activated
			if encryption :
				done = False
				while not done :
					res = subprocess.getstatusoutput("gpg2 -c --cipher-algo=AES256 "+dataPath)
					if res[0] == 0 :
						#If the encryption went well, we removed the unencrypted file
						subprocess.call("rm "+dataPath,shell=True)
						done = True
					elif "cancelled" in res[1]:
						#If the user cancelled the encryption operation, we do nothing
						done = True

			#We write a file to signal the host to shutdown all running VMs
			subprocess.call("touch "+VM.sharedFolder+"VM.shutdown", shell=True)

			#We finish the execution of the script
			shutdown = True

		else :
			#We terminate the browser process
			browserProcess.kill()

			#We switch the list of plugins and fonts
			machine.selectFonts()
			machine.selectPlugins()

			#We remove the "browser.switch" file
			subprocess.call("rm "+VM.sharedFolder+"browser.switch",shell=True)
Example #4
0
def main():
    print("Blink VM Main script")

    #Change the working directory to the Shared folder
    os.chdir(VM.sharedFolder)

    #We create an instance of a VM
    machine = VM()

    #We chose the fonts and the plugins
    machine.selectFonts()
    machine.selectPlugins()

    #We look for the JSON data file
    dataPath = VM.jsonDataFile
    encryptedDataPath = dataPath + ".gpg"

    #Decrypt file if encrypted
    if os.path.isfile(encryptedDataPath):
        cancelled = False
        while not os.path.isfile(dataPath) and not cancelled:
            res = subprocess.getstatusoutput("gpg2 -d -o " + dataPath + " " +
                                             encryptedDataPath)
            if res[0] != 0 and "cancelled" in res[1]:
                cancelled = True
        subprocess.call("rm " + encryptedDataPath, shell=True)

    #Look in the browser folder for the browser but
    #Execute a different command according to the browser used
    if os.path.isfile(VM.sharedFolder + "chrome.browser"):
        browser = Chrome()
    else:
        browser = Firefox()

    #We import the user profile inside the browser
    browser.importData()

    #We initialise a boolean to indicate if the
    #VM must be shutdown
    shutdown = False

    while not shutdown:
        #We launch the browser
        browserProcess = browser.runBrowser()

        #We wait for either the browsing session to be finished or the computer to be locked
        while not isinstance(browserProcess.poll(),
                             int) and not os.path.isfile(VM.sharedFolder +
                                                         "browser.switch"):
            time.sleep(10)

        encryption = browser.exportData()

        #If the browsing session is finished
        if isinstance(browserProcess.poll(), int):
            #Encrypt file if the encryption is activated
            if encryption:
                done = False
                while not done:
                    res = subprocess.getstatusoutput(
                        "gpg2 -c --cipher-algo=AES256 " + dataPath)
                    if res[0] == 0:
                        #If the encryption went well, we removed the unencrypted file
                        subprocess.call("rm " + dataPath, shell=True)
                        done = True
                    elif "cancelled" in res[1]:
                        #If the user cancelled the encryption operation, we do nothing
                        done = True

            #We write a file to signal the host to shutdown all running VMs
            subprocess.call("touch " + VM.sharedFolder + "VM.shutdown",
                            shell=True)

            #We finish the execution of the script
            shutdown = True

        else:
            #We terminate the browser process
            browserProcess.kill()

            #We switch the list of plugins and fonts
            machine.selectFonts()
            machine.selectPlugins()

            #We remove the "browser.switch" file
            subprocess.call("rm " + VM.sharedFolder + "browser.switch",
                            shell=True)