@@ -27,44 +27,41 @@ function update_script() {
2727 msg_error " No ${APP} Installation Found!"
2828 exit
2929 fi
30- RELEASE=$( curl -fsSL https://api.github.com/repos/MagicMirrorOrg/MagicMirror/releases/latest | grep " tag_name" | awk ' {print substr($2, 3, length($2)-4) }' )
31- if [[ ! -f /opt/${APP} _version.txt ]]; then touch /opt/${APP} _version.txt; fi
32- if [[ ! -f /opt/${APP} _version.txt ]] || [[ " ${RELEASE} " != " $( cat /opt/${APP} _version.txt) " ]]; then
30+ if ! command -v jq & > /dev/null; then
31+ $STD apt-get install -y jq
32+ fi
33+
34+ RELEASE=$( curl -fsSL https://api.github.com/repos/MagicMirrorOrg/MagicMirror/releases/latest | jq -r ' .tag_name' | sed ' s/^v//' )
35+ if [[ ! -f ~ /.magicmirror ]] || [[ " ${RELEASE} " != " $( cat ~ /.magicmirror) " ]]; then
3336 msg_info " Stopping Service"
3437 systemctl stop magicmirror
3538 msg_ok " Stopped Service"
3639
37- msg_info " Updating ${APP} to v${RELEASE} "
38- $STD apt-get update
39- $STD apt-get upgrade -y
40+ msg_info " Backing up data"
4041 rm -rf /opt/magicmirror-backup
4142 mkdir /opt/magicmirror-backup
4243 cp /opt/magicmirror/config/config.js /opt/magicmirror-backup
4344 if [[ -f /opt/magicmirror/css/custom.css ]]; then
4445 cp /opt/magicmirror/css/custom.css /opt/magicmirror-backup
4546 fi
4647 cp -r /opt/magicmirror/modules /opt/magicmirror-backup
47- temp_file= $( mktemp )
48- curl -fsSL " https://github.com/MagicMirrorOrg/MagicMirror/archive/refs/tags/v ${RELEASE} .tar.gz " -o " " $temp_file " "
49- tar -xzf " $temp_file "
50- rm -rf /opt/magicmirror
51- mv MagicMirror- ${RELEASE} /opt/magicmirror
48+ msg_ok " Backed up data "
49+
50+ fetch_and_deploy_gh_release " magicmirror " " MagicMirrorOrg/MagicMirror " " tarball "
51+
52+ msg_info " Configuring MagicMirror "
5253 cd /opt/magicmirror
5354 $STD npm run install-mm
5455 cp /opt/magicmirror-backup/config.js /opt/magicmirror/config/
5556 if [[ -f /opt/magicmirror-backup/custom.css ]]; then
5657 cp /opt/magicmirror-backup/custom.css /opt/magicmirror/css/
5758 fi
58- echo " ${RELEASE} " > " /opt/${APP} _version.txt"
59- msg_ok " Updated ${APP} to v${RELEASE} "
59+ msg_ok " Configured MagicMirror"
6060
6161 msg_info " Starting Service"
6262 systemctl start magicmirror
6363 msg_ok " Started Service"
6464
65- msg_info " Cleaning up"
66- rm -f $temp_file
67- msg_ok " Cleaned"
6865 msg_ok " Updated Successfully"
6966 else
7067 msg_ok " No update required. ${APP} is already at v${RELEASE} ."
@@ -79,4 +76,4 @@ description
7976msg_ok " Completed Successfully!\n"
8077echo -e " ${CREATING}${GN}${APP} setup has been successfully initialized!${CL} "
8178echo -e " ${INFO}${YW} Access it using the following URL:${CL} "
82- echo -e " ${TAB}${GATEWAY}${BGN} http://${IP} :8080${CL} "
79+ echo -e " ${TAB}${GATEWAY}${BGN} http://${IP} :8080${CL} "
0 commit comments