fixed both script changed pip env to uv

This commit is contained in:
bilulib
2025-07-21 14:30:16 +02:00
parent e2b9ac687f
commit 2c61e49140
2 changed files with 91 additions and 85 deletions

View File

@ -30,59 +30,78 @@ function update_script() {
msg_error "No ${APP} Installation Found!"
exit
fi
setup_uv
# Crawling the new version and checking whether an update is required
RELEASE=$(curl -fsSL https://api.github.com/repos/Dictionarry-Hub/profilarr/releases/latest | grep "tag_name" | awk '{print substr($2, 3, length($2)-4)}')
if [[ "${RELEASE}" != "$(cat /opt/${APP}_version.txt)" ]] || [[ ! -f /opt/${APP}_version.txt ]]; then
# Stopping Services
msg_info "Stopping $APP"
systemctl stop profilarr
msg_ok "Stopped $APP"
# Creating Backup
msg_info "Creating Backup"
tar -czf "/opt/${APP}_backup_$(date +%F).tar.gz" /opt/${APP} /opt/${APP}_config
msg_ok "Backup Created"
# Execute Update
msg_info "Updating $APP to v${RELEASE}"
temp_file=$(mktemp)
curl -fsSL -o "$temp_file" "https://github.com/Dictionarry-Hub/profilarr/archive/refs/tags/v${RELEASE}.zip"
cd /tmp
unzip -q "$temp_file"
rm -rf /opt/${APP}/backend /opt/${APP}/frontend
mv "profilarr-${RELEASE}/backend" /opt/${APP}/
mv "profilarr-${RELEASE}/frontend" /opt/${APP}/
# Update Python dependencies
cd /opt/${APP}/backend
/opt/${APP}/venv/bin/pip install -r requirements.txt
# Build frontend
cd /opt/${APP}/frontend
npm install
npm run build
cp -r dist/* /opt/${APP}/backend/app/static/
msg_ok "Updated $APP to v${RELEASE}"
# Starting Services
msg_info "Starting $APP"
systemctl start profilarr
msg_ok "Started $APP"
# Cleaning up
msg_info "Cleaning Up"
rm -f "$temp_file"
rm -rf "/tmp/profilarr-${RELEASE}"
msg_ok "Cleanup Completed"
# Last Action
echo "${RELEASE}" >/opt/${APP}_version.txt
msg_ok "Update Successful"
else
msg_ok "No update required. ${APP} is already at v${RELEASE}"
RELEASE=$(curl -fsSL https://api.github.com/repos/Dictionarry-Hub/profilarr/releases/latest | grep "tag_name" | awk '{print substr($2, 2, length($2)-3)}')
if [[ -f /opt/${APP}_version.txt ]] && [[ "${RELEASE}" == "$(cat /opt/${APP}_version.txt)" ]]; then
msg_ok "No update required. ${APP} is already at ${RELEASE}"
exit
fi
# Stopping Services
msg_info "Stopping $APP"
systemctl stop ${APP}
msg_ok "Stopped $APP"
# Creating Backup
msg_info "Creating Backup"
if ls /opt/"${APP}"_backup_*.tar.gz &>/dev/null; then
rm -f /opt/"${APP}"_backup_*.tar.gz
msg_info "Removed previous backup"
fi
tar -czf "/opt/${APP}_backup_$(date +%F).tar.gz" /opt/${APP} /opt/${APP}_config
msg_ok "Backup Created"
# Execute Update
msg_info "Updating $APP to v${RELEASE}"
temp_file=$(mktemp)
curl -fsSL -o "$temp_file" "https://github.com/Dictionarry-Hub/profilarr/archive/refs/tags/${RELEASE}.zip"
unzip -q -o "$temp_file" -d /tmp
rm -rf /opt/${APP}/backend /opt/${APP}/frontend
mv "/tmp/profilarr-${RELEASE}/backend" /opt/${APP}/
mv "/tmp/profilarr-${RELEASE}/frontend" /opt/${APP}/
# Update Python dependencies
msg_info "Updating Python dependencies"
cd /opt/${APP}/backend || exit
if [[ -f "/opt/${APP}/.requirements_checksum" ]]; then
CURRENT_CHECKSUM=$(md5sum requirements.txt | awk '{print $1}')
STORED_CHECKSUM=$(cat /opt/${APP}/.requirements_checksum)
if [[ "$CURRENT_CHECKSUM" != "$STORED_CHECKSUM" ]]; then
msg_info "Requirements have changed. Performing full upgrade."
$STD uv pip install -r requirements.txt --python /opt/${APP}/venv/bin/python
else
msg_info "Requirements unchanged. Verifying installation."
$STD uv pip install -r requirements.txt --python /opt/${APP}/venv/bin/python
fi
else
$STD uv pip install -r requirements.txt --python /opt/${APP}/venv/bin/python
fi
md5sum requirements.txt | awk '{print $1}' >/opt/${APP}/.requirements_checksum
msg_ok "Updated Python dependencies"
# Build frontend
msg_info "Building Frontend"
cd /opt/${APP}/frontend || exit
npm install
npm run build
cp -r dist/* /opt/${APP}/backend/app/static/
msg_ok "Built Frontend"
# Starting Services
msg_info "Starting $APP"
systemctl start ${APP}
msg_ok "Started $APP"
# Cleaning up
msg_info "Cleaning Up"
rm -f "$temp_file"
rm -rf "/tmp/profilarr-${RELEASE}"
msg_ok "Cleanup Completed"
# Last Action
echo "${RELEASE}" >/opt/${APP}_version.txt
msg_ok "Updated $APP to v${RELEASE}"
exit
}