mirror of
https://github.com/checktheroads/hyperglass
synced 2024-05-11 05:55:08 +00:00
improve systemd copying
This commit is contained in:
@@ -136,6 +136,7 @@ def setup(unattended):
|
|||||||
make_systemd,
|
make_systemd,
|
||||||
write_to_file,
|
write_to_file,
|
||||||
migrate_static_assets,
|
migrate_static_assets,
|
||||||
|
install_systemd,
|
||||||
)
|
)
|
||||||
|
|
||||||
user_path = Path.home() / "hyperglass"
|
user_path = Path.home() / "hyperglass"
|
||||||
@@ -150,7 +151,10 @@ def setup(unattended):
|
|||||||
]
|
]
|
||||||
if not unattended:
|
if not unattended:
|
||||||
answer = inquirer.prompt(install_paths)
|
answer = inquirer.prompt(install_paths)
|
||||||
|
if answer is None:
|
||||||
|
error("A directory for hyperglass is required")
|
||||||
install_path = answer["install_path"]
|
install_path = answer["install_path"]
|
||||||
|
|
||||||
elif unattended:
|
elif unattended:
|
||||||
install_path = user_path
|
install_path = user_path
|
||||||
|
|
||||||
@@ -160,6 +164,7 @@ def setup(unattended):
|
|||||||
create_dir(install_path)
|
create_dir(install_path)
|
||||||
create_dir(ui_dir, parents=True)
|
create_dir(ui_dir, parents=True)
|
||||||
create_dir(custom_dir, parents=True)
|
create_dir(custom_dir, parents=True)
|
||||||
|
migrate_static_assets(install_path)
|
||||||
|
|
||||||
example_dir = WORKING_DIR.parent / "examples"
|
example_dir = WORKING_DIR.parent / "examples"
|
||||||
files = example_dir.iterdir()
|
files = example_dir.iterdir()
|
||||||
@@ -188,5 +193,4 @@ def setup(unattended):
|
|||||||
systemd_file = install_path / "hyperglass.service"
|
systemd_file = install_path / "hyperglass.service"
|
||||||
systemd = make_systemd(user)
|
systemd = make_systemd(user)
|
||||||
write_to_file(systemd_file, systemd)
|
write_to_file(systemd_file, systemd)
|
||||||
|
install_systemd(install_path)
|
||||||
migrate_static_assets(install_path)
|
|
||||||
|
@@ -373,3 +373,32 @@ def migrate_static_assets(app_path):
|
|||||||
callback = success
|
callback = success
|
||||||
|
|
||||||
callback(msg, a=a, b=b)
|
callback(msg, a=a, b=b)
|
||||||
|
|
||||||
|
|
||||||
|
def install_systemd(app_path):
|
||||||
|
"""Installs generated systemd file to system's systemd directory.
|
||||||
|
|
||||||
|
Arguments:
|
||||||
|
app_path {Path} -- hyperglass runtime path
|
||||||
|
|
||||||
|
Raises:
|
||||||
|
ClickException: Raised if the /etc/systemd/system does not exist
|
||||||
|
ClickException: Raised if the symlinked file does not exit
|
||||||
|
|
||||||
|
Returns:
|
||||||
|
{bool} -- True if successful
|
||||||
|
"""
|
||||||
|
service = app_path / "hyperglass.service"
|
||||||
|
systemd = Path("/etc/systemd/system")
|
||||||
|
installed = systemd / "hyperglass.service"
|
||||||
|
|
||||||
|
if not systemd.exists():
|
||||||
|
error("{e} does not exist. Unable to install systemd service.", e=systemd)
|
||||||
|
|
||||||
|
installed.symlink_to(service)
|
||||||
|
|
||||||
|
if not installed.exists():
|
||||||
|
error("Unable to symlink {s} to {d}", s=service, d=installed)
|
||||||
|
|
||||||
|
success("Symlinked {s} to {d}", s=service, d=installed)
|
||||||
|
return True
|
||||||
|
Reference in New Issue
Block a user