Guest

munsking

By: a guest on Nov 26th, 2009  |  syntax: Bash  |  size: 4.07 KB  |  hits: 152  |  expires: Never
download  |  raw  |  embed  |  report abuse
Copied
  1. #! /bin/bash
  2. #----------------
  3. # Vars
  4. A="a"
  5. D="d"
  6. B="b"
  7. I="i"
  8. U="u"
  9. H="h"
  10. Q="q"
  11. Y="y"
  12. N="n"
  13. #----------------
  14. #functions
  15. function packcheck {
  16.         sudo apt-get install subversion build-essential automake flex bison libpopt-dev libpng12-dev libsdl1.2-dev libopenal-dev libphysfs-dev libvorbis-dev libtheora-dev libglc-dev zip > /dev/null
  17. echo "checked for packages and installed missing ones"
  18. }
  19.  
  20. function choose {
  21.         read choice
  22.         if [ $choice = $Y ] ; then
  23.                 $*
  24.         else
  25.                 echo "aborting!"
  26.                 exit 0
  27.         fi
  28. }
  29.  
  30. function dircheck {
  31.         echo "where would you like me to $* ? (define from root)"
  32.         read where
  33.         if [ -d $where ] ; then
  34.                 echo "location allready exists, continue?(Y/N)"
  35.                 choose echo "ok"
  36.                 cd $where
  37.         else
  38.                 echo "location does not exit, create it?(Y/N)"
  39.                 choose mkdir $1
  40.         fi
  41. }
  42.  
  43. function smod {
  44.         sudo chmod 755 $1 -R
  45. }
  46. #----------------
  47. # starter
  48. if [ -z $1 ] ; then
  49. #----------------
  50. # root checker!
  51. if [ $(whoami) != 'root' ] ; then
  52.         echo "please execute as root"
  53.         echo "if sudo doesn't work, move this script to /bin/"
  54.         exit 0
  55. else
  56.  
  57. #----------------
  58. #script
  59. clear
  60. echo "----------------------------------------------------------------------"
  61. echo "     __    __           _____                 ____  _  ___   ___      "
  62. echo "    / / /\ \ \__ _ _ __/ _  / ___  _ __   ___|___ \/ |/ _ \ / _ \     "
  63. echo "    \ \/  \/ / _\` | '__\// / / _ \| '_ \ / _ \ __) | | | | | | | |    "
  64. echo "     \  /\  / (_| | |   / //\ (_) | | | |  __// __/| | |_| | |_| |    "
  65. echo "      \/  \/ \__,_|_|  /____/\___/|_| |_|\___|_____|_|\___/ \___/     "
  66. echo "                 installer script, made by munsking                   "
  67. echo "----------------------------------------------------------------------"
  68. echo ""
  69. echo "What do you want to do?"
  70. echo "  [A]ll"
  71. echo "  [D]ownload"
  72. echo "  [B]uild"
  73. echo "  [I]nstall"
  74. echo "  [U]ninstall"
  75. echo "  [H]elp"
  76. echo "  [Q]uit"
  77. read Choice
  78. clear
  79.  
  80. if [ $Choice = $A ] ; then
  81.         dircheck install the whole thing
  82.         packcheck
  83.         `svn co https://warzone2100.svn.sourceforge.net/svnroot/warzone2100/trunk/ $where`
  84.         ./autogen.sh
  85.         ./configure
  86.         make
  87.         make install
  88. elif [ $Choice = $D ] ; then
  89.         dircheck download
  90.         `sudo svn co https://warzone2100.svn.sourceforge.net/svnroot/warzone2100/trunk/ $where`
  91. elif [ $Choice = $B ] ; then
  92.         dircheck build
  93.         ./autogen.sh
  94.         ./configure
  95.         make
  96. elif [ $Choice = $I ] ; then
  97.         dircheck install
  98.         make install
  99. elif [ $Choice = $U ] ; then
  100.         dircheck uninstall
  101.         echo "are you sure you want to uninstall(Y/N)?"
  102.         choose make uninstall
  103. elif [ $Choice = $H ] ; then
  104.         echo "----------------------------------------------------------------------"
  105.         echo "     __    __           _____                 ____  _  ___   ___      "
  106.         echo "    / / /\ \ \__ _ _ __/ _  / ___  _ __   ___|___ \/ |/ _ \ / _ \     "
  107.         echo "    \ \/  \/ / _\` | '__\// / / _ \| '_ \ / _ \ __) | | | | | | | |    "
  108.         echo "     \  /\  / (_| | |   / //\ (_) | | | |  __// __/| | |_| | |_| |    "
  109.         echo "      \/  \/ \__,_|_|  /____/\___/|_| |_|\___|_____|_|\___/ \___/     "
  110.         echo "                 installer script, made by munsking                   "
  111.         echo "----------------------------------------------------------------------"
  112.         echo ""
  113.         echo "  HELP:"
  114.         echo "          why would you need help? just follow the instructions :P"
  115.         echo "          you only need to type the brackated letter in lower case"
  116.         echo "          so to download, just type \"a\" and it will start the download"
  117.         echo "          if asked for (Y/N) type \"y\" or \"n\""
  118.         echo "          if asked for a location, just type it from root. so in my case:"
  119.         echo "          \"/home/munsking/\""
  120.         echo ""
  121.         echo "  credits:"
  122.         echo "          Munsking for creating this script (munsking@gmail.com)"
  123.         echo "          Pumpkin Studios and Eidos Interactive for making the game"
  124.         echo "          the Warzone2100 Project for keeping the game alive and for linux(wz2100.net)"
  125.         echo ""
  126.         exit 0
  127. elif [ $Choice = $Q ] ; then
  128.         echo "bye bye"
  129.         exit 0
  130. else
  131.         echo "please enter the bracketed letter in lower case"
  132.         echo "try again? (Y/N)"
  133.         choose sudo $0
  134.         exit 0
  135. fi
  136. echo "done"
  137. smod $where
  138. fi
  139. else
  140. echo "no need for syntaxes, just execute :)"
  141. exit 0
  142. fi