Compare commits

...

8 Commits
test ... main

Author SHA1 Message Date
88823ef727
build: always try to pull a newer build image
All checks were successful
continuous-integration/drone/push Build is passing
2024-10-10 22:25:29 +02:00
fcecdaee88
build: enforce building on computing nodes only
Some checks failed
continuous-integration/drone/push Build is failing
2024-10-10 22:20:48 +02:00
714db9fb25
ADD: own function for parsing subscriptions
Some checks failed
continuous-integration/drone Build is failing
2024-03-17 08:51:28 +01:00
002f1fa11a
ADD: provide version info as internal"
All checks were successful
continuous-integration/drone/push Build is passing
Closes: #33
2024-03-09 19:34:59 +01:00
f0fae9fd82
FIX: enforce integer in JSON string
All checks were successful
continuous-integration/drone/push Build is passing
Closes: #19 #32
2024-03-09 17:57:11 +01:00
f09fa33ef8
ADD: added information about installation
All checks were successful
continuous-integration/drone/push Build is passing
2024-03-02 12:59:41 +01:00
016fe149b9
ADD: fixed destination path
All checks were successful
continuous-integration/drone/push Build is passing
2024-03-02 11:49:43 +01:00
6e20d6675a
ADD: started ci/cd
All checks were successful
continuous-integration/drone/push Build is passing
2024-03-02 09:59:46 +01:00
6 changed files with 173 additions and 8 deletions

105
.drone.yml Normal file
View File

@ -0,0 +1,105 @@
kind: pipeline
type: kubernetes
name: build-amd64
platform:
arch: amd64
node_selector:
kubernetes.io/arch: amd64
federationhq.de/location: Blumendorf
federationhq.de/compute: true
volumes:
- name: fedhq-ca-crt
config_map:
name: fedhq-ca-crt
default_mode: 420 # same as 644 in octal, or u+w,a+r
optional: false
steps:
- name: generate control
image: debian:bookworm
pull: always
commands:
- apt-get -qy update && apt-get -qy install git
- scripts/generate_control.sh
- name: build amd64
image: quay.io/buildah/stable
pull: always
privileged: true
volumes:
- name: fedhq-ca-crt
path: /etc/ssl/certs2/
commands:
- scripts/setupEnvironment.sh
- buildah bud -t "registry.cloud.federationhq.de/nginx-fhem-ntfy:latest-amd64" --arch amd64 .
- buildah push --all registry.cloud.federationhq.de/nginx-fhem-ntfy:latest-amd64
---
kind: pipeline
type: kubernetes
name: build-arm64
platform:
arch: arm64
node_selector:
kubernetes.io/arch: arm64
federationhq.de/location: Blumendorf
federationhq.de/compute: true
volumes:
- name: fedhq-ca-crt
config_map:
name: fedhq-ca-crt
default_mode: 420 # same as 644 in octal, or u+w,a+r
optional: false
steps:
- name: generate control
image: debian:bookworm
pull: always
commands:
- apt-get -qy update && apt-get -qy install git
- scripts/generate_control.sh
- name: build arm64
image: quay.io/buildah/stable
pull: always
privileged: true
volumes:
- name: fedhq-ca-crt
path: /etc/ssl/certs2/
commands:
- scripts/setupEnvironment.sh
- buildah bud -t "registry.cloud.federationhq.de/nginx-fhem-ntfy:latest-arm64" --arch arm64 .
- buildah push --all registry.cloud.federationhq.de/nginx-fhem-ntfy:latest-arm64
---
kind: pipeline
type: kubernetes
name: push
node_selector:
kubernetes.io/arch: amd64
federationhq.de/location: Blumendorf
federationhq.de/compute: true
volumes:
- name: fedhq-ca-crt
config_map:
name: fedhq-ca-crt
default_mode: 420 # same as 644 in octal, or u+w,a+r
optional: false
steps:
- name: push
image: quay.io/buildah/stable
pull: always
privileged: true
volumes:
- name: fedhq-ca-crt
path: /etc/ssl/certs2/
commands:
- scripts/setupEnvironment.sh
- buildah manifest create nginx-fhem-ntfy:latest registry.cloud.federationhq.de/nginx-fhem-ntfy:latest-arm64 registry.cloud.federationhq.de/nginx-fhem-ntfy:latest-amd64
- buildah manifest push --all nginx-fhem-ntfy:latest docker://registry.cloud.federationhq.de/nginx-fhem-ntfy:latest
- buildah manifest rm nginx-fhem-ntfy:latest
depends_on:
- build-amd64
- build-arm64

5
Containerfile Normal file
View File

@ -0,0 +1,5 @@
FROM docker.io/nginx:latest
COPY FHEM /usr/share/nginx/html/FHEM/
COPY controls_byterazor-fhem-ntfy.txt /usr/share/nginx/html/
COPY CHANGED /usr/share/nginx/html/

View File

@ -140,6 +140,7 @@ sub NTFY_Define
$hash->{NAME} = $name; $hash->{NAME} = $name;
$hash->{SERVER} = $params->[2]; $hash->{SERVER} = $params->[2];
$hash->{VERSION} = $VERSION;
$hash->{USERNAME} = $h->{user} || ""; $hash->{USERNAME} = $h->{user} || "";
$hash->{helper}{PASSWORD} = $h->{password}; $hash->{helper}{PASSWORD} = $h->{password};
$modules{NTFY_CLIENT}{defptr}{$hash->{SERVER}} = $hash; $modules{NTFY_CLIENT}{defptr}{$hash->{SERVER}} = $hash;
@ -149,17 +150,25 @@ sub NTFY_Define
return; return;
} }
sub NTFY_Get_Subscriptions
{
my $hash = shift;
my @subscriptions;
for my $k (keys %{$modules{NTFY_TOPIC}{defptr}})
{
$k=~/^(.*)_(.*)$/;
push(@subscriptions,$2);
}
return @subscriptions;
}
sub NTFY_Update_Subscriptions_Readings sub NTFY_Update_Subscriptions_Readings
{ {
my $hash = shift; my $hash = shift;
my @topics; my @topics = NTFY_Get_Subscriptions($hash);
for my $k (keys %{$modules{NTFY_TOPIC}{defptr}})
{
$k=~/^(.*)_(.*)$/;
push(@topics,$2);
}
readingsSingleUpdate($hash,"subscriptions", join(",", @topics),1); readingsSingleUpdate($hash,"subscriptions", join(",", @topics),1);
} }
@ -221,7 +230,7 @@ sub NTFY_Publish_Msg
if ($msg->{priority}) if ($msg->{priority})
{ {
$message->{priority} = $msg->{priority}; $message->{priority} = int($msg->{priority});
} }
if ($msg->{keywords}) if ($msg->{keywords})

View File

@ -20,6 +20,19 @@ that this is a sparetime project of someone with a family.
You will find the issue tracker at https://rm.byterazor.de/projects/fhem-ntfy. You will find the issue tracker at https://rm.byterazor.de/projects/fhem-ntfy.
## Installation
### Manual
just copy the files within the FHEM directory to you FHEM installations FHEM directory and restart the server
### FHEM Updates
On the FHEM command line run
update add https://rm.byterazor.de/upd-fhem-ntfy/controls_byterazor-fhem-ntfy.txt
update
## Authors ## Authors
- Dominik Meyer <dmeyer@federationhq.de> - Dominik Meyer <dmeyer@federationhq.de>

30
scripts/generate_control.sh Executable file
View File

@ -0,0 +1,30 @@
#!/bin/bash
CONTROL_FILE="controls_byterazor-fhem-ntfy.txt"
if [ -e $CONTROL_FILE ]; then
rm $CONTROL_FILE
fi
find ./FHEM -type f \( ! -iname "0.*" \) -print0 | while IFS= read -r -d '' f;
do
out="UPD $(stat --format "%z %s" $f | sed -e "s#\([0-9-]*\)\ \([0-9:]*\)\.[0-9]*\ [+0-9]*#\1_\2#") $f"
echo "${out//.\//}" >> $CONTROL_FILE
done
#generate CHANGELOG
rm CHANGED
DATE=
git log --no-merges --pretty=format:'%ci|%s' | while read -r line; do
CDATE=$(echo "${line}" | awk '{print $1}')
MSG=$(echo "${line}" | awk -F '|' '{print $2}')
if [ "$DATE" != "$CDATE" ]; then
DATE=$CDATE
echo "$DATE" >> CHANGED
fi
echo " ${MSG}" >> CHANGED
done

3
scripts/setupEnvironment.sh Executable file
View File

@ -0,0 +1,3 @@
#!/bin/bash
cp /etc/ssl/certs2/federationHQ-CA.pem /etc/pki/ca-trust/source/anchors/
update-ca-trust