Last active
January 16, 2023 12:36
-
-
Save connorhu/87fb9c87e0396a1ef3fadacb1ca969e9 to your computer and use it in GitHub Desktop.
phpmyadmin update script
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/sh | |
CURRENT_VERSION=$(ls -la | grep \ web | awk '{ print $11 }' | sed -e 's/phpMyAdmin-\(.*\)-all-languages/\1/') # ' | |
VERSION_CONTENT=$(curl -s https://www.phpmyadmin.net/home_page/version.json | php -r 'echo json_decode(file_get_contents("php://stdin"), true)["version"];') | |
LATEST_VERSION=$(echo "$VERSION_CONTENT" | head -n1) | |
LATEST_VERSION_DL_URL="https://files.phpmyadmin.net/phpMyAdmin/${LATEST_VERSION}/phpMyAdmin-${LATEST_VERSION}-all-languages.zip" | |
PHP_VERSION="php8.2" | |
if [ ! -f config.inc.php ] | |
then | |
echo "Current config not found." | |
exit 1 | |
fi | |
if ! command -v unzip &> /dev/null | |
then | |
echo "unzip could not be found" | |
exit 1 | |
fi | |
if ! command -v curl &> /dev/null | |
then | |
echo "curl could not be found" | |
exit 1 | |
fi | |
if [ $CURRENT_VERSION != $LATEST_VERSION ] | |
then | |
echo "update" | |
FILENAME=${LATEST_VERSION_DL_URL##*/} | |
NEWDIRNAME=$(basename $FILENAME .zip) | |
if [ -d "$NEWDIRNAME" ] | |
then | |
echo "$NEWDIRNAME already exists. how?" | |
exit 1 | |
fi | |
curl -s $LATEST_VERSION_DL_URL > $FILENAME | |
unzip $FILENAME > /dev/null | |
rm $FILENAME | |
cp config.inc.php $NEWDIRNAME/ | |
ln -sfn $NEWDIRNAME web | |
service ${PHP_VERSION}-fpm restart | |
service nginx restart | |
fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment