def _run_upgrade(self):
     self._logger.info("hooks: %s" % self._options.skip_existing_hooks)
     self._python_lib = glob.glob("%s/rootfs/usr/lib/python*"
                                  % self._tmp_dir)
     if not self._python_lib:
         raise RuntimeError("Unable to determine python path")
     self._python_lib = self._python_lib[0]
     self._tmp_python_path = "%s/site-packages/ovirtnode" \
         % self._python_lib
     shutil.copytree(self._tmp_python_path, self._ovirtnode_dir)
     # import install and ovirtfunctions modules from new image
     f, filename, description = imp.find_module(
         'install',
         [self._ovirtnode_dir],
     )
     install = imp.load_module(
         'install',
         f,
         filename,
         description,
     )
     # log module detail for debugging
     self._logger.debug(install)
     from install import Install
     upgrade = Install()
     self._logger.propagate = True
     self._logger.info("Installing Bootloader")
     if not upgrade.ovirt_boot_setup():
         raise RuntimeError("Bootloader Installation Failed")
Пример #2
0
    def install_extras(self):
        """Overrides main install_extras function to add in Mythbuntu
           drivers and services, and then call the parent function"""
        video_driver = self.db.get('mythbuntu/video_driver')
        vnc = self.db.get('mythbuntu/x11vnc')
        nfs = self.db.get('mythbuntu/nfs-kernel-server')
        to_install = []
        to_remove = set()
        if video_driver != "Open Source Driver":
            to_install.append(video_driver)
        if vnc == 'true':
            to_install.append('x11vnc')
        if nfs == 'true':
            to_install.append('nfs-kernel-server')
            to_install.append('portmap')

        #Remove any conflicts before installing new items
        if to_remove != []:
            self.do_remove(to_remove)
        #Mark new items
        self.record_installed(to_install)

        #Actually install extras
        ParentInstall.install_extras(self)

        #Run depmod if we might be using a DKMS enabled driver
        if video_driver != "Open Source Driver":
            self.chrex('/sbin/depmod','-a')
Пример #3
0
    def __init__(self,
                 answers,
                 APP,
                 dryrun=False,
                 debug=False,
                 stop=False,
                 answers_format=ANSWERS_FILE_SAMPLE_FORMAT,
                 **kwargs):

        self.debug = debug
        self.dryrun = dryrun
        self.stop = stop
        self.kwargs = kwargs

        if "answers_output" in kwargs:
            self.answers_output = kwargs["answers_output"]

        if os.environ and "IMAGE" in os.environ:
            self.app_path = APP
            APP = os.environ["IMAGE"]
            del os.environ["IMAGE"]
        elif "image" in kwargs:
            logger.warning("Setting image to %s" % kwargs["image"])

            self.app_path = APP
            APP = kwargs["image"]
            del kwargs["image"]

        self.kwargs = kwargs

        if APP and os.path.exists(APP):
            self.app_path = APP
        else:
            if not self.app_path:
                self.app_path = os.getcwd()
            install = Install(answers,
                              APP,
                              dryrun=dryrun,
                              target_path=self.app_path,
                              answers_format=answers_format)
            install.install()
            printStatus("Install Successful.")

        self.nulecule_base = Nulecule_Base(target_path=self.app_path,
                                           dryrun=dryrun,
                                           file_format=answers_format)
        if "ask" in kwargs:
            self.nulecule_base.ask = kwargs["ask"]

        workdir = None
        if "workdir" in kwargs:
            workdir = kwargs["workdir"]

        self.utils = Utils(self.app_path, workdir)
        if "workdir" not in kwargs:
            kwargs["workdir"] = self.utils.workdir

        self.answers_file = answers
        self.plugin = Plugin()
        self.plugin.load_plugins()
Пример #4
0
 def _run_upgrade(self):
     self._logger.info("hooks: %s" % self._options.skip_existing_hooks)
     self._python_lib = glob.glob("%s/rootfs/usr/lib/python*"
                                  % self._tmp_dir)
     if not self._python_lib:
         raise RuntimeError("Unable to determine python path")
     self._python_lib = self._python_lib[0]
     self._tmp_python_path = "%s/site-packages/ovirtnode" \
         % self._python_lib
     shutil.copytree(self._tmp_python_path, self._ovirtnode_dir)
     # import install and ovirtfunctions modules from new image
     f, filename, description = imp.find_module(
         'install',
         [self._ovirtnode_dir],
     )
     install = imp.load_module(
         'install',
         f,
         filename,
         description,
     )
     # log module detail for debugging
     self._logger.debug(install)
     from install import Install
     upgrade = Install()
     self._logger.propagate = True
     self._logger.info("Installing Bootloader")
     if not upgrade.ovirt_boot_setup():
         raise RuntimeError("Bootloader Installation Failed")
