Hamsta

Bitmessage installer

Mar 27th, 2013
153
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Bash 4.60 KB | None | 0 0
  1. #!/bin/bash
  2. #
  3. # The MIT License (MIT)
  4. #
  5. # Copyright (c) 2013 Thomas Klose
  6. #
  7. # Permission is hereby granted, free of charge, to any person obtaining a copy of this software
  8. # and associated documentation files (the "Software"), to deal in the Software without restriction,
  9. # including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense,
  10. # and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so,
  11. # subject to the following conditions:
  12. # The above copyright notice and this permission notice shall be included in all copies or substantial
  13. # portions of the Software.
  14. #
  15. # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT
  16. # LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO
  17. # EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
  18. # IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR
  19. # THE USE OR OTHER DEALINGS IN THE SOFTWARE
  20. #
  21.  
  22. echo "Welcomme to Bitmessageinstaller"
  23. echo "if this script stops working properly, please install bitmesaage manually"
  24. echo "as descibed in https://bitmessage.org/wiki/Compiling_instructions"
  25. echo " "
  26. echo "setting up environment"
  27.  
  28. BITMESSAGE_GIT="https://github.com/Bitmessage/PyBitmessage"
  29. EXIT_UNKOWNINSTALLER=1
  30. EXIT_REQUIREMENTSUNRESSOLVED=2
  31. EXIT_BITMESSAGEEXECUTEABLENOTFOUND=3
  32.  
  33. INSTALLDIR="/home/`id -un`/.bitmessage/"
  34. PY_EXECUTEABLE="/home/`id -un`/.bitmessage/PyBitmessage/bitmessagemain.py"
  35. BM_EXECUTEABLE="/usr/local/bin/bitmessage"
  36.  
  37. if [ -n $(which sudo) ]  
  38. then
  39.     SWITCHTOROOTCOMMAND="sudo"
  40. else
  41.     SWITCHTOROOTCOMMAND="su root"
  42. fi
  43.  
  44. echo "discovering requirements ..."
  45.  
  46. REQUIREMENTSTOINSTALL=""
  47.  
  48. if [ -z $(which python) ]  
  49. then
  50.     REQUIREMENTSTOINSTALL="$REQUIREMENTSTOINSTALL python"
  51. fi
  52.  
  53. if [ -z $(which openssl) ]  
  54. then
  55.     REQUIREMENTSTOINSTALL="$REQUIREMENTSTOINSTALL openssl"
  56. fi
  57.  
  58. if [ -z $(which python-qt4) ]  
  59. then
  60.     REQUIREMENTSTOINSTALL="$REQUIREMENTSTOINSTALL python-qt4"
  61. fi  
  62. if [ -z $(which git) ]  
  63. then
  64.     REQUIREMENTSTOINSTALL="$REQUIREMENTSTOINSTALL git"
  65. fi
  66.  
  67. if [ -n "$REQUIREMENTSTOINSTALL" ]
  68. then
  69.     if [ -n $(which apt-get) ]
  70.     then
  71.         INSTALLTOOL="apt-get"
  72.     elif [ -n $(which yum) ]
  73.     then
  74.         INSTALLTOOL="yum"
  75.     else
  76.         echo "couldn't find yum or apt-get, please install 'REQUIREMENTSTOINSTALL' and restart this script"
  77.         exit $EXIT_UNKOWNINSTALLER
  78.     fi
  79.      
  80.     echo "installing requirements ($REQUIREMENTSTOINSTALL)"
  81.     if [ -n $(which sudo) ]  
  82.     then
  83.         sudo $INSTALLTOOL -y --force-yes install $REQUIREMENTSTOINSTALL
  84.     else
  85.         su root -c"$INSTALLTOOL -y install $REQUIREMENTSTOINSTALL"
  86.     fi
  87. fi
  88.  
  89. if [ "`which git openssl python | grep -c /`" != "3" ]
  90. then
  91.     echo "unable to resolve all requirements, please install '$REQUIREMENTSTOINSTALL' and restart this script"
  92.     exit $EXIT_REQUIREMENTSUNRESSOLVED
  93. fi
  94.  
  95. echo "downloading bitmessage from github"
  96.  
  97. mkdir "$INSTALLDIR"
  98. cd "$INSTALLDIR"
  99. git clone "$BITMESSAGE_GIT"
  100. if [ -f "$PY_EXECUTEABLE" ]
  101. then
  102.     if [ ! -x "$PY_EXECUTEABLE" ]
  103.     then
  104.         chmod u+x "$PY_EXECUTEABLE"
  105.     fi        
  106. else
  107.     echo "Error: Excpected File $PY_EXECUTEABLE does not exist"
  108.     exit $EXIT_BITMESSAGEEXECUTEABLENOTFOUND
  109. fi
  110.  
  111. if [ ! -x "$BM_EXECUTEABLE" ]
  112. then
  113.     if [ -n $(which sudo) ]  
  114.     then
  115.         sudo bash << EOF
  116.         echo "#!/bin/bash" >  $BM_EXECUTEABLE
  117.         echo "python ~/.bitmessage/PyBitmessage/bitmessagemain.py" >>  $BM_EXECUTEABLE
  118.         chmod a+x "$BM_EXECUTEABLE"
  119. EOF
  120.  
  121.     else
  122.         su root -c"bash" << EOF
  123.         echo "#!/bin/bash" >  $BM_EXECUTEABLE
  124.         echo "python ~/.bitmessage/PyBitmessage/bitmessagemain.py" >>  $BM_EXECUTEABLE
  125.         chmod a+x "$BM_EXECUTEABLE"
  126. EOF
  127.  
  128.     fi
  129. fi
  130.  
  131. if [ ! -x "$PY_EXECUTEABLE" ]
  132. then
  133.     echo "File $PY_EXECUTEABLEยด could not be set as executeable."
  134.     echo "set it executeable to use bitmessage"
  135. fi        
  136.  
  137. if [ ! -x "$BM_EXECUTEABLE" ]
  138. then
  139.     echo "Unable to create $BM_EXECUTEABLE. create it with following contents:"
  140.     echo " "
  141.     echo "#!/bin/bash"
  142.     echo "python ~/.bitmessage/PyBitmessage/bitmessagemain.py"
  143.     echo " "
  144.     echo "and set it as executeable"
  145. fi
  146.  
  147. echo "installation of bitmessage was successfull"
  148. echo "you can find a userguide at bitmessage.org"
  149. echo "start Bitmeassege by 'bitmessage' command"
Advertisement
Add Comment
Please, Sign In to add comment