-
Notifications
You must be signed in to change notification settings - Fork 0
/
deploy.py
executable file
·98 lines (84 loc) · 2.75 KB
/
deploy.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
#!/usr/bin/env python3
# LED Deploy script
# 2024 Akop Karapetyan
import argparse
from ctl_server import config
import subprocess
import sys
CTL_SERVER_EXE='serve.sh'
parser = argparse.ArgumentParser()
parser.add_argument('--ctl', action='store_true', help='Deploy to control server')
parser.add_argument('--cli', action='store_true', help='Deploy to clients')
parser.add_argument('--svr', action='store_true', help='Deploy to game server')
parser.add_argument('--all', action='store_true', help='Deploy everything')
args = parser.parse_args()
if not (args.ctl or args.svr or args.cli or args.all):
sys.exit('Specify at least one option or "--all" to deploy everything')
config = config.Config('deploy.yaml')
if args.ctl or args.all:
if not config.control_server:
raise ValueError('Missing control server configuration')
print("Generating config...")
config.write_control_server_config(f'{config.control_server.path}/config.yaml')
print("Deploying control server...")
subprocess.call([
'rsync',
'-avrL',
'--exclude', '.*',
'--exclude', '*_example.yaml',
'--exclude', '__pycache__',
'--exclude', 'venv/',
f'{config.control_server.path}',
f'{config.control_server.host}:'
])
subprocess.call([
'ssh',
'-o',
'StrictHostKeyChecking no',
f'{config.control_server.host}',
f'cd {config.control_server.path}; nohup ./{CTL_SERVER_EXE} >log.txt 2>&1 &',
])
if args.svr or args.all:
if not config.game_server:
raise ValueError('Missing game server configuration')
print("Deploying to server...")
subprocess.call([
'rsync',
'-vrtp',
'--exclude', '*.exclude',
'--exclude-from', 'game_servers/common.exclude',
'--exclude-from', 'game_servers/fbneo.exclude',
f'game_servers/',
f'{config.game_server.host}:{config.game_server.path}',
])
print("Building server(s)...")
subprocess.call([
'ssh',
'-o',
'StrictHostKeyChecking no',
f'{config.game_server.host}',
'-t',
f'cd {config.game_server.path} && ./build.sh',
])
if args.cli or args.all:
if not config.game_clients:
raise ValueError('Missing game client configuration')
print("Deploying to clients...")
for client in config.game_clients:
# Copy rgbclient
subprocess.call([
'rsync',
'-vrt',
'--exclude', '.*',
f'rgbclient/',
f'{client.host}:{client.path}',
])
# Build
subprocess.call([
'ssh',
'-o',
'StrictHostKeyChecking no',
f'{client.host}',
'-t',
f'cd {client.path} && make',
])