Update phpmyadmin.sh

This commit is contained in:
CanbiZ 2025-04-29 11:57:21 +02:00
parent 59b73234fd
commit 8a77edb9de

View File

@ -178,9 +178,10 @@ function uninstall_phpmyadmin() {
}
function update_phpmyadmin() {
msg_info "Fetching latest phpMyAdmin version from GitHub"
msg_info "Fetching latest phpMyAdmin release from GitHub"
LATEST_VERSION_RAW=$(curl -s https://api.github.com/repos/phpmyadmin/phpmyadmin/releases/latest | grep tag_name | cut -d '"' -f4)
LATEST_VERSION=$(echo "$LATEST_VERSION_RAW" | sed -e 's/^RELEASE_//' -e 's/_/./g')
if [[ -z "$LATEST_VERSION" ]]; then
msg_error "Could not determine latest phpMyAdmin version from GitHub falling back to 5.2.2"
LATEST_VERSION="5.2.2"
@ -189,13 +190,31 @@ function update_phpmyadmin() {
TARBALL_URL="https://files.phpmyadmin.net/phpMyAdmin/${LATEST_VERSION}/phpMyAdmin-${LATEST_VERSION}-all-languages.tar.gz"
msg_info "Downloading ${TARBALL_URL}"
if ! curl -fsSL "$TARBALL_URL" -o /tmp/phpmyadmin.tar.gz; then
msg_error "Download failed: $TARBALL_URL"
exit 1
fi
BACKUP_DIR="/tmp/phpmyadmin-backup-$(date +%Y%m%d-%H%M%S)"
mkdir -p "$BACKUP_DIR"
BACKUP_ITEMS=("config.inc.php" "upload" "save" "tmp" "themes")
msg_info "Backing up existing phpMyAdmin data"
for item in "${BACKUP_ITEMS[@]}"; do
[[ -e "$INSTALL_DIR/$item" ]] && cp -a "$INSTALL_DIR/$item" "$BACKUP_DIR/" && echo " ↪︎ $item"
done
msg_ok "Backup completed: $BACKUP_DIR"
tar xf /tmp/phpmyadmin.tar.gz --strip-components=1 -C "$INSTALL_DIR"
msg_ok "Updated phpMyAdmin to $LATEST_VERSION"
msg_ok "Extracted phpMyAdmin $LATEST_VERSION"
msg_info "Restoring preserved files"
for item in "${BACKUP_ITEMS[@]}"; do
[[ -e "$BACKUP_DIR/$item" ]] && cp -a "$BACKUP_DIR/$item" "$INSTALL_DIR/" && echo " ↪︎ $item restored"
done
msg_ok "Restoration completed"
configure_phpmyadmin
}