예제 #1
0
파일: ppp.py 프로젝트: ed-aicradle/monotone
    def _start_mgetty(self):
        inittab = InittabManager()
        port = self._get_port_name()
        gname = 'MPX_MGETTY_%s' % port.upper()

        if self.enable:
            loglevel = 0
            if self.debug:
                loglevel = 9
            else:
                # Remove stale mgetty log if not debugging.  No sense using
                # TARGET_ROOT here since mgetty doesn't know anything about it.
                logfile = "/var/log/mgetty.log.%s" % port
                if os.path.isfile(logfile):
                    os.remove(logfile)

            tag = port[-2:]
            if not inittab.findgroup(gname):
                inittab.addgroup(
                    InittabGroup(
                        gname, '%s:2345:respawn:/sbin/mgetty -x %d -n 1 %s' %
                        (tag, loglevel, port)))
        else:
            inittab.remgroup(gname)

        inittab.commit()
예제 #2
0
파일: ppp.py 프로젝트: mcruse/monotone
    def _start_mgetty( self ):
        inittab = InittabManager()
        port = self._get_port_name()
        gname = 'MPX_MGETTY_%s' % port.upper()

        if self.enable:
            loglevel = 0
            if self.debug:
                loglevel = 9
            else:
                # Remove stale mgetty log if not debugging.  No sense using
                # TARGET_ROOT here since mgetty doesn't know anything about it.
                logfile = "/var/log/mgetty.log.%s" % port
                if os.path.isfile( logfile ):
                    os.remove( logfile )

            tag = port[-2:]
            if not inittab.findgroup( gname ):
                inittab.addgroup(
                    InittabGroup(gname,
                                 '%s:2345:respawn:/sbin/mgetty -x %d -n 1 %s'
                                 % (tag, loglevel, port))
                    )
        else:
            inittab.remgroup( gname )

        inittab.commit()
예제 #3
0
 def _start_ppp_program(self):
     inittab = InittabManager()
     port_name = self._getPortName()
     tag = port_name[-2:]
     gname = 'MPX_MGETTY_%s' % port_name.upper()
     if self.enable:
         if not inittab.findgroup(gname):
             inittab.addgroup(
                 InittabGroup(
                     gname, '%s:2345:respawn:/sbin/mgetty -x 0 -n 1 %s' %
                     (tag, port_name)))
     else:
         inittab.remgroup(gname)
     inittab.commit()
 def _update_inittab(self):
     # @todo Support xinit.d enabling/disabling as well.
     wdt = os.path.join(BIN_DIR, 'wdt')
     wdt_key = 'HW_WATCHDOG'
     blinky_bill = os.path.join(BIN_DIR, 'blinky_bill')
     blinky_key = 'MPX_STATUS_LED'
     proftpd = '/usr/sbin/proftpd'
     proftpd_key = 'MPX_FTPD'
     service_map = {
         wdt_key: {
             'delete_all': '^([^:]*):([^:]*):([^:]*):(.*\\bwdt\\b.*)',
             'add': ('wdt:2345:once:%s' % wdt)
         },
         blinky_key: {
             'delete_all':
             '^([^:]*):([^:]*):([^:]*):(.*\\bblinky_bill\\b.*)',
             'add': ('led:2345:respawn:%s' % blinky_bill)
         },
         proftpd_key: {
             'delete_all':
             '^([^:]*):([^:]*):([^:]*):(.*\\b\\Sproftpd\\b.*)',
             'add': ('%s%sftpd:2345:respawn:%s -n' %
                     (InittabGroup.ENTRY_DISABLED_TAG, InittabGroup.TAG_SEP,
                      proftpd))
         },
         'MPX_APP': {
             'delete_all': ('^([^:]*):([^:]*):([^:]*):(.*\\b%s\\b.*)' %
                            os.path.basename(RC_MFW_SCRIPT)),
             'add': ('mfw:345:respawn:%s >/dev/null' % RC_MFW_SCRIPT)
         },
     }
     for f, k in ((wdt, wdt_key), (blinky_bill, blinky_key), (proftpd,
                                                              proftpd_key)):
         if not os.path.exists(f):
             service_map[k].pop('add', None)
     inittab = InittabManager()
     for gname in service_map.keys():
         inittab.remgroup(gname)
         inittab.delete_matching_lines(service_map[gname]['delete_all'])
         if service_map[gname].has_key('add'):
             inittab.addgroup(InittabGroup(gname,
                                           service_map[gname]['add']))
     inittab.commit()
     return
