|
| 1 | +#!/bin/bash |
| 2 | + |
| 3 | +check_errs() |
| 4 | +{ |
| 5 | + # Function. Parameter 1 is the return code |
| 6 | + # Para. 2 is text to display on failure. |
| 7 | + if [ "${1}" -ne "0" ]; then |
| 8 | + echo "ERROR # ${1} : ${2}" |
| 9 | + # as a bonus, make our script exit with the right error code. |
| 10 | + exit ${1} |
| 11 | + fi |
| 12 | +} |
| 13 | + |
| 14 | +#---------------------------------------------------------------------- |
| 15 | +# Ensure running as root |
| 16 | +#---------------------------------------------------------------------- |
| 17 | +#if [[ $EUID -ne 0 ]]; then |
| 18 | +# echo "This script must be run as root" 1>&2 |
| 19 | +# exit 1 |
| 20 | +#fi |
| 21 | + |
| 22 | + |
| 23 | +#---------------------------------------------------------------------- |
| 24 | +# Install package dependencies |
| 25 | +#---------------------------------------------------------------------- |
| 26 | +APT_PKGS="python-dev g++ libssl-dev libgmp3c2 libgmp3-dev git-core" |
| 27 | +APT_PKGS="${APT_PKGS} libtool automake swig autoconf-archive" |
| 28 | +APT_PKGS="${APT_PKGS} libio-socket-ssl-perl libhttp-daemon-ssl-perl" |
| 29 | +APT_PKGS="${APT_PKGS} librpc-xml-perl" |
| 30 | + |
| 31 | +/usr/bin/sudo /usr/bin/apt-get update |
| 32 | +check_errs $? "apt-get failed to update" |
| 33 | + |
| 34 | +/usr/bin/sudo /usr/bin/apt-get install -y ${APT_PKGS} |
| 35 | +check_errs $? "apt-get failed to install packages" |
| 36 | + |
| 37 | +# Download and build strongswan |
| 38 | +/usr/bin/wget http://download.strongswan.org/strongswan-4.4.0.tar.bz2 |
| 39 | +check_errs $? "wget strongswan failed" |
| 40 | + |
| 41 | +/bin/tar xjvf strongswan-4.4.0.tar.bz2 |
| 42 | +check_errs $? "untar strongswan failed" |
| 43 | + |
| 44 | +pushd strongswan-4.4.0 |
| 45 | +check_errs $? "strongswan dir does not exist" |
| 46 | + |
| 47 | +STRONGSWAN_SRC_DIR=`pwd` |
| 48 | +./configure --enable-monolithic --disable-gmp --enable-openssl |
| 49 | +check_errs $? "strongswan configure failed" |
| 50 | + |
| 51 | +cd src/libstrongswan |
| 52 | +check_errs $? "strongswan src/libstrongswan does not exist" |
| 53 | + |
| 54 | +/usr/bin/make |
| 55 | +check_errs $? "strongswan make failed" |
| 56 | + |
| 57 | +/usr/bin/sudo /usr/bin/make install |
| 58 | +check_errs $? "strongswan make install failed" |
| 59 | + |
| 60 | +popd |
| 61 | +check_errs $? "popd failed" |
| 62 | + |
| 63 | +# git clone abac |
| 64 | +/usr/bin/git clone git://abac.deterlab.net/abac.git |
| 65 | +check_errs $? "git clone abac failed" |
| 66 | + |
| 67 | +# build abac |
| 68 | +pushd abac |
| 69 | +check_errs $? "abac directory does not exist" |
| 70 | + |
| 71 | +./autogen.sh |
| 72 | +check_errs $? "abac autogen.sh failed" |
| 73 | + |
| 74 | +./configure --with-strongswan=$STRONGSWAN_SRC_DIR |
| 75 | +check_errs $? "abac configure failed" |
| 76 | + |
| 77 | +/usr/bin/make |
| 78 | +check_errs $? "abac make failed" |
| 79 | + |
| 80 | +/usr/bin/sudo /usr/bin/make install |
| 81 | +check_errs $? "abac make install failed" |
| 82 | + |
| 83 | +popd |
| 84 | +check_errs $? "popd 2 failed" |
| 85 | + |
| 86 | +# Add /usr/local/lib to the LD_LIBRARY_PATH |
| 87 | +#/bin/cat > /tmp/abac.sh <<EOF |
| 88 | +#LD_LIBRARY_PATH="\${LD_LIBRARY_PATH}":/usr/local/lib |
| 89 | +#export LD_LIBRARY_PATH |
| 90 | +#EOF |
| 91 | +#/bin/chmod 0644 /tmp/abac.sh |
| 92 | +#sudo /bin/chown root.root /tmp/abac.sh |
| 93 | +#sudo /bin/mv /tmp/abac.sh /etc/profile.d/abac.sh |
| 94 | + |
| 95 | +# Cache the new libraries in the dynamic library config |
| 96 | +sudo /sbin/ldconfig |
| 97 | + |
| 98 | +# Install abac / gcf integration dependencies while we're root |
| 99 | +APT_PKGS="python-pyasn1 python-m2crypto python-dateutil python-openssl" |
| 100 | +APT_PKGS="${APT_PKGS} libxmlsec1 xmlsec1 libxmlsec1-openssl libxmlsec1-dev" |
| 101 | +/usr/bin/sudo /usr/bin/apt-get install -y ${APT_PKGS} |
| 102 | +check_errs $? "Failed to install abac-gcf integration dependencies" |
| 103 | + |
| 104 | +exit 0 |
0 commit comments