예제 #1
0
파일: main.py 프로젝트: zydudu/teleport
    def _check_installation(self):
        cc.o(' - check local installation ... ', end='')

        # old version, the daemon named `eom_ts`.
        # from 2.0.0.1, the daemon rename to `teleport`.
        # we must check both.
        if os.path.exists('/etc/init.d/eom_ts'):
            self._is_installed = True
            self._install_path = '/usr/local/eom/teleport'
            # self._fix_path()
        elif os.path.exists('/etc/init.d/teleport'):
            self._is_installed = True
            self._install_path = '/usr/local/teleport'

            with open('/etc/init.d/teleport', 'r') as f:
                lines = f.readlines()
                for l in lines:
                    if l.startswith('DAEMON_PATH='):
                        l = l.replace('\r', '')
                        l = l.replace('\n', '')
                        x = l.split('=')
                        self._install_path = x[1]
                        break

            # self._fix_path()

        if self._is_installed:
            cc.i('[{}]'.format(self._install_path))
            self._fix_path()
        else:
            cc.i('[not exists]')
            return
예제 #2
0
파일: main.py 프로젝트: zydudu/teleport
 def _start_service(self):
     cc.v('')
     cc.o('start services...')
     _ret, _ = utils.sys_exec('/etc/init.d/teleport start',
                              direct_output=True)
     if _ret != 0:
         raise RuntimeError('not all services started.')
예제 #3
0
파일: main.py 프로젝트: eomsoft/teleport
    def _stop_service(self):
        cc.o(' - stop teleport core service ... ', end='')

        # old version, the daemon named `eom_ts`.
        if os.path.exists('/etc/init.d/eom_ts'):
            utils.sys_exec('/etc/init.d/eom_ts stop')
        # from 2.0.0.1, the daemon rename to `teleport`.
        if os.path.exists('/etc/init.d/teleport'):
            utils.sys_exec('/etc/init.d/teleport stop')

        cc.i('[done]')
예제 #4
0
파일: main.py 프로젝트: zydudu/teleport
    def _stop_service(self):
        cc.o(' - stop teleport core service ... ', end='')

        # old version, the daemon named `eom_ts`.
        if os.path.exists('/etc/init.d/eom_ts'):
            utils.sys_exec('/etc/init.d/eom_ts stop')
        # from 2.0.0.1, the daemon rename to `teleport`.
        if os.path.exists('/etc/init.d/teleport'):
            utils.sys_exec('/etc/init.d/teleport stop')

        cc.i('[done]')
예제 #5
0
파일: main.py 프로젝트: stlcours/teleport-1
    def _init(self):
        _width = 79
        cc.v('')
        cc.v('[]{}[]'.format('=' * (_width - 4)))
        _str = 'Teleport Server Installation'
        cc.o((cc.CR_VERBOSE, ' | '), (cc.CR_INFO, _str),
             (cc.CR_VERBOSE, '{}|'.format(' ' * (_width - 5 - len(_str)))))
        cc.v(' |{}|'.format('=' * (_width - 4)))
        cc.o((cc.CR_VERBOSE, ' |    ver: '), (cc.CR_NORMAL, self._current_ver),
             (cc.CR_VERBOSE, '{}|'.format(
                 ' ' * (_width - 13 - len(self._current_ver)))))
        _str = 'author: [email protected]'
        cc.v(' | {}{}|'.format(_str, ' ' * (_width - 5 - len(_str))))
        cc.v('[]{}[]'.format('=' * (_width - 4)))
        cc.v('')
        cc.v('Welcome to install Teleport Server!')
        cc.v('')
        # cc.v('  NOTICE: if you want to use the default settings, just press `Enter`...')
        cc.o((
            cc.CR_VERBOSE,
            'NOTICE: There are a few steps need you enter information or make choice,\n        if you want to use the '
        ), (cc.CR_WARN, 'default settings'),
             (cc.CR_VERBOSE, ', just press `Enter` key.'))
        cc.o((cc.CR_VERBOSE, '        Otherwise you need enter the '),
             (cc.CR_NORMAL, 'highlight character'),
             (cc.CR_VERBOSE, ' to make choice.'))
        cc.v('')
        cc.v('')

        cc.v('Prepare installation...')
        self._check_installation()
        self._check_installation_ver()
        cc.v('')
예제 #6
0
파일: main.py 프로젝트: eomsoft/teleport
    def _check_service(self):
        cc.o(' - check teleport core service status ... ', end='')
        _err, _o = utils.sys_exec(r'sc query "{}"'.format(self._core_service_name))
        if _err == 1060 or _err == 0:
            cc.i('[running]')
        else:
            cc.e('[not running]')

        cc.o(' - check teleport web service status ... ', end='')
        _err, _o = utils.sys_exec(r'sc query "{}"'.format(self._web_service_name))
        if _err == 1060 or _err == 0:
            cc.i('[running]')
        else:
            cc.e('[not running]')