예제 #5
0
 def _start_ppp_program( self ):
     inittab = InittabManager()
     port_name = self._getPortName()
     tag = port_name[-2:]
     gname = 'MPX_MGETTY_%s' % port_name.upper()
     if self.enable:
         if not inittab.findgroup( gname ):
             inittab.addgroup( 
                 InittabGroup( gname, '%s:2345:respawn:/sbin/mgetty -x 0 -n 1 %s' % (tag, port_name) ) )
     else:
         inittab.remgroup( gname )
     inittab.commit()
예제 #6
0
    def _configure_webdev_ftp(self, enable_webdev_user):
        my_node_url = as_node_url(self)
        inittab = InittabManager()
        assert inittab.has_key("MPX_FTPD"), (
            "inittab must contain an MPX_FTPD group, run " +
            "moab/linux/broadway.moab.linux.install from it's local directory."
        )
        daemon_name = 'ftpd'
        group = inittab["MPX_FTPD"]
        nodes = group.subset("REQUIRED_BY")
        has_my_node = nodes.has_item(my_node_url)
        docommit = 0
        if enable_webdev_user:
            if not has_my_node:
                nodes.add_item(my_node_url)
                docommit = 1
        else:
            if has_my_node:
                nodes.remove_item(my_node_url)
                docommit = 1
        is_already_enabled = group.is_daemon_enabled(daemon_name)

        if nodes.num_items() > 0:
            # There are nodes requiring MPX_FTPD.  Enable it, if it wasn't
            # already.
            if not is_already_enabled:
                group.enable_daemon(daemon_name)
                docommit = 1
        else:
            # No nodes require MPX_FTPD.  Disable it, if it wasn't already.
            if is_already_enabled:
                group.disable_daemon(daemon_name)
                docommit = 1
        if docommit:
            inittab.commit()
        return
 def install(self):
     #
     # Note:  Unfortunately the following two import statements have
     #        the side-effect of trying to create a directory under
     #        /var/mpx.  This isn't necessary when just trying to
     #        query this install script and in fact fails in some
     #        cases, so the imports were moved from the top of this
     #        script to here.
     #
     from moab.linux.lib.servicemgr import InittabManager
     from moab.linux.lib.servicemgr import InittabGroup
     
     chown(ROOT, MPX_UID, MPX_GID, recurse=1, ignore_errors=1)
     keywords = {}
     keywords.update(self.keywords)
     keywords.update({'ROOT':DUP_DIR})
     keywords[CommandKeywords.FATAL_KEY] = 1
     # Duplicate the config service so it will work after /usr/lib/broadway
     # is nuked.
     makedirs(DUP_DIR)
     os.system("cp *.pyc %s" % DUP_DIR, **keywords)
     chown(DUP_DIR, MPX_UID, MPX_GID, recurse=1, ignore_errors=1)
     os.system("chmod -R %o %s/*" % (0664, DUP_DIR), **keywords)
     # Create the config_service's custom launcher.
     create_pyscript(CONFIG_SCRIPT, CONFIG_PYC, **keywords)
     # Update inittab to include the new config service.
     inittab = InittabManager(**keywords)
     gname = 'MEDIATOR_CONFIGURATION_SERVICE'
     # Remove any existing mpx_igmp entry.
     for group in inittab.group_list:
         lines = group.text.split('\n')
         found = 0
         for i in range(0, len(lines)):
             line = lines[i]
             if line and line[0] != '#' and line.find('mpx_igmp') != -1:
                 lines[i] = "# %s # - %s" % (line, gname)
                 found = 1
         if found:
             text = lines.pop(0)
             for line in lines:
                 text = "%s\n%s" % (text, line)
             group.text = text
     # Add the Mediator Configuration Service.
     mcs = inittab.findgroup(gname)
     text = 'MCS:2345:respawn:%s' % CONFIG_SCRIPT
     if mcs is None:
         inittab.addgroup(InittabGroup(gname, text))
     else:
         mcs.text = text
     inittab.commit()
     return 0
