Exemplo n.º 1
0
    def handle_part(self, data, ctype, filename, payload, frequency):
        if ctype in handlers.CONTENT_SIGNALS:
            return

        # See: https://bugs.launchpad.net/bugs/819507
        if frequency != PER_INSTANCE:
            return

        if not self.upstart_dir:
            return

        filename = util.clean_filename(filename)
        (_name, ext) = os.path.splitext(filename)
        if not ext:
            ext = ''
        ext = ext.lower()
        if ext != ".conf":
            filename = filename + ".conf"

        payload = util.dos2unix(payload)
        path = os.path.join(self.upstart_dir, filename)
        util.write_file(path, payload, 0o644)

        if SUITABLE_UPSTART:
            util.subp(["initctl", "reload-configuration"], capture=False)
Exemplo n.º 2
0
 def _write_part(self, payload, filename):
     filename = util.clean_filename(filename)
     filepath = os.path.join(self.boothook_dir, filename)
     contents = util.strip_prefix_suffix(util.dos2unix(payload),
                                         prefix=self.prefixes[0])
     util.write_file(filepath, contents.lstrip(), 0o700)
     return filepath
Exemplo n.º 3
0
    def handle_part(self, data, ctype, filename, payload, frequency):
        if ctype in handlers.CONTENT_SIGNALS:
            return

        # See: https://bugs.launchpad.net/bugs/819507
        if frequency != PER_INSTANCE:
            return

        if not self.upstart_dir:
            return

        filename = util.clean_filename(filename)
        (_name, ext) = os.path.splitext(filename)
        if not ext:
            ext = ''
        ext = ext.lower()
        if ext != ".conf":
            filename = filename + ".conf"

        payload = util.dos2unix(payload)
        path = os.path.join(self.upstart_dir, filename)
        util.write_file(path, payload, 0o644)

        if SUITABLE_UPSTART:
            subp.subp(["initctl", "reload-configuration"], capture=False)
Exemplo n.º 4
0
 def _write_part(self, payload, filename):
     filename = util.clean_filename(filename)
     filepath = os.path.join(self.boothook_dir, filename)
     contents = util.strip_prefix_suffix(util.dos2unix(payload),
                                         prefix=self.prefixes[0])
     util.write_file(filepath, contents.lstrip(), 0o700)
     return filepath
Exemplo n.º 5
0
    def handle_part(self, data, ctype, filename, payload, frequency):
        if ctype in handlers.CONTENT_SIGNALS:
            # TODO(harlowja): maybe delete existing things here
            return

        filename = util.clean_filename(filename)
        payload = util.dos2unix(payload)
        path = os.path.join(self.script_dir, filename)
        util.write_file(path, payload, 0o700)
Exemplo n.º 6
0
    def handle_part(self, data, ctype, filename, payload, frequency):
        if ctype in handlers.CONTENT_SIGNALS:
            # TODO(harlowja): maybe delete existing things here
            return

        filename = util.clean_filename(filename)
        payload = util.dos2unix(payload)
        path = os.path.join(self.script_dir, filename)
        util.write_file(path, payload, 0700)
Exemplo n.º 7
0
def write_script_by_frequency(script_path, payload, frequency, scripts_dir):
    """Given a filename, a payload, a frequency, and a scripts folder, write
    the payload to the correct frequency-specific path"""
    filename = os.path.basename(script_path)
    filename = util.clean_filename(filename)
    folder = get_script_folder_by_frequency(frequency, scripts_dir)
    path = os.path.join(folder, filename)
    payload = util.dos2unix(payload)
    util.write_file(path, payload, 0o700)
Exemplo n.º 8
0
 def handle_part(self, data, ctype, script_path, payload, frequency):
     if script_path is not None:
         filename = os.path.basename(script_path)
         filename = util.clean_filename(filename)
         write_script_by_frequency(script_path, payload,
                                   self.script_frequency, self.scripts_dir)