mirror of
https://github.com/community-scripts/ProxmoxVE
synced 2025-03-10 15:40:01 +00:00
Update MagicMirror install and update scripts (#2409)
This commit is contained in:
parent
b7df0ee936
commit
60e32a05cd
@ -1,7 +1,7 @@
|
|||||||
#!/usr/bin/env bash
|
#!/usr/bin/env bash
|
||||||
source <(curl -s https://raw.githubusercontent.com/community-scripts/ProxmoxVE/main/misc/build.func)
|
source <(curl -s https://raw.githubusercontent.com/community-scripts/ProxmoxVE/main/misc/build.func)
|
||||||
# Copyright (c) 2021-2025 tteck
|
# Copyright (c) 2021-2025 tteck
|
||||||
# Author: tteck (tteckster)
|
# Author: tteck (tteckster) | Co-Author Slaviša Arežina (tremor021)
|
||||||
# License: MIT | https://github.com/community-scripts/ProxmoxVE/raw/main/LICENSE
|
# License: MIT | https://github.com/community-scripts/ProxmoxVE/raw/main/LICENSE
|
||||||
# Source: https://magicmirror.builders/
|
# Source: https://magicmirror.builders/
|
||||||
|
|
||||||
@ -27,18 +27,45 @@ function update_script() {
|
|||||||
msg_error "No ${APP} Installation Found!"
|
msg_error "No ${APP} Installation Found!"
|
||||||
exit
|
exit
|
||||||
fi
|
fi
|
||||||
if [[ "$(node -v | cut -d 'v' -f 2)" == "18."* ]]; then
|
RELEASE=$(curl -s https://api.github.com/repos/MagicMirrorOrg/MagicMirror/releases/latest | grep "tag_name" | awk '{print substr($2, 3, length($2)-4) }')
|
||||||
if ! command -v npm >/dev/null 2>&1; then
|
if [[ ! -f /opt/${APP}_version.txt ]]; then touch /opt/${APP}_version.txt; fi
|
||||||
echo "Installing NPM..."
|
if [[ ! -f /opt/${APP}_version.txt ]] || [[ "${RELEASE}" != "$(cat /opt/${APP}_version.txt)" ]]; then
|
||||||
apt-get install -y npm >/dev/null 2>&1
|
msg_info "Stopping Service"
|
||||||
echo "Installed NPM..."
|
systemctl stop magicmirror
|
||||||
|
msg_ok "Stopped Service"
|
||||||
|
|
||||||
|
msg_info "Updating ${APP} to v${RELEASE}"
|
||||||
|
mkdir /opt/magicmirror-backup
|
||||||
|
cp /opt/magicmirror/config/config.js /opt/magicmirror-backup
|
||||||
|
if [[ -f /opt/magicmirror/css/custom.css ]]; then
|
||||||
|
cp /opt/magicmirror/css/custom.css /opt/magicmirror-backup
|
||||||
fi
|
fi
|
||||||
|
cp -r /opt/magicmirror/modules /opt/magicmirror-backup
|
||||||
|
temp_file=$(mktemp)
|
||||||
|
wget -q "https://github.com/MagicMirrorOrg/MagicMirror/archive/refs/tags/v${RELEASE}.tar.gz" -O "$temp_file"
|
||||||
|
tar -xzf "$temp_file"
|
||||||
|
rm -rf /opt/magicmirror
|
||||||
|
mv MagicMirror-${RELEASE} /opt/magicmirror
|
||||||
|
cd /opt/magicmirror
|
||||||
|
npm run install-mm &> /dev/null
|
||||||
|
cp /opt/magicmirror-backup/config.js /opt/magicmirror/config/
|
||||||
|
if [[ -f /opt/magicmirror-backup/custom.css ]]; then
|
||||||
|
cp /opt/magicmirror-backup/custom.css /opt/magicmirror/css/
|
||||||
|
fi
|
||||||
|
echo "${RELEASE}" >"/opt/${APP}_version.txt"
|
||||||
|
msg_ok "Updated ${APP} to v${RELEASE}"
|
||||||
|
|
||||||
|
msg_info "Starting Service"
|
||||||
|
systemctl start magicmirror
|
||||||
|
msg_ok "Started Service"
|
||||||
|
|
||||||
|
msg_info "Cleaning up"
|
||||||
|
rm -f $temp_file
|
||||||
|
msg_ok "Cleaned"
|
||||||
|
msg_ok "Updated Successfully"
|
||||||
|
else
|
||||||
|
msg_ok "No update required. ${APP} is already at v${RELEASE}."
|
||||||
fi
|
fi
|
||||||
msg_info "Updating ${APP} LXC"
|
|
||||||
cd /opt/magicmirror
|
|
||||||
git pull &>/dev/null
|
|
||||||
npm install --only=prod --omit=dev &>/dev/null
|
|
||||||
msg_ok "Updated Successfully"
|
|
||||||
exit
|
exit
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,9 +1,10 @@
|
|||||||
#!/usr/bin/env bash
|
#!/usr/bin/env bash
|
||||||
|
|
||||||
# Copyright (c) 2021-2025 tteck
|
# Copyright (c) 2021-2025 tteck
|
||||||
# Author: tteck (tteckster)
|
# Author: tteck (tteckster) | Co-Author Slaviša Arežina (tremor021)
|
||||||
# License: MIT
|
# License: MIT
|
||||||
# https://github.com/community-scripts/ProxmoxVE/raw/main/LICENSE
|
# https://github.com/community-scripts/ProxmoxVE/raw/main/LICENSE
|
||||||
|
# Source: https://magicmirror.builders/
|
||||||
|
|
||||||
source /dev/stdin <<< "$FUNCTIONS_FILE_PATH"
|
source /dev/stdin <<< "$FUNCTIONS_FILE_PATH"
|
||||||
color
|
color
|
||||||
@ -14,12 +15,11 @@ 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 ca-certificates
|
gnupg
|
||||||
$STD apt-get install -y gnupg
|
|
||||||
msg_ok "Installed Dependencies"
|
msg_ok "Installed Dependencies"
|
||||||
|
|
||||||
msg_info "Setting up Node.js Repository"
|
msg_info "Setting up Node.js Repository"
|
||||||
@ -33,14 +33,14 @@ $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 MagicMirror Repository"
|
msg_info "Setup MagicMirror"
|
||||||
$STD git clone https://github.com/MichMich/MagicMirror /opt/magicmirror
|
temp_file=$(mktemp)
|
||||||
msg_ok "Set up MagicMirror Repository"
|
RELEASE=$(curl -s https://api.github.com/repos/MagicMirrorOrg/MagicMirror/releases/latest | grep "tag_name" | awk '{print substr($2, 3, length($2)-4) }')
|
||||||
|
wget -q "https://github.com/MagicMirrorOrg/MagicMirror/archive/refs/tags/v${RELEASE}.tar.gz" -O "$temp_file"
|
||||||
msg_info "Installing MagicMirror"
|
tar -xzf "$temp_file"
|
||||||
|
mv MagicMirror-${RELEASE} /opt/magicmirror
|
||||||
cd /opt/magicmirror
|
cd /opt/magicmirror
|
||||||
$STD npm install --only=prod --omit=dev
|
$STD npm run install-mm
|
||||||
|
|
||||||
cat <<EOF >/opt/magicmirror/config/config.js
|
cat <<EOF >/opt/magicmirror/config/config.js
|
||||||
let config = {
|
let config = {
|
||||||
address: "0.0.0.0",
|
address: "0.0.0.0",
|
||||||
@ -130,11 +130,12 @@ let config = {
|
|||||||
/*************** DO NOT EDIT THE LINE BELOW ***************/
|
/*************** DO NOT EDIT THE LINE BELOW ***************/
|
||||||
if (typeof module !== "undefined") {module.exports = config;}
|
if (typeof module !== "undefined") {module.exports = config;}
|
||||||
EOF
|
EOF
|
||||||
msg_ok "Installed MagicMirror"
|
echo "${RELEASE}" >"/opt/${APPLICATION}_version.txt"
|
||||||
|
msg_ok "Setup MagicMirror"
|
||||||
|
|
||||||
msg_info "Creating Service"
|
msg_info "Creating Service"
|
||||||
service_path="/etc/systemd/system/magicmirror.service"
|
cat <<EOF >/etc/systemd/system/magicmirror.service
|
||||||
echo "[Unit]
|
[Unit]
|
||||||
Description=Magic Mirror
|
Description=Magic Mirror
|
||||||
After=network.target
|
After=network.target
|
||||||
StartLimitIntervalSec=0
|
StartLimitIntervalSec=0
|
||||||
@ -145,17 +146,19 @@ Restart=always
|
|||||||
RestartSec=1
|
RestartSec=1
|
||||||
User=root
|
User=root
|
||||||
WorkingDirectory=/opt/magicmirror/
|
WorkingDirectory=/opt/magicmirror/
|
||||||
ExecStart=/usr/bin/node serveronly
|
ExecStart=/usr/bin/npm run server
|
||||||
|
|
||||||
[Install]
|
[Install]
|
||||||
WantedBy=multi-user.target" >$service_path
|
WantedBy=multi-user.target
|
||||||
$STD systemctl enable --now magicmirror
|
EOF
|
||||||
|
systemctl enable --now magicmirror
|
||||||
msg_ok "Created Service"
|
msg_ok "Created Service"
|
||||||
|
|
||||||
motd_ssh
|
motd_ssh
|
||||||
customize
|
customize
|
||||||
|
|
||||||
msg_info "Cleaning up"
|
msg_info "Cleaning up"
|
||||||
|
rm -rf $temp_file
|
||||||
$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"
|
||||||
|
Loading…
Reference in New Issue
Block a user