diff --git a/.drone.yml b/.drone.yml new file mode 100644 index 0000000..617fc40 --- /dev/null +++ b/.drone.yml @@ -0,0 +1,47 @@ +kind: pipeline +type: kubernetes +name: default + +node_selector: + physical-node: dev2 + +trigger: + branch: + - master + event: + - push +workspace: + path: /drone/src + +steps: + - name: build multiarch from dev + image: docker.io/owncloudci/drone-docker-buildx:4 + privileged: true + settings: + cache-from: [ "registry.dev.format.hu/homeassistant-init-container" ] + registry: registry.dev.format.hu + repo: registry.dev.format.hu/homeassistant-init-container + tags: latest + dockerfile: Dockerfile + username: + from_secret: dev-hu-registry-username + password: + from_secret: dev-hu-registry-password + platforms: + - linux/amd64 + - linux/arm64 + + - name: pull image to dockerhub + image: docker.io/owncloudci/drone-docker-buildx:4 + privileged: true + settings: + cache-from: [ "safebox/homeassistant-init-container" ] + repo: safebox/homeassistant-init-container + tags: latest + username: + from_secret: dockerhub-username + password: + from_secret: dockerhub-password + platforms: + - linux/amd64 + - linux/arm64 diff --git a/entrypoint.sh b/entrypoint.sh index 14f4311..d958ccf 100644 --- a/entrypoint.sh +++ b/entrypoint.sh @@ -2,21 +2,19 @@ HOMEASSISTANT_DOMAIN="https://$DOMAIN"; -if [ "$DOMAIN" == "localhost" ]; then - SELECTOR=$HOMEASSISTANT - HOMEASSISTANT_IP=$(hostname -i | awk '{print $1}') - HOST_FILE=/etc/system/data/dns/hosts.local; - - EXISTS=$(grep -w -F $SELECTOR $HOST_FILE); - if [ -n "$EXISTS" ]; then - # selector already exists in hosts file and SCALE is not in use - IP=$(echo $EXISTS | cut -d ' ' -f1); - sed "s/$IP/$HOMEASSISTANT_IP/g" $HOST_FILE > /tmp/hosts.local - mv /tmp/hosts.local $HOST_FILE; - else - echo "$HOMEASSISTANT_IP $SELECTOR" >> $HOST_FILE - fi +SELECTOR=$HOMEASSISTANT +HOMEASSISTANT_IP=$(hostname -i | awk '{print $1}') +HOST_FILE=/etc/system/data/dns/hosts.local; + +EXISTS=$(grep -w -F $SELECTOR $HOST_FILE); +if [ -n "$EXISTS" ]; then + # selector already exists in hosts file and SCALE is not in use + IP=$(echo $EXISTS | cut -d ' ' -f1); + sed "s/$IP/$HOMEASSISTANT_IP/g" $HOST_FILE > /tmp/hosts.local + mv /tmp/hosts.local $HOST_FILE; +else + echo "$HOMEASSISTANT_IP $SELECTOR" >> $HOST_FILE fi mkdir -p /etc/user/data/homeassistant/config