diff --git a/ct/revealjs.sh b/ct/revealjs.sh index 64b8af169..07981e48c 100644 --- a/ct/revealjs.sh +++ b/ct/revealjs.sh @@ -23,29 +23,25 @@ function update_script() { header_info check_container_storage check_container_resources - if [[ ! -d "/opt/revealjs" ]]; then msg_error "No ${APP} Installation Found!" exit fi + RELEASE=$(curl -fsSL https://api.github.com/repos/hakimel/reveal.js/releases/latest | grep "tag_name" | awk '{print substr($2, 2, length($2)-3) }') - if [[ "${RELEASE}" != "$(cat /opt/${APP}_version.txt)" ]] || [[ ! -f /opt/${APP}_version.txt ]]; then + if [[ "${RELEASE}" != "$(cat ~/.revealjs 2>/dev/null)" ]] || [[ ! -f ~/.revealjs ]]; then msg_info "Stopping $APP" systemctl stop revealjs msg_ok "Stopped $APP" - msg_info "Updating $APP to ${RELEASE}" - temp_file=$(mktemp) -curl -fsSL "https://github.com/hakimel/reveal.js/archive/refs/tags/${RELEASE}.tar.gz" -o "$temp_file" - tar zxf $temp_file - rm -rf /opt/revealjs/node_modules/* cp /opt/revealjs/index.html /opt - cp -rf reveal.js-${RELEASE}/* /opt/revealjs + fetch_and_deploy_gh_release "revealjs" "hakimel/reveal.js" "tarball" + + msg_info "Updating $APP to ${RELEASE}" cd /opt/revealjs $STD npm install cp -f /opt/index.html /opt/revealjs sed -i '25s/localhost/0.0.0.0/g' /opt/revealjs/gulpfile.js - echo "${RELEASE}" >/opt/${APP}_version.txt msg_ok "Updated $APP to ${RELEASE}" msg_info "Starting $APP" @@ -53,8 +49,7 @@ curl -fsSL "https://github.com/hakimel/reveal.js/archive/refs/tags/${RELEASE}.ta msg_ok "Started $APP" msg_info "Cleaning Up" - rm -f $temp_file - rm -rf ~/reveal.js-${RELEASE} + rm -f /opt/index.html msg_ok "Cleanup Completed" msg_ok "Update Successful" @@ -71,4 +66,4 @@ description msg_ok "Completed Successfully!\n" echo -e "${CREATING}${GN}${APP} setup has been successfully initialized!${CL}" echo -e "${INFO}${YW} Access it using the following URL:${CL}" -echo -e "${TAB}${GATEWAY}${BGN}http://${IP}:8000${CL}" \ No newline at end of file +echo -e "${TAB}${GATEWAY}${BGN}http://${IP}:8000${CL}" diff --git a/install/revealjs-install.sh b/install/revealjs-install.sh index eb1665608..9d1fbaee1 100644 --- a/install/revealjs-install.sh +++ b/install/revealjs-install.sh @@ -14,17 +14,12 @@ network_check update_os NODE_VERSION="22" setup_nodejs +fetch_and_deploy_gh_release "revealjs" "hakimel/reveal.js" "tarball" -msg_info "Setup ${APPLICATION}" -temp_file=$(mktemp) -RELEASE=$(curl -fsSL https://api.github.com/repos/hakimel/reveal.js/releases/latest | grep "tag_name" | awk '{print substr($2, 2, length($2)-3) }') -curl -fsSL "https://github.com/hakimel/reveal.js/archive/refs/tags/${RELEASE}.tar.gz" -o "$temp_file" -tar zxf $temp_file -mv reveal.js-${RELEASE}/ /opt/revealjs +msg_info "Configuring ${APPLICATION}" cd /opt/revealjs $STD npm install sed -i '25s/localhost/0.0.0.0/g' /opt/revealjs/gulpfile.js -echo "${RELEASE}" >/opt/${APPLICATION}_version.txt msg_ok "Setup ${APPLICATION}" msg_info "Creating Service" @@ -50,7 +45,6 @@ motd_ssh customize msg_info "Cleaning up" -rm -f $temp_file $STD apt-get -y autoremove $STD apt-get -y autoclean msg_ok "Cleaned"