#!/bin/sh
set -ex

# XXX: This is cargo-culted and is probably pointless now but checking is painful.

# Autopkgtest may run in a special network where using the http proxy is mandatory.
sudo mkdir -p /etc/systemd/system/snapd.service.d/
if [ "${http_proxy:-}" != "" ]; then
    cat <<EOF | sudo tee /etc/systemd/system/snapd.service.d/proxy.conf
[Service]
Environment=http_proxy=$http_proxy
Environment=https_proxy=$http_proxy
EOF
    echo "http_proxy=$http_proxy" | sudo tee -a /etc/environment
    echo "https_proxy=$http_proxy" | sudo tee -a /etc/environment
fi

sudo systemctl daemon-reload

snap version
sudo snap install hello
snap run hello
