#!/bin/bash set -e # This code is based on snapcraft's own patch to work around this problem at # https://github.com/snapcore/snapcraft/blob/a97fb5c7ea553a1bd20f4887a7c3393e75761890/patches/ctypes_init.diff. case "${SNAP_ARCH}" in 'arm64') ARCH_TRIPLET='aarch64-linux-gnu';; 'armhf') ARCH_TRIPLET='arm-linux-gnueabihf';; 'i386') ARCH_TRIPLET='i386-linux-gnu';; 'ppc64el') ARCH_TRIPLET='powerpc64le-linux-gnu';; 'powerpc') ARCH_TRIPLET='powerpc-linux-gnu';; 'amd64') ARCH_TRIPLET='x86_64-linux-gnu';; 's390x') ARCH_TRIPLET='s390x-linux-gnu';; *) echo "Unrecongized value of SNAP_ARCH: ${SNAP_ARCH}" >&2 exit 1 esac PARTIAL_LIBRARY_PATH="${SNAP}/usr/lib/${ARCH_TRIPLET}/" export LD_LIBRARY_PATH="${PARTIAL_LIBRARY_PATH}:${LD_LIBRARY_PATH}" export CERTBOT_AUGEAS_PATH="${PARTIAL_LIBRARY_PATH}libaugeas.so.0" join() { sep=$1 first=$2 if [ "$first" != "" ]; then shift 2 echo -n "${first}" for item in "$@"; do echo -n "${sep}${item}"; done echo fi } paths=$(for plugin_snap in $(snap connections certbot|sed -n '2,$p'|awk '$1=="content[certbot-1]"{print $3}'|cut -d: -f1); do echo /snap/$plugin_snap/current/lib/python3.8/site-packages; done) export CERTBOT_PLUGIN_PATH=$(join : $paths) exec certbot "$@"