install: fixes to properly install/uninstall example files to desired directory as before
This commit is contained in:
parent
c2fdbbca32
commit
86cd0a8e18
1 changed files with 12 additions and 6 deletions
18
tasks.py
18
tasks.py
|
@ -265,13 +265,14 @@ def install_service(c, verbose=False, prefix=DEFAULT_PREFIX):
|
||||||
print(f"ERROR: systemd service path not found: {systemd_dir}")
|
print(f"ERROR: systemd service path not found: {systemd_dir}")
|
||||||
|
|
||||||
|
|
||||||
def install_scripts(c, local=False, verbose=False, prefix=DEFAULT_PREFIX):
|
def install_core_files(c, local=False, verbose=False, prefix=DEFAULT_PREFIX):
|
||||||
"""
|
"""
|
||||||
install core script files, modified to leverage virtual environment
|
install core files (scripts, examples, and configuration)
|
||||||
"""
|
"""
|
||||||
hide = not verbose
|
hide = not verbose
|
||||||
python = get_python(c)
|
python = get_python(c)
|
||||||
bin_dir = Path(prefix).joinpath("bin")
|
bin_dir = Path(prefix).joinpath("bin")
|
||||||
|
# install scripts
|
||||||
for script in Path("daemon/scripts").iterdir():
|
for script in Path("daemon/scripts").iterdir():
|
||||||
dest = bin_dir.joinpath(script.name)
|
dest = bin_dir.joinpath(script.name)
|
||||||
with open(script, "r") as f:
|
with open(script, "r") as f:
|
||||||
|
@ -290,7 +291,6 @@ def install_scripts(c, local=False, verbose=False, prefix=DEFAULT_PREFIX):
|
||||||
# copy normal links
|
# copy normal links
|
||||||
else:
|
else:
|
||||||
c.run(f"sudo cp {script} {dest}", hide=hide)
|
c.run(f"sudo cp {script} {dest}", hide=hide)
|
||||||
|
|
||||||
# setup core python helper
|
# setup core python helper
|
||||||
if not local:
|
if not local:
|
||||||
core_python = bin_dir.joinpath("core-python")
|
core_python = bin_dir.joinpath("core-python")
|
||||||
|
@ -303,12 +303,15 @@ def install_scripts(c, local=False, verbose=False, prefix=DEFAULT_PREFIX):
|
||||||
c.run(f"sudo cp {temp.name} {core_python}", hide=hide)
|
c.run(f"sudo cp {temp.name} {core_python}", hide=hide)
|
||||||
c.run(f"sudo chmod 755 {core_python}", hide=hide)
|
c.run(f"sudo chmod 755 {core_python}", hide=hide)
|
||||||
os.unlink(temp.name)
|
os.unlink(temp.name)
|
||||||
|
|
||||||
# install core configuration file
|
# install core configuration file
|
||||||
config_dir = "/etc/core"
|
config_dir = "/etc/core"
|
||||||
c.run(f"sudo mkdir -p {config_dir}", hide=hide)
|
c.run(f"sudo mkdir -p {config_dir}", hide=hide)
|
||||||
c.run(f"sudo cp -n daemon/data/core.conf {config_dir}", hide=hide)
|
c.run(f"sudo cp -n daemon/data/core.conf {config_dir}", hide=hide)
|
||||||
c.run(f"sudo cp -n daemon/data/logging.conf {config_dir}", hide=hide)
|
c.run(f"sudo cp -n daemon/data/logging.conf {config_dir}", hide=hide)
|
||||||
|
# install examples
|
||||||
|
examples_dir = f"{prefix}/share/core"
|
||||||
|
c.run(f"sudo mkdir -p {examples_dir}", hide=hide)
|
||||||
|
c.run(f"sudo cp -r daemon/examples {examples_dir}", hide=hide)
|
||||||
|
|
||||||
|
|
||||||
@task(
|
@task(
|
||||||
|
@ -354,8 +357,8 @@ def install(
|
||||||
install_type = "core" if local else "core virtual environment"
|
install_type = "core" if local else "core virtual environment"
|
||||||
with p.start(f"installing {install_type}"):
|
with p.start(f"installing {install_type}"):
|
||||||
install_poetry(c, dev, local, hide)
|
install_poetry(c, dev, local, hide)
|
||||||
with p.start("installing scripts and /etc/core"):
|
with p.start("installing scripts, examples, and configuration"):
|
||||||
install_scripts(c, local, hide, prefix)
|
install_core_files(c, local, hide, prefix)
|
||||||
with p.start("installing systemd service"):
|
with p.start("installing systemd service"):
|
||||||
install_service(c, hide, prefix)
|
install_service(c, hide, prefix)
|
||||||
if ospf:
|
if ospf:
|
||||||
|
@ -470,6 +473,9 @@ def uninstall(
|
||||||
for script in Path("daemon/scripts").iterdir():
|
for script in Path("daemon/scripts").iterdir():
|
||||||
dest = bin_dir.joinpath(script.name)
|
dest = bin_dir.joinpath(script.name)
|
||||||
c.run(f"sudo rm -f {dest}", hide=hide)
|
c.run(f"sudo rm -f {dest}", hide=hide)
|
||||||
|
with p.start("uninstalling examples"):
|
||||||
|
examples_dir = Path(prefix).joinpath("share/core")
|
||||||
|
c.run(f"sudo rm -rf {examples_dir}")
|
||||||
|
|
||||||
# remove core-python symlink
|
# remove core-python symlink
|
||||||
if not local:
|
if not local:
|
||||||
|
|
Loading…
Reference in a new issue