mirror of
https://github.com/community-scripts/ProxmoxVE
synced 2025-02-09 01:09:16 +00:00
Compare commits
8 Commits
8fed3ba0c0
...
80f33abf8f
Author | SHA1 | Date | |
---|---|---|---|
|
80f33abf8f | ||
|
c5fa9f8b69 | ||
|
36dfd44ca1 | ||
|
8e382fc03f | ||
|
52fbc5e093 | ||
|
714ec3ffea | ||
|
a4e2f373ea | ||
|
23f89faf0f |
@ -2,7 +2,7 @@
|
|||||||
: "${BRANCH:=develop}"
|
: "${BRANCH:=develop}"
|
||||||
: "${CSCRIPTS_BASE_URL:=https://raw.githubusercontent.com/community-scripts/ProxmoxVE/${BRANCH}}"
|
: "${CSCRIPTS_BASE_URL:=https://raw.githubusercontent.com/community-scripts/ProxmoxVE/${BRANCH}}"
|
||||||
source <(curl -s "${CSCRIPTS_BASE_URL}/misc/build.func")
|
source <(curl -s "${CSCRIPTS_BASE_URL}/misc/build.func")
|
||||||
# Copyright (c) 2021-2024 tteck
|
# Copyright (c) 2021-2025 tteck
|
||||||
# Author: tteck (tteckster)
|
# Author: tteck (tteckster)
|
||||||
# License: MIT | https://github.com/community-scripts/ProxmoxVE/raw/main/LICENSE
|
# License: MIT | https://github.com/community-scripts/ProxmoxVE/raw/main/LICENSE
|
||||||
# Source: https://www.zigbee2mqtt.io/
|
# Source: https://www.zigbee2mqtt.io/
|
||||||
@ -30,95 +30,45 @@ function update_script() {
|
|||||||
header_info
|
header_info
|
||||||
check_container_storage
|
check_container_storage
|
||||||
check_container_resources
|
check_container_resources
|
||||||
if [[ ! -d /opt/zigbee2mqtt ]]; then
|
|
||||||
msg_error "No ${APP} Installation Found!"
|
|
||||||
exit
|
|
||||||
fi
|
|
||||||
if [[ "$(node -v | cut -d 'v' -f 2)" == "18."* ]]; then
|
if [[ "$(node -v | cut -d 'v' -f 2)" == "18."* ]]; then
|
||||||
if ! command -v npm >/dev/null 2>&1; then
|
if ! command -v pnpm >/dev/null 2>&1; then
|
||||||
echo "Installing NPM..."
|
echo "Installing NPM..."
|
||||||
apt-get install -y npm >/dev/null 2>&1
|
apt-get install -y npm >/dev/null 2>&1
|
||||||
echo "Installed NPM..."
|
echo "Installed NPM..."
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
cd /opt/zigbee2mqtt
|
if [[ ! -d /opt/zigbee2mqtt ]]; then
|
||||||
|
msg_error "No ${APP} Installation Found!"
|
||||||
stop_zigbee2mqtt() {
|
exit
|
||||||
if which systemctl 2>/dev/null >/dev/null; then
|
|
||||||
echo "Shutting down Zigbee2MQTT..."
|
|
||||||
sudo systemctl stop zigbee2mqtt
|
|
||||||
else
|
|
||||||
echo "Skipped stopping Zigbee2MQTT, no systemctl found"
|
|
||||||
fi
|
|
||||||
}
|
|
||||||
|
|
||||||
start_zigbee2mqtt() {
|
|
||||||
if which systemctl 2>/dev/null >/dev/null; then
|
|
||||||
echo "Starting Zigbee2MQTT..."
|
|
||||||
sudo systemctl start zigbee2mqtt
|
|
||||||
else
|
|
||||||
echo "Skipped starting Zigbee2MQTT, no systemctl found"
|
|
||||||
fi
|
|
||||||
}
|
|
||||||
|
|
||||||
set -e
|
|
||||||
|
|
||||||
if [ -d data-backup ]; then
|
|
||||||
echo "ERROR: Backup directory exists. May be previous restoring was failed?"
|
|
||||||
echo "1. Save 'data-backup' and 'data' dirs to safe location to make possibility to restore config later."
|
|
||||||
echo "2. Manually delete 'data-backup' dir and try again."
|
|
||||||
exit 1
|
|
||||||
fi
|
fi
|
||||||
|
RELEASE=$(curl -s https://api.github.com/repos/Koenkk/zigbee2mqtt/releases/latest | grep "tag_name" | awk '{print substr($2, 2, length($2)-3) }')
|
||||||
|
if [[ ! -f /opt/${APP}_version.txt ]] || [[ "${RELEASE}" != "$(cat /opt/${APP}_version.txt)" ]]; then
|
||||||
|
msg_info "Stopping Service"
|
||||||
|
systemctl stop zigbee2mqtt
|
||||||
|
msg_ok "Stopped Service"
|
||||||
|
|
||||||
stop_zigbee2mqtt
|
msg_info "Creating Backup"
|
||||||
|
mkdir -p /opt/z2m_backup
|
||||||
|
tar -czf /opt/z2m_backup/${APP}_backup_$(date +%Y%m%d%H%M%S).tar.gz -C /opt zigbee2mqtt &>/dev/null
|
||||||
|
mv /opt/zigbee2mqtt/data /opt/z2m_backup
|
||||||
|
msg_ok "Backup Created"
|
||||||
|
|
||||||
echo "Generating a backup of the configuration..."
|
msg_info "Updating ${APP} to v${RELEASE}"
|
||||||
cp -R data data-backup || {
|
cd /opt
|
||||||
echo "Failed to create backup."
|
wget -q "https://github.com/Koenkk/zigbee2mqtt/archive/refs/tags/${RELEASE}.zip"
|
||||||
exit 1
|
unzip -q ${RELEASE}.zip
|
||||||
}
|
mv zigbee2mqtt-${RELEASE} /opt/zigbee2mqtt
|
||||||
|
rm -rf /opt/zigbee2mqtt/data
|
||||||
|
mv /opt/z2m_backup/data /opt/zigbee2mqtt
|
||||||
|
msg_ok "Updated ${APP} to v${RELEASE}"
|
||||||
|
|
||||||
echo "Checking if any changes were made to package-lock.json..."
|
msg_info "Starting Service"
|
||||||
git checkout package-lock.json || {
|
systemctl start zigbee2mqtt
|
||||||
echo "Failed to check package-lock.json."
|
msg_ok "Started Service"
|
||||||
exit 1
|
echo "${RELEASE}" >/opt/${APP}_version.txt
|
||||||
}
|
else
|
||||||
|
msg_ok "No update required. ${APP} is already at v${RELEASE}."
|
||||||
echo "Initiating update..."
|
|
||||||
if ! git pull; then
|
|
||||||
echo "Update failed, temporarily storing changes and trying again."
|
|
||||||
git stash && git pull || (
|
|
||||||
echo "Update failed even after storing changes. Aborting."
|
|
||||||
exit 1
|
|
||||||
)
|
|
||||||
fi
|
fi
|
||||||
|
|
||||||
echo "Acquiring necessary components..."
|
|
||||||
npm ci || {
|
|
||||||
echo "Failed to install necessary components."
|
|
||||||
exit 1
|
|
||||||
}
|
|
||||||
|
|
||||||
echo "Building..."
|
|
||||||
npm run build || {
|
|
||||||
echo "Failed to build new version."
|
|
||||||
exit 1
|
|
||||||
}
|
|
||||||
|
|
||||||
echo "Restoring configuration..."
|
|
||||||
cp -R data-backup/* data || {
|
|
||||||
echo "Failed to restore configuration."
|
|
||||||
exit 1
|
|
||||||
}
|
|
||||||
|
|
||||||
rm -rf data-backup || {
|
|
||||||
echo "Failed to remove backup directory."
|
|
||||||
exit 1
|
|
||||||
}
|
|
||||||
|
|
||||||
start_zigbee2mqtt
|
|
||||||
|
|
||||||
echo "Done!"
|
|
||||||
exit
|
exit
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -128,5 +78,5 @@ description
|
|||||||
|
|
||||||
msg_ok "Completed Successfully!\n"
|
msg_ok "Completed Successfully!\n"
|
||||||
echo -e "${CREATING}${GN}${APP} setup has been successfully initialized!${CL}"
|
echo -e "${CREATING}${GN}${APP} setup has been successfully initialized!${CL}"
|
||||||
echo -e "${INFO}${YW} Access it using the following URL:${CL}"
|
echo -e "${INFO}${YW} Access it after configure the configuration.yaml using the following URL:${CL}"
|
||||||
echo -e "${TAB}${GATEWAY}${BGN}http://${IP}:9442${CL}"
|
echo -e "${TAB}${GATEWAY}${BGN}http://${IP}:9442${CL}"
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
#!/usr/bin/env bash
|
#!/usr/bin/env bash
|
||||||
|
|
||||||
# Copyright (c) 2021-2024 tteck
|
# Copyright (c) 2021-2025 tteck
|
||||||
# Author: tteck (tteckster)
|
# Author: tteck (tteckster)
|
||||||
# License: MIT
|
# License: MIT
|
||||||
# https://github.com/community-scripts/ProxmoxVE/raw/main/LICENSE
|
# https://github.com/community-scripts/ProxmoxVE/raw/main/LICENSE
|
||||||
@ -14,15 +14,16 @@ network_check
|
|||||||
update_os
|
update_os
|
||||||
|
|
||||||
msg_info "Installing Dependencies"
|
msg_info "Installing Dependencies"
|
||||||
$STD apt-get install -y curl
|
$STD apt-get install -y \
|
||||||
$STD apt-get install -y sudo
|
curl \
|
||||||
$STD apt-get install -y mc
|
sudo \
|
||||||
$STD apt-get install -y git
|
mc \
|
||||||
$STD apt-get install -y make
|
git \
|
||||||
$STD apt-get install -y g++
|
make \
|
||||||
$STD apt-get install -y gcc
|
g++ \
|
||||||
$STD apt-get install -y ca-certificates
|
gcc \
|
||||||
$STD apt-get install -y gnupg
|
ca-certificates \
|
||||||
|
gnupg
|
||||||
msg_ok "Installed Dependencies"
|
msg_ok "Installed Dependencies"
|
||||||
|
|
||||||
msg_info "Setting up Node.js Repository"
|
msg_info "Setting up Node.js Repository"
|
||||||
@ -36,49 +37,45 @@ $STD apt-get update
|
|||||||
$STD apt-get install -y nodejs
|
$STD apt-get install -y nodejs
|
||||||
msg_ok "Installed Node.js"
|
msg_ok "Installed Node.js"
|
||||||
|
|
||||||
msg_info "Setting up Zigbee2MQTT Repository"
|
msg_info "Installing pnpm"
|
||||||
$STD git clone --depth 1 https://github.com/Koenkk/zigbee2mqtt.git /opt/zigbee2mqtt
|
$STD npm install -g pnpm
|
||||||
msg_ok "Set up Zigbee2MQTT Repository"
|
msg_ok "Installed pnpm"
|
||||||
|
|
||||||
read -r -p "Switch to Edge/dev branch? (y/N) " prompt
|
msg_info "Setting up Zigbee2MQTT"
|
||||||
if [[ $prompt == "y" ]]; then
|
cd /opt
|
||||||
DEV="y"
|
RELEASE=$(curl -s https://api.github.com/repos/Koenkk/zigbee2mqtt/releases/latest | grep "tag_name" | awk '{print substr($2, 2, length($2)-3) }')
|
||||||
else
|
wget -q "https://github.com/Koenkk/zigbee2mqtt/archive/refs/tags/${RELEASE}.zip"
|
||||||
DEV="n"
|
unzip -q ${RELEASE}.zip
|
||||||
fi
|
mv zigbee2mqtt-${RELEASE} /opt/zigbee2mqtt
|
||||||
|
cd /opt/zigbee2mqtt/data
|
||||||
msg_info "Installing Zigbee2MQTT"
|
mv configuration.example.yaml configuration.yaml
|
||||||
cd /opt/zigbee2mqtt
|
cd /opt/zigbee2mqtt
|
||||||
if [[ $DEV == "y" ]]; then
|
$STD pnpm install
|
||||||
$STD git fetch origin dev:dev
|
|
||||||
$STD git checkout dev
|
|
||||||
$STD git pull
|
|
||||||
fi
|
|
||||||
$STD npm ci
|
|
||||||
msg_ok "Installed Zigbee2MQTT"
|
msg_ok "Installed Zigbee2MQTT"
|
||||||
|
|
||||||
msg_info "Creating Service"
|
msg_info "Creating Service"
|
||||||
service_path="/etc/systemd/system/zigbee2mqtt.service"
|
cat <<EOF >/etc/systemd/system/zigbee2mqtt.service
|
||||||
echo "[Unit]
|
echo "[Unit]
|
||||||
Description=zigbee2mqtt
|
Description=zigbee2mqtt
|
||||||
After=network.target
|
After=network.target
|
||||||
[Service]
|
[Service]
|
||||||
Environment=NODE_ENV=production
|
Environment=NODE_ENV=production
|
||||||
ExecStart=/usr/bin/npm start
|
ExecStart=/usr/bin/pnpm start
|
||||||
WorkingDirectory=/opt/zigbee2mqtt
|
WorkingDirectory=/opt/zigbee2mqtt
|
||||||
StandardOutput=inherit
|
StandardOutput=inherit
|
||||||
StandardError=inherit
|
StandardError=inherit
|
||||||
Restart=always
|
Restart=always
|
||||||
User=root
|
User=root
|
||||||
[Install]
|
[Install]
|
||||||
WantedBy=multi-user.target" >$service_path
|
EOF
|
||||||
$STD systemctl enable zigbee2mqtt.service
|
systemctl enable -q --now zigbee2mqtt.service
|
||||||
msg_ok "Created Service"
|
msg_ok "Created Service"
|
||||||
|
|
||||||
motd_ssh
|
motd_ssh
|
||||||
customize
|
customize
|
||||||
|
|
||||||
msg_info "Cleaning up"
|
msg_info "Cleaning up"
|
||||||
|
rm -rf /opt/${RELEASE}.zip
|
||||||
$STD apt-get -y autoremove
|
$STD apt-get -y autoremove
|
||||||
$STD apt-get -y autoclean
|
$STD apt-get -y autoclean
|
||||||
msg_ok "Cleaned"
|
msg_ok "Cleaned"
|
||||||
|
@ -262,6 +262,7 @@ base_settings() {
|
|||||||
MAC=""
|
MAC=""
|
||||||
VLAN=""
|
VLAN=""
|
||||||
SSH="no"
|
SSH="no"
|
||||||
|
SSH_AUTHORIZED_KEY=""
|
||||||
TAGS="community-script;"
|
TAGS="community-script;"
|
||||||
|
|
||||||
# Override default settings with variables from ct script
|
# Override default settings with variables from ct script
|
||||||
@ -620,6 +621,10 @@ advanced_settings() {
|
|||||||
|
|
||||||
if [[ "${SSH}" == "yes" ]]; then
|
if [[ "${SSH}" == "yes" ]]; then
|
||||||
SSH_AUTHORIZED_KEY="$(whiptail --backtitle "Proxmox VE Helper Scripts" --inputbox "SSH Authorized key for root (leave empty for none)" 8 58 --title "SSH Key" 3>&1 1>&2 2>&3)"
|
SSH_AUTHORIZED_KEY="$(whiptail --backtitle "Proxmox VE Helper Scripts" --inputbox "SSH Authorized key for root (leave empty for none)" 8 58 --title "SSH Key" 3>&1 1>&2 2>&3)"
|
||||||
|
|
||||||
|
if [[ -z "${SSH_AUTHORIZED_KEY}" ]]; then
|
||||||
|
echo "Warning: No SSH key provided."
|
||||||
|
fi
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if (whiptail --backtitle "Proxmox VE Helper Scripts" --defaultno --title "VERBOSE MODE" --yesno "Enable Verbose Mode?" 10 58); then
|
if (whiptail --backtitle "Proxmox VE Helper Scripts" --defaultno --title "VERBOSE MODE" --yesno "Enable Verbose Mode?" 10 58); then
|
||||||
|
Loading…
Reference in New Issue
Block a user