diff --git a/ct/homarr.sh b/ct/homarr.sh index b04bf9660..fa3ca417f 100644 --- a/ct/homarr.sh +++ b/ct/homarr.sh @@ -66,29 +66,37 @@ if [[ ! -f /opt/${APP}_version.txt ]] || [[ "${RELEASE}" != "$(cat /opt/${APP}_v systemctl stop homarr msg_ok "Services Stopped" + msg_info "Backing up Data" + mkdir -p /opt/homarr-data-backup + cp /opt/homarr/.env /opt/homarr-data-backup/.env + cp /opt/homarr/database/db.sqlite /opt/homarr-data-backup/db.sqlite + cp -r /opt/homarr/data/configs /opt/homarr-data-backup/configs + msg_ok "Backed up Data" + msg_info "Updating ${APP} to ${RELEASE}" - cp /opt/homarr/.env /opt/.env - cp -a /opt/homarr/data /opt/ - rm -rf /opt/homarr wget -q "https://github.com/ajnart/homarr/archive/refs/tags/v${RELEASE}.zip" unzip -q v${RELEASE}.zip + rm -rf v${RELEASE}.zip + rm -rf /opt/homarr mv homarr-${RELEASE} /opt/homarr - mv /opt/.env /opt/homarr/.env - rm -rf /opt/homarr/data - mv /opt/data /opt/homarr/ + mv /opt/homarr-data-backup/.env /opt/homarr/.env + cd /opt/homarr yarn install &>/dev/null yarn build &>/dev/null - yarn db:migrate &>/dev/null echo "${RELEASE}" >/opt/${APP}_version.txt msg_ok "Updated ${APP}" + msg_info "Restoring Data" + rm -rf /opt/homarr/data/configs + mv /opt/homarr-data-backup/configs /opt/homarr/data/configs + mv /opt/homarr-data-backup/db.sqlite /opt/homarr/database/db.sqlite + yarn db:migrate &>/dev/null + rm -rf /opt/homarr-data-backup + msg_ok "Restored Data" + msg_info "Starting Services" systemctl start homarr msg_ok "Started Services" - - msg_info "Cleaning Up" - rm -rf v${RELEASE}.zip - msg_ok "Cleaned" msg_ok "Updated Successfully" else msg_ok "No update required. ${APP} is already at ${RELEASE}" diff --git a/install/homarr-install.sh b/install/homarr-install.sh index b0561b993..fe138d402 100644 --- a/install/homarr-install.sh +++ b/install/homarr-install.sh @@ -39,6 +39,7 @@ msg_info "Installing Homarr (Patience)" RELEASE=$(curl -s https://api.github.com/repos/ajnart/homarr/releases/latest | grep "tag_name" | awk '{print substr($2, 3, length($2)-4) }') wget -q "https://github.com/ajnart/homarr/archive/refs/tags/v${RELEASE}.zip" unzip -q v${RELEASE}.zip +rm -rf v${RELEASE}.zip mv homarr-${RELEASE} /opt/homarr cat </opt/homarr/.env DATABASE_URL="file:./database/db.sqlite" @@ -76,7 +77,6 @@ motd_ssh customize msg_info "Cleaning up" -rm -rf v${RELEASE}.zip $STD apt-get -y autoremove $STD apt-get -y autoclean msg_ok "Cleaned"