예제 #8
0
파일: webdev.py 프로젝트: mcruse/monotone
 def _configure_webdev_ftp(self, enable_webdev_user):
     my_node_url = as_node_url(self)
     inittab = InittabManager()
     assert inittab.has_key("MPX_FTPD"), (
         "inittab must contain an MPX_FTPD group, run " +
         "moab/linux/broadway.moab.linux.install from it's local directory."
         )
     daemon_name = 'ftpd'
     group = inittab["MPX_FTPD"]
     nodes = group.subset("REQUIRED_BY")
     has_my_node = nodes.has_item(my_node_url)
     docommit = 0
     if enable_webdev_user:
         if not has_my_node:
             nodes.add_item(my_node_url)
             docommit = 1
     else:
         if has_my_node:
             nodes.remove_item(my_node_url)
             docommit = 1
     is_already_enabled = group.is_daemon_enabled(daemon_name)
     
     if nodes.num_items() > 0:
         # There are nodes requiring MPX_FTPD.  Enable it, if it wasn't
         # already.
         if not is_already_enabled:
             group.enable_daemon(daemon_name)
             docommit = 1
     else:
         # No nodes require MPX_FTPD.  Disable it, if it wasn't already.
         if is_already_enabled:
             group.disable_daemon(daemon_name)
             docommit = 1
     if docommit:
         inittab.commit()
     return
예제 #9
0
 def _update_inittab(self):
     # @todo Support xinit.d enabling/disabling as well.
     wdt = os.path.join(BIN_DIR, "wdt")
     wdt_key = "HW_WATCHDOG"
     blinky_bill = os.path.join(BIN_DIR, "blinky_bill")
     blinky_key = "MPX_STATUS_LED"
     proftpd = "/usr/sbin/proftpd"
     proftpd_key = "MPX_FTPD"
     service_map = {
         wdt_key: {"delete_all": "^([^:]*):([^:]*):([^:]*):(.*\\bwdt\\b.*)", "add": ("wdt:2345:once:%s" % wdt)},
         blinky_key: {
             "delete_all": "^([^:]*):([^:]*):([^:]*):(.*\\bblinky_bill\\b.*)",
             "add": ("led:2345:respawn:%s" % blinky_bill),
         },
         proftpd_key: {
             "delete_all": "^([^:]*):([^:]*):([^:]*):(.*\\b\\Sproftpd\\b.*)",
             "add": (
                 "%s%sftpd:2345:respawn:%s -n" % (InittabGroup.ENTRY_DISABLED_TAG, InittabGroup.TAG_SEP, proftpd)
             ),
         },
         "MPX_APP": {
             "delete_all": ("^([^:]*):([^:]*):([^:]*):(.*\\b%s\\b.*)" % os.path.basename(RC_MFW_SCRIPT)),
             "add": ("mfw:345:respawn:%s >/dev/null" % RC_MFW_SCRIPT),
         },
     }
     for f, k in ((wdt, wdt_key), (blinky_bill, blinky_key), (proftpd, proftpd_key)):
         if not os.path.exists(f):
             service_map[k].pop("add", None)
     inittab = InittabManager()
     for gname in service_map.keys():
         inittab.remgroup(gname)
         inittab.delete_matching_lines(service_map[gname]["delete_all"])
         if service_map[gname].has_key("add"):
             inittab.addgroup(InittabGroup(gname, service_map[gname]["add"]))
     inittab.commit()
     return