#!/bin/bash # Automatic update of phpMyAdmin via Shell/Crontab (update_pma.sh) # Copyright 2019 - 2023 Daniel Marschall and Victor Negoescu, ViaThinkSoft # Version 2023-09-13 # # 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 https://docs.phpmyadmin.net/en/latest/setup.html#installing-from-git # https://github.com/phpmyadmin/phpmyadmin/issues/17716#issuecomment-1242722992 # exit on errors set -e DIR=$(pwd) INSTALL_DIR="public_html" # NOTE: The STABLE branch (5.2.0, last checked 10 Sep 2022) # has the bug that it does not work with composer "--no-dev". # So, either choose STABLE and remove "--no-dev" or choose QA_5_2 # Reported bug: https://github.com/phpmyadmin/phpmyadmin/issues/17716 # TODO: Remove this notice and switch to STABLE, once the fix has been applied in STABLE BRANCH="STABLE" #BRANCH="QA_5_2" # --- # First installation if [ ! -d "$DIR/$INSTALL_DIR" ]; then cd "$DIR" git clone --branch="$BRANCH" https://github.com/phpmyadmin/phpmyadmin.git "$INSTALL_DIR" fi # Installation/Update cd "$DIR"/"$INSTALL_DIR" # switch to branch git checkout "$BRANCH" # package.json gets modified. We need to undo that, otherwise "git pull" won't work git reset --hard # remove unversioned files git clean -fd # fetch HEAD #git pull --quiet git pull --quiet --ff # Special requirement for ViaThinkSoft. php-fcgi needs to be inside public_html, because "public_html" is hardcoded in suEXEC! if [ -d /home/phpmyadmin/cgi-bin ]; then ln -s /home/phpmyadmin/cgi-bin /home/phpmyadmin/public_html/cgi-bin fi # Install phpMyAdmin #composer update --no-dev composer install --optimize-autoloader --no-dev #yarn install --production yarn install --production --frozen-lockfile # Foreign language recompile # Requires: sudo aptitude install gettext # Attention: the cwd MUST be phpmyadmin! scripts/generate-mo --quiet # Copy custom phpMyAdmin configuration if it exists cd .. if [ -d "$DIR"/config.inc.php ]; then cp "$DIR"/config.inc.php "$DIR"/"$INSTALL_DIR"/ fi # Now remove the thousands of yarn tmp folders that are never deleted! rm -rf /tmp/yarn--*