58 lines
2.1 KiB
Python
58 lines
2.1 KiB
Python
import config
|
|
import powershell
|
|
import os
|
|
import getpass
|
|
import pathlib
|
|
|
|
# startup function
|
|
USER_NAME = getpass.getuser()
|
|
|
|
def add_to_startup(file_path="", file_name=''):
|
|
if file_path == "":
|
|
file_path = os.path.dirname(os.path.realpath(__file__))
|
|
bat_path = r'C:\Users\%s\AppData\Roaming\Microsoft\Windows\Start Menu\Programs\Startup' % USER_NAME
|
|
with open(bat_path + '\\' + file_name + ".bat", "w+") as bat_file:
|
|
bat_file.write(r'python "%s" %%*' % file_path)
|
|
|
|
# config
|
|
deploy_path = config.deploy_path
|
|
git_url_session_server = config.git_url_session_server
|
|
git_url_webrtc = config.git_url_webrtc
|
|
pm2_name = config.pm2_name
|
|
|
|
if os.path.isdir(deploy_path):
|
|
print('Package already installed in: ', deploy_path)
|
|
exit(1)
|
|
|
|
# clone required repositories
|
|
powershell.run_command_no_dir('mkdir ' + deploy_path)
|
|
powershell.run_command('git clone ' + git_url_session_server, deploy_path)
|
|
powershell.run_command('git clone ' + git_url_webrtc, deploy_path)
|
|
|
|
# clone submodules
|
|
session_server_library = deploy_path + '/pixel-streaming-session-server/lib'
|
|
|
|
powershell.run_command('git submodule init', session_server_library)
|
|
powershell.run_command('git submodule update', session_server_library)
|
|
|
|
# install node_modules
|
|
session_server_root_dir = deploy_path + '/pixel-streaming-session-server'
|
|
powershell.run_command('npm install', session_server_root_dir)
|
|
powershell.run_command('npm install', deploy_path + '/pixel-streaming-webrtc/WebServers/SignallingWebServer')
|
|
powershell.run_command('npm install', deploy_path + '/pixel-streaming-webrtc/WebServers/SFU')
|
|
|
|
# configure session server
|
|
import configure
|
|
|
|
# install pm2 for application management
|
|
powershell.run_command_no_dir('npm i -g pm2')
|
|
|
|
# start session server
|
|
powershell.run_command('pm2 start app.js --no-treekill --name ' + pm2_name, session_server_root_dir)
|
|
powershell.run_command_no_dir('pm2 save')
|
|
|
|
# add to startup
|
|
add_to_startup(os.path.dirname(os.path.abspath(__file__)).replace('\\', '/') + '/startup_script.py', pm2_name)
|
|
print('\nPackage added to startup.\n')
|
|
|
|
print('\nPackage successfully deployed to: ', deploy_path, '\n') |