Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
phpMyAdmin Updater Shell Script
#!/bin/bash
# Directories
BASE_PATH="/mnt/1TBHDD/www"
BACKUP_DIR="$BASE_PATH/backup"
DOCROOT="$BASE_PATH/docroot"
APP_DIR="$DOCROOT/phpmyadmin"
# Ask for the latest version
printf " > Enter the latest phpMyAdmin version: "
read version
echo " > Create a backup of the config file..."
cp "$APP_DIR/config.inc.php" $BACKUP_DIR
echo " > Delete the old directory..."
rm -rf $APP_DIR
DL_DIR="phpMyAdmin-$version-all-languages"
DL_FILE="$DL_DIR.tar.gz"
DL_FILE_ABSOLUTE="$BASE_PATH/$DL_FILE"
DL_URL="https://files.phpmyadmin.net/phpMyAdmin/$version/$DL_FILE"
echo " > Download $DL_URL..."
wget -q $DL_URL -O $DL_FILE_ABSOLUTE
echo " > Extract new version to $APP_DIR..."
tar -xzf $DL_FILE_ABSOLUTE -C $DOCROOT
echo " > Rename extracted directory..."
mv "$DOCROOT/$DL_DIR" $APP_DIR
echo " > Restore config backup..."
cp "$BACKUP_DIR/config.inc.php" "$APP_DIR/config.inc.php"
echo " > Delete downloaded archive..."
rm $DL_FILE_ABSOLUTE
echo " > Done."
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment