|
1 | | -#!/usr/bin/env python3 |
2 | | -# -*- coding: utf-8 -*- |
3 | | - |
4 | | -import os |
5 | | -import sys |
6 | | - |
7 | | -import xmir_base |
8 | | -import gateway |
9 | | -from gateway import die |
10 | | - |
11 | | - |
12 | | -gw = gateway.Gateway() |
13 | | - |
14 | | -fn_dir = 'data/' |
15 | | -fn_local = 'data/ssh_patch.sh' |
16 | | -fn_remote = '/tmp/ssh_patch.sh' |
17 | | -fn_local_i = 'data/ssh_install.sh' |
18 | | -fn_remote_i = '/tmp/ssh_install.sh' |
19 | | -fn_local_u = 'data/ssh_uninstall.sh' |
20 | | -fn_remote_u = '/tmp/ssh_uninstall.sh' |
21 | | - |
22 | | -action = 'install' |
23 | | -if len(sys.argv) > 1: |
24 | | - if sys.argv[1].startswith('u') or sys.argv[1].startswith('r'): |
25 | | - action = 'uninstall' |
26 | | - |
27 | | -if action == 'install': |
28 | | - gw.upload(fn_local, fn_remote) |
29 | | - gw.upload(fn_local_i, fn_remote_i) |
30 | | - |
31 | | -gw.upload(fn_local_u, fn_remote_u) |
32 | | - |
33 | | -print("All files uploaded!") |
34 | | -''' |
35 | | -if action == 'install': |
36 | | - gw.ssh_close() |
37 | | - import passw |
38 | | - gw = gateway.Gateway() |
39 | | - if not gw.ping(): |
40 | | - die('SSH not active!') |
41 | | -''' |
42 | | - |
43 | | -print("Run scripts...") |
44 | | -if action == 'install': |
45 | | - gw.run_cmd("sh " + fn_remote_i) |
46 | | -else: |
47 | | - gw.run_cmd("sh " + fn_remote_u) |
48 | | - |
49 | | -gw.run_cmd("rm -f " + fn_remote) |
50 | | -gw.run_cmd("rm -f " + fn_remote_i) |
51 | | -gw.run_cmd("rm -f " + fn_remote_u) |
52 | | - |
53 | | -print("Ready! The SSH patch installed.") |
| 1 | +#!/usr/bin/env python3 |
| 2 | +# -*- coding: utf-8 -*- |
| 3 | + |
| 4 | +import os |
| 5 | +import sys |
| 6 | +import time |
| 7 | + |
| 8 | +import xmir_base |
| 9 | +from gateway import * |
| 10 | + |
| 11 | +gw = Gateway() |
| 12 | + |
| 13 | +FN_patch = 'data/ssh_patch.sh' |
| 14 | +fn_patch = '/tmp/ssh_patch.sh' |
| 15 | +FN_install = 'data/ssh_install.sh' |
| 16 | +fn_install = '/tmp/ssh_install.sh' |
| 17 | +FN_uninstall = 'data/ssh_uninstall.sh' |
| 18 | +fn_uninstall = '/tmp/ssh_uninstall.sh' |
| 19 | + |
| 20 | +action = 'install' |
| 21 | +if len(sys.argv) > 1: |
| 22 | + if sys.argv[1].startswith('u') or sys.argv[1].startswith('r'): |
| 23 | + action = 'uninstall' |
| 24 | + |
| 25 | +if action == 'install': |
| 26 | + gw.upload(FN_patch, fn_patch) |
| 27 | + gw.upload(FN_install, fn_install) |
| 28 | + |
| 29 | +gw.upload(FN_uninstall, fn_uninstall) |
| 30 | + |
| 31 | +print("All files uploaded!") |
| 32 | + |
| 33 | +print("Run scripts...") |
| 34 | +run_script = fn_install if action == 'install' else fn_uninstall |
| 35 | +gw.run_cmd(f"chmod +x {run_script} ; {run_script}") |
| 36 | + |
| 37 | +time.sleep(1.5) |
| 38 | + |
| 39 | +gw.run_cmd(f"rm -f {fn_patch} ; rm -f {fn_install} ; rm -f {fn_uninstall}") |
| 40 | + |
| 41 | +print("Ready! The Permanent SSH patch installed.") |
0 commit comments