Advertisement
opexxx

install_script_ubuntu.sh

Apr 7th, 2014
181
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Bash 6.12 KB | None | 0 0
  1. #!/bin/bash
  2. #
  3. # Script to install GRR from scratch on an Ubuntu 12.04, 12.10 or 13.04 system.
  4. #
  5. # By default this will install into /usr and set the config in
  6. # /etc/grr/
  7. #
  8. PREFIX=/usr
  9.  
  10. # Variables to control the install versions etc. Made for changing this to
  11. # support other platforms more easily.
  12. PLAT=amd64
  13. INSTALL_DIR=${PREFIX}/share/grr
  14.  
  15. # We now host files on google drive since code.google.com downloads are
  16. # deprecated: https://code.google.com/p/support/wiki/DownloadsFAQ
  17. DEB_DEPENDENCIES_URL=https://googledrive.com/host/0B1wsLqFoT7i2aW5mWXNDX1NtTnc/ubuntu-12.04-${PLAT}-debs.tar.gz;
  18. DEB_DEPENDENCIES_DIR=ubuntu-12.04-${PLAT}-debs;
  19. SLEUTHKIT_DEB=sleuthkit-lib_3.2.3-1_${PLAT}.deb
  20. PYTSK_DEB=pytsk3_3.2.3-1_${PLAT}.deb
  21. M2CRYPTO_DEB=m2crypto_0.21.1-1_${PLAT}.deb
  22.  
  23. GRR_STABLE_VERSION=0.2.9-1
  24. GRR_TEST_VERSION=0.2.10-1
  25. SERVER_DEB_STABLE_BASE_URL=https://googledrive.com/host/0B1wsLqFoT7i2c3F0ZmI1RDJlUEU/grr-server_
  26. SERVER_DEB_TEST_BASE_URL=https://googledrive.com/host/0B1wsLqFoT7i2c3F0ZmI1RDJlUEU/test-grr-server_
  27.  
  28.  
  29. # Take command line parameters as these are easier for users than shell
  30. # variables.
  31. if [ "$1" == "--localtest" ]
  32. then
  33.   GRR_LOCAL_TEST=1;
  34.   GRR_TESTING=1;
  35. elif [ "$1" == "--test" ]
  36. then
  37.   GRR_LOCAL_TEST=0;
  38.   GRR_TESTING=1;
  39. fi
  40.  
  41.  
  42. if [ -z "${GRR_TESTING}" ];
  43. then
  44.   SERVER_DEB_URL=${SERVER_DEB_STABLE_BASE_URL}${GRR_STABLE_VERSION}_${PLAT}.deb
  45. else
  46.   echo "#########################################"
  47.   echo "#### Running with Beta test versions ####"
  48.   echo "#########################################"
  49.   SERVER_DEB_URL=${SERVER_DEB_TEST_BASE_URL}${GRR_TEST_VERSION}_${PLAT}.deb
  50. fi
  51.  
  52. # Used for local testing, if set it will assume the deb is in the current path
  53. # instead of attempting wget for it.
  54. if [ -z "${GRR_LOCAL_TEST}" ];
  55. then
  56.   GRR_LOCAL_TEST=0;
  57. fi
  58.  
  59.  
  60. # Variable to store if the user has answered "Yes to All"
  61. ALL_YES=0;
  62.  
  63.  
  64. function header()
  65. {
  66.   echo ""
  67.   echo "##########################################################################################"
  68.   echo "     ${*}";
  69.   echo "##########################################################################################"
  70. }
  71.  
  72. function run_header()
  73. {
  74.   echo "#### Running #### ${*}"
  75. }
  76.  
  77.  
  78. function exit_fail()
  79. {
  80.   FAIL=$*;
  81.   echo "#########################################################################################";
  82.   echo "FAILURE RUNNING: ${FAIL}";
  83.   echo "#########################################################################################";
  84.   exit 0
  85. }
  86.  
  87.  
  88. function run_cmd_confirm()
  89. {
  90.   CMD=$*;
  91.   if [ ${ALL_YES} = 0 ]; then
  92.     echo ""
  93.     read -p "Run ${CMD} [Y/n/a]? " REPLY
  94.     case $REPLY in
  95.       y|Y|'') run_header ${CMD};;
  96.       a|A) echo "Answering yes from now on"; ALL_YES=1;;
  97.       *) return ;;
  98.     esac
  99.   fi
  100.   ${CMD};
  101.   RETVAL=$?
  102.   if [ $RETVAL -ne 0 ]; then
  103.     exit_fail $CMD;
  104.   fi
  105. };
  106.  
  107.  
  108. header "Updating APT and Installing dependencies"
  109. run_cmd_confirm sudo apt-get --yes update;
  110. run_cmd_confirm sudo apt-get --yes upgrade;
  111. run_cmd_confirm sudo apt-get --force-yes --yes install python-setuptools python-dateutil python-django ipython apache2-utils zip wget python-ipaddr python-support python-psutil python-matplotlib python-mox python-yaml python-pip dpkg-dev debhelper;
  112.  
  113. header "Getting the right version of M2Crypto installed"
  114. run_cmd_confirm sudo apt-get --yes remove python-m2crypto;
  115.  
  116. DEB_DEPENDENCIES_TARBALL=$(basename ${DEB_DEPENDENCIES_URL});
  117. run_cmd_confirm wget --no-verbose ${DEB_DEPENDENCIES_URL} -O ${DEB_DEPENDENCIES_TARBALL};
  118. run_cmd_confirm tar zxfv ${DEB_DEPENDENCIES_TARBALL};
  119. run_cmd_confirm sudo dpkg -i ${DEB_DEPENDENCIES_DIR}/${M2CRYPTO_DEB};
  120.  
  121. header "Installing Protobuf"
  122. run_cmd_confirm sudo apt-get --yes --force-yes install libprotobuf-dev python-protobuf;
  123.  
  124. header "Installing Sleuthkit and Pytsk"
  125. run_cmd_confirm sudo apt-get --yes remove libtsk3* sleuthkit
  126. run_cmd_confirm sudo dpkg -i ${DEB_DEPENDENCIES_DIR}/${SLEUTHKIT_DEB} ${DEB_DEPENDENCIES_DIR}/${PYTSK_DEB};
  127.  
  128. header "Installing Mongodb"
  129. run_cmd_confirm sudo apt-get --yes --force-yes install mongodb python-pymongo;
  130.  
  131. header "Getting correct psutil version (we require 0.6 or newer)"
  132. PSUTIL_VERSION=`dpkg-query -W python-psutil | cut -f 2`
  133. if [[ "$PSUTIL_VERSION" == 0.5* ]]; then
  134.   echo "Unsupported psutil version ${PSUTIL_VERSION}. Upgrading with pip."
  135.   run_cmd_confirm sudo apt-get --yes remove python-psutil;
  136.   run_cmd_confirm sudo apt-get --yes --force-yes install build-essential python-dev;
  137.   run_cmd_confirm sudo easy_install psutil;
  138. fi
  139.  
  140. header "Installing Selenium test framework for Tests"
  141. run_cmd_confirm sudo easy_install selenium
  142.  
  143.  
  144. header "Checking Django version is > 1.4 and fixing up"
  145. # We need 1.4, 12.04 ships with 1.3
  146. DJANGO_VERSION=`dpkg-query -W python-django | cut -f 2`
  147. if [[ "$DJANGO_VERSION" == 1.3* ]]; then
  148.   echo "Unsupported Django version ${DJANGO_VERSION}. Upgrading with pip."
  149.   run_cmd_confirm sudo apt-get --yes remove python-django
  150.   run_cmd_confirm sudo easy_install django
  151. fi
  152.  
  153.  
  154. header "Installing GRR from prebuilt package"
  155. SERVER_DEB=$(basename ${SERVER_DEB_URL});
  156. if [ $GRR_LOCAL_TEST = 0 ]; then
  157.   run_cmd_confirm wget --no-verbose ${SERVER_DEB_URL} -O ${SERVER_DEB};
  158.   run_cmd_confirm sudo dpkg -i ${SERVER_DEB};
  159. else
  160.   run_cmd_confirm sudo dpkg -i ${SERVER_DEB};
  161. fi
  162.  
  163. header "Initialize the configuration, building clients and setting options."
  164. run_cmd_confirm sudo grr_config_updater initialize
  165.  
  166. header "Enable grr-single-server to start automatically on boot"
  167. SERVER_DEFAULT=/etc/default/grr-single-server
  168. run_cmd_confirm sudo sed -i 's/START=\"no\"/START=\"yes\"/' ${SERVER_DEFAULT};
  169.  
  170. header "Starting up the service"
  171. sudo initctl status grr-single-server | grep "running"
  172. IS_RUNNING=$?
  173. if [ $IS_RUNNING = 0 ]; then
  174.   run_cmd_confirm sudo service grr-single-server stop
  175. fi
  176. run_cmd_confirm sudo service grr-single-server start
  177.  
  178. HOSTNAME=`hostname`
  179. echo "############################################################################################"
  180. echo "Install complete. Congratulations. Point your browser at http://${HOSTNAME}:8000"
  181. echo "############################################################################################"
  182. echo ""
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement