bootstrap.sh 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101
  1. #!/usr/bin/env bash
  2. function command_exists { type "$1" &> /dev/null; }
  3. # install NodeJS
  4. if command_exists "mosh"; then
  5. echo "Skipping mosh install"
  6. else
  7. echo "Installing mosh"
  8. sudo apt-get install -y mosh
  9. fi
  10. # install NodeJS
  11. if command_exists "nodejs"; then
  12. echo "Skipping nodejs install"
  13. else
  14. echo "Installing nodejs"
  15. curl -sL https://deb.nodesource.com/setup_6.x | sudo -E bash -
  16. sudo apt-get install -y nodejs
  17. fi
  18. # install RethinkDB
  19. if command_exists "rethinkdb"; then
  20. echo "Skipping rethinkdb install"
  21. else
  22. echo "Installing rethinkdb"
  23. source /etc/lsb-release && echo "deb http://download.rethinkdb.com/apt $DISTRIB_CODENAME main" | sudo tee /etc/apt/sources.list.d/rethinkdb.list
  24. wget -qO- https://download.rethinkdb.com/apt/pubkey.gpg | sudo apt-key add -
  25. sudo apt-get update
  26. sudo apt-get install -y rethinkdb
  27. fi
  28. # setup a service for RethinkDB
  29. if [ -f /etc/init/rethinkdb.conf ]; then
  30. echo "Skipping up rethinkdb service"
  31. else
  32. echo "Setting up rethinkdb service"
  33. sudo tee -a /etc/init/rethinkdb.conf > /dev/null <<EOF
  34. description "Service file for starting / stopping rethinkdb"
  35. author "Musare Developers"
  36. start on filesystem
  37. stop on shutdown
  38. setgid rethinkdb
  39. console log
  40. script
  41. echo \$\$ > /var/run/rethinkdb.pid
  42. cd /musare
  43. exec rethinkdb --bind all
  44. end script
  45. pre-start script
  46. echo "[\`date\`] rethinkdb starting" >> /var/log/rethinkdb.log
  47. end script
  48. pre-stop script
  49. rm /var/run/rethinkdb.pid
  50. echo "[\`date\`] rethinkdb stopping" >> /var/log/rethinkdb.log
  51. end script
  52. EOF
  53. fi
  54. # setup a service for Musare
  55. if [ -f /etc/init/musare.conf ]; then
  56. echo "Skipping up musare service"
  57. else
  58. echo "Setting up musare service"
  59. sudo tee -a /etc/init/musare.conf > /dev/null <<EOF
  60. description "Service file for starting / stopping musare"
  61. author "Musare Developers"
  62. start on filesystem
  63. stop on shutdown
  64. setgid www-data
  65. console log
  66. script
  67. until mountpoint -q /musare; do sleep 1; done
  68. echo \$\$ > /var/run/musare.pid
  69. cd /musare
  70. exec gulp
  71. end script
  72. pre-start script
  73. echo "[\`date\`] musare starting" >> /var/log/musare.log
  74. end script
  75. pre-stop script
  76. rm /var/run/musare.pid
  77. echo "[\`date\`] musare stopping" >> /var/log/musare.log
  78. end script
  79. EOF
  80. fi
  81. # automatically install all of our dependencies
  82. cd /musare
  83. npm install --no-bin-links
  84. sudo npm install --global gulp-cli