From 0f81a008d84ad12b3d51fad6e5e747bf7a72acd7 Mon Sep 17 00:00:00 2001 From: Zsolt Ero Date: Tue, 5 Dec 2023 23:58:27 +0100 Subject: [PATCH] work --- init-server.py | 1 - ssh_lib/nginx.py | 9 +++++---- ssh_lib/pkg_base.py | 18 ++++++++++++++---- ssh_lib/utils.py | 1 + 4 files changed, 20 insertions(+), 9 deletions(-) diff --git a/init-server.py b/init-server.py index 9d32c78..6d47abc 100755 --- a/init-server.py +++ b/init-server.py @@ -37,7 +37,6 @@ if input(f'run {sys.argv[0]} on {HOSTNAME}? [y/N]: ') != 'y': c = Connection( host=HOSTNAME, - user='ofm', config=Config(overrides={'sudo': {'password': OFM_USER_PASSWD}}), ) prepare_server(c) diff --git a/ssh_lib/nginx.py b/ssh_lib/nginx.py index f7d06f5..8cbcd55 100644 --- a/ssh_lib/nginx.py +++ b/ssh_lib/nginx.py @@ -51,12 +51,13 @@ def nginx(c): def certbot(c): - # https://certbot.eff.org/lets-encrypt/ubuntubionic-nginx apt_get_install(c, 'snapd') - c.sudo('snap install core', warn=True) + + # this is silly, but needs to be run twice + c.sudo('snap install core', warn=True, echo=True) + c.sudo('snap install core', warn=True, echo=True) + c.sudo('snap refresh core', warn=True) apt_get_purge(c, 'certbot') c.sudo('snap install --classic certbot', warn=True) - c.sudo('snap set certbot trust-plugin-with-root=ok') - c.sudo('snap install certbot-dns-cloudflare') diff --git a/ssh_lib/pkg_base.py b/ssh_lib/pkg_base.py index abb88eb..65eff6d 100644 --- a/ssh_lib/pkg_base.py +++ b/ssh_lib/pkg_base.py @@ -15,7 +15,7 @@ def pkg_upgrade(c): def pkg_clean(c): - clean_list = [ + pkg_list = [ # firewalls 'ufw', 'nftables', @@ -28,11 +28,21 @@ def pkg_clean(c): 'ubuntu-advantage-tools', ] - apt_get_purge(c, ' '.join(clean_list)) + apt_get_purge(c, ' '.join(pkg_list)) apt_get_autoremove(c) sudo_cmd(c, 'dpkg --list | grep "^rc" | cut -d " " -f 3 | xargs -r dpkg --purge') - c.sudo('iptables -L') + c.sudo('iptables -L', warn=True) def pkg_base(c): - apt_get_install(c, 'python3 nload iftop') + pkg_list = [ + 'wget', + 'gpg', + 'gnupg-agent', + 'python3', + 'nload', + 'iftop', + 'snapd', + ] + + apt_get_install(c, ' '.join(pkg_list)) diff --git a/ssh_lib/utils.py b/ssh_lib/utils.py index 6bdd7eb..0e79fa8 100644 --- a/ssh_lib/utils.py +++ b/ssh_lib/utils.py @@ -88,6 +88,7 @@ def apt_get_install(c, pkgs, warn=False): c.sudo( f'DEBIAN_FRONTEND=noninteractive apt-get install -y --no-install-recommends {pkgs}', warn=warn, + echo=True, )