├── .gitignore ├── LICENCE ├── README.md ├── install-cronjob.sh └── pma-update.sh /.gitignore: -------------------------------------------------------------------------------- 1 | #idea 2 | *.iml 3 | .idea 4 | .4 5 | 0 6 | 7 | *.4 8 | -------------------------------------------------------------------------------- /LICENCE: -------------------------------------------------------------------------------- 1 | Copyright (c) 2013 Stefan Schulz-Lauterbach and Michael Riehemann 2 | 3 | MIT License 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining 6 | a copy of this software and associated documentation files (the 7 | "Software"), to deal in the Software without restriction, including 8 | without limitation the rights to use, copy, modify, merge, publish, 9 | distribute, sublicense, and/or sell copies of the Software, and to 10 | permit persons to whom the Software is furnished to do so, subject to 11 | the following conditions: 12 | 13 | The above copyright notice and this permission notice shall be 14 | included in all copies or substantial portions of the Software. 15 | 16 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 17 | EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 18 | MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 19 | NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE 20 | LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION 21 | OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION 22 | WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # phpMyAdmin updatescript for your shell 2 | This script will update your current phpMyAdmin to the latest version directly from your shell. 3 | 4 | ## Requirements 5 | - wget 6 | - tar 7 | 8 | ## Installation 9 | Copy the script to any location of your machine. 10 | IMPORTANT: You need to edit the script to set the correct settings. 11 | 12 | If you want to install a cronjob, run 13 | 14 | sh install-cronjob.sh 15 | 16 | ## Settings 17 | 18 | Open the file config.sh and edit the variables LOCATION, PMA. If you set f.e. LOCATION="/var/www" and PMA="pma" your PMA 19 | installation will be installed into "/var/www/pma". 20 | 21 | If you want, change the compression type - "tar.gz" and "tar.bz2" are possible. 22 | 23 | ## User based settings 24 | 25 | Instead of changing the settings in the script, you can place the variables in a user based .pma-updaterc file in the home folder from the user this script runs as. 26 | 27 | ## Usage 28 | For updating phpMyAdmin to the latest version, execute the shell script like this: 29 | 30 | sh pma-update.sh 31 | 32 | If you want to install a specific version 33 | 34 | sh pma-update.sh -r 3.5.0 35 | 36 | 37 | ### More options 38 | sh pma-update.sh [-hvf] [-r version] 39 | -h this help 40 | -v output all warnings 41 | -f force download, even if this version is installed already 42 | -r version choose a different version than the latest. 43 | -------------------------------------------------------------------------------- /install-cronjob.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | ## 3 | # PHPMYADMIN UPDATE SCRIPT 4 | # https://github.com/stefansl/pma-updatescript/ 5 | ## 6 | 7 | # SETTING 8 | CRONPATH="/etc/cron.daily/pma-update" 9 | 10 | # GO 11 | installcron() { 12 | touch $CRONPATH 13 | echo "#!/bin/sh" >> $CRONPATH 14 | echo "sh $(pwd)/pma-update.sh" >> $CRONPATH 15 | echo "Cronjob for phpmyadmin updatescript installed." 16 | chmod 755 $CRONPATH 17 | break 18 | } 19 | 20 | for file in $CRONPATH ]; do 21 | if [ -f $file ]; then 22 | echo "Cronjob for pma-update already exists. Do you want to renew it? [y|N]" 23 | read answer 24 | if [ "$answer" = y -o "$answer" = Y ]; then 25 | rm $CRONPATH 26 | installcron; 27 | else 28 | echo "Ok, I did nothing!" 29 | break 30 | fi 31 | else 32 | installcron; 33 | fi 34 | done 35 | -------------------------------------------------------------------------------- /pma-update.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | ## 4 | # PHPMYADMIN UPDATE SCRIPT 5 | # https://github.com/stefansl/pma-updatescript/ 6 | # Author: Stefan Schulz-Lauterbach, Michael Riehemann, Igor Buyanov 7 | ## 8 | 9 | # SETTINGS 10 | # Please check this settings. Without changing 11 | # location and pma your installation will not work! 12 | # 13 | # Instead of changing these values below, 14 | # you can place them in a .pma-updaterc file in the 15 | # home folder from the user this script runs as. 16 | ## 17 | 18 | LOCATION="" # Directory of PMA installation. Without a slash at the end. For example: LOCATION="/var/www" 19 | PMA="" # Name of the PMA folder. For example: pma or phpMyAdmin 20 | LANGUAGE="" # Language of PMA. Leave it blank for all languages or specify a language pack, for example: english 21 | USER="" # User of files 22 | GROUP="" # Group of files 23 | CTYPE="tar.gz" # Compression type. default "tar.gz". tar.bz2 is possible, too. 24 | LOGLEVEL=1 # set 0 for quiet mode (no output) 25 | # set 1 to output warnings (DEFAULT) 26 | # set 2 to output all messages 27 | DELETE=0 # set 1 to delete directory examples 28 | VERSIONLINK="https://www.phpmyadmin.net/home_page/version.php" 29 | DOWNLOADURL="https://files.phpmyadmin.net/phpMyAdmin" 30 | FORCE="off" 31 | 32 | CONFIG_FILE=~/.pma-updaterc 33 | 34 | 35 | ################################################ 36 | # # 37 | # DON'T CHANGE ANYTHING FROM HERE # 38 | # unless you're not into shell scripting # 39 | # # 40 | ################################################ 41 | 42 | 43 | # Output help 44 | usage() { 45 | echo "usage: sh pma-update.sh [-hvf] [-r version]"; 46 | echo "-h this help"; 47 | echo "-v output all warnings"; 48 | echo "-f force download, even if this version is installed already"; 49 | echo "-r version choose a different version than the latest."; 50 | } 51 | 52 | # If user based config exists, load it 53 | if [ -f $CONFIG_FILE ]; then 54 | command . $CONFIG_FILE; 55 | fi 56 | 57 | 58 | # Output warnings 59 | log() { 60 | if [ $LOGLEVEL -gt 0 ]; then 61 | echo "$@"; 62 | fi 63 | } 64 | 65 | 66 | # Output additional messages 67 | info() { 68 | if [ $LOGLEVEL -eq 2 ]; then 69 | echo "$@"; 70 | fi 71 | } 72 | 73 | # Options 74 | params="$(getopt -o hvfr: -l help --name "$cmdname" -- "$@")" 75 | 76 | if [ $? -ne 0 ]; then 77 | usage 78 | fi 79 | 80 | eval set -- "$params" 81 | unset params 82 | 83 | while true 84 | do 85 | case "$1" in 86 | -v) LOGLEVEL=2;; 87 | -f) FORCE=on;; 88 | -r) VERSION="$2"; shift;; 89 | -h|--help) 90 | usage 91 | exit;; 92 | --) 93 | shift 94 | break;; 95 | *) 96 | usage;; 97 | esac 98 | shift 99 | done 100 | 101 | 102 | # Check location settings 103 | if [ -z "$LOCATION" -o -z "$PMA" ]; then 104 | log "Please, check your settings. The variables LOCATION, PMA are mandatory!"; 105 | exit 1; 106 | fi 107 | 108 | 109 | # Get the local installed version 110 | if [ -f $LOCATION/$PMA/README ]; then 111 | VERSIONLOCAL=$(sed -n 's/^Version \(.*\)$/\1/p' $LOCATION/$PMA/README); 112 | info "Found local installation version" $VERSIONLOCAL; 113 | else 114 | log "Did not found a working installation. Please, check the script settings."; 115 | exit 1; 116 | fi 117 | 118 | 119 | 120 | # If $USER or $GROUP empty, read from installed phpMyAdmin 121 | if [ -z "$USER" ]; then 122 | USER=$(stat -c "%U" $LOCATION/$PMA/index.php); 123 | fi 124 | if [ -z "$GROUP" ]; then 125 | GROUP=$(stat -c "%G" $LOCATION/$PMA/index.php); 126 | fi 127 | 128 | 129 | # Check user/group settings 130 | if [ -z "$USER" -o -z "$GROUP" ]; then 131 | log "Please, check your settings. Set USER and GROUP, please!"; 132 | exit 1; 133 | fi 134 | 135 | if [ -z "$LANGUAGE" ]; then 136 | LANGUAGE="all-languages"; 137 | fi 138 | 139 | 140 | 141 | # Get latest version 142 | if [ -n "$VERSION" ]; then 143 | 144 | # Check the versions 145 | if [ "$VERSION" = "$VERSIONLOCAL" ]; then 146 | info "phpMyAdmin $VERSIONLOCAL is already installed!"; 147 | if [ "$FORCE" != "on" ]; then 148 | exit 0; 149 | fi 150 | info "I will install it anyway."; 151 | fi 152 | 153 | else 154 | 155 | # Find out latest version 156 | VERSION=$(wget -q -O /tmp/phpMyAdmin_Update.html $VERSIONLINK && sed -ne '1p' /tmp/phpMyAdmin_Update.html); 157 | 158 | 159 | # Check the versions 160 | if [ "$VERSION" = "$VERSIONLOCAL" ]; then 161 | info "You have the latest version of phpMyAdmin installed!"; 162 | if [ "$FORCE" != "on" ]; then 163 | exit 0; 164 | fi 165 | info "I will install it anyway."; 166 | fi 167 | fi 168 | 169 | 170 | # Set output parameters 171 | WGETLOG="-q"; 172 | VERBOSELOG=""; 173 | if [ "$CTYPE" = "tar.gz" ]; then 174 | TARLOG="xzf"; 175 | elif [ "$CTYPE" = "tar.bz2" ]; then 176 | TARLOG="xjf"; 177 | fi 178 | if [ $LOGLEVEL -eq 2 ]; then 179 | WGETLOG="-v"; 180 | VERBOSELOG="-v"; 181 | TARLOG=${TARLOG}v; 182 | fi 183 | 184 | 185 | # Start update 186 | if [ -n "$VERSION" ]; then 187 | 188 | cd $LOCATION; 189 | MYLOCATION=`pwd`; 190 | 191 | if [ $MYLOCATION != $LOCATION ]; then 192 | 193 | log "An error occured while changing the directory. Please check your settings! Your given directory: $LOCATION"; 194 | pwd; 195 | 196 | else 197 | 198 | wget $WGETLOG --directory-prefix=$LOCATION $DOWNLOADURL/$VERSION/phpMyAdmin-$VERSION-$LANGUAGE.$CTYPE 199 | 200 | if [ -f "$LOCATION/phpMyAdmin-$VERSION-$LANGUAGE.$CTYPE" ]; then 201 | 202 | tar $TARLOG phpMyAdmin-$VERSION-$LANGUAGE.$CTYPE || exit 1; 203 | mv $VERBOSELOG $LOCATION/$PMA/config.inc.php $LOCATION/phpMyAdmin-$VERSION-$LANGUAGE/ 204 | rm -R $VERBOSELOG $LOCATION/$PMA 205 | mv $VERBOSELOG $LOCATION/phpMyAdmin-$VERSION-$LANGUAGE $LOCATION/$PMA 206 | chown -R $VERBOSELOG $USER:$GROUP $LOCATION/$PMA 207 | # Remove downloaded package 208 | rm $VERBOSELOG phpMyAdmin-$VERSION-$LANGUAGE.$CTYPE 209 | # Remove setup-folder for security issues 210 | rm -R $VERBOSELOG $LOCATION/$PMA/setup 211 | 212 | if [ $DELETE -eq 1 ]; then 213 | # Remove examples-folder 214 | rm -R $VERBOSELOG $LOCATION/$PMA/examples 215 | fi 216 | 217 | log "PhpMyAdmin successfully updated from version $VERSIONLOCAL to $VERSION in $LOCATION. Enjoy!" 218 | 219 | else 220 | 221 | log "An error occured while downloading phpMyAdmin. Downloading unsuccessful from: $DOWNLOADURL/$VERSION/phpMyAdmin-$VERSION-$LANGUAGE.$CTYPE."; 222 | 223 | fi 224 | fi 225 | else 226 | 227 | log "Something went wrong while getting the version of phpMyAdmin. :(" 228 | log "Maybe this link here is dead: $VERSIONLINK"; 229 | 230 | fi 231 | --------------------------------------------------------------------------------