nitrous-post-create.sh 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  1. #!/bin/bash
  2. rm -rf ~/code/example
  3. export LANG=en_US.UTF-8
  4. export LANGUAGE=en_US.UTF-8
  5. export LC_ALL=en_US.UTF-8
  6. export DEBIAN_FRONTEND=noninteractive
  7. sudo apt-get update
  8. sudo -E apt-get -q -y install mysql-server
  9. sudo apt-get -y install libmysqlclient-dev pwgen
  10. sudo apt-get clean
  11. cp .env.example .env
  12. MYSQL_PASSWORD=`pwgen -1`
  13. mysql -u root -e "CREATE USER 'huginn'@'localhost' IDENTIFIED BY '$MYSQL_PASSWORD';"
  14. mysql -u root -e "GRANT ALL PRIVILEGES ON *.* TO 'huginn'@'localhost';"
  15. sed -i 's/DATABASE_USERNAME=.*/DATABASE_USERNAME=huginn/g' .env
  16. sed -i "s/DATABASE_PASSWORD=.*/DATABASE_PASSWORD=\"$MYSQL_PASSWORD\"/g" .env
  17. APP_SECRET_TOKEN=`pwgen 24 -1`
  18. sed -i "s/APP_SECRET_TOKEN=.*/APP_SECRET_TOKEN=$APP_SECRET_TOKEN/g" .env
  19. npm install -g phantomjs-prebuilt
  20. gem install bundler
  21. bundle install
  22. bundle exec rake db:create
  23. bundle exec rake db:migrate
  24. bundle exec rake db:seed
  25. cat >> ~/code/huginn/README.nitrous.md <<EOT
  26. # Setup
  27. Welcome to your Huginn project on Nitrous.
  28. ## Running the development server:
  29. In the [Nitrous IDE](https://community.nitrous.io/docs/ide-overview), start Huginn via "Run > Start Huginn" and wait for 30 seconds for the server to be started.
  30. Now you've got a development server running and can see the output in the Nitrous terminal window. You can open up a new shell or utilize [tmux](https://community.nitrous.io/docs/tmux) to open new shells to run other commands.
  31. ## Preview the app
  32. In the Nitrous IDE, open the "Preview" menu and click "Port 3000".
  33. EOT