bootstrap.sh 2.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105
  1. #!/usr/bin/env bash
  2. function command_exists { type "$1" &> /dev/null; }
  3. # install mosh
  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 mongodb
  19. if command_exists "mongo"; then
  20. echo "Skipping mongodb install"
  21. else
  22. echo "Installing mongodb"
  23. sudo apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv EA312927
  24. echo "deb http://repo.mongodb.org/apt/ubuntu xenial/mongodb-org/3.2 multiverse" | sudo tee /etc/apt/sources.list.d/mongodb-org-3.2.list
  25. sudo apt-get update
  26. sudo apt-get install -y mongodb-org
  27. fi
  28. # setup a service for mongodb
  29. if [ -f /etc/init/mongodb.conf ]; then
  30. echo "Skipping up mongodb service"
  31. else
  32. echo "Setting up mongoDB service"
  33. sudo tee -a /etc/init/mongodb.conf > /dev/null <<EOF
  34. description "Service file for starting / stopping mongodb"
  35. author "Musare Developers"
  36. start on filesystem
  37. stop on shutdown
  38. console log
  39. script
  40. exec mongod
  41. end script
  42. pre-start script
  43. echo "[\`date\`] mongodb starting" >> /var/log/mongodb.log
  44. end script
  45. pre-stop script
  46. rm /var/run/mongodb.pid
  47. echo "[\`date\`] mongodb stopping" >> /var/log/mongodb.log
  48. end script
  49. EOF
  50. fi
  51. # setup a service for Musare
  52. if [ -f /etc/init/musare.conf ]; then
  53. echo "Skipping up musare service"
  54. else
  55. echo "Setting up musare service"
  56. sudo tee -a /etc/init/musare.conf > /dev/null <<EOF
  57. description "Service file for starting / stopping musare"
  58. author "Musare Developers"
  59. start on filesystem
  60. stop on shutdown
  61. setgid www-data
  62. console log
  63. script
  64. until mountpoint -q /musare; do sleep 1; done
  65. echo \$\$ > /var/run/musare.pid
  66. cd /musare
  67. exec gulp
  68. end script
  69. pre-start script
  70. echo "[\`date\`] musare starting" >> /var/log/musare.log
  71. end script
  72. pre-stop script
  73. rm /var/run/musare.pid
  74. echo "[\`date\`] musare stopping" >> /var/log/musare.log
  75. end script
  76. EOF
  77. fi
  78. # automatically install all of our dependencies
  79. cd /musare
  80. cd backend
  81. rm -rf node_modules/
  82. npm install --no-bin-links
  83. cd ../
  84. cd frontend
  85. rm -rf node_modules/
  86. npm install
  87. cd ../
  88. sudo npm install -g gulp-cli
  89. sudo mkdir -p /data/db