Skip to content

Instantly share code, notes, and snippets.

@sarciszewski
Last active July 15, 2016 08:52
Show Gist options
  • Select an option

  • Save sarciszewski/f03aae0b4c521c138b94 to your computer and use it in GitHub Desktop.

Select an option

Save sarciszewski/f03aae0b4c521c138b94 to your computer and use it in GitHub Desktop.
Install libsodium-1.0.2 and PECL libsodium on Ubuntu 14.04
#!/bin/sh
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 89F7B8300E87E03C52B05289926BC5171CDEA439
if [ $? -ne 0 ]; then
echo -e "\033[33mDownloading PGP Public Key...\033[0m"
gpg --recv-keys 89F7B8300E87E03C52B05289926BC5171CDEA439
# Jedi/Sector One <[email protected]>
gpg --fingerprint 89F7B8300E87E03C52B05289926BC5171CDEA439
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