#!/bin/bash # Automatic update of phpMyAdmin via Shell/Crontab (update_pma.sh) # Copyright 2019 - 2022 Daniel Marschall, ViaThinkSoft # Version 2022-06-06 # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. # # Based on http://www.networkjack.info/blog/2011/04/05/simple-checkout-of-phpmyadmin-with-git/ DIR=$( dirname "$0" ) INSTALL_DIR="phpmyadmin" # It was created by these commands: if [ ! -d "$DIR/$INSTALL_DIR" ]; then cd "$DIR" mkdir tmp cd tmp # # git clone --depth=1 https://phpmyadmin.git.sourceforge.net/gitroot/phpmyadmin/phpmyadmin # git clone --depth=1 https://github.com/phpmyadmin/phpmyadmin.git # cd phpmyadmin # git remote update # git fetch # git checkout --track -b PMASTABLE origin/STABLE # cd .. # git clone --depth=1 --branch=STABLE git://github.com/phpmyadmin/phpmyadmin.git git clone --branch=STABLE https://github.com/phpmyadmin/phpmyadmin.git mv phpmyadmin ../ cd .. rm -R tmp fi # ---- STEP 1: Hide composer.lock and yarn.lock to avoid problems during the GIT pull #if [ -f "$DIR"/"$INSTALL_DIR"/composer.lock ]; then # mv "$DIR"/"$INSTALL_DIR"/composer.lock "$DIR"/"$INSTALL_DIR"/.composer.lock #fi #if [ -f "$DIR"/"$INSTALL_DIR"/yarn.lock ]; then # mv "$DIR"/"$INSTALL_DIR"/yarn.lock "$DIR"/"$INSTALL_DIR"/.yarn.lock #fi # ---- STEP 2: Download from GIT # Renew: cd "$DIR"/"$INSTALL_DIR" git config --global user.name "homepage@viathinksoft.de" # zu STABLE wechseln git checkout STABLE # package.json gets modified. We need to undo that, otherwise "git pull" won't work git reset --hard # unversionierte Dateien entfernen git clean -fd # git pull | grep -v "Already up-to-date." git pull --quiet RET=$? if [ $RET -ne 0 ]; then >&2 echo 'GIT Pull FAILED' exit $RET fi # --- Activate lock files again #if [ -f "$DIR"/"$INSTALL_DIR"/.composer.lock ]; then # mv "$DIR"/"$INSTALL_DIR"/.composer.lock "$DIR"/"$INSTALL_DIR"/composer.lock #fi # #if [ -f "$DIR"/"$INSTALL_DIR"/.yarn.lock ]; then # mv "$DIR"/"$INSTALL_DIR"/.yarn.lock "$DIR"/"$INSTALL_DIR"/yarn.lock #fi # ---- STEP 3: Generate language # German language recompile # benötigt: sudo aptitude install gettext # Attention: the cwd MUST be phpmyadmin! scripts/generate-mo --quiet # ---- STEP 4: Update dependencies # see https://getcomposer.org/doc/faqs/how-to-install-composer-programmatically.md #08.06.2021 : wget does not work anymore? Because of MIME type? #EXPECTED_SIGNATURE=$(wget -q -O - https://composer.github.io/installer.sig) EXPECTED_SIGNATURE=$(curl https://composer.github.io/installer.sig) php -r "copy('https://getcomposer.org/installer', 'composer-setup.php');" ACTUAL_SIGNATURE=$(php -r "echo hash_file('SHA384', 'composer-setup.php');") if [ "$EXPECTED_SIGNATURE" != "$ACTUAL_SIGNATURE" ]; then >&2 echo 'ERROR: Invalid composer installer signature' rm composer-setup.php exit 1 fi php composer-setup.php --quiet RET=$? rm composer-setup.php if [ $RET -ne 0 ]; then >&2 echo 'Install composer FAILED' exit $RET fi # Bug! (8 Sep 2022) If you use "--no-dev", then the "Export" tab does not work anymore! # Reported bug: https://github.com/phpmyadmin/phpmyadmin/issues/17716 ./composer.phar update -q RET=$? if [ $RET -ne 0 ]; then >&2 echo 'Dependency update FAILED' exit $RET fi # curl -sL https://deb.nodesource.com/setup_12.x | bash - # aptitude install nodejs # npm install -g yarn # Update to newer npm using "npm install -g npm" # Update to newer yarn version using "yarn set version berry" # yarn 1.22.4 fills your /tmp dir and they won't fix it ( https://github.com/yarnpkg/yarn/issues/6685 ) yarn install --production #The --production option is deprecated on 'install'; use 'yarn workspaces focus' instead # This doesn't work anymore?! #yarn -v #yarn set version berry #yarn init #yarn install RET=$? if [ $RET -ne 0 ]; then >&2 echo 'Yarn update FAILED' exit $RET fi # see https://github.com/browserslist/browserslist#browsers-data-updating # Added "2>&1" redirection, because this command outputs following message to STDERR, even if "-q" argument is provided! # "npx: installed 6 in 2.019s" npm_config_yes=true npx browserslist@latest --update-db 2>&1 RET=$? # Workaround, see https://github.com/browserslist/browserslist/issues/552 if [ $RET -ne 0 ]; then yarn add caniuse-lite && yarn remove caniuse-lite RET=$? fi if [ $RET -ne 0 ]; then >&2 echo 'Update browser list FAILED' exit $RET fi # Now remove the thousands of yarn tmp folders that are never deleted! rm -rf /tmp/yarn--* exit 0