Skip to content

Instantly share code, notes, and snippets.

@sarciszewski
Last active July 15, 2016 08:52
Show Gist options
  • Star 3 You must be signed in to star a gist
  • Fork 4 You must be signed in to fork a gist
  • Save sarciszewski/f03aae0b4c521c138b94 to your computer and use it in GitHub Desktop.
Save sarciszewski/f03aae0b4c521c138b94 to your computer and use it in GitHub Desktop.
Install libsodium-1.0.2 and PECL libsodium on Ubuntu 14.04
#!/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 <j@pureftpd.org>
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
@sarciszewski
Copy link
Author

This installs libsodium and the PECL libsodium extension for PHP in one go.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment