-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathadmin.py
More file actions
61 lines (53 loc) · 1.84 KB
/
admin.py
File metadata and controls
61 lines (53 loc) · 1.84 KB
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
import subprocess
import re
from functions import *
from config import rclone_bin, location_list, ip_nas
rclone_web_acess_options = "serve http --addr :8080"
def web_files_access(index, snapshot):
value = location_list[index]
destino = value["destin"].localpath
recover_function = value["destin"].cmd_recover
list_command = [
rclone_bin,
rclone_web_acess_options,
recover_function(f"{destino}.zfs/snapshot/{snapshot}/"),
]
print(f"Acesse o link: http://{ip_nas}:8080")
print("-" * 30)
cmd = " ".join(list_command)
print(cmd)
subprocess.call(cmd, shell=True)
def get_file():
for index, value in enumerate(location_list):
print(index, "-", value["nome"].upper())
print("-" * 30)
index_pa = int(input(f"Selecione o PA: "))
destino = location_list[index_pa]["destin"].localpath
list_snapshots = (
subprocess.check_output(f"ls {destino}.zfs/snapshot/", shell=True)
.decode()
.split("\n")
)
list_snapshots = [i for i in list_snapshots[::-1] if i != '']
for index, value in enumerate(list_snapshots):
print(index, "-", value)
print("-" * 30)
index_snapshot = int(input(f"Selecione o Snaphost: "))
snapshot = list_snapshots[index_snapshot]
web_files_access(index_pa, snapshot)
def get_log():
log_dir = "/var/log/"
print(f"Acesse o link: http://{ip_nas}:8080")
print("-" * 30)
subprocess.call(f'rclone serve http --addr :8080 {log_dir} --include "backup*" ', shell=True)
repeat_loop = True
while repeat_loop:
repeat_loop = False
escolha_funcao = input('Deseja recuperar arquivos ou ver os logs? (R,L): ')
if escolha_funcao.upper() == 'R':
get_file()
elif escolha_funcao.upper() == 'L':
get_log()
else:
print('Escolha invalida! Digite L ou R')
repeat_loop = True