コード例 #1
0
ファイル: PublisherHooks.py プロジェクト: codecwatch/OSCIED
    def hook_config_changed(self):
        cfg, local_cfg = self.config, self.local_config

        self.info(u'Configure Apache 2')
        self.info(u'{0} Apache H.264 streaming module'.format(u'Enable' if cfg.mod_streaming else u'Disable'))
        mods = (u'LoadModule h264_streaming_module /usr/lib/apache2/modules/mod_h264_streaming.so',
                u'AddHandler h264-streaming.extensions .mp4')
        lines = filter(lambda l: l not in mods, open(local_cfg.apache_config_file, u'r', u'utf-8'))
        if cfg.mod_streaming:
            lines += u'\n'.join(mods) + u'\n'
            if not local_cfg.mod_streaming_installed:
                self.info(u'Compile and install Apache H.264 streaming module')
                mod = u'mod_h264_streaming-2.2.7'
                apxs2 = self.cmd(u'which apxs2')[u'stdout']
                make(u'apache_{0}.tar.gz'.format(mod), path=mod, configure_options=u'--with-apxs={0}'.format(apxs2),
                     install=True, remove_temporary=True, log=self.debug)
                local_cfg.mod_streaming_installed = True
        open(local_cfg.apache_config_file, u'w', u'utf-8').write(u''.join(lines))

        infos = {u'publish_path': self.publish_path}
        self.template2config(local_cfg.site_template_file,     local_cfg.site_file, infos)
        self.template2config(local_cfg.site_ssl_template_file, local_cfg.site_ssl_file, infos)
        local_cfg.www_root_path = cfg.www_root_path
        self.storage_remount()
        self.subordinate_register()
コード例 #2
0
 def hook_install(self):
     self.hook_uninstall()
     self.generate_locales((u'fr_CH.UTF-8',))
     self.install_packages(TransformHooks.PACKAGES, ppas=self.PPAS)
     self.restart_ntp()
     # FIXME Compile and install openSVCDecoder
     if 'tar.bz2' in self.config.open_hevc_origin:
         self.info(u'Compile and install openHEVC from archive {0}'.format(self.config.open_hevc_origin))
         self.cmd(u'apt-get -y install cmake')
         self.debug(make(self.config.open_hevc_origin, with_cmake=True, log=self.debug)['cmake'])
     if 'tar.bz2' in self.config.x264_origin:
         self.info(u'Compile and install x264')
         self.cmd(u'apt-get -y build-dep x264')
         self.debug(make(self.config.x264_origin, configure_options=u'--enable-shared', log=self.debug)['configure'])
     else:
         self.info(u'Install x264')
         self.cmd(u'apt-get -y install x264')
     if 'tar.bz2' in self.config.ffmpeg_origin:
         self.info(u'Compile and install ffmpeg from archive {0}'.format(self.config.ffmpeg_origin))
         self.cmd(u'apt-get -y install {0}'.format(u' '.join(TransformHooks.FF_ALL_PACKAGES)))
         self.cmd(u'apt-get -y remove {0}'.format(u' '.join(TransformHooks.FF_RMV_PACKAGES)))
         self.debug(make(self.config.ffmpeg_origin, configure_options=TransformHooks.FF_CONFIGURE_OPTIONS,
                    log=self.debug)['configure'])
     else:
         self.info(u'Install ffmpeg')
         self.cmd(u'apt-get -y install ffmpeg')
     if 'tar.bz2' in self.config.gpac_origin:
         self.info(u'Compile and install GPAC/DashCast from archive {0}'.format(self.config.gpac_origin))
         self.cmd(u'apt-get -y build-dep gpac')
         self.debug(make(u'gpac.tar.bz2', log=self.debug)['configure'])
     elif 'deb' in self.config.gpac_origin:
         self.info(u'Install GPAC/DashCast from debian package {0}'.format(self.config.gpac_origin))
         self.cmd(u'dpkg -i {0}'.format(self.config.gpac_origin), fail=False)
         self.cmd(u'apt-get -y -f install')
         self.cmd(u'dpkg -i {0}'.format(self.config.gpac_origin), fail=False)  # Reinstall package if removed !
     else:
         self.info(u'Install GPAC/DashCast')
         self.cmd(u'apt-get -y install gpac')