diff --git a/lib/pyinfra-util/pyinfra_util.egg-info/PKG-INFO b/lib/pyinfra-util/pyinfra_util.egg-info/PKG-INFO new file mode 100644 index 0000000..7d9179b --- /dev/null +++ b/lib/pyinfra-util/pyinfra_util.egg-info/PKG-INFO @@ -0,0 +1,3 @@ +Metadata-Version: 2.1 +Name: pyinfra-util +Version: 0.1 diff --git a/lib/pyinfra-util/pyinfra_util.egg-info/SOURCES.txt b/lib/pyinfra-util/pyinfra_util.egg-info/SOURCES.txt new file mode 100644 index 0000000..1d99e4c --- /dev/null +++ b/lib/pyinfra-util/pyinfra_util.egg-info/SOURCES.txt @@ -0,0 +1,7 @@ +pyproject.toml +pyinfra_util/__init__.py +pyinfra_util/util.py +pyinfra_util.egg-info/PKG-INFO +pyinfra_util.egg-info/SOURCES.txt +pyinfra_util.egg-info/dependency_links.txt +pyinfra_util.egg-info/top_level.txt \ No newline at end of file diff --git a/lib/pyinfra-util/pyinfra_util.egg-info/dependency_links.txt b/lib/pyinfra-util/pyinfra_util.egg-info/dependency_links.txt new file mode 100644 index 0000000..8b13789 --- /dev/null +++ b/lib/pyinfra-util/pyinfra_util.egg-info/dependency_links.txt @@ -0,0 +1 @@ + diff --git a/lib/pyinfra-util/pyinfra_util.egg-info/top_level.txt b/lib/pyinfra-util/pyinfra_util.egg-info/top_level.txt new file mode 100644 index 0000000..1c602f1 --- /dev/null +++ b/lib/pyinfra-util/pyinfra_util.egg-info/top_level.txt @@ -0,0 +1 @@ +pyinfra_util diff --git a/lib/pyinfra-util/pyinfra_util/__init__.py b/lib/pyinfra-util/pyinfra_util/__init__.py new file mode 100644 index 0000000..675fb98 --- /dev/null +++ b/lib/pyinfra-util/pyinfra_util/__init__.py @@ -0,0 +1 @@ +from .util import get_pass, deploy_tmux diff --git a/lib/pyinfra-util/pyinfra_util/__pycache__/__init__.cpython-310.pyc b/lib/pyinfra-util/pyinfra_util/__pycache__/__init__.cpython-310.pyc new file mode 100644 index 0000000..4cc203e Binary files /dev/null and b/lib/pyinfra-util/pyinfra_util/__pycache__/__init__.cpython-310.pyc differ diff --git a/lib/pyinfra-util/pyinfra_util/__pycache__/util.cpython-310.pyc b/lib/pyinfra-util/pyinfra_util/__pycache__/util.cpython-310.pyc new file mode 100644 index 0000000..f9f24fc Binary files /dev/null and b/lib/pyinfra-util/pyinfra_util/__pycache__/util.cpython-310.pyc differ diff --git a/lib/pyinfra-util/pyinfra_util/util.py b/lib/pyinfra-util/pyinfra_util/util.py new file mode 100644 index 0000000..41d5d9d --- /dev/null +++ b/lib/pyinfra-util/pyinfra_util/util.py @@ -0,0 +1,56 @@ +""" +nginx deploy +""" +import subprocess +from pyinfra.operations import files, apt + + +def get_pass(filename: str) -> str: + """Get the data from the password manager.""" + try: + r = subprocess.run(["pass", "show", filename], capture_output=True) + except FileNotFoundError: + readme_url = "https://git.0x90.space/deltachat/secrets" + print(f"Please install pass and pull the latest version of our pass secrets from {readme_url}") + exit() + return r.stdout.decode('utf-8') + + +def deploy_tmux(home_dir="/root", escape_key="C-b", additional_config=[]): + apt.packages( + name="apt install tmux", + packages=["tmux"], + ) + + config = [ + f"set-option -g prefix {escape_key}", + "set-option -g aggressive-resize on", + "set-option -g mouse on", + "set-option -g set-titles on", + "set-option -g set-titles-string '#I:#W - \"#H\"'", + "unbind-key C-b", + "bind-key ` send-prefix", + "bind-key a last-window", + "bind-key k kill-session", + ] + for item in additional_config: + config.append(item) + for line in config: + files.line( + path=f"{home_dir}/.tmux.conf", + line=line, + ) + + dot_profile_add = """ +# autostart tmux +if [ -t 0 -a -z "$TMUX" ] +then + test -z "$(tmux list-sessions)" && exec tmux new -s "$USER" || exec tmux new -A -s $(tty | tail -c +6) -t "$USER" +fi +""" + files.block( + name="connect to tmux session on login", + path=f"{home_dir}/.profile", + content=dot_profile_add, + try_prevent_shell_expansion=True, + ) diff --git a/lib/pyinfra-util/pyproject.toml b/lib/pyinfra-util/pyproject.toml new file mode 100644 index 0000000..25f8663 --- /dev/null +++ b/lib/pyinfra-util/pyproject.toml @@ -0,0 +1,7 @@ +[build-system] +requires = ["setuptools>=45"] +build-backend = "setuptools.build_meta" + +[project] +name = "pyinfra-util" +version = "0.1"