Created
August 23, 2019 23:35
-
-
Save gnanet/d919b5eaf0d604f35a1dd58e02c164c1 to your computer and use it in GitHub Desktop.
This script adds the apt-repository for PHP 5.6.x packages, created by Ondřej Surý
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/bash | |
# | |
# Original script source: https://packages.sury.org/php/README.txt | |
# | |
# This script adds the apt-repository for PHP 5.6.x packages, created by Ondřej Surý | |
# The script should work both on Debian and Ubuntu | |
# Extra check added, to make sure a "Release" file is available for the specific codename, before it is added. | |
if [ "$(whoami)" != "root" ]; then | |
SUDO=sudo | |
fi | |
# Install common packages | |
${SUDO} apt-get -y update | |
${SUDO} apt-get -y upgrade | |
${SUDO} apt-get -y install apt-transport-https lsb-release ca-certificates | |
if [ "$(${SUDO} lsb_release -si)" == "Ubuntu" ]; then | |
if [ "$(curl "http://ppa.launchpad.net/ondrej/php/ubuntu/dists/$(${SUDO} lsb_release -sc)/Release" -s -o /dev/null -w "%{http_code}\n")" != "200" ]; then | |
echo "Sorry no packages for $(${SUDO} lsb_release -si) $(${SUDO} lsb_release -sc)" | |
exit 1 | |
fi | |
${SUDO} apt-get -y install software-properties-common | |
${SUDO} add-apt-repository -y ppa:ondrej/php | |
exit 0 | |
fi | |
if [ "$(${SUDO} lsb_release -si)" == "Debian" ]; then | |
if [ "$(curl "https://packages.sury.org/php/dists/$(${SUDO} lsb_release -sc)/Release" -s -o /dev/null -w "%{http_code}\n")" != "200" ]; then | |
echo "Sorry no packages for $(${SUDO} lsb_release -si) $(${SUDO} lsb_release -sc)" | |
exit 1 | |
fi | |
${SUDO} curl -ssL -o /etc/apt/trusted.gpg.d/php.gpg https://packages.sury.org/php/apt.gpg | |
${SUDO} sh -c 'echo "deb https://packages.sury.org/php/ $(lsb_release -sc) main" > /etc/apt/sources.list.d/php.list' | |
${SUDO} apt-get update | |
exit 0 | |
fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment