Преглед изворни кода

Version bump and remove WOT-plugin since typing is no longer an issue

Joachim M. Giæver пре 3 година
родитељ
комит
e4b34f9cff

+ 0 - 60
scripts/bin/certs-daemon

@@ -1,60 +0,0 @@
-#!/usr/bin/env bash
-
-if [ `id -gn` != "root" ]; then
-    echo "Run as root!"
-    exit 1
-fi
-
-source "${SNAP}/init"
-DOMAIN=`snapctl get domain`
-
-echo "See log (journal -exf --grep=snap.${SNAP_NAME}*) for result"
-if [ "${DOMAIN}" != "--not-set" ]; then
-    snapctl is-connected certs
-
-    if [ $? -ne 0 ]; then
-        snapctl set domain="--not-set"
-        exit 0
-    fi
-
-    readarray -d '' DOMAINS < <(find "${CERTS_DIR}" -type d -name "${DOMAIN}" -print0)
-
-    if [ "${#DOMAINS[@]}" -ne 0 ]; then
-        DOMAIN_DIR="${DOMAINS[0]}"
-        LAST_EDITED=`stat "${DOMAIN_DIR}/.time" --format="%Y" 2> /dev/null || echo 0`
-        ORIG_EDITED=`stat "${SSL_DIR}/.time" --format="%Y" 2> /dev/null || echo 0`
-
-        if [ "${LAST_EDITED}" -le "${ORIG_EDITED}" ]; then 
-            logger "${SNAP_NAME}: Certificate for ${DOMAIN} is not changed"
-            exit 0
-        fi
-
-        gpg_start_agent
-
-        i=0
-        readarray -d '' CERTIFICATES < <(find "${DOMAIN_DIR}" -type f -name "*.gpg" -print0)
-        for CERTIFICATE in "${CERTIFICATES[@]}"; do
-            DEST="${SSL_DIR}/`basename "${CERTIFICATE}" ".gpg"`"
-            ORIG=""
-            if [ -f "${DEST}" ]; then
-                ORIG="`cat "${DEST}"`"
-            fi
-            gpg --batch --yes --output "${DEST}" --decrypt "${CERTIFICATE}"
-                
-            DIFF=`echo "${ORIG}" | diff "${DEST}" -`
-            RET=$?
-            if [ "${RET}" -ne 0 ]; then
-                echo "${ORIG}" > "${DEST}.backup"
-                (( i = $i + 1 ))
-            fi
-        done
-        if [ "${i}" -ne 0 ]; then
-            cp -f "${DOMAIN_DIR}/.time" "${SSL_DIR}/.time"
-            logger "${SNAP_NAME}: Certificates (${DOMAIN}) changed for ${SNAP_NAME}-${UUID}, restart"
-            snapctl restart "${SNAP_NAME}"
-        fi
-        gpg_close_agent
-    else
-        logger "No certificate for ${DOMAIN} for ${SNAP_NAME}"
-    fi
-fi

+ 1 - 28
scripts/config/init

@@ -12,31 +12,4 @@ fi
 
 UUID=`cat ${UUID_FILE}`
 
-DOMAIN=`snapctl get domain`
-if [ -z "${DOMAIN}" ]; then
-    DOMAIN="--not-set"
-fi
-
-snapctl set domain="${DOMAIN}"
-
-function gpg_start_agent {
-    gpg-agent 2> /dev/null
-    if [ $? -ne 0 ]; then
-        logger "GPG-agent not here"
-        gpg-agent --daemon 2> /dev/null
-        if [ $? -eq 0 ]; then
-            logger "GPG-agent started"
-        else
-            logger "Failed starting GPG-agent, trying anyway"
-        fi
-    fi
-    return 0
-}
-
-function gpg_close_agent {
-    PID=`ps -T | grep gpg-agent | head -n 1 | cut -d' ' -f1`
-    if [ -n "${PID}" ]; then
-        logger "Kill GPG-agent: ${PID}"
-        kill -9 "${PID}" >> /dev/null
-    fi
-}
+logger "${SNAP_NAME} does not support ACME.sh anymore. Please look into using Lets Encrypt or a proxy for SSL support."

+ 0 - 25
scripts/hooks/configure

@@ -2,28 +2,3 @@
 
 source "${SNAP}/init"
 
