| 12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849 | #!/usr/bin/env bashsource "${SNAP}/helper/init"# if ! [[ -d "${CERTS_DIR}" ]]; then#     logger "Creating dir ${CERTS_DIR}"#     mkdir "${CERTS_DIR}"#     chmod 1755 "${CERTS_DIR}"# fiif ! [[ -d "${SSL_DIR}" ]]; then    logger "Creating local cert dir ${SSL_DIR}"    mkdir "${SSL_DIR}"filogger "Creating connection from ${SNAP_NAME} (uuid: ${UUID})"KEY=`gpg --armor --export "${UUID}"`if [ -z "${KEY}" ]; then    gpg_start_agent    logger "Create GPG-key"    gpg --batch --no-tty --gen-key <<< "    %echo Generating a basic OpenPGP key    Key-Type: default    Subkey-Type: default    Name-Real: ${SNAP_NAME}    Name-Email: ${UUID}@${SNAP_NAME}.gpg    Name-comment: Generated from ${SNAP_NAME} for certs-slot    Expire-Date: 0    %no-protection    %commit    %echo done"    gpg_close_agentfiKEY=`gpg --armor --export "${UUID}"`if [ $? -ne 0 ]; then    echo "Failed to create GPG-key"    logger "Failed to create GPG-key for ${UUID}"    exit 1fisnapctl set :certs snapname="${SNAP_NAME}"snapctl set :certs uuid="${UUID}"snapctl set :certs pkey="${KEY}"logger "${SNAP_NAME}:certs (uuid: ${UUID}) prepared"logger "Key: ${KEY}"
 |