Skip to content

Commit

Permalink
Fix homarr update (#162)
Browse files Browse the repository at this point in the history
  • Loading branch information
havardthom authored Nov 10, 2024
1 parent e0df745 commit c229c9c
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 12 deletions.
30 changes: 19 additions & 11 deletions ct/homarr.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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}"
Expand Down
2 changes: 1 addition & 1 deletion install/homarr-install.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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 <<EOF >/opt/homarr/.env
DATABASE_URL="file:./database/db.sqlite"
Expand Down Expand Up @@ -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"

0 comments on commit c229c9c

Please sign in to comment.