-DOMAIN=`snapctl get domain`
-
-if [ -z "${DOMAIN}" ]; then
-    DOMAIN="--not-set"
-else
-    snapctl is-connected certs
-    if [ $? -eq 0 ]; then
-        HIT=`ls -Al "${SNAP_DATA}/certs/" | grep "${UUID}_${DOMAIN}" | wc -l`
-        if [ "${HIT}" -eq 0 ]; then
-            echo "No certificate available for"
-            echo "Snap: ${SNAP_NAME}"
-            echo "UUID: ${UUID}"
-            echo "Domain: ${DOMAIN}"
-            echo "See 'acme-sh' (snap install acme-sh)"
-            DOMAIN="--not-set"
-        fi
-    else 
-        "Slot 'certs' not connected"
-        echo "See 'acme-sh' (snap install acme-sh)"
-        echo "then 'snap connect acme-sh:certs ${SNAP_DATA}:certs'"
-        DOMAIN='--not-set'
-    fi 
-fi
-
-snapctl set domain="${DOMAIN}"

+ 0 - 43
scripts/hooks/prepare-slot-certs

@@ -1,43 +0,0 @@
-#!/usr/bin/env bash
-
-source "${SNAP}/init"
-
-if ! [[ -d "${SSL_DIR}" ]]; then
-    logger "Creating local cert dir ${SSL_DIR}"
-    mkdir "${SSL_DIR}"
-fi
-
-logger "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_agent
-fi
-
-KEY=`gpg --armor --export "${UUID}"`
-if [ $? -ne 0 ]; then
-    echo "Failed to create GPG-key"
-    logger "Failed to create GPG-key for ${UUID}"
-    exit 1
-fi
-
-snapctl 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}"

+ 0 - 7
snap/hooks/disconnect-slot-certs

@@ -1,7 +0,0 @@
-#!/usr/bin/env bash
-
-source "${SNAP}/init"
-logger "Disconnect ${SNAP_NAME}:certs (uuid: ${UUID})"
-
-rm -rf "${SSL_DIR}"
-snapctl restart "${SNAP_NAME}"

+ 1 - 0
snap/plugins/python_wot_plugin.py

@@ -3,6 +3,7 @@
 import snapcraft
 import snapcraft.plugins.v2 as plugins
 from typing import Any, Dict, List, Set
+import os
 
 """
 See snapcraft.plugins.v2.python.PythonPlugin

+ 4 - 46
snap/snapcraft.yaml

@@ -1,5 +1,5 @@
 name: home-assistant-snap
-version: '2021.1.5'
+version: '2021.2.0'
 summary: Open source home automation that puts local control and privacy first
 description: |
   Home Assistant is a home automation platform running on Python 3. 
@@ -30,26 +30,11 @@ slots:
     content: components
     write: 
       - $SNAP_DATA/custom_components
-  certs:
-    interface: content
-    content: certs
-    write: 
-      - $SNAP_DATA/certs
   configurations:
     interface: content
     write:
       - $SNAP_DATA
 
-hooks:
-  install:
-    plugs:
-      - network
-      - network-bind
-  prepare-slot-certs:
-    plugs:
-      - network
-      - network-bind
-
 apps:
   home-assistant-snap:
     command: bin/hass --config $SNAP_DATA
@@ -71,27 +56,10 @@ apps:
       - components
   check-config:
     command: bin/hass --script check_config
-  renew-cert:
-    command: bin/certs-daemon
-    daemon: oneshot
-    restart-condition: always
-    timer: 00:00-24:00/24
-    slots:
-      - certs
-    plugs:
-      - network
-      - network-bind
-  force-renew-cert:
-    command: bin/certs-daemon
-    slots:
-      - certs
-    plugs:
-      - network
-      - network-bind
 
 parts:
   homeassistant:
-    plugin: python-wot-plugin
+    plugin: python #-wot-plugin
     source: https://github.com/home-assistant/core.git
     source-tag: ${SNAPCRAFT_PROJECT_VERSION}
     python-packages:
@@ -99,6 +67,8 @@ parts:
       - wheel
       - Cython
       - pip
+    # build-environment:
+    #   - SNAPCRAFT_PYTHON_INTERPRETER: python3.9
     build-packages:
       - python3
       - python3-dev
@@ -146,23 +116,11 @@ parts:
     source-type: local
     stage-packages:
       - uuid
-      - libossp-uuid16
-      - libassuan0
-      - gpg
-      - gpg-agent
     organize:
       install: snap/hooks/install
       configure: snap/hooks/configure
       post-refresh: snap/hooks/post-refresh
-      prepare-slot-certs: snap/hooks/prepare-slot-certs
       connect-plug-bin: snap/hooks/connect-plug-bin
-  bins:
-    plugin: dump
-    source: ./scripts/bin
-    source-type: local
-    organize:
-      slot-certs: bin/slot-certs
-      certs-daemon: bin/certs-daemon
   config:
     plugin: dump
     source: ./scripts/config