mirror of https://github.com/tp4a/teleport
now we can make final installer package of teleport server for windows with zip format.
parent
f88a21a2b0
commit
4b594ed274
|
@ -28,6 +28,7 @@ __pycache__
|
|||
**/.idea/watcherTasks.xml
|
||||
**/.idea/codeStyleSettings.xml
|
||||
**/.idea/inspectionProfiles
|
||||
**/.idea/vcs.xml
|
||||
|
||||
# for tmp folder or files.
|
||||
/out
|
||||
|
@ -37,33 +38,38 @@ __pycache__
|
|||
/external/mongoose
|
||||
/external/openssl
|
||||
/external/python
|
||||
/external/libssh-win-static/include/libssh
|
||||
/external/libssh-win-static/src
|
||||
/external/libssh-win-static/lib
|
||||
/external/mbedtls
|
||||
/external/sqlite
|
||||
/client/tools/putty
|
||||
/client/tools/winscp
|
||||
|
||||
|
||||
# for dist folder
|
||||
/dist/*.zip
|
||||
/dist/*.tar.gz
|
||||
/dist/installer/linux/server/_tmp_
|
||||
**/_tmp_
|
||||
# /dist/*.zip
|
||||
# /dist/*.tar.gz
|
||||
/dist/windows/server/script/data
|
||||
/dist/windows/client/assist/apps
|
||||
/dist/windows/client/assist/cfg
|
||||
|
||||
/server/share/data/ts_db.db
|
||||
/server/share/data/replay
|
||||
/server/share/etc/core.ini
|
||||
/server/share/etc/web.ini
|
||||
# /server/share/data/ts_db.db
|
||||
/server/share/data
|
||||
/server/share/log
|
||||
# /server/share/data/replay
|
||||
/server/www/teleport/.idea/vcs.xml
|
||||
/server/www/teleport/static/js/var.js
|
||||
# /server/www/teleport/static/js/var.js
|
||||
/server/www/packages/packages-windows/x64
|
||||
|
||||
|
||||
# for generated files.
|
||||
/config.ini
|
||||
/build.bat
|
||||
|
||||
# for not finished code
|
||||
/common/libex/test
|
||||
/external/mbedtls
|
||||
/external/sqlite
|
||||
/server/share/etc/core.ini
|
||||
/server/share/etc/web.ini
|
||||
/client/tp_rdp
|
||||
/external/libssh-win-static/lib
|
||||
/server/share/log
|
||||
/config.ini
|
||||
/build.bat
|
||||
/dist/windows/client/assist/apps
|
||||
/dist/windows/client/assist/cfg
|
||||
/client/tools/putty
|
||||
/client/tools/winscp
|
||||
/external/libssh-win-static/include/libssh
|
||||
/external/libssh-win-static/src
|
||||
|
|
|
@ -1,4 +1,3 @@
|
|||
#!/bin/env python3
|
||||
# -*- coding: utf-8 -*-
|
||||
|
||||
import shutil
|
||||
|
@ -6,13 +5,12 @@ import shutil
|
|||
from core import colorconsole as cc
|
||||
from core import makepyo
|
||||
from core import utils
|
||||
from core.env import env
|
||||
from core.context import *
|
||||
from core.ver import *
|
||||
|
||||
ctx = BuildContext()
|
||||
|
||||
ROOT_PATH = utils.cfg.ROOT_PATH
|
||||
|
||||
|
||||
# COMMON_MODULES = ['paste', 'pyasn1', 'pymemcache', 'pymysql', 'rsa', 'tornado', 'six.py']
|
||||
|
||||
|
@ -26,9 +24,9 @@ class BuilderBase:
|
|||
|
||||
def _build_web(self, base_path, dist, target_path):
|
||||
cc.n('make Teleport Web package...')
|
||||
# src_path = os.path.join(ROOT_PATH, 'server', 'www', 'teleport')
|
||||
# pkg_path = os.path.join(ROOT_PATH, 'server', 'www', 'packages')
|
||||
src_path = os.path.join(ROOT_PATH, 'server', 'www')
|
||||
# src_path = os.path.join(env.root_path, 'server', 'www', 'teleport')
|
||||
# pkg_path = os.path.join(env.root_path, 'server', 'www', 'packages')
|
||||
src_path = os.path.join(env.root_path, 'server', 'www')
|
||||
pkg_path = os.path.join(src_path, 'packages')
|
||||
tmp_path = os.path.join(base_path, '_tmp_web_')
|
||||
|
||||
|
@ -50,14 +48,18 @@ class BuilderBase:
|
|||
# shutil.copy(s, t)
|
||||
|
||||
cc.n(' - copy packages...')
|
||||
pkgs = ['packages-common', 'packages-{}'.format(dist)]
|
||||
for d in pkgs:
|
||||
s = os.path.join(pkg_path, d)
|
||||
t = os.path.join(tmp_path, 'packages', d)
|
||||
if os.path.isdir(s):
|
||||
shutil.copytree(s, t)
|
||||
else:
|
||||
shutil.copy(s, t)
|
||||
utils.copy_ex(pkg_path, os.path.join(tmp_path, 'packages'), 'packages-common')
|
||||
utils.copy_ex(os.path.join(pkg_path, 'packages-{}'.format(dist)), os.path.join(tmp_path, 'packages', 'packages-{}'.format(dist)), ctx.bits_path)
|
||||
|
||||
|
||||
# pkgs = ['packages-common', 'packages-{}'.format(dist)]
|
||||
# for d in pkgs:
|
||||
# s = os.path.join(pkg_path, d)
|
||||
# t = os.path.join(tmp_path, 'packages', d)
|
||||
# if os.path.isdir(s):
|
||||
# shutil.copytree(s, t)
|
||||
# else:
|
||||
# shutil.copy(s, t)
|
||||
|
||||
makepyo.remove_cache(tmp_path)
|
||||
|
||||
|
@ -73,7 +75,7 @@ class BuilderBase:
|
|||
|
||||
# if not os.path.exists(os.path.join(tmp_path, 'static', 'download')):
|
||||
# utils.makedirs(os.path.join(tmp_path, 'static', 'download'))
|
||||
# utils.copy_file(os.path.join(ROOT_PATH, 'dist'), os.path.join(tmp_path, 'static', 'download'), 'teleport-assist-win.zip')
|
||||
# utils.copy_file(os.path.join(env.root_path, 'dist'), os.path.join(tmp_path, 'static', 'download'), 'teleport-assist-win.zip')
|
||||
|
||||
shutil.copytree(tmp_path, os.path.join(target_path, 'www'))
|
||||
utils.remove(tmp_path)
|
||||
|
@ -82,15 +84,15 @@ class BuilderBase:
|
|||
class BuilderWin(BuilderBase):
|
||||
def __init__(self):
|
||||
super().__init__()
|
||||
|
||||
# now = time.localtime(time.time())
|
||||
# _ver = '1.0.{:2d}.{:d}{:02d}'.format(now.tm_year - 2000, now.tm_mon, now.tm_mday)
|
||||
# self.name = 'teleport-server-windows-{}-{}'.format(ctx.bits_path, _ver)
|
||||
self.name = 'teleport-server-windows-{}-{}'.format(ctx.bits_path, VER_TELEPORT_SERVER)
|
||||
self._final_file = os.path.join(env.root_path, 'out', 'installer', '{}.zip'.format(self.name))
|
||||
|
||||
self.base_path = os.path.join(ROOT_PATH, 'dist', 'installer', ctx.dist, 'server')
|
||||
self.dist_path = os.path.join(env.root_path, 'dist', ctx.dist, 'server')
|
||||
self.base_path = os.path.join(env.root_path, 'out', 'installer')
|
||||
self.base_tmp = os.path.join(self.base_path, '_tmp_')
|
||||
self.tmp_path = os.path.join(self.base_tmp, self.name, 'data', 'teleport')
|
||||
|
||||
self.path_tmp = os.path.join(self.base_tmp, self.name)
|
||||
self.path_tmp_data = os.path.join(self.path_tmp, 'data')
|
||||
|
||||
def build_installer(self):
|
||||
cc.n('make teleport installer package...')
|
||||
|
@ -98,78 +100,45 @@ class BuilderWin(BuilderBase):
|
|||
if os.path.exists(self.base_tmp):
|
||||
utils.remove(self.base_tmp)
|
||||
|
||||
# self._build_web_backend(self.base_path, 'windows', self.tmp_path)
|
||||
# utils.copy_file(os.path.join(ROOT_PATH, 'share', 'etc'), os.path.join(self.tmp_path, 'tmp', 'etc'), 'web-backend.conf')
|
||||
#
|
||||
# self._build_web_frontend(self.base_path, 'windows', self.tmp_path)
|
||||
# utils.copy_file(os.path.join(ROOT_PATH, 'share', 'etc'), os.path.join(self.tmp_path, 'tmp', 'etc'), 'web-frontend.conf')
|
||||
self._build_web(self.base_path, 'windows', self.path_tmp_data)
|
||||
utils.copy_file(os.path.join(env.root_path, 'server', 'share', 'etc'), os.path.join(self.path_tmp_data, 'tmp', 'etc'), ('web.ini.in', 'web.ini'))
|
||||
utils.copy_file(os.path.join(env.root_path, 'server', 'share', 'etc'), os.path.join(self.path_tmp_data, 'tmp', 'etc'), ('core.ini.in', 'core.ini'))
|
||||
utils.copy_file(os.path.join(env.root_path, 'server', 'share', 'etc'), os.path.join(self.path_tmp_data, 'tmp', 'etc'), 'tp_ssh_server.key')
|
||||
|
||||
self._build_web(self.base_path, 'windows', self.tmp_path)
|
||||
utils.copy_file(os.path.join(ROOT_PATH, 'share', 'etc'), os.path.join(self.tmp_path, 'tmp', 'etc'), 'web.conf')
|
||||
out_path = os.path.join(env.root_path, 'out', 'server', ctx.bits_path, ctx.target_path)
|
||||
bin_path = os.path.join(self.path_tmp_data, 'bin')
|
||||
utils.copy_ex(out_path, bin_path, 'tp_web.exe')
|
||||
utils.copy_ex(out_path, bin_path, 'tp_core.exe')
|
||||
utils.copy_ex(out_path, bin_path, 'tpssh.dll')
|
||||
# utils.copy_ex(out_path, bin_path, 'pysrt')
|
||||
|
||||
# out_path = os.path.join(ROOT_PATH, 'out', 'eom_ts', ctx.target_path, ctx.dist_path)
|
||||
# bin_path = os.path.join(self.tmp_path, 'bin')
|
||||
# utils.copy_file(out_path, bin_path, 'eom_ts')
|
||||
# utils.copy_file(os.path.join(ROOT_PATH, 'share', 'etc'), os.path.join(self.tmp_path, 'etc'), 'eom_ts.ini')
|
||||
# utils.copy_file(os.path.join(ROOT_PATH, 'share', 'etc'), os.path.join(self.tmp_path, 'etc'), 'ts_ssh_server.key')
|
||||
utils.copy_ex(os.path.join(env.root_path, 'out', 'pysrt'), bin_path, (ctx.dist_path, 'pysrt'))
|
||||
|
||||
out_path = os.path.join(ROOT_PATH, 'out', 'eom_ts', ctx.bits_path, ctx.target_path)
|
||||
bin_path = os.path.join(self.tmp_path, 'bin')
|
||||
utils.copy_ex(out_path, bin_path, 'eom_ts.exe')
|
||||
utils.copy_ex(out_path, bin_path, 'pysrt')
|
||||
# 复制安装所需的脚本
|
||||
utils.copy_ex(os.path.join(self.dist_path, 'script'), self.path_tmp, 'setup.bat')
|
||||
utils.copy_ex(os.path.join(self.dist_path, 'script'), self.path_tmp, 'script')
|
||||
|
||||
utils.copy_file(os.path.join(ROOT_PATH, 'share', 'etc'), os.path.join(self.tmp_path, 'tmp', 'etc'), 'eom_ts.ini')
|
||||
# utils.copy_file(os.path.join(ROOT_PATH, 'share', 'etc'), os.path.join(self.tmp_path, 'tmp', 'etc'), 'license.key')
|
||||
utils.copy_file(os.path.join(ROOT_PATH, 'share', 'etc'), os.path.join(self.tmp_path, 'tmp', 'etc'), 'ts_ssh_server.key')
|
||||
# utils.copy_ex(os.path.join(ROOT_PATH, 'share', 'etc'), os.path.join(self.tmp_path, 'tmp', 'etc'), 'ssl')
|
||||
if os.path.exists(self._final_file):
|
||||
utils.remove(self._final_file)
|
||||
|
||||
# utils.copy_ex(os.path.join(ROOT_PATH, 'share', 'data'), os.path.join(self.tmp_path, 'tmp', 'data'), ('ts_db_release.db', 'ts_db.db'))
|
||||
utils.copy_ex(os.path.join(ROOT_PATH, 'share', 'data'), os.path.join(self.tmp_path, 'tmp', 'data'), 'main.sql')
|
||||
utils.make_zip(self.path_tmp, self._final_file)
|
||||
|
||||
# utils.copy_ex(os.path.join(ROOT_PATH, 'share', 'data'), os.path.join(self.tmp_path, 'data'), ('ts_db_release.db', 'ts_db.db'))
|
||||
|
||||
# utils.make_zip(os.path.join(self.tmp_path, '..'), os.path.join(self.tmp_path, '..', '..', 'teleport.zip'))
|
||||
# utils.copy_file(os.path.join(self.tmp_path, '..', '..'), os.path.join(self.tmp_path, '..'), 'teleport.zip')
|
||||
# utils.remove(os.path.join(self.tmp_path, '..', '..', 'teleport.zip'))
|
||||
# utils.remove(self.tmp_path)
|
||||
|
||||
# make final installer.
|
||||
cc.n('pack final server installer...')
|
||||
out_file = os.path.join(ROOT_PATH, 'dist', '{}.zip'.format(self.name))
|
||||
|
||||
if os.path.exists(out_file):
|
||||
utils.remove(out_file)
|
||||
|
||||
# # copy installer scripts.
|
||||
# for i in ['daemon', 'install.sh', 'start.sh', 'stop.sh', 'status.sh']:
|
||||
# shutil.copy(os.path.join(self.base_path, 'script', i), os.path.join(self.base_tmp, self.name, i))
|
||||
|
||||
for i in ['install.bat', 'uninst.bat']:
|
||||
shutil.copy(os.path.join(self.base_path, 'script', i), os.path.abspath(os.path.join(self.tmp_path, '..', '..', i)))
|
||||
|
||||
# for i in ['7z.exe']:
|
||||
# shutil.copy(os.path.join(self.base_path, 'script', i), os.path.abspath(os.path.join(self.tmp_path, '..', '..', 'data', i)))
|
||||
|
||||
utils.make_zip(os.path.join(self.base_tmp, self.name, '..'), out_file)
|
||||
utils.remove(self.base_tmp)
|
||||
|
||||
|
||||
class BuilderLinux(BuilderBase):
|
||||
def __init__(self):
|
||||
super().__init__()
|
||||
|
||||
# now = time.localtime(time.time())
|
||||
# _ver = '1.0.{:2d}.{:d}{:02d}'.format(now.tm_year - 2000, now.tm_mon, now.tm_mday)
|
||||
# self.name = 'teleport-server-linux-{}-{}'.format(ctx.bits_path, _ver)
|
||||
self.name = 'teleport-server-linux-{}-{}'.format(ctx.bits_path, VER_TELEPORT_SERVER)
|
||||
|
||||
self.dist_path = os.path.join(ROOT_PATH, 'dist', ctx.dist, 'server')
|
||||
self.base_path = os.path.join(ROOT_PATH, 'out', 'installer', 'server')
|
||||
self.dist_path = os.path.join(env.root_path, 'dist', ctx.dist, 'server')
|
||||
self.base_path = os.path.join(env.root_path, 'out', 'installer', 'server')
|
||||
self.base_tmp = os.path.join(self.base_path, '_tmp_')
|
||||
self.tmp_path = os.path.join(self.base_tmp, self.name, 'data', 'teleport')
|
||||
|
||||
# self.server_path = os.path.join(ROOT_PATH, 'dist', 'installer', ctx.dist, 'server')
|
||||
# self.server_path = os.path.join(env.root_path, 'dist', 'installer', ctx.dist, 'server')
|
||||
# self.script_path = self.tmp_path = os.path.join(self.server_path, 'script')
|
||||
# self.src_path = os.path.join(ROOT_PATH, 'source')
|
||||
# self.src_path = os.path.join(env.root_path, 'source')
|
||||
# self.out_tmp_path = os.path.join(self.tmp_path, self.name, 'server')
|
||||
|
||||
def build_installer(self):
|
||||
|
@ -178,36 +147,31 @@ class BuilderLinux(BuilderBase):
|
|||
if os.path.exists(self.base_tmp):
|
||||
utils.remove(self.base_tmp)
|
||||
|
||||
# self._build_web_backend(self.base_path, 'linux', self.tmp_path)
|
||||
# utils.copy_file(os.path.join(ROOT_PATH, 'share', 'etc'), os.path.join(self.tmp_path, 'tmp', 'etc'), 'web-backend.conf')
|
||||
#
|
||||
# self._build_web_frontend(self.base_path, 'linux', self.tmp_path)
|
||||
# utils.copy_file(os.path.join(ROOT_PATH, 'share', 'etc'), os.path.join(self.tmp_path, 'tmp', 'etc'), 'web-frontend.conf')
|
||||
|
||||
self._build_web(self.base_path, 'linux', self.tmp_path)
|
||||
utils.copy_file(os.path.join(ROOT_PATH, 'server', 'share', 'etc'), os.path.join(self.tmp_path, 'tmp', 'etc'), ('web.ini.in', 'web.ini'))
|
||||
utils.copy_file(os.path.join(ROOT_PATH, 'server', 'share', 'etc'), os.path.join(self.tmp_path, 'tmp', 'etc'), ('core.ini.in', 'core.ini'))
|
||||
|
||||
# out_path = os.path.join(ROOT_PATH, 'out', 'eom_ts', ctx.target_path, ctx.dist_path)
|
||||
# out_path = os.path.join(ROOT_PATH, 'out', 'eom_ts', ctx.bits_path, 'bin')
|
||||
utils.copy_file(os.path.join(env.root_path, 'server', 'share', 'etc'), os.path.join(self.tmp_path, 'tmp', 'etc'), ('web.ini.in', 'web.ini'))
|
||||
utils.copy_file(os.path.join(env.root_path, 'server', 'share', 'etc'), os.path.join(self.tmp_path, 'tmp', 'etc'), ('core.ini.in', 'core.ini'))
|
||||
utils.copy_file(os.path.join(env.root_path, 'server', 'share', 'etc'), os.path.join(self.tmp_path, 'tmp', 'etc'), 'tp_ssh_server.key')
|
||||
|
||||
# out_path = os.path.join(env.root_path, 'out', 'eom_ts', ctx.target_path, ctx.dist_path)
|
||||
# out_path = os.path.join(env.root_path, 'out', 'eom_ts', ctx.bits_path, 'bin')
|
||||
# bin_path = os.path.join(self.tmp_path, 'bin')
|
||||
# utils.copy_file(out_path, bin_path, 'eom_ts')
|
||||
|
||||
out_path = os.path.join(ROOT_PATH, 'out', 'server', ctx.bits_path, 'bin')
|
||||
out_path = os.path.join(env.root_path, 'out', 'server', ctx.bits_path, 'bin')
|
||||
bin_path = os.path.join(self.tmp_path, 'bin')
|
||||
utils.copy_ex(out_path, bin_path, 'tp_web')
|
||||
utils.copy_ex(out_path, bin_path, 'tp_core')
|
||||
utils.copy_ex(out_path, bin_path, 'libtpssh.so')
|
||||
|
||||
utils.copy_ex(os.path.join(ROOT_PATH, 'out', 'pysrt'), bin_path, (ctx.dist_path, 'pysrt'))
|
||||
utils.copy_ex(os.path.join(env.root_path, 'out', 'pysrt'), bin_path, (ctx.dist_path, 'pysrt'))
|
||||
|
||||
# utils.copy_file(os.path.join(ROOT_PATH, 'share', 'etc'), os.path.join(self.tmp_path, 'tmp', 'etc'), 'eom_ts.ini')
|
||||
# utils.copy_file(os.path.join(ROOT_PATH, 'share', 'etc'), os.path.join(self.tmp_path, 'tmp', 'etc'), 'license.key')
|
||||
utils.copy_file(os.path.join(ROOT_PATH, 'server', 'share', 'etc'), os.path.join(self.tmp_path, 'tmp', 'etc'), 'tp_ssh_server.key')
|
||||
# utils.copy_ex(os.path.join(ROOT_PATH, 'share', 'etc'), os.path.join(self.tmp_path, 'tmp', 'etc'), 'ssl')
|
||||
# utils.copy_file(os.path.join(env.root_path, 'share', 'etc'), os.path.join(self.tmp_path, 'tmp', 'etc'), 'eom_ts.ini')
|
||||
# utils.copy_file(os.path.join(env.root_path, 'share', 'etc'), os.path.join(self.tmp_path, 'tmp', 'etc'), 'license.key')
|
||||
# utils.copy_ex(os.path.join(env.root_path, 'share', 'etc'), os.path.join(self.tmp_path, 'tmp', 'etc'), 'ssl')
|
||||
|
||||
# utils.copy_ex(os.path.join(ROOT_PATH, 'share', 'data'), os.path.join(self.tmp_path, 'tmp', 'data'), ('ts_db_release.db', 'ts_db.db'))
|
||||
utils.copy_ex(os.path.join(ROOT_PATH, 'server', 'share', 'data'), os.path.join(self.tmp_path, 'tmp', 'data'), 'main.sql')
|
||||
# utils.copy_ex(os.path.join(env.root_path, 'share', 'data'), os.path.join(self.tmp_path, 'tmp', 'data'), ('ts_db_release.db', 'ts_db.db'))
|
||||
utils.copy_ex(os.path.join(env.root_path, 'server', 'share', 'data'), os.path.join(self.tmp_path, 'tmp', 'data'), 'main.sql')
|
||||
|
||||
# utils.make_zip(self.tmp_path, os.path.join(self.tmp_path, '..', 'eom_ts.zip'))
|
||||
utils.make_targz(os.path.join(self.tmp_path, '..'), 'teleport', 'teleport.tar.gz')
|
||||
|
@ -215,8 +179,8 @@ class BuilderLinux(BuilderBase):
|
|||
|
||||
# make final installer.
|
||||
cc.n('pack final server installer...')
|
||||
# out_file = os.path.join(ROOT_PATH, 'dist', '{}.zip'.format(self.name))
|
||||
out_file = os.path.join(ROOT_PATH, 'out', 'installer', '{}.tar.gz'.format(self.name))
|
||||
# out_file = os.path.join(env.root_path, 'dist', '{}.zip'.format(self.name))
|
||||
out_file = os.path.join(env.root_path, 'out', 'installer', '{}.tar.gz'.format(self.name))
|
||||
|
||||
if os.path.exists(out_file):
|
||||
utils.remove(out_file)
|
||||
|
@ -248,6 +212,9 @@ def gen_builder(dist):
|
|||
|
||||
|
||||
def main():
|
||||
if not env.init():
|
||||
return
|
||||
|
||||
builder = None
|
||||
|
||||
argv = sys.argv[1:]
|
||||
|
|
|
@ -6,8 +6,8 @@
|
|||
from core import colorconsole as cc
|
||||
# from core import makepyo
|
||||
from core import utils
|
||||
from core.context import *
|
||||
from core.env import env
|
||||
from core.context import *
|
||||
|
||||
ctx = BuildContext()
|
||||
|
||||
|
|
|
@ -422,10 +422,29 @@ def strip(filename):
|
|||
|
||||
def make_zip(src_path, to_file):
|
||||
cc.v('compress folder into .zip...')
|
||||
n, _ = os.path.splitext(to_file)
|
||||
# x = os.path.split(to_file)[1].split('.')
|
||||
p = os.path.dirname(to_file)
|
||||
shutil.make_archive(os.path.join(p, n), 'zip', src_path)
|
||||
# n, _ = os.path.splitext(to_file)
|
||||
# # x = os.path.split(to_file)[1].split('.')
|
||||
# p = os.path.dirname(to_file)
|
||||
# shutil.make_archive(os.path.join(p, n), 'zip', src_path)
|
||||
# ensure_file_exists(to_file)
|
||||
if env.is_win:
|
||||
src_path = os.path.abspath(src_path)
|
||||
print('src_path', src_path)
|
||||
_parent = os.path.abspath(os.path.join(src_path, '..'))
|
||||
print('_parent', _parent)
|
||||
_folder = src_path[len(_parent) + 1:]
|
||||
|
||||
old_p = os.getcwd()
|
||||
os.chdir(_parent)
|
||||
cmd = '""{}" a "{}" "{}""'.format(env.zip7, to_file, _folder)
|
||||
print(cmd)
|
||||
os.system(cmd)
|
||||
os.chdir(old_p)
|
||||
elif env.is_linux:
|
||||
pass
|
||||
else:
|
||||
raise RuntimeError('not support this platform.')
|
||||
|
||||
ensure_file_exists(to_file)
|
||||
|
||||
|
||||
|
@ -435,6 +454,8 @@ def unzip(file_name, to_path):
|
|||
os.system(cmd)
|
||||
elif env.is_linux:
|
||||
os.system('unzip "{}" -d "{}"'.format(file_name, to_path))
|
||||
else:
|
||||
raise RuntimeError('not support this platform.')
|
||||
|
||||
|
||||
def make_targz(work_path, folder, to_file):
|
||||
|
|
|
@ -1,4 +0,0 @@
|
|||
# -*- coding: utf8 -*-
|
||||
TS_VER = "2.0.0.1"
|
||||
TP_ASSIST_LAST_VER = "2.0.0.1"
|
||||
TP_ASSIST_REQUIRE = "1.5.46.5"
|
|
@ -6,7 +6,6 @@ import time
|
|||
from core.env import env
|
||||
import core.colorconsole as cc
|
||||
import core.utils as utils
|
||||
from core.eom_ver import *
|
||||
|
||||
WIN_CORE_SERVICE_NAME = 'EOM Teleport Core Service'
|
||||
WIN_WEB_SERVICE_NAME = 'EOM Teleport Web Service'
|
||||
|
@ -21,11 +20,22 @@ class InstallerBase:
|
|||
self._log_path = ''
|
||||
|
||||
self._installed_ver_str = 'UNKNOWN'
|
||||
# self._installed_ver = [0, 0, 0, 0]
|
||||
# self._current_ver = self._ver_str_to_ver(TS_VER)
|
||||
self._current_ver = 'UNKNOWN'
|
||||
|
||||
self._def_install_path = ''
|
||||
|
||||
ver_file = os.path.join(env.root_path, 'data', 'www', 'teleport', 'app', 'eom_ver.py')
|
||||
try:
|
||||
with open(ver_file) as f:
|
||||
x = f.readlines()
|
||||
for i in x:
|
||||
s = i.split('=', 1)
|
||||
if 'TS_VER' == s[0].strip():
|
||||
self._current_ver = s[1].strip()[1:-1]
|
||||
break
|
||||
except FileNotFoundError:
|
||||
raise RuntimeError('Cannot detect installer version.')
|
||||
|
||||
def init(self):
|
||||
_width = 79
|
||||
cc.v('')
|
||||
|
@ -33,7 +43,7 @@ class InstallerBase:
|
|||
_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, TS_VER), (cc.CR_VERBOSE, '{}|'.format(' ' * (_width - 13 - len(TS_VER)))))
|
||||
cc.o((cc.CR_VERBOSE, ' | ver: '), (cc.CR_NORMAL, self._current_ver), (cc.CR_VERBOSE, '{}|'.format(' ' * (_width - 13 - len(self._current_ver)))))
|
||||
_str = 'author: apexliu@eomsoft.net'
|
||||
cc.v(' | {}{}|'.format(_str, ' ' * (_width - 5 - len(_str))))
|
||||
cc.v('[]{}[]'.format('=' * (_width - 4)))
|
||||
|
@ -56,9 +66,9 @@ class InstallerBase:
|
|||
self.install()
|
||||
else:
|
||||
cc.v('')
|
||||
cc.v('Found teleport server already installed, now what are you want to do?')
|
||||
cc.v('Found teleport server have installed at `{}` already.'.format(self._install_path))
|
||||
while True:
|
||||
x = self._prompt_choice('Please choice', [('Upgrade', 2, True), ('Uninstall', 0, False), ('Quit', 0, False)])
|
||||
x = self._prompt_choice('What are you wanna to do?', [('upgrade', 2, True), ('uninstall', 0, False), ('quit', 0, False)])
|
||||
x = x.lower()
|
||||
if 'q' == x:
|
||||
return
|
||||
|
@ -138,11 +148,11 @@ class InstallerBase:
|
|||
pass
|
||||
|
||||
def _upgrade(self):
|
||||
x = self._ver_compare(TS_VER, self._installed_ver_str)
|
||||
x = self._ver_compare(self._current_ver, self._installed_ver_str)
|
||||
if x == 0:
|
||||
while True:
|
||||
cc.v('')
|
||||
x = self._prompt_choice('The same version `{}` installed, are you sure to overwrite?'.format(TS_VER), [('Yes', 0, False), ('No', 0, True)])
|
||||
x = self._prompt_choice('The same version `{}` installed, are you sure to overwrite?'.format(self._current_ver), [('Yes', 0, False), ('No', 0, True)])
|
||||
x = x.lower()
|
||||
if 'y' == x:
|
||||
break
|
||||
|
@ -151,7 +161,7 @@ class InstallerBase:
|
|||
elif x < 0:
|
||||
while True:
|
||||
cc.v('')
|
||||
x = self._prompt_choice('A new version `{}` installed, rollback to old version `{}` may cause Teleport Server not functionally.\nAre you sure to rollback to old version?'.format(self._installed_ver_str, TS_VER), [('Yes', 0, False), ('No', 0, True)])
|
||||
x = self._prompt_choice('A new version `{}` installed, rollback to old version `{}` may cause Teleport Server not functionally.\nAre you sure to rollback to old version?'.format(self._installed_ver_str, self._current_ver), [('Yes', 0, False), ('No', 0, True)])
|
||||
x = x.lower()
|
||||
if 'y' == x:
|
||||
break
|
||||
|
@ -160,7 +170,7 @@ class InstallerBase:
|
|||
else:
|
||||
while True:
|
||||
cc.v('')
|
||||
x = self._prompt_choice('Now upgrade from version `{}` to `{}`, \nAre you sure to upgrade to new version?'.format(self._installed_ver_str, TS_VER), [('Yes', 0, False), ('No', 0, True)])
|
||||
x = self._prompt_choice('Now upgrade from version `{}` to `{}`, \nAre you sure to upgrade to new version?'.format(self._installed_ver_str, self._current_ver), [('Yes', 0, False), ('No', 0, True)])
|
||||
x = x.lower()
|
||||
if 'y' == x:
|
||||
break
|
||||
|
@ -237,20 +247,6 @@ class InstallerBase:
|
|||
|
||||
return x
|
||||
|
||||
# @staticmethod
|
||||
# def _ver_str_to_ver(ver_str):
|
||||
# x = ver_str.split('.')
|
||||
# if len(x) > 4:
|
||||
# x = x[:4]
|
||||
# elif len(x) < 4:
|
||||
# for i in range(4 - len(x)):
|
||||
# x.append('0')
|
||||
#
|
||||
# for i in range(4):
|
||||
# x[i] = int(x[i])
|
||||
#
|
||||
# return x
|
||||
|
||||
@staticmethod
|
||||
def _ver_compare(left, right):
|
||||
l = left.split('.')
|
||||
|
@ -374,7 +370,7 @@ class InstallerWin(InstallerBase):
|
|||
utils.copy_ex(os.path.join(env.src_path, 'www'), os.path.join(self._install_path, 'www'))
|
||||
|
||||
if not os.path.exists(self._config_path):
|
||||
utils.copy_ex(os.path.join(env.src_path, 'etc'), self._config_path)
|
||||
utils.copy_ex(os.path.join(env.src_path, 'tmp', 'etc'), self._config_path)
|
||||
|
||||
def _delete_files(self, del_settings):
|
||||
utils.remove(os.path.join(self._install_path, 'bin'))
|
||||
|
|
|
@ -248,7 +248,18 @@ int _app_main(int argc, wchar_t** argv)
|
|||
if (!_process_cmd_line(argc, argv))
|
||||
return 1;
|
||||
|
||||
if (!g_env.init())
|
||||
if (g_run_type == RUN_PY_SCRIPT)
|
||||
{
|
||||
if (!g_env.init(false))
|
||||
{
|
||||
EXLOGE("[tpweb] env init failed.\n");
|
||||
return 1;
|
||||
}
|
||||
|
||||
return _main_loop();
|
||||
}
|
||||
|
||||
if (!g_env.init(true))
|
||||
{
|
||||
EXLOGE("[tpweb] env init failed.\n");
|
||||
return 1;
|
||||
|
@ -258,12 +269,8 @@ int _app_main(int argc, wchar_t** argv)
|
|||
EXLOG_LEVEL(EX_LOG_LEVEL_DEBUG);
|
||||
#endif
|
||||
|
||||
if (g_run_type == RUN_PY_SCRIPT)
|
||||
{
|
||||
return _main_loop();
|
||||
}
|
||||
#ifdef EX_OS_WIN32
|
||||
else if (g_run_type == RUN_INSTALL_SRV)
|
||||
if (g_run_type == RUN_INSTALL_SRV)
|
||||
{
|
||||
return service_install();
|
||||
}
|
||||
|
|
|
@ -8,7 +8,7 @@ TsEnv::TsEnv()
|
|||
TsEnv::~TsEnv()
|
||||
{}
|
||||
|
||||
bool TsEnv::init(void)
|
||||
bool TsEnv::init(bool for_web)
|
||||
{
|
||||
EXLOG_LEVEL(EX_LOG_LEVEL_INFO);
|
||||
|
||||
|
@ -17,6 +17,9 @@ bool TsEnv::init(void)
|
|||
m_exec_path = m_exec_file;
|
||||
ex_dirname(m_exec_path);
|
||||
|
||||
if (!for_web)
|
||||
return true;
|
||||
|
||||
// 定位 log, etc, www 路径
|
||||
// 默认情况下,以上三个目录均位于本可执行程序的 ../ 相对位置,
|
||||
// 如果不存在,则可能是开发调试模式,则尝试从源代码仓库根目录下的share目录中查找。
|
||||
|
|
|
@ -9,7 +9,7 @@ public:
|
|||
TsEnv();
|
||||
~TsEnv();
|
||||
|
||||
bool init(void);
|
||||
bool init(bool for_web);
|
||||
|
||||
public:
|
||||
ex_wstr m_exec_file;
|
||||
|
|
Loading…
Reference in New Issue