From e8ca109e7a4a09838cbdb37bcd335d97bafe7684 Mon Sep 17 00:00:00 2001 From: Jamil Bou Kheir Date: Sun, 11 Jul 2021 11:30:27 -0700 Subject: [PATCH] Test removal of package --- .ci/functional_test.sh | 24 +++++++++++++++---- pkg/ubuntu_18.04_amd64/DEBIAN/postinst | 8 +++---- .../lib/systemd/system/firezone.service | 1 + .../lib/systemd/system/firezone.service | 1 + .../lib/systemd/system/firezone.service | 1 + .../lib/systemd/system/firezone.service | 1 + 6 files changed, 28 insertions(+), 8 deletions(-) diff --git a/.ci/functional_test.sh b/.ci/functional_test.sh index 628e6c1b8..17e469331 100755 --- a/.ci/functional_test.sh +++ b/.ci/functional_test.sh @@ -7,20 +7,36 @@ sudo apt-get install -y -q postgresql \ sudo systemctl start postgresql sudo dpkg -i *.deb -echo "Enabling service..." +echo "Enabling service" sudo systemctl start firezone # Wait for app to start +# XXX: Remove sleeps sleep 10 -echo "Service status..." +echo "Service status" sudo systemctl status firezone.service -echo "Printing service logs..." +echo "Printing service logs" sudo journalctl -u firezone.service -echo "Trying to load homepage..." +echo "Trying to load homepage" curl -i -vvv -k https://$(hostname):8800/ echo "Printing SSL debug info" openssl s_client -connect $(hostname):8800 -servername $(hostname) -showcerts -prexit + +echo "Removing package" +sudo apt-get remove firezone + +echo "Checking if directory was removed" +if [ -d /opt/firezone ]; then + echo "Package removal issue" + exit 1 +fi + +echo "Checking if database was dropped" +if $(sudo su postgres -c "psql -lqt | cut -d \| -f 1 | grep -qw firezone"); then + echo "Database still exists" + exit 1 +fi diff --git a/pkg/ubuntu_18.04_amd64/DEBIAN/postinst b/pkg/ubuntu_18.04_amd64/DEBIAN/postinst index f6b67cb1b..dc130fe95 100755 --- a/pkg/ubuntu_18.04_amd64/DEBIAN/postinst +++ b/pkg/ubuntu_18.04_amd64/DEBIAN/postinst @@ -62,8 +62,10 @@ secret_key_base="$(openssl rand -base64 48)" db_key="$(openssl rand -base64 32)" wg_server_key="$(wg genkey)" -# Write FireZone config files -if [ ! -f /opt/firezone/config.env ]; then +# Write FireZone config file +if [ -f /opt/firezone/config.env ]; then + echo "config file exists; not creating" +else cat <> /opt/firezone/config.env # This file is loaded into FireZone's Environment upon launch to configure it. @@ -117,8 +119,6 @@ SSL_KEY_FILE=/opt/firezone/ssl/key.pem # users via the CLI. DISABLE_SIGNUP=yes EOT -else - echo "config file exists; not creating" fi # Set perms diff --git a/pkg/ubuntu_18.04_amd64/lib/systemd/system/firezone.service b/pkg/ubuntu_18.04_amd64/lib/systemd/system/firezone.service index 93714f254..b55af7901 100644 --- a/pkg/ubuntu_18.04_amd64/lib/systemd/system/firezone.service +++ b/pkg/ubuntu_18.04_amd64/lib/systemd/system/firezone.service @@ -11,6 +11,7 @@ AmbientCapabilities=CAP_NET_ADMIN CAP_NET_RAW CAP_DAC_READ_SEARCH EnvironmentFile=/opt/firezone/config.env ExecStartPre=/opt/firezone/bin/firezone eval "FzHttp.Release.migrate" ExecStart=/opt/firezone/bin/firezone start +# XXX: Remove sleeps ExecStartPost=/bin/sleep 8 ExecStartPost=/opt/firezone/bin/firezone rpc "FzHttp.Release.create_admin_user" diff --git a/pkg/ubuntu_18.04_arm64/lib/systemd/system/firezone.service b/pkg/ubuntu_18.04_arm64/lib/systemd/system/firezone.service index 1ffca6203..a1be51acd 100644 --- a/pkg/ubuntu_18.04_arm64/lib/systemd/system/firezone.service +++ b/pkg/ubuntu_18.04_arm64/lib/systemd/system/firezone.service @@ -11,6 +11,7 @@ AmbientCapabilities=CAP_NET_ADMIN CAP_NET_RAW CAP_DAC_READ_SEARCH EnvironmentFile=/opt/firezone/config.env ExecStartPre=/opt/firezone/bin/firezone eval "FzHttp.Release.migrate" ExecStart=/opt/firezone/bin/firezone start +# XXX: Remove sleeps ExecStartPost=/bin/sleep 8 ExecStartPost=/opt/firezone/bin/firezone rpc "FzHttp.Release.create_admin_user" diff --git a/pkg/ubuntu_20.04_amd64/lib/systemd/system/firezone.service b/pkg/ubuntu_20.04_amd64/lib/systemd/system/firezone.service index 1ffca6203..a1be51acd 100644 --- a/pkg/ubuntu_20.04_amd64/lib/systemd/system/firezone.service +++ b/pkg/ubuntu_20.04_amd64/lib/systemd/system/firezone.service @@ -11,6 +11,7 @@ AmbientCapabilities=CAP_NET_ADMIN CAP_NET_RAW CAP_DAC_READ_SEARCH EnvironmentFile=/opt/firezone/config.env ExecStartPre=/opt/firezone/bin/firezone eval "FzHttp.Release.migrate" ExecStart=/opt/firezone/bin/firezone start +# XXX: Remove sleeps ExecStartPost=/bin/sleep 8 ExecStartPost=/opt/firezone/bin/firezone rpc "FzHttp.Release.create_admin_user" diff --git a/pkg/ubuntu_20.04_arm64/lib/systemd/system/firezone.service b/pkg/ubuntu_20.04_arm64/lib/systemd/system/firezone.service index 1ffca6203..a1be51acd 100644 --- a/pkg/ubuntu_20.04_arm64/lib/systemd/system/firezone.service +++ b/pkg/ubuntu_20.04_arm64/lib/systemd/system/firezone.service @@ -11,6 +11,7 @@ AmbientCapabilities=CAP_NET_ADMIN CAP_NET_RAW CAP_DAC_READ_SEARCH EnvironmentFile=/opt/firezone/config.env ExecStartPre=/opt/firezone/bin/firezone eval "FzHttp.Release.migrate" ExecStart=/opt/firezone/bin/firezone start +# XXX: Remove sleeps ExecStartPost=/bin/sleep 8 ExecStartPost=/opt/firezone/bin/firezone rpc "FzHttp.Release.create_admin_user"