Advertisement
kenwi

deps.sh

Sep 24th, 2014
449
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.76 KB | None | 0 0
  1. #!/bin/bash
  2. # Easy installer script for installing binwalk extraction utilities on Debian/RedHat systems.
  3.  
  4. SUDO=$(which sudo)
  5. SUMOUNT="$1 $2"
  6.  
  7. function fmk
  8. {
  9. # Get and build the firmware mod kit
  10. if [ -e /opt/firmware-mod-kit ]
  11. then
  12. if [ ! -e /opt/firmware-mod-kit/.git ]
  13. then
  14. $SUDO rm -rf /opt/firmware-mod-kit/
  15. fi
  16. fi
  17.  
  18. if [ ! -e /opt/firmware-mod-kit ]
  19. then
  20. $SUDO mkdir -p /opt/firmware-mod-kit
  21. $SUDO chown $USER /opt/firmware-mod-kit
  22. $SUDO chmod o+rwx /opt/firmware-mod-kit
  23. fi
  24.  
  25. if [ ! -e /opt/firmware-mod-kit/.git ]
  26. then
  27. git clone http://code.google.com/p/firmware-mod-kit /opt/firmware-mod-kit/
  28. fi
  29.  
  30. cd /opt/firmware-mod-kit/src
  31. ./configure && $SUDO make
  32.  
  33. if [ "$(echo "$SUMOUNT" | grep -e '--sumount')" != "" ]
  34. then
  35. # The following will allow you - and others - to mount/unmount file systems without root permissions.
  36. # This may be problematic, especially on a multi-user system, so think about it first.
  37. $SUDO chown root ./mountcp/mountsu
  38. $SUDO chmod u+s ./mountcp/mountsu
  39. $SUDO chmod o-w ./mountcp/mountsu
  40.  
  41. $SUDO chown root ./mountcp/umountsu
  42. $SUDO chmod u+s ./mountcp/umountsu
  43. $SUDO chmod o-w ./mountcp/umountsu
  44.  
  45. $SUDO chown root ./jffs2/sunjffs2
  46. $SUDO chmod u+s ./jffs2/sunjffs2
  47. $SUDO chmod o-w ./jffs2/sunjffs2
  48. fi
  49.  
  50. cd -
  51. }
  52.  
  53.  
  54. function debian
  55. {
  56. # First make sure the repos are up to date
  57. $SUDO apt-get update
  58.  
  59. # The appropriate unrar package goes under different names in Debian vs Ubuntu
  60. $SUDO apt-get -y install unrar
  61. if [ "$?" != "0" ]
  62. then
  63. echo "WARNING: Failed to install 'unrar' package, trying 'unrar-free' instead..."
  64. $SUDO apt-get -y install unrar-free
  65. fi
  66.  
  67. # Install binwalk/fmk pre-requisites and extraction tools
  68. # lha isn't in newer ubuntu repos, so install it separately in case it fails
  69. $SUDO apt-get -y install lha
  70. $SUDO apt-get -y install git build-essential libtool autoconf mtd-utils zlib1g-dev liblzma-dev ncompress gzip bzip2 tar arj p7zip p7zip-full openjdk-6-jdk
  71. # $SUDO apt-get -y install python-opengl python-qt4 python-qt4-gl python-numpy python-scipy
  72. # if [ "$(which python3)" != "" ]
  73. # then
  74. # $SUDO apt-get -y install python3-pyqt4 python3-numpy python3-scipy
  75. fi
  76. }
  77.  
  78. function redhat
  79. {
  80. $SUDO yum groupinstall -y "Development Tools"
  81. $SUDO yum install -y git libtool autoconf mtd-utils unrar zlib1g-dev liblzma-dev xz-devel compress gzip bzip2 tar arj lha p7zip p7zip-full openjdk-6-jdk
  82. # $SUDO yum install -y libqt4-opengl python-opengl python-qt4 python-qt4-gl python-numpy python-scipy
  83. # if [ "$(which python3)" != "" ]
  84. # then
  85. # $SUDO yum -y install python3-pyqt4 python3-numpy python3-scipy
  86. fi
  87. }
  88.  
  89. if [ "$1" == "" ] || [ "$1" == "--sumount" ]
  90. then
  91. PLATFORM=$(python -c 'import platform; print (platform.system().lower())')
  92. DISTRO=$(python -c 'import platform; print (platform.linux_distribution()[0].strip("\"").split()[0].lower())')
  93. else
  94. DISTRO="$1"
  95. fi
  96.  
  97. if [ "$DISTRO" == "" ]
  98. then
  99. DISTRO="$PLATFORM"
  100. fi
  101.  
  102. echo "Detected $DISTRO $PLATFORM"
  103.  
  104. case $DISTRO in
  105. debian)
  106. debian
  107. ;;
  108. ubuntu)
  109. debian
  110. ;;
  111. linuxmint)
  112. debian
  113. ;;
  114. knoppix)
  115. debian
  116. ;;
  117. aptosid)
  118. debian
  119. ;;
  120. elementary)
  121. debian
  122. ;;
  123.  
  124. redhat)
  125. redhat
  126. ;;
  127. rhel)
  128. redhat
  129. ;;
  130. fedora)
  131. redhat
  132. ;;
  133. centos)
  134. redhat
  135. ;;
  136. *)
  137. echo ""
  138. echo "This system is not recognized by easy install! You may need to install dependent packages manually."
  139. echo ""
  140. echo "If your system is a derivative of Debian or RedHat, you can try manually specifying your system type on the command line:"
  141. echo ""
  142. echo -e "\t$0 [debian | redhat] [--sumount]"
  143. echo ""
  144. exit 1
  145. esac
  146.  
  147. # Get and build the firmware mod kit
  148. fmk
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement