boot.sh 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596
  1. #!/bin/bash
  2. cd /root
  3. if test ! -e "reset.sh" ; then
  4. cat > "reset.sh" << FIN
  5. #!/bin/bash
  6. curl https://s3.amazonaws.com/finalsclub.org/boot.sh | sh
  7. FIN
  8. chmod 500 reset.sh
  9. fi
  10. echo "Booting" `date`
  11. yes | yum --nogpgcheck install gcc-c++
  12. yes | yum --nogpgcheck install openssl-devel
  13. yes | yum --nogpgcheck install make
  14. yes | yum --nogpgcheck install git
  15. yes | yum --nogpgcheck install sqlite-devel
  16. yes | yum --nogpgcheck install mysql-server
  17. # /etc/init.d/mysqld start
  18. # /usr/bin/mysqladmin -u root password 'foobarbazquX'
  19. # install mongodb
  20. mongover="1.8.2"
  21. if test ! -e mongodb.tgz ; then
  22. curl http://fastdl.mongodb.org/linux/mongodb-linux-i686-$mongover.tgz > mongodb-linux-i686-$mongover.tgz
  23. tar xzf mongodb-linux-i686-$mongover.tgz
  24. cd mongodb-linux-i686-$mongover/bin
  25. chmod a+rx *
  26. chmod uo-w *
  27. cp -f * /usr/local/bin
  28. mkdir -p /data/db
  29. /usr/local/bin/mongod -v --rest --replSet finalsclubset &> /var/log/mongod.log &
  30. ## optional arbiter start command
  31. ## mkdir -p /data/arbiterdb
  32. ## /usr/local/bin/mongod -v --dbpath /data/arbiterdb --port 27021 --rest --replSet finalsclubset &> /var/log/mongod-arbiter.log &
  33. fi
  34. # install node
  35. nodever="v0.4.10"
  36. if test ! -e node-$nodever ; then
  37. curl http://nodejs.org/dist/node-$nodever.tar.gz > node-$nodever.tar.gz
  38. tar xzvf node-$nodever.tar.gz
  39. cd node-$nodever
  40. ./configure
  41. make
  42. make install
  43. fi
  44. # install npm
  45. if test ! -e npm ; then
  46. git clone http://github.com/isaacs/npm.git
  47. cd npm
  48. sudo make install
  49. cd ..
  50. fi
  51. npm install nodemon -g
  52. npm install forever -g
  53. ## make it easier for root to run node
  54. cd /usr/bin
  55. ln -sf /usr/local/bin/node .
  56. ln -sf /usr/local/bin/forever .
  57. ## haproxy install (optional)
  58. # assumes this script is running as root
  59. mkdir /usr/local/haproxy
  60. cd /usr/local/haproxy
  61. wget http://haproxy.1wt.eu/download/1.4/bin/haproxy-1.4.17-pcre-40kses-linux-i586.notstripped.gz
  62. gunzip haproxy-1.4.17-pcre-40kses-linux-i586.notstripped.gz
  63. ln -sf haproxy-1.4.17-pcre-40kses-linux-i586.notstripped haproxy
  64. chmod 770 haproxy*
  65. wget https://s3.amazonaws.com/finalsclub.org/haproxy.cfg
  66. chmod 660 haproxy.cfg
  67. ## command to start haproxy (from /usr/local/haproxy dir)
  68. # sudo /usr/local/haproxy/haproxy -f /usr/local/haproxy/haproxy.cfg -p /var/run/haproxy.pid &
  69. ## init the reboot-restart.sh script, but don't run it.
  70. cd ~
  71. wget https://s3.amazonaws.com/finalsclub.org/reboot-restart.sh
  72. chmod 755 reboot-restart.sh
  73. echo "/root/reboot-restart.sh &> /var/log/fc-reboot-restart.log.txt &" >> /etc/rc.local
  74. curl https://s3.amazonaws.com/finalsclub.org/start.sh | sudo -u ec2-user sh