#!/usr/bin/env bash PECLVER="0.1.1" LIBSODIUMVER="1.0.2" if [[ $EUID -ne 0 ]]; then echo "This script must be run as root" 1>&2 exit 1 fi gpg --fingerprint 54A2B8892CC3D6A597B92B6C210627AABA709FE1 if [ $? -ne 0 ]; then echo -e "\033[33mDownloading PGP Public Key...\033[0m" gpg --recv-keys 54A2B8892CC3D6A597B92B6C210627AABA709FE1 # Jedi/Sector One gpg --fingerprint 54A2B8892CC3D6A597B92B6C210627AABA709FE1 if [ $? -ne 0 ]; then echo -e "\033[31mCould not download PGP public key for verification\033[0m" exit fi fi # Let's try to install the PECL Extension pecl install channel://pecl.php.net/libsodium-$PECLVER if [ $? -ne 0 ]; then # We need to install libsodium mkdir tmp cd tmp if [ ! -f libsodium-$LIBSODIUMVER.tar.gz ]; then wget https://download.libsodium.org/libsodium/releases/libsodium-$LIBSODIUMVER.tar.gz fi if [ ! -f libsodium-$LIBSODIUMVER.tar.gz.sig ]; then wget https://download.libsodium.org/libsodium/releases/libsodium-$LIBSODIUMVER.tar.gz.sig fi gpg --verify libsodium-$LIBSODIUMVER.tar.gz.sig libsodium-$LIBSODIUMVER.tar.gz if [ $? -eq 0 ]; then tar -xvzf libsodium-$LIBSODIUMVER.tar.gz cd libsodium-$LIBSODIUMVER ./configure make && make check if [ $? -eq 0 ]; then # we passed our tests? let's install libsodium make install if [ $? -eq 0 ]; then # cleanup cd .. cd .. rm -rf tmp # now let's install the PECL extension pecl install channel://pecl.php.net/libsodium-$PECLVER fi fi else echo -e "\033[31mSignature did not match! Check /tmp/libsodium-$LIBSODIUMVER.tar.gz for trojans\033[0m" cd .. exit fi fi