-
Notifications
You must be signed in to change notification settings - Fork 1
/
reload-terminus-plugin
executable file
·43 lines (35 loc) · 1.39 KB
/
reload-terminus-plugin
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
#!/usr/bin/env python3
# Copyright (c) 2021 Moneysocket Developers
# Distributed under the MIT software license, see the accompanying
# file LICENSE or http://www.opensource.org/licenses/mit-license.php
import os
import sys
import subprocess
import argparse
import shutil
SRC_DIR = os.path.dirname(os.path.abspath(__file__))
STUFF_TO_COPY = ["terminus", "terminus-plugin"]
DEFAULT = os.path.join(os.path.expanduser("~"), ".lightning/plugins")
PLUGIN_DIR_HELP = "C-Lightning plugin directory (default: %s)" % DEFAULT
parser = argparse.ArgumentParser(prog="install-terminus-plugin")
parser.add_argument('-p', '--plugin-dir', type=str, default=DEFAULT,
help=PLUGIN_DIR_HELP)
s = parser.parse_args()
PLUGIN_NAME = os.path.join(DEFAULT, "terminus-plugin")
r = subprocess.call(["lightning-cli", "plugin", "stop", PLUGIN_NAME])
print(r)
for item in STUFF_TO_COPY:
dst_path = os.path.join(DEFAULT, item)
src_path = os.path.join(SRC_DIR, item)
print("src: %s dst: %s" % (src_path, dst_path))
if os.path.isdir(src_path):
if os.path.exists(dst_path):
shutil.rmtree(dst_path)
shutil.copytree(src_path, dst_path)
else:
if os.path.exists(dst_path):
os.remove(dst_path)
shutil.copyfile(src_path, dst_path)
shutil.copymode(src_path, dst_path)
r = subprocess.call(["lightning-cli", "plugin", "start", PLUGIN_NAME])
print(r)