2023-03-23 00:48:20 +00:00
|
|
|
#!/usr/bin/env bash
|
|
|
|
|
2025-01-01 12:37:29 +00:00
|
|
|
# Copyright (c) 2021-2025 tteck
|
2023-03-23 00:48:20 +00:00
|
|
|
# Author: tteck (tteckster)
|
|
|
|
# License: MIT
|
2024-11-02 07:48:05 +00:00
|
|
|
# https://github.com/community-scripts/ProxmoxVE/raw/main/LICENSE
|
2023-03-23 00:48:20 +00:00
|
|
|
|
|
|
|
source /dev/stdin <<< "$FUNCTIONS_FILE_PATH"
|
|
|
|
color
|
|
|
|
verb_ip6
|
|
|
|
catch_errors
|
|
|
|
setting_up_container
|
|
|
|
network_check
|
|
|
|
update_os
|
|
|
|
|
|
|
|
msg_info "Installing Dependencies"
|
2025-01-05 16:02:27 +00:00
|
|
|
$STD apt-get install -y \
|
|
|
|
curl \
|
|
|
|
sudo \
|
|
|
|
mc \
|
|
|
|
git \
|
|
|
|
make \
|
|
|
|
g++ \
|
|
|
|
gcc \
|
|
|
|
ca-certificates \
|
|
|
|
gnupg
|
2023-03-23 00:48:20 +00:00
|
|
|
msg_ok "Installed Dependencies"
|
|
|
|
|
|
|
|
msg_info "Setting up Node.js Repository"
|
2023-09-02 12:36:54 +00:00
|
|
|
mkdir -p /etc/apt/keyrings
|
2023-09-01 11:19:05 +00:00
|
|
|
curl -fsSL https://deb.nodesource.com/gpgkey/nodesource-repo.gpg.key | gpg --dearmor -o /etc/apt/keyrings/nodesource.gpg
|
2025-01-05 16:02:27 +00:00
|
|
|
echo "deb [signed-by=/etc/apt/keyrings/nodesource.gpg] https://deb.nodesource.com/node_22.x nodistro main" >/etc/apt/sources.list.d/nodesource.list
|
2023-03-23 00:48:20 +00:00
|
|
|
msg_ok "Set up Node.js Repository"
|
|
|
|
|
|
|
|
msg_info "Installing Node.js"
|
2023-09-01 11:19:05 +00:00
|
|
|
$STD apt-get update
|
2023-03-23 00:48:20 +00:00
|
|
|
$STD apt-get install -y nodejs
|
|
|
|
msg_ok "Installed Node.js"
|
|
|
|
|
2025-01-05 16:02:27 +00:00
|
|
|
msg_info "Installing pnpm"
|
|
|
|
$STD npm install -g pnpm
|
|
|
|
msg_ok "Installed pnpm"
|
2023-03-23 00:48:20 +00:00
|
|
|
|
2025-01-05 16:02:27 +00:00
|
|
|
msg_info "Setting up Zigbee2MQTT"
|
|
|
|
cd /opt
|
|
|
|
RELEASE=$(curl -s https://api.github.com/repos/Koenkk/zigbee2mqtt/releases/latest | grep "tag_name" | awk '{print substr($2, 2, length($2)-3) }')
|
|
|
|
wget -q "https://github.com/Koenkk/zigbee2mqtt/archive/refs/tags/${RELEASE}.zip"
|
|
|
|
unzip -q ${RELEASE}.zip
|
|
|
|
mv zigbee2mqtt-${RELEASE} /opt/zigbee2mqtt
|
|
|
|
cd /opt/zigbee2mqtt/data
|
|
|
|
mv configuration.example.yaml configuration.yaml
|
2023-03-23 00:48:20 +00:00
|
|
|
cd /opt/zigbee2mqtt
|
2025-01-05 16:02:27 +00:00
|
|
|
$STD pnpm install --frozen-lockfile
|
|
|
|
$STD pnpm build
|
2023-03-23 00:48:20 +00:00
|
|
|
msg_ok "Installed Zigbee2MQTT"
|
|
|
|
|
|
|
|
msg_info "Creating Service"
|
2025-01-05 16:02:27 +00:00
|
|
|
cat <<EOF >/etc/systemd/system/zigbee2mqtt.service
|
2025-01-05 16:57:35 +00:00
|
|
|
[Unit]
|
2023-03-23 00:48:20 +00:00
|
|
|
Description=zigbee2mqtt
|
|
|
|
After=network.target
|
|
|
|
[Service]
|
|
|
|
Environment=NODE_ENV=production
|
2025-01-05 16:02:27 +00:00
|
|
|
ExecStart=/usr/bin/pnpm start
|
2023-03-23 00:48:20 +00:00
|
|
|
WorkingDirectory=/opt/zigbee2mqtt
|
|
|
|
StandardOutput=inherit
|
|
|
|
StandardError=inherit
|
|
|
|
Restart=always
|
|
|
|
User=root
|
|
|
|
[Install]
|
2025-01-05 17:00:24 +00:00
|
|
|
WantedBy=multi-user.target
|
2025-01-05 16:02:27 +00:00
|
|
|
EOF
|
|
|
|
systemctl enable -q --now zigbee2mqtt.service
|
2023-03-23 00:48:20 +00:00
|
|
|
msg_ok "Created Service"
|
|
|
|
|
|
|
|
motd_ssh
|
2023-05-15 11:39:30 +00:00
|
|
|
customize
|
2023-03-23 00:48:20 +00:00
|
|
|
|
|
|
|
msg_info "Cleaning up"
|
2025-01-05 16:02:27 +00:00
|
|
|
rm -rf /opt/${RELEASE}.zip
|
2024-05-02 17:26:16 +00:00
|
|
|
$STD apt-get -y autoremove
|
|
|
|
$STD apt-get -y autoclean
|
2023-03-23 00:48:20 +00:00
|
|
|
msg_ok "Cleaned"
|