Пример #5
0
def install(help=False):
    this_dir = os.path.dirname(os.path.realpath(__file__))
    # first we append the path with the management package
    # so we can import utils in the install module
    sys.path.append(
        os.path.join(
            this_dir,
            'snodas',
            'management',
        )
    )
    # then we add the commands package to the path
    # so we have access to the install module
    sys.path.append(
        os.path.join(
            this_dir,
            'snodas',
            'management',
            'commands',
        )
    )
    # and lastly we add the directory of this file
    # to the path so we can import from setup.py
    sys.path.append(
        os.path.join(
            this_dir,
        )
    )
    from install import Install
    if help:
        Install.print_help(sys.argv[0], sys.argv[2])
    else:
        Install.run_from_argv(sys.argv)
Пример #6
0
    def __init__(self, answers, APP, dryrun = False, debug = False, **kwargs):

        self.debug = debug
        self.dryrun = dryrun
        self.kwargs = kwargs
        if "answers_output" in kwargs:
            self.answers_output = kwargs["answers_output"]

        if os.environ and "IMAGE" in os.environ:
            self.app_path = APP
            APP = os.environ["IMAGE"]
            del os.environ["IMAGE"]

        if APP and os.path.exists(APP):
            self.app_path = APP
        else:
            self.app_path = os.getcwd()
            install = Install(answers, APP, dryrun = dryrun, target_path = self.app_path)
            install.install()

        self.params = Params(target_path=self.app_path)
        if "ask" in kwargs:
            self.params.ask = kwargs["ask"]

        self.utils = Utils(self.params)

        self.answers_file = answers
        self.plugin = Plugin()
        self.plugin.load_plugins()
Пример #7
0
    def __init__(
            self, answers, APP, dryrun=False, debug=False, stop=False,
            answers_format=ANSWERS_FILE_SAMPLE_FORMAT, **kwargs):

        self.debug = debug
        self.dryrun = dryrun
        self.stop = stop
        self.kwargs = kwargs
        self.cli_provider = None

        if "answers_output" in kwargs:
            self.answers_output = kwargs["answers_output"]

        if "cli_provider" in kwargs:
            self.cli_provider = kwargs["cli_provider"]

        if os.environ and "IMAGE" in os.environ:
            self.app_path = APP
            APP = os.environ["IMAGE"]
            del os.environ["IMAGE"]
        elif "image" in kwargs:
            logger.warning("Setting image to %s" % kwargs["image"])

            self.app_path = APP
            APP = kwargs["image"]
            del kwargs["image"]

        self.kwargs = kwargs

        if APP and os.path.exists(APP):
            self.app_path = APP
        else:
            if not self.app_path:
                self.app_path = os.getcwd()
            install = Install(
                answers, APP, dryrun=dryrun, target_path=self.app_path,
                answers_format=answers_format)
            install.install()
            printStatus("Install Successful.")

        self.nulecule_base = Nulecule_Base(
            target_path=self.app_path,
            dryrun=dryrun,
            file_format=answers_format,
            cli_provider=self.cli_provider)
        if "ask" in kwargs:
            self.nulecule_base.ask = kwargs["ask"]

        workdir = None
        if "workdir" in kwargs:
            workdir = kwargs["workdir"]

        self.utils = Utils(self.app_path, workdir)
        if "workdir" not in kwargs:
            kwargs["workdir"] = self.utils.workdir

        self.answers_file = answers
        self.plugin = Plugin()
        self.plugin.load_plugins()
Пример #8
0
    def __init__(self):
        """Initializes the Mythbuntu installer extra objects"""

        #Configure Parent cclass First so we can override things
        ParentInstall.__init__(self)

        self.lirc=LircHandler()
        self.vnc=VNCHandler()
        self.type = self.db.get('mythbuntu/install_type')

        #This forces install_langpacks to do Nothing
        self.langpacks={}
Пример #9
0
 def __check_install_fun(self):
     # 调用checkInstall函数 检查是否初始化
     if Install().check_install():
         # print('执行项目Test')
         self.__unittest_init()
     else:
         print('初始化完成')
Пример #10
0
    def __init__(self, answers, APP, dryrun = False, debug = False, stop = False, **kwargs):

        self.debug = debug
        self.dryrun = dryrun
        self.stop = stop
        self.kwargs = kwargs
        
        if "answers_output" in kwargs:
            self.answers_output = kwargs["answers_output"]

        if os.environ and "IMAGE" in os.environ:
            self.app_path = APP
            APP = os.environ["IMAGE"]
            del os.environ["IMAGE"]
        elif "image" in kwargs:
            logger.warning("Setting image to %s" % kwargs["image"])

            self.app_path = APP
            APP = kwargs["image"]
            del kwargs["image"]

        self.kwargs = kwargs

        if APP and os.path.exists(APP):
            self.app_path = APP
        else:
            if not self.app_path:
                self.app_path = os.getcwd()
            install = Install(answers, APP, dryrun = dryrun, target_path = self.app_path)
            install.install()

        self.nulecule_base = Nulecule_Base(target_path=self.app_path)
        if "ask" in kwargs:
            self.nulecule_base.ask = kwargs["ask"]

        workdir = None
        if "workdir" in kwargs:
            workdir = kwargs["workdir"]

        self.utils = Utils(self.app_path, workdir)
        if not "workdir" in kwargs:
            kwargs["workdir"] = self.utils.workdir


        self.answers_file = answers
        self.plugin = Plugin()
        self.plugin.load_plugins()
Пример #11
0
    def configure_hardware(self):
        """Overrides parent function to add in hooks for configuring
           drivers and services"""

        #Drivers
        self.db.progress('INFO', 'ubiquity/install/drivers')
        video_driver = self.db.get('mythbuntu/video_driver')
        out = self.db.get('mythbuntu/tvout')
        standard = self.db.get('mythbuntu/tvstandard')
        if 'nvidia' in video_driver:
            self.enable_nvidia(out,standard)
        elif 'fglrx' in video_driver:
            self.enable_amd(out,standard)

        #Services
        self.db.progress('INFO', 'ubiquity/install/services')
        if self.db.get('mythbuntu/samba') == 'true':
            shutil.copy('/usr/share/mythbuntu-common/examples/smb.conf.dist',self.target + '/etc/samba/smb.conf')
        if self.db.get('mythbuntu/nfs-kernel-server') == 'true':
            shutil.copy('/usr/share/mythbuntu-common/examples/exports.dist',self.target + '/etc/exports')
        if self.db.get('mythbuntu/openssh-server') == 'true':
            for file in ['ssh_host_dsa_key','ssh_host_dsa_key.pub','ssh_host_rsa_key','ssh_host_rsa_key.pub']:
                os.remove(self.target + '/etc/ssh/' + file)
            self.reconfigure('openssh-server')
        if self.db.get('mythbuntu/mysql-server') == 'true':
            f=open(self.target + '/etc/mysql/conf.d/mythtv.cnf','w')
            print >>f, """\
[mysqld]
bind-address=0.0.0.0"""
            f.close()
        if self.db.get('mythbuntu/x11vnc') == 'true':
            self.vnc.create_password(self.passwd)
            directory = self.target + '/home/' + self.user + '/.vnc'
            if not os.path.exists(directory):
                os.mkdir(directory)
            shutil.move('/root/.vnc/passwd', directory + '/passwd')
            os.system('chown ' + str(self.uid) + ':' + str(self.gid) + ' -R ' + directory)

        #Remotes & Transmitters
        self.db.progress('INFO', 'ubiquity/install/ir')
        self.configure_ir()

        #Regular parent hardware configure f/n
        self.db.progress('INFO', 'ubiquity/install/hardware')
        ParentInstall.configure_hardware(self)
Пример #12
0
 def main(self):
     if self.a.install:
         i = Install()
         i.install()
     if self.a.uninstall:
         i = Install()
         i.uninstall()
         exit("Uninstall Complete")
     if not self.a.filename:
         self.a.filename = "passwords.txt"
     if self.a.ssid or self.a.password:
         self.add_to_list(self.a.filename, self.a.ssid, self.a.password)
     w = Wifi()
Пример #13
0
    def remove_extras(self):
        """Try to remove packages that are installed on the live CD but not on
        the installed system."""
        #First remove normal live-desktop packages
        ParentInstall.remove_extras(self)

        #now take care of mythbuntu specifics
        packages=set()
        ## system role
        if 'Slave' in self.type or self.type == 'Frontend':
            packages.add('mythtv-backend-master')
        if 'Frontend' not in self.type:
            packages.add('mythtv-frontend')
        ## services that are installed by default
        for service in ['samba','openssh-server']:
            if self.db.get('mythbuntu/' + service) == "false":
                packages.add(service)

        if len(packages) >= 0:
            #recursively remove to make sure we get plugins and services that
            #aren't necessary anymore
            self.do_remove(packages,True)