예제 #7
0
파일: main.py 프로젝트: eomsoft/teleport
    def _init(self):
        _width = 79
        cc.v('')
        cc.v('[]{}[]'.format('=' * (_width - 4)))
        _str = 'Teleport Server Installation'
        cc.o((cc.CR_VERBOSE, ' | '), (cc.CR_VERBOSE, _str), (cc.CR_VERBOSE, '{}|'.format(' ' * (_width - 5 - len(_str)))))
        cc.v(' |{}|'.format('=' * (_width - 4)))
        cc.o((cc.CR_VERBOSE, ' |    ver: '), (cc.CR_ERROR, self._current_ver),
             (cc.CR_VERBOSE, '{}|'.format(' ' * (_width - 13 - len(self._current_ver)))))
        _str = 'author: [email protected]'
        cc.v(' | {}{}|'.format(_str, ' ' * (_width - 5 - len(_str))))
        cc.v('[]{}[]'.format('=' * (_width - 4)))
        cc.v('')
        cc.v('Welcome to install Teleport Server!')
        cc.v('')
        cc.o((cc.CR_VERBOSE,
              'NOTICE: There are a few steps need you enter information or make choice,\n'
              '        if you want to use the DEFAULT choice, just press `Enter` key.'))
        cc.o((cc.CR_VERBOSE, '        Otherwise you need enter the '), (cc.CR_ERROR, 'highlight character'),
             (cc.CR_VERBOSE, ' to make choice.'))
        cc.v('')
        cc.v('')

        cc.v('Prepare installation...')
        self._check_installation()
        self._check_installation_ver()
        cc.v('')
예제 #8
0
파일: main.py 프로젝트: zydudu/teleport
    def _init(self):
        _width = 79
        cc.v('')
        cc.v('[]{}[]'.format('=' * (_width - 4)))
        _str = 'Teleport Server Installation'
        cc.o((cc.CR_VERBOSE, ' | '), (cc.CR_VERBOSE, _str),
             (cc.CR_VERBOSE, '{}|'.format(' ' * (_width - 5 - len(_str)))))
        cc.v(' |{}|'.format('=' * (_width - 4)))
        cc.o((cc.CR_VERBOSE, ' |    ver: '), (cc.CR_ERROR, self._current_ver),
             (cc.CR_VERBOSE, '{}|'.format(
                 ' ' * (_width - 13 - len(self._current_ver)))))
        _str = 'author: [email protected]'
        cc.v(' | {}{}|'.format(_str, ' ' * (_width - 5 - len(_str))))
        cc.v('[]{}[]'.format('=' * (_width - 4)))
        cc.v('')
        cc.v('Welcome to install Teleport Server!')
        cc.v('')
        cc.o((
            cc.CR_VERBOSE,
            'NOTICE: There are a few steps need you enter information or make choice,\n'
            '        if you want to use the DEFAULT choice, just press `Enter` key.'
        ))
        cc.o((cc.CR_VERBOSE, '        Otherwise you need enter the '),
             (cc.CR_ERROR, 'highlight character'),
             (cc.CR_VERBOSE, ' to make choice.'))
        cc.v('')
        cc.v('')

        cc.v('Prepare installation...')
        self._check_installation()
        self._check_installation_ver()
        cc.v('')
예제 #9
0
파일: main.py 프로젝트: eomsoft/teleport
    def _uninstall_service(self):
        _check_service_name = [self._old_core_service_name, self._old_web_service_name, self._core_service_name,
                               self._web_service_name]

        for _service_name in _check_service_name:
            cc.o(' - remove service [{}] ... '.format(_service_name), end='')
            _err, _ = utils.sys_exec(r'sc delete "{}"'.format(_service_name))
            if _err == 1060 or _err == 0:
                cc.i('[done]')
            elif _err == 1072:
                cc.e('[failed]')
                raise RuntimeError('can not remove service [{}]. please close Service Manager and try again.'.format(_service_name))
            else:
                cc.e('[failed]')
                raise RuntimeError('can not remove service [{}].'.format(_service_name))
예제 #10
0
파일: main.py 프로젝트: zydudu/teleport
    def _check_service(self):
        cc.o(' - check teleport core service status ... ', end='')
        _err, _o = utils.sys_exec(r'sc query "{}"'.format(
            self._core_service_name))
        if _err == 1060 or _err == 0:
            cc.i('[running]')
        else:
            cc.e('[not running]')

        cc.o(' - check teleport web service status ... ', end='')
        _err, _o = utils.sys_exec(r'sc query "{}"'.format(
            self._web_service_name))
        if _err == 1060 or _err == 0:
            cc.i('[running]')
        else:
            cc.e('[not running]')
