-
Notifications
You must be signed in to change notification settings - Fork 0
/
MiddleWare
80 lines (63 loc) · 2.12 KB
/
MiddleWare
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
#!/usr/bin/env python3
import os
import tarfile
import wget
import shutil
import subprocess
import random
import string
import subprocess
import time
def stop_lncli():
try:
# Define the command to stop lncli
stop_command = ['lncli', 'stop']
# Execute the command
subprocess.run(stop_command, check=True)
print('lncli has been stopped.')
except subprocess.CalledProcessError as e:
print(f'Error: {e}')
except Exception as e:
print(f'An unexpected error occurred: {e}')
if __name__ == '__main__':
stop_lncli()
def timer():
print("Starting 5-second timer...")
time.sleep(5)
print("Timer expired after 5 seconds!")
if __name__ == '__main__':
timer()
def change_tor_cookie_permissions():
cookie_path = "/run/tor/control.authcookie"
try:
# Check if the file exists
if not os.path.exists(cookie_path):
print(f"Error: The file '{cookie_path}' does not exist.")
return
# Use subprocess to run the 'sudo chmod' command
subprocess.run(['sudo', 'chmod', 'o+r', cookie_path])
print(f"Changed permissions for '{cookie_path}' to allow read access by others.")
except Exception as e:
print(f"Error: {str(e)}")
if __name__ == "__main__":
change_tor_cookie_permissions()
def enable_rpc_middleware():
# Change the current working directory to the .lnd directory
lnd_directory = os.path.expanduser('/home/humble/.lnd')
if not os.path.exists(lnd_directory):
print('The .lnd directory does not exist at /home/humble/.lnd.')
return
# Change the working directory to .lnd
os.chdir(lnd_directory)
# Define the command to enable rpcmiddleware
enable_command = ['lnd', '--rpcmiddleware.enable']
try:
# Execute the command
subprocess.run(enable_command, check=True)
print('rpcmiddleware has been enabled.')
except subprocess.CalledProcessError as e:
print(f'Error: {e}')
except Exception as e:
print(f'An unexpected error occurred: {e}')
if __name__ == '__main__':
enable_rpc_middleware()