Пример #14
0
class InstallTest(unittest.TestCase):
    def setUp(self):
        self.install = Install()

    def test_install_docker(self):
        self.install.install_docker()
        subprocess.check_call("docker -v", stdout=subprocess.PIPE,
                              stderr=subprocess.STDOUT, shell=True)
        a = os.system('echo $?')
        self.assertEqual(a, 0)

    def test_docker_image(self):
        self.install.docker_image()
        subprocess.check_call("docker images | grep phusion",
                              stdout=subprocess.PIPE, stderr=subprocess.STDOUT,
                              shell=True)
        a = os.system('echo $?')
        self.assertEqual(a, 0)

    def test_build_docker(self):
        self.install.build_docker()
        subprocess.check_call("docker images | grep hackademic",
                              stdout=subprocess.PIPE, stderr=subprocess.STDOUT,
                              shell=True)
        a = os.system('echo $?')
        self.assertEqual(a, 0)

    def tearDown(self):
        self.install.dispose()
        self.install = None
        subprocess.check_call("docker rmi -f hackademic",
                              stdout=subprocess.PIPE, stderr=subprocess.STDOUT,
                              shell=True)
        subprocess.check_call("sudo apt-get remove lxc-docker",
                              stdout=subprocess.PIPE, stderr=subprocess.STDOUT,
                              shell=True)
Пример #15
0
 def setUp(self):
     self.install = Install()
Пример #16
0
    def configure_user(self):
        """Configures by the regular user configuration stuff
        followed by mythbuntu specific user addons"""

        #Before beginning, set the initial root sql pass to the user pass
        self.passwd=self.db.get('passwd/user-password')
        self.set_debconf('mythtv/mysql_admin_password',self.passwd)
        self.set_debconf('mysql-server/root_password',self.passwd)
        self.set_debconf('mysql-server/root_password_again',self.passwd)

        #Regular ubuntu user configuration
        ParentInstall.configure_user(self)

        #We'll be needing the username, uid, gid
        self.user = self.db.get('passwd/username')
        self.uid = self.gid = ''
        try:
            self.uid = self.db.get('passwd/user-uid')
        except debconf.DebconfError:
            pass
        try:
            self.gid = self.db.get('passwd/user-gid')
        except debconf.DebconfError:
            pass
        if self.uid == '':
            self.uid = 1000
        else:
            self.uid = int(self.uid)
        if self.gid == '':
            self.gid = 1000
        else:
            self.gid = int(self.gid)

        #Create a .mythtv directory
        home_mythtv_dir = self.target + '/home/' + self.user + '/.mythtv'
        if not os.path.isdir(home_mythtv_dir):
            #in case someone made a symlink or file for the directory
            if os.path.islink(home_mythtv_dir) or os.path.exists(home_mythtv_dir):
                os.remove(home_mythtv_dir)
            os.mkdir(home_mythtv_dir)
            os.chown(home_mythtv_dir,self.uid,self.gid)

        #Remove mysql.txt from home directory if it's there, then make one
        sql_txt= home_mythtv_dir + '/mysql.txt'
        if os.path.islink(sql_txt) or os.path.exists(sql_txt):
            os.remove(sql_txt)
        try:
            os.symlink('/etc/mythtv/mysql.txt',sql_txt)
        except OSError:
            #on a live disk there is a chance this was a broken link
            #depending on what the user did in the livefs
            pass

        #mythtv.desktop autostart
        if 'Frontend' in self.type:
            config_dir = self.target + '/home/' + self.user + '/.config'
            autostart_dir =  config_dir + '/autostart'
            autostart_link = autostart_dir + '/mythtv.desktop'
            if not os.path.isdir(config_dir):
                os.makedirs(config_dir)
                os.chown(config_dir,self.uid,self.gid)
            if not os.path.isdir(autostart_dir):
                os.makedirs(autostart_dir)
                os.chown(autostart_dir,self.uid,self.gid)
            elif os.path.islink(autostart_link) or os.path.exists(autostart_link):
                os.remove(autostart_link)
            try:
                os.symlink('/usr/share/applications/mythtv.desktop',autostart_link)
            except OSError:
                #on a live disk, this will appear a broken link, but it works
                pass

        #group membership
        self.chrex('adduser', self.user, 'mythtv')
        self.chrex('adduser', self.user, 'video')
Пример #17
0
# -------------------------------- Procedural --------------------------------

args = processArguments()

if args.version:  # prints program legal / dev / version info
    print("Current Version: " + VERSION)
    print("Author: K4YT3X")
    print("License: GNU GPL v3")
    print("Github Page: https://github.com/K4YT3X/DefenseMatrix")
    print("Contact: [email protected]")
    print()
    exit(0)

if os.getuid() != 0:
    avalon.error("This app requires root privilege to run!")
    exit(0)


try:
    if args.install:
        installer = Install()
        installer.install()
    elif args.uninstall:
        uninstaller = Install()
        uninstaller.uninstall()
    elif args.audit:
        securityAudit.audit()
except KeyboardInterrupt:
    avalon.warning("Aborting")