예제 #11
0
파일: main.py 프로젝트: eomsoft/teleport
    def _start_service(self):
        cc.o(' - start teleport core service ... ', end='')
        _err, _o = utils.sys_exec(r'sc start "{}"'.format(self._core_service_name))
        # print('start core', _err, _o)
        if _err == 0:
            cc.i('[done]')
        else:
            cc.e('[failed]')
            raise RuntimeError('Can not start core service.')

        cc.o(' - start teleport web service ...', end='')
        _err, _ = utils.sys_exec(r'sc start "{}"'.format(self._web_service_name))
        if _err == 0:
            cc.i('[done]')
        else:
            cc.e('[failed]')
            raise RuntimeError('Can not start web service.')
예제 #12
0
파일: main.py 프로젝트: eomsoft/teleport
    def _check_installation(self):
        cc.o(' - check local installation ... ', end='')

        _check_service_name = [self._old_core_service_name, self._old_web_service_name, self._core_service_name,
                               self._web_service_name]
        for _service_name in _check_service_name:
            _exec_file = self._get_service_exec(_service_name)
            if _exec_file is not None:
                self._is_installed = True
                self._install_path = os.path.abspath(os.path.join(os.path.dirname(_exec_file), '..'))
                break

        if self._is_installed:
            cc.i('[{}]'.format(self._install_path))
            self._fix_path()
        else:
            cc.i('[not exists]')
            return
예제 #13
0
파일: main.py 프로젝트: zydudu/teleport
    def _start_service(self):
        cc.o(' - start teleport core service ... ', end='')
        _err, _o = utils.sys_exec(r'sc start "{}"'.format(
            self._core_service_name))
        # print('start core', _err, _o)
        if _err == 0:
            cc.i('[done]')
        else:
            cc.e('[failed]')
            raise RuntimeError('Can not start core service.')

        cc.o(' - start teleport web service ...', end='')
        _err, _ = utils.sys_exec(r'sc start "{}"'.format(
            self._web_service_name))
        if _err == 0:
            cc.i('[done]')
        else:
            cc.e('[failed]')
            raise RuntimeError('Can not start web service.')
예제 #14
0
파일: main.py 프로젝트: eomsoft/teleport
    def _install_service(self):
        cc.o(' - install teleport core service ... ', end='')
        _core = os.path.join(self._install_path, 'bin', 'tp_core.exe')
        _err, _ = utils.sys_exec(r'"{}" -i'.format(_core))
        if _err == 0 or _err == 1:
            cc.i('[done]')
        else:
            cc.e('[failed]')
            raise RuntimeError('Install core service failed. error code: {}'.format(_err))

        cc.o(' - install teleport web service ... ', end='')
        _core = os.path.join(self._install_path, 'bin', 'tp_web.exe')
        _err, _ = utils.sys_exec(r'"{}" -i'.format(_core))
        if _err == 0 or _err == 1:
            cc.i('[done]')
        else:
            cc.e('[failed]')
            raise RuntimeError('Install web service failed. error code: {}'.format(_err))

        return True
예제 #15
0
파일: main.py 프로젝트: zydudu/teleport
    def _uninstall_service(self):
        _check_service_name = [
            self._old_core_service_name, self._old_web_service_name,
            self._core_service_name, self._web_service_name
        ]

        for _service_name in _check_service_name:
            cc.o(' - remove service [{}] ... '.format(_service_name), end='')
            _err, _ = utils.sys_exec(r'sc delete "{}"'.format(_service_name))
            if _err == 1060 or _err == 0:
                cc.i('[done]')
            elif _err == 1072:
                cc.e('[failed]')
                raise RuntimeError(
                    'can not remove service [{}]. please close Service Manager and try again.'
                    .format(_service_name))
            else:
                cc.e('[failed]')
                raise RuntimeError(
                    'can not remove service [{}].'.format(_service_name))
예제 #16
0
파일: main.py 프로젝트: eomsoft/teleport
    def _check_installation_ver(self):
        if not self._is_installed:
            return

        # try to get the installed version from www/teleport/app/eom_ver.py
        cc.o(' - check installed version ... ', end='')
        ver_file = os.path.join(self._install_path, 'www', 'teleport', 'webroot', 'app', 'app_ver.py')
        try:
            with open(ver_file) as f:
                x = f.readlines()
                for i in x:
                    s = i.split('=', 1)
                    if 'TP_SERVER_VER' == s[0].strip():
                        self._installed_ver_str = s[1].strip()[1:-1]
                        cc.i('[{}]'.format(self._installed_ver_str))
                        # self._installed_ver = self._ver_str_to_ver(self._installed_ver_str)
                        break
        except FileNotFoundError:
            cc.e('[failed]')
            cc.e('   the installation maybe broken')
