#!/bin/sh ## # phpMyAdmin upgrading and installing utility # # @author Phi1 'l0rdphi1' Stier # @version 1.4 # ## cd $HOME echo echo "********************************************************" echo -e "* \033[1;37mphpMyAdmin upgrading and installing utility v1.4\033[0m *" echo "********************************************************" echo echo -n "Upgrade to what version? (e.g., 2.5.6 ) [2.5.6] " read INSTALL_VERSION if [ "${INSTALL_VERSION}" = "" ] then INSTALL_VERSION=2.5.6 fi echo "Use which mirror to pull 'phpMyAdmin-$INSTALL_VERSION.tar.gz' from?" echo -n "[http://aleron.dl.sourceforge.net/sourceforge/phpmyadmin/] " read MIRROR if [ "${MIRROR}" = "" ] then MIRROR=http://aleron.dl.sourceforge.net/sourceforge/phpmyadmin/ fi echo -n "Where should we install phpMyAdmin locally? [/var/www/html/phpMyAdmin] " read INSTALL_DIRECTORY if [ "${INSTALL_DIRECTORY}" = "" ] then INSTALL_DIRECTORY=/var/www/html/phpMyAdmin fi MODE=1 until [ -e ${INSTALL_DIRECTORY} ] do _save_inst_dir=$INSTALL_DIRECTORY echo "" echo "Can not locate a copy of phpMyAdmin in ${INSTALL_DIRECTORY} to upgrade.." echo "If you would like to install phpMyAdmin to specified directory, hit enter." echo "If you would like to specify a different directory to upgrade from, enter it now." read INSTALL_DIRECTORY if [ "${INSTALL_DIRECTORY}" = "" ] then MODE=2 INSTALL_DIRECTORY=$_save_inst_dir break; fi unset _save_inst_dir done # if upgrading, backup old files if [ $MODE = 1 ] then BACKUP_DIRECTORY="$INSTALL_DIRECTORY-backup" until [ ! -d $BACKUP_DIRECTORY ] do echo echo "The backup location; $BACKUP_DIRECTORY already exists. Please specify a new location for your phpMyAdmin." echo -n "New Backup Location: " read BACKUP_DIRECTORY done mv $INSTALL_DIRECTORY $BACKUP_DIRECTORY fi mkdir ${INSTALL_DIRECTORY} rm -fr ${INSTALL_DIRECTORY}/* # download new tarball cd ${INSTALL_DIRECTORY} wget -q ${MIRROR}phpMyAdmin-${INSTALL_VERSION}.tar.gz # did we get the file? if [ ! -e "${INSTALL_DIRECTORY}/phpMyAdmin-${INSTALL_VERSION}.tar.gz" ] then echo echo "Can not import ${MIRROR}phpMyAdmin-${INSTALL_VERSION}.tar.gz" echo "Check to make sure '${INSTALL_VERSION}' is a real version. Exiting..." echo exit 0; fi tar xzf phpMyAdmin-${INSTALL_VERSION}.tar.gz -C ${INSTALL_DIRECTORY} # need to copy extracted version directory into install directory & rm tarball mv -f ${INSTALL_DIRECTORY}/phpMyAdmin-${INSTALL_VERSION}/* ${INSTALL_DIRECTORY} rm -f ${INSTALL_DIRECTORY}/phpMyAdmin-${INSTALL_VERSION}.tar.gz rm -fr ${INSTALL_DIRECTORY}/phpMyAdmin-${INSTALL_VERSION} # if upgrading... if [ $MODE = 1 ] then # restore old config.inc.php IFF old one exists if [ -e $BACKUP_DIRECTORY/config.inc.php ] then rm -f $INSTALL_DIRECTORY/config.inc.php cp -f $BACKUP_DIRECTORY/config.inc.php $INSTALL_DIRECTORY else echo "\nOld confing.inc.php not found, using new."; fi echo echo "Upgraded!" echo echo "Now, check and make sure phpMyAdmin is working." echo "Hit 'y' to remove old version backups ($BACKUP_DIRECTORY)." echo "Hit 'n' to leave the backups." echo -n "(y/n) [y] " read bool_rmback case "$bool_rmback" in [nN]) ;; *) echo "Removing backups..." rm -fr $BACKUP_DIRECTORY ;; esac fi echo "" echo "Successfully installed phpMyAdmin v${INSTALL_VERSION} to ${INSTALL_DIRECTORY}!" echo "" exit 0;