2023-03-22 20:48:20 -04:00
|
|
|
#!/usr/bin/env bash
|
2025-04-01 10:25:46 +02:00
|
|
|
source <(curl -fsSL https://raw.githubusercontent.com/community-scripts/ProxmoxVE/main/misc/build.func)
|
2025-01-01 13:37:29 +01:00
|
|
|
# Copyright (c) 2021-2025 tteck
|
2025-02-15 16:46:37 +01:00
|
|
|
# Author: tteck (tteckster) | Co-Author Slaviša Arežina (tremor021)
|
2024-12-16 12:42:51 +01:00
|
|
|
# License: MIT | https://github.com/community-scripts/ProxmoxVE/raw/main/LICENSE
|
|
|
|
|
# Source: https://magicmirror.builders/
|
2023-03-22 20:48:20 -04:00
|
|
|
|
|
|
|
|
APP="MagicMirror"
|
2025-04-10 11:56:52 +02:00
|
|
|
var_tags="${var_tags:-smarthome}"
|
|
|
|
|
var_cpu="${var_cpu:-1}"
|
|
|
|
|
var_ram="${var_ram:-512}"
|
|
|
|
|
var_disk="${var_disk:-3}"
|
|
|
|
|
var_os="${var_os:-debian}"
|
|
|
|
|
var_version="${var_version:-12}"
|
|
|
|
|
var_unprivileged="${var_unprivileged:-1}"
|
2024-12-16 12:42:51 +01:00
|
|
|
|
|
|
|
|
header_info "$APP"
|
2023-03-22 20:48:20 -04:00
|
|
|
variables
|
|
|
|
|
color
|
|
|
|
|
catch_errors
|
|
|
|
|
|
|
|
|
|
function update_script() {
|
2024-12-16 12:42:51 +01:00
|
|
|
header_info
|
|
|
|
|
check_container_storage
|
|
|
|
|
check_container_resources
|
|
|
|
|
if [[ ! -d /opt/magicmirror ]]; then
|
|
|
|
|
msg_error "No ${APP} Installation Found!"
|
|
|
|
|
exit
|
|
|
|
|
fi
|
2025-08-01 07:26:35 +02:00
|
|
|
if ! command -v jq &>/dev/null; then
|
|
|
|
|
$STD apt-get install -y jq
|
|
|
|
|
fi
|
|
|
|
|
|
|
|
|
|
RELEASE=$(curl -fsSL https://api.github.com/repos/MagicMirrorOrg/MagicMirror/releases/latest | jq -r '.tag_name' | sed 's/^v//')
|
|
|
|
|
if [[ ! -f ~/.magicmirror ]] || [[ "${RELEASE}" != "$(cat ~/.magicmirror)" ]]; then
|
2025-02-15 16:46:37 +01:00
|
|
|
msg_info "Stopping Service"
|
|
|
|
|
systemctl stop magicmirror
|
|
|
|
|
msg_ok "Stopped Service"
|
|
|
|
|
|
2025-08-01 07:26:35 +02:00
|
|
|
msg_info "Backing up data"
|
2025-02-18 12:00:24 +01:00
|
|
|
rm -rf /opt/magicmirror-backup
|
2025-02-15 16:46:37 +01:00
|
|
|
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
|
|
|
|
|
cp -r /opt/magicmirror/modules /opt/magicmirror-backup
|
2025-08-01 07:26:35 +02:00
|
|
|
msg_ok "Backed up data"
|
|
|
|
|
|
|
|
|
|
fetch_and_deploy_gh_release "magicmirror" "MagicMirrorOrg/MagicMirror" "tarball"
|
|
|
|
|
|
|
|
|
|
msg_info "Configuring MagicMirror"
|
2025-02-15 16:46:37 +01:00
|
|
|
cd /opt/magicmirror
|
2025-08-02 17:23:32 +02:00
|
|
|
sed -i -E 's/("postinstall": )".*"/\1""/; s/("prepare": )".*"/\1""/' package.json
|
2025-02-24 12:49:16 +01:00
|
|
|
$STD npm run install-mm
|
2025-02-15 16:46:37 +01:00
|
|
|
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/
|
2024-01-03 01:30:09 -05:00
|
|
|
fi
|
2025-08-01 07:26:35 +02:00
|
|
|
msg_ok "Configured MagicMirror"
|
2025-02-15 16:46:37 +01:00
|
|
|
|
|
|
|
|
msg_info "Starting Service"
|
|
|
|
|
systemctl start magicmirror
|
|
|
|
|
msg_ok "Started Service"
|
|
|
|
|
|
|
|
|
|
msg_ok "Updated Successfully"
|
|
|
|
|
else
|
|
|
|
|
msg_ok "No update required. ${APP} is already at v${RELEASE}."
|
2024-01-03 01:30:09 -05:00
|
|
|
fi
|
2024-12-16 12:42:51 +01:00
|
|
|
exit
|
2023-03-22 20:48:20 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
start
|
|
|
|
|
build_container
|
|
|
|
|
description
|
|
|
|
|
|
|
|
|
|
msg_ok "Completed Successfully!\n"
|
2024-12-16 12:42:51 +01:00
|
|
|
echo -e "${CREATING}${GN}${APP} setup has been successfully initialized!${CL}"
|
|
|
|
|
echo -e "${INFO}${YW} Access it using the following URL:${CL}"
|
2025-08-01 07:26:35 +02:00
|
|
|
echo -e "${TAB}${GATEWAY}${BGN}http://${IP}:8080${CL}"
|