예제 #17
0
파일: main.py 프로젝트: zydudu/teleport
    def _check_installation_ver(self):
        if not self._is_installed:
            return

        # try to get the installed version from www/teleport/app/eom_ver.py
        cc.o(' - check installed version ... ', end='')
        ver_file = os.path.join(self._install_path, 'www', 'teleport',
                                'webroot', 'app', 'app_ver.py')
        try:
            with open(ver_file) as f:
                x = f.readlines()
                for i in x:
                    s = i.split('=', 1)
                    if 'TP_SERVER_VER' == s[0].strip():
                        self._installed_ver_str = s[1].strip()[1:-1]
                        cc.i('[{}]'.format(self._installed_ver_str))
                        # self._installed_ver = self._ver_str_to_ver(self._installed_ver_str)
                        break
        except FileNotFoundError:
            cc.e('[failed]')
            cc.e('   the installation maybe broken')
예제 #18
0
파일: main.py 프로젝트: eomsoft/teleport
    def _check_installation(self):
        cc.o(' - check local installation ... ', end='')

        # old version, the daemon named `eom_ts`.
        # from 2.0.0.1, the daemon rename to `teleport`.
        # we must check both.
        if os.path.exists('/etc/init.d/eom_ts'):
            self._is_installed = True
            self._install_path = '/usr/local/eom/teleport'
            # self._fix_path()
        elif os.path.exists('/etc/init.d/teleport'):
            self._is_installed = True
            self._install_path = '/usr/local/teleport'
            # self._fix_path()

        if self._is_installed:
            cc.i('[{}]'.format(self._install_path))
            self._fix_path()
        else:
            cc.i('[not exists]')
            return
예제 #19
0
파일: main.py 프로젝트: zydudu/teleport
    def _check_installation(self):
        cc.o(' - check local installation ... ', end='')

        _check_service_name = [
            self._old_core_service_name, self._old_web_service_name,
            self._core_service_name, self._web_service_name
        ]
        for _service_name in _check_service_name:
            _exec_file = self._get_service_exec(_service_name)
            if _exec_file is not None:
                self._is_installed = True
                self._install_path = os.path.abspath(
                    os.path.join(os.path.dirname(_exec_file), '..'))
                break

        if self._is_installed:
            cc.i('[{}]'.format(self._install_path))
            self._fix_path()
        else:
            cc.i('[not exists]')
            return
예제 #20
0
파일: main.py 프로젝트: stlcours/teleport-1
    def _check_installation(self):
        cc.o(' - check local installation ... ', end='')

        # old version, the daemon named `eom_ts`.
        # from 2.0.0.1, the daemon rename to `teleport`.
        # we must check both.
        if os.path.exists('/etc/init.d/eom_ts'):
            self._is_installed = True
            self._install_path = '/usr/local/eom/teleport'
            # self._fix_path()
        elif os.path.exists('/etc/init.d/teleport'):
            self._is_installed = True
            self._install_path = '/usr/local/teleport'
            # self._fix_path()

        if self._is_installed:
            cc.i('[{}]'.format(self._install_path))
            self._fix_path()
        else:
            cc.i('[not exists]')
            return
예제 #21
0
파일: main.py 프로젝트: zydudu/teleport
    def _install_service(self):
        cc.o(' - install teleport core service ... ', end='')
        _core = os.path.join(self._install_path, 'bin', 'tp_core.exe')
        _err, _ = utils.sys_exec(r'"{}" -i'.format(_core))
        if _err == 0 or _err == 1:
            cc.i('[done]')
        else:
            cc.e('[failed]')
            raise RuntimeError(
                'Install core service failed. error code: {}'.format(_err))

        cc.o(' - install teleport web service ... ', end='')
        _core = os.path.join(self._install_path, 'bin', 'tp_web.exe')
        _err, _ = utils.sys_exec(r'"{}" -i'.format(_core))
        if _err == 0 or _err == 1:
            cc.i('[done]')
        else:
            cc.e('[failed]')
            raise RuntimeError(
                'Install web service failed. error code: {}'.format(_err))

        return True
예제 #22
0
 def build_player(self):
     cc.o('skip build tp_player now...')
예제 #23
0
파일: main.py 프로젝트: zydudu/teleport
 def _check_service(self):
     cc.v('')
     cc.o('check services status...')
     utils.sys_exec('/etc/init.d/teleport status', direct_output=True)
예제 #24
0
파일: main.py 프로젝트: eomsoft/teleport
 def _start_service(self):
     cc.v('')
     cc.o('start services...')
     _ret, _ = utils.sys_exec('/etc/init.d/teleport start', direct_output=True)
     if _ret != 0:
         raise RuntimeError('not all services started.')
예제 #25
0
파일: main.py 프로젝트: eomsoft/teleport
 def _check_service(self):
     cc.v('')
     cc.o('check services status...')
     utils.sys_exec('/etc/init.d/teleport status', direct_output=True)