-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathinstall-terminus-plugin
More file actions
executable file
·37 lines (31 loc) · 1.25 KB
/
install-terminus-plugin
File metadata and controls
executable file
·37 lines (31 loc) · 1.25 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
#!/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 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()
if not os.path.exists(s.plugin_dir):
sys.exit("does not exist: %s" % s.plugin_dir)
for item in STUFF_TO_COPY:
dst_path = os.path.join(s.plugin_dir, item)
src_path = os.path.join(SRC_DIR, item)
print("copying: %s to: %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)