This commit is contained in:
2025-09-15 14:22:25 +02:00
parent d4dd02c115
commit 59a92477c4
2 changed files with 166 additions and 0 deletions

50
ct/alpine-mqtt.sh Normal file
View File

@@ -0,0 +1,50 @@
#!/usr/bin/env bash
source <(curl -fsSL https://raw.githubusercontent.com/community-scripts/ProxmoxVE/main/misc/build.func)
# Copyright (c) 2021-2025 tteck
# Author: tteck (tteckster)
# License: MIT | https://github.com/community-scripts/ProxmoxVE/raw/main/LICENSE
# Source: https://www.zigbee2mqtt.io/
APP="Alpine-MQTT"
var_tags="${var_tags:-alpine;zigbee;mqtt;smarthome}"
var_disk="${var_disk:-1}"
var_cpu="${var_cpu:-1}"
var_ram="${var_ram:-512}"
var_os="${var_os:-alpine}"
var_version="${var_version:-3.22}"
var_unprivileged="${var_unprivileged:-0}"
header_info "$APP"
variables
color
catch_errors
function update_script() {
if ! apk -e info newt >/dev/null 2>&1; then
apk add -q newt
fi
while true; do
CHOICE=$(
whiptail --backtitle "Proxmox VE Helper Scripts" --title "SUPPORT" --menu "Select option" 11 58 1 \
"1" "Check for MQTT Updates" 3>&2 2>&1 1>&3
)
exit_status=$?
if [ $exit_status == 1 ]; then
clear
exit-script
fi
header_info
case $CHOICE in
1)
$STD apk -U upgrade
exit
;;
esac
done
}
start
build_container
description
msg_ok "Completed Successfully!\n"

View File

@@ -0,0 +1,116 @@
#!/usr/bin/env bash
# Copyright (c) 2021-2025 tteck
# Author: tteck (tteckster)
# License: MIT | https://github.com/community-scripts/ProxmoxVE/raw/main/LICENSE
# Source: https://www.zigbee2mqtt.io/
source /dev/stdin <<<"$FUNCTIONS_FILE_PATH"
color
verb_ip6
catch_errors
setting_up_container
network_check
update_os
msg_info "Installing Alpine-Mosquitto_Zigbee2MQTT_haBridge"
# mosquitto
msg_info "Installing Mosquitto"
apk add mosquitto
mosquitto_config=/etc/mosquitto/mosquitto.conf
sed -i -e "s/^#allow_anonymous.*$/allow_anonymous true/" $mosquitto_config
sed -i -e "s/^#listener.*$/listener 1883/" $mosquitto_config
rc-update add mosquitto
rc-service start mosquitto
# ha-bridge
msg_info "Installing haBridge"
apk add openjdk11
java --version
mkdir -p /opt/habridge
cd /opt/habridge
release=$( curl -fsSL https://api.github.com/repos/bwssytems/ha-bridge/releases/latest | grep "tag_name" | awk '{print substr($2, 3, length($2)-4) }')
wget -q https://github.com/bwssytems/ha-bridge/releases/download/v5.4.1/ha-bridge-${release}.jar
initfile=/etc/init.d/habridge
cat > $initfile <<EOF
#!/sbin/openrc-run
command="/usr/bin/java"
command_args="-jar -Dconfig.file=/opt/habridge/data/habridge.config /opt/habridge/ha-bridge.jar"
name="habridge"
description="HA Bridge Service"
pidfile="/run/habridge.pid"
directory="/opt/habridge"
#user="habridge" # or leave as root if needed
user="root"
depend() {
need net
after firewall
}
start_pre() {
checkpath --directory --owner $user:$user /run
}
start() {
ebegin "Starting ha-bridge"
start-stop-daemon --start --background \
--pidfile $pidfile \
--make-pidfile \
--chdir $directory \
--user $user \
--exec $command -- $command_args
eend $?
}
stop() {
ebegin "Stopping ha-bridge"
start-stop-daemon --stop --pidfile $pidfile --retry 10
eend $?
}
EOF
chmod +x $initfile
rc-update add habridge default
rc-service habridge start
rc-service habridge status
# zigbee2mqtt
set2net_ip=192.168.178.29
set2net_port=20108
ser2net_baud=115200
#mkdir -p /root/.z2m /etc/zigbee2mqtt
#$STD apk add zigbee2mqtt
#ln -s /etc/zigbee2mqtt/ /root/.z2m
#chown -R root:root /etc/zigbee2mqtt /root/.z2m
#$STD rc-update add zigbee2mqtt
#$STD rc-service zigbee2mqtt restart
#mkdir -p /etc/zigbee2mqtt
$STD apg add zigbee2mqtt
sed -i -e 's/#datadir="\/var\/lib\/zigbee2mqtt"/datadir="\/etc\/zigbee2mqtt"/' -e 's/#command_user="zigbee2mqtt"/command_user="root"/' /etc/conf.d/zigbee2mqtt
cat >>/etc/conf.d/zigbee2mqtt <<EOF
export ZIGBEE2MQTT_CONFIG_MQTT_BASE_TOPIC="zigbee"
export ZIGBEE2MQTT_CONFIG_SERIAL_PORT="tcp://$ser2net_ip:$seer2net_port"
export ZIGBEE2MQTT_CONFIG_SERIAL_RTSCTS="false"
export ZIGBEE2MQTT_CONFIG_SERIAL_BAUDRATE="$ser2net_baud"
export ZIGBEE2MQTT_CONFIG_SERIAL_ADAPTER="ezsp"
export ZIGBEE2MQTT_CONFIG_FRONTEND_PORT="8089"
export ZIGBEE2MQTT_CONFIG_FRONTEND_ENABLED="true"
EOF
$STD rc-update add zigbee2mqtt default
$STD rc-service zigbee2mqtt start
$STD rc-service zigbee2mqtt status
msg_ok "Installed Alpine-Zigbee2MQTT"
motd_ssh
customize