diff --git a/Deployment/Baremetal/DEBIAN/control b/Deployment/Baremetal/DEBIAN/control index 807cbba6..4523614c 100644 --- a/Deployment/Baremetal/DEBIAN/control +++ b/Deployment/Baremetal/DEBIAN/control @@ -1,6 +1,6 @@ Package: philbot-baremetal Provides: philbot-deployment -Version: 2.5.1 +Version: 2.6.0 Architecture: all Depends: philbot-config (>= 4.0.0), bash, cron, wget, tar, jq, ruby, ruby-bundler, nodejs (>= 20.0.0), npm, python3, python3-pip, python3-venv, libopusfile0, ffmpeg, curl, iptables-persistent, opentelemetry-shell (>= 2.4.3) Conflicts: philbot-containerized, philbot-k8s diff --git a/Deployment/Baremetal/DEBIAN/postinst b/Deployment/Baremetal/DEBIAN/postinst index d6a9f251..d1da7d75 100755 --- a/Deployment/Baremetal/DEBIAN/postinst +++ b/Deployment/Baremetal/DEBIAN/postinst @@ -1,21 +1,22 @@ #!/bin/bash -e source /usr/bin/philbot_init_otel - -if [ "$1" = "triggered" ]; then - philbot_stop +if [ "$1" = 'abort-configure' ] || [ "$1" = 'abort-upgrade' ] || [ "$1" = 'abort-remove' ] || [ "$1" = 'abort-deconfigure' ]; then + exit 0 +elif [ "$1" = 'triggered' ] || [ "$1" = 'reconfigure' ]; then + philbot_config_populate + philbot_restart +elif [ "$1" = 'configure' ]; then + philbot_config_populate + source /usr/bin/philbot_init_otel + wget -O /opt/philbot/libopus.tar.bz2 https://anaconda.org/anaconda/libopus/1.3/download/linux-64/libopus-1.3-h7b6447c_0.tar.bz2 + tar -xf /opt/philbot/libopus.tar.bz2 -C /opt/philbot + rm /opt/philbot/libopus.tar.bz2 + iptables -t nat -A PREROUTING -p tcp --dport 80 -j REDIRECT --to-port 8080 + iptables -t nat -A PREROUTING -p tcp --dport 443 -j REDIRECT --to-port 4443 + iptables-save > /etc/iptables/rules.v4 + systemctl daemon-reload + systemctl enable philbot_scheduler philbot_discordgateway2http philbot_backend philbot_voice + philbot_start +else + exit 1 fi - -philbot_config_populate -source /usr/bin/philbot_init_otel - -wget -O /opt/philbot/libopus.tar.bz2 https://anaconda.org/anaconda/libopus/1.3/download/linux-64/libopus-1.3-h7b6447c_0.tar.bz2 -tar -xf /opt/philbot/libopus.tar.bz2 -C /opt/philbot -rm /opt/philbot/libopus.tar.bz2 - -iptables -t nat -A PREROUTING -p tcp --dport 80 -j REDIRECT --to-port 8080 -iptables -t nat -A PREROUTING -p tcp --dport 443 -j REDIRECT --to-port 4443 -iptables-save > /etc/iptables/rules.v4 - -systemctl daemon-reload -systemctl enable philbot_scheduler philbot_discordgateway2http philbot_backend philbot_voice -philbot_start diff --git a/Deployment/Baremetal/DEBIAN/postrm b/Deployment/Baremetal/DEBIAN/postrm index c240d74f..6aa15e05 100755 --- a/Deployment/Baremetal/DEBIAN/postrm +++ b/Deployment/Baremetal/DEBIAN/postrm @@ -1,10 +1,14 @@ -#!/bin/bash +#!/bin/bash -e if [ -f /usr/bin/philbot_init_otel ]; then source /usr/bin/philbot_init_otel fi systemctl daemon-reload -if [ "$1" = "remove" ] || [ "$1" = "purge" ]; then - rm -rf /opt/philbot +if [ "$1" = 'remove' ] || [ "$1" = 'purge' ] || [ "$1" = 'disappear' ]; then + rm -rf /opt/philbot /var/lib/philbot/collector.yaml /var/lib/philbot/environment.properties.* +elif [ "$1" = 'upgrade' ]; then + true +elif [ "$1" = 'failed-upgrade' ] || [ "$1" = 'abort-install' ] || [ "$1" = 'abort-upgrade' ]; then + true +else + exit 1 fi -rm /var/lib/philbot/collector.yaml /var/lib/philbot/environment.properties.* -exit 0 diff --git a/Deployment/Baremetal/DEBIAN/preinst b/Deployment/Baremetal/DEBIAN/preinst index 4c8f57d9..3ad8b51f 100755 --- a/Deployment/Baremetal/DEBIAN/preinst +++ b/Deployment/Baremetal/DEBIAN/preinst @@ -1,6 +1,13 @@ -#!/bin/bash +#!/bin/bash -e if [ -f /usr/bin/philbot_init_otel ]; then source /usr/bin/philbot_init_otel fi -philbot_stop -exit 0 +if [ "$1" = 'install' ]; then + true +elif [ "$1" = 'upgrade' ]; then + philbot_stop +elif [ "$1" = 'abort-upgrade' ]; then + philbot_start || true +else + exit 1 +fi diff --git a/Deployment/Baremetal/DEBIAN/prerm b/Deployment/Baremetal/DEBIAN/prerm index e3014f0f..91e8a3ab 100755 --- a/Deployment/Baremetal/DEBIAN/prerm +++ b/Deployment/Baremetal/DEBIAN/prerm @@ -1,5 +1,10 @@ -#!/bin/bash +#!/bin/bash -e source /usr/bin/philbot_init_otel -philbot_stop -systemctl disable philbot_scheduler philbot_discordgateway2http philbot_backend philbot_voice -exit 0 +if [ "$1" = 'remove' ] || [ "$1" = 'upgrade' ] || [ "$1" = 'deconfigure' ]; then + philbot_stop + systemctl disable philbot_scheduler philbot_discordgateway2http philbot_backend philbot_voice +elif [ "$1" = 'failed-upgrade' ]; then + philbot_start || true +else + exit 1 +fi diff --git a/Deployment/Containerized/DEBIAN/control b/Deployment/Containerized/DEBIAN/control index 8b629bbf..710d94ee 100644 --- a/Deployment/Containerized/DEBIAN/control +++ b/Deployment/Containerized/DEBIAN/control @@ -1,6 +1,6 @@ Package: philbot-containerized Provides: philbot-deployment -Version: 2.8.10 +Version: 2.9.0 Architecture: all Depends: philbot-config (>= 4.0.0), debconf, bash, parallel, cron, wget, docker.io, iptables-persistent, jq, opentelemetry-shell (>= 2.6.1) Conflicts: philbot-baremetal, philbot-k8s @@ -8,4 +8,3 @@ Priority: extra Maintainer: Philipp Lengauer Homepage: https://github.com/plengauer/Philbot Description: Philbot as containerized installation, bot will auto-update - diff --git a/Deployment/Containerized/DEBIAN/postinst b/Deployment/Containerized/DEBIAN/postinst index ca47fb5b..93ef65dd 100755 --- a/Deployment/Containerized/DEBIAN/postinst +++ b/Deployment/Containerized/DEBIAN/postinst @@ -1,46 +1,39 @@ #!/bin/bash -e source /usr/bin/philbot_init_otel - -if [ "$1" = "triggered" ]; then - philbot_stop >&2 +if [ "$1" = 'abort-configure' ] || [ "$1" = 'abort-upgrade' ] || [ "$1" = 'abort-remove' ] || [ "$1" = 'abort-deconfigure' ]; then + true +elif [ "$1" = 'triggered' ] || [ "$1" = 'reconfigure' ]; then + philbot_config_populate + philbot_stop + philbot_start +elif [ "$1" = 'configure' ]; then + philbot_config_populate + source /usr/bin/philbot_init_otel + echo "OPENTELEMETRY_TRACES_API_ENDPOINT=http://127.0.0.1:4318/v1/traces" >> /var/lib/philbot/environment.properties.scheduler + echo "OPENTELEMETRY_TRACES_API_ENDPOINT=http://127.0.0.1:4318/v1/traces" >> /var/lib/philbot/environment.properties.discordgateway2http + echo "OPENTELEMETRY_TRACES_API_ENDPOINT=http://127.0.0.1:4318/v1/traces" >> /var/lib/philbot/environment.properties.discordgateway2httpmaster + echo "OPENTELEMETRY_TRACES_API_ENDPOINT=http://127.0.0.1:4318/v1/traces" >> /var/lib/philbot/environment.properties.backend + echo "OPENTELEMETRY_TRACES_API_ENDPOINT=http://127.0.0.1:4318/v1/traces" >> /var/lib/philbot/environment.properties.voice + echo "OPENTELEMETRY_METRICS_API_ENDPOINT=http://127.0.0.1:4318/v1/metrics" >> /var/lib/philbot/environment.properties.scheduler + echo "OPENTELEMETRY_METRICS_API_ENDPOINT=http://127.0.0.1:4318/v1/metrics" >> /var/lib/philbot/environment.properties.discordgateway2http + echo "OPENTELEMETRY_METRICS_API_ENDPOINT=http://127.0.0.1:4318/v1/metrics" >> /var/lib/philbot/environment.properties.discordgateway2httpmaster + echo "OPENTELEMETRY_METRICS_API_ENDPOINT=http://127.0.0.1:4318/v1/metrics" >> /var/lib/philbot/environment.properties.backend + echo "OPENTELEMETRY_METRICS_API_ENDPOINT=http://127.0.0.1:4318/v1/metrics" >> /var/lib/philbot/environment.properties.voice + echo "OPENTELEMETRY_LOGS_API_ENDPOINT=http://127.0.0.1:4318/v1/logs" >> /var/lib/philbot/environment.properties.scheduler + echo "OPENTELEMETRY_LOGS_API_ENDPOINT=http://127.0.0.1:4318/v1/logs" >> /var/lib/philbot/environment.properties.discordgateway2http + echo "OPENTELEMETRY_LOGS_API_ENDPOINT=http://127.0.0.1:4318/v1/logs" >> /var/lib/philbot/environment.properties.discordgateway2httpmaster + echo "OPENTELEMETRY_LOGS_API_ENDPOINT=http://127.0.0.1:4318/v1/logs" >> /var/lib/philbot/environment.properties.backend + echo "OPENTELEMETRY_LOGS_API_ENDPOINT=http://127.0.0.1:4318/v1/logs" >> /var/lib/philbot/environment.properties.voice + . /usr/share/debconf/confmodule + config() { db_get philbot-containerized/"$*"; echo "$*=$RET"; } + config SHARD_COUNT_MIN >> /var/lib/philbot/environment.properties.discordgateway2httpmaster + config SHARD_COUNT_MAX >> /var/lib/philbot/environment.properties.discordgateway2httpmaster + config SHARD_COUNT_REDUNDANT >> /var/lib/philbot/environment.properties.discordgateway2httpmaster + db_stop + iptables -t nat -A PREROUTING -p tcp --dport 80 -j REDIRECT --to-port 8080 + iptables -t nat -A PREROUTING -p tcp --dport 443 -j REDIRECT --to-port 4443 + iptables-save > /etc/iptables/rules.v4 + if [ ! -f "/opt/philbot/shards" ]; then echo "SHARD_COUNT=0" > /opt/philbot/shards; fi + philbot_start >&2 + curl -v http://127.0.0.1:8080/invite 2>&1 | grep location | rev | cut -d' ' -f1 | rev | xargs echo 'Invite with' >&2 fi - -philbot_config_populate -source /usr/bin/philbot_init_otel - -echo "OPENTELEMETRY_TRACES_API_ENDPOINT=http://127.0.0.1:4318/v1/traces" >> /var/lib/philbot/environment.properties.scheduler -echo "OPENTELEMETRY_TRACES_API_ENDPOINT=http://127.0.0.1:4318/v1/traces" >> /var/lib/philbot/environment.properties.discordgateway2http -echo "OPENTELEMETRY_TRACES_API_ENDPOINT=http://127.0.0.1:4318/v1/traces" >> /var/lib/philbot/environment.properties.discordgateway2httpmaster -echo "OPENTELEMETRY_TRACES_API_ENDPOINT=http://127.0.0.1:4318/v1/traces" >> /var/lib/philbot/environment.properties.backend -echo "OPENTELEMETRY_TRACES_API_ENDPOINT=http://127.0.0.1:4318/v1/traces" >> /var/lib/philbot/environment.properties.voice -echo "OPENTELEMETRY_METRICS_API_ENDPOINT=http://127.0.0.1:4318/v1/metrics" >> /var/lib/philbot/environment.properties.scheduler -echo "OPENTELEMETRY_METRICS_API_ENDPOINT=http://127.0.0.1:4318/v1/metrics" >> /var/lib/philbot/environment.properties.discordgateway2http -echo "OPENTELEMETRY_METRICS_API_ENDPOINT=http://127.0.0.1:4318/v1/metrics" >> /var/lib/philbot/environment.properties.discordgateway2httpmaster -echo "OPENTELEMETRY_METRICS_API_ENDPOINT=http://127.0.0.1:4318/v1/metrics" >> /var/lib/philbot/environment.properties.backend -echo "OPENTELEMETRY_METRICS_API_ENDPOINT=http://127.0.0.1:4318/v1/metrics" >> /var/lib/philbot/environment.properties.voice -echo "OPENTELEMETRY_LOGS_API_ENDPOINT=http://127.0.0.1:4318/v1/logs" >> /var/lib/philbot/environment.properties.scheduler -echo "OPENTELEMETRY_LOGS_API_ENDPOINT=http://127.0.0.1:4318/v1/logs" >> /var/lib/philbot/environment.properties.discordgateway2http -echo "OPENTELEMETRY_LOGS_API_ENDPOINT=http://127.0.0.1:4318/v1/logs" >> /var/lib/philbot/environment.properties.discordgateway2httpmaster -echo "OPENTELEMETRY_LOGS_API_ENDPOINT=http://127.0.0.1:4318/v1/logs" >> /var/lib/philbot/environment.properties.backend -echo "OPENTELEMETRY_LOGS_API_ENDPOINT=http://127.0.0.1:4318/v1/logs" >> /var/lib/philbot/environment.properties.voice - -. /usr/share/debconf/confmodule -config() { - db_get philbot-containerized/"$*" - echo "$*=$RET" -} -config SHARD_COUNT_MIN >> /var/lib/philbot/environment.properties.discordgateway2httpmaster -config SHARD_COUNT_MAX >> /var/lib/philbot/environment.properties.discordgateway2httpmaster -config SHARD_COUNT_REDUNDANT >> /var/lib/philbot/environment.properties.discordgateway2httpmaster -db_stop - -iptables -t nat -A PREROUTING -p tcp --dport 80 -j REDIRECT --to-port 8080 -iptables -t nat -A PREROUTING -p tcp --dport 443 -j REDIRECT --to-port 4443 -iptables-save > /etc/iptables/rules.v4 - -if [ ! -f "/opt/philbot/shards" ]; then - echo "SHARD_COUNT=0" > /opt/philbot/shards -fi -philbot_start >&2 - -curl -v http://127.0.0.1:8080/invite 2>&1 | grep location | rev | cut -d' ' -f1 | rev | xargs echo 'Invite with' >&2 diff --git a/Deployment/Containerized/DEBIAN/postrm b/Deployment/Containerized/DEBIAN/postrm index 6ca0eb11..54065f33 100755 --- a/Deployment/Containerized/DEBIAN/postrm +++ b/Deployment/Containerized/DEBIAN/postrm @@ -1,9 +1,14 @@ -#!/bin/bash +#!/bin/bash -e if [ -f /usr/bin/philbot_init_otel ]; then source /usr/bin/philbot_init_otel fi -if [ "$1" = "remove" ] || [ "$1" = "purge" ]; then +if [ "$1" = 'remove' ] || [ "$1" = 'purge' ] || [ "$1" = 'disappear' ]; then + rm /opt/philbot/shards /var/lib/philbot/collector.yaml /var/lib/philbot/environment.properties.* docker image prune --all --force +elif [ "$1" = 'upgrade' ]; then + true +elif [ "$1" = 'failed-upgrade' ] || [ "$1" = 'abort-install' ] || [ "$1" = 'abort-upgrade' ]; then + true +else + exit 1 fi -rm /opt/philbot/shards /var/lib/philbot/collector.yaml /var/lib/philbot/environment.properties.* -exit 0 diff --git a/Deployment/Containerized/DEBIAN/preinst b/Deployment/Containerized/DEBIAN/preinst index 4c8f57d9..6b098be5 100755 --- a/Deployment/Containerized/DEBIAN/preinst +++ b/Deployment/Containerized/DEBIAN/preinst @@ -1,6 +1,11 @@ -#!/bin/bash +#!/bin/bash -e if [ -f /usr/bin/philbot_init_otel ]; then source /usr/bin/philbot_init_otel fi -philbot_stop -exit 0 +if [ "$1" = 'install' ] || [ "$1" = 'upgrade' ]; then + philbot_stop +elif [ "$1" = 'abort-upgrade' ]; then + philbot_start || true +else + exit 1 +fi diff --git a/Deployment/Containerized/DEBIAN/prerm b/Deployment/Containerized/DEBIAN/prerm index 4c00be46..c1ba8f1c 100755 --- a/Deployment/Containerized/DEBIAN/prerm +++ b/Deployment/Containerized/DEBIAN/prerm @@ -1,3 +1,9 @@ #!/bin/bash -e source /usr/bin/philbot_init_otel -philbot_stop +if [ "$1" = 'remove' ] || [ "$1" = 'upgrade' ] || [ "$1" = 'deconfigure' ]; then + philbot_stop +elif [ "$1" = 'failed-upgrade' ]; then + philbot_start || true +else + exit 1 +fi