-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathglobal-install-scripts.py
More file actions
executable file
·31 lines (24 loc) · 974 Bytes
/
Copy pathglobal-install-scripts.py
File metadata and controls
executable file
·31 lines (24 loc) · 974 Bytes
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
#!/usr/bin/env python3
# Install scripts into
from macros import *
if os.environ["USER"] != "root":
prntfail("Please run as root, from a readable (by other) directory.")
# TODO: more robust arg parse? nahh - what could possibly go wrong with this.
cwd = pwd()
if "tmp" in cwd and ("--ignore-tmp" not in sys.argv[1:]):
prntfail("WARNING: cwd='%s' looks like a tmp directory. Pass flag '--ignore-tmp' to continue.")
def install(loc="/usr/local/bin", exe=True):
mkdir(loc)
def _inst(f):
target = join(cwd, f)
name = join(loc, basename(f))
trywarn(ln, FileExistsError)(target, name)
chown(name, "root", "root")
if exe: chmod(name, 0o755)
else: chmod(name, 0o644)
# TODO: check if cwd is readable / executable?
return _inst
bin_files = glob("lxc/*") + glob("misc/*") + glob("net/*") + glob("root/*")
lib_files = ["macros.py"]
lmap(install("/usr/local/bin"), bin_files)
lmap(install("/usr/local/lib/python3", exe=False), lib_files)