Add cloud 9 installation shell script

This commit is contained in:
Jeremy Zhang 2017-05-31 19:21:14 +00:00
parent d5e5650322
commit e99b52f433

45
cloud9_install.sh Normal file
View File

@ -0,0 +1,45 @@
#!/usr/bin/env bash
echo "[C9Setup] Installing mysql, and creating titan db table"
cd ~/workspace/
mysql-ctl start
mysql -u root -e "CREATE DATABASE titan;"
echo "[C9Setup] Copying config.py for webapp/discordbot and alembic.ini"
cp ~/workspace/webapp/config.example.py ~/workspace/webapp/config.py
cp ~/workspace/discordbot/config.example.py ~/workspace/discordbot/config.py
cp ~/workspace/webapp/alembic.example.ini ~/workspace/webapp/alembic.ini
echo "[C9Setup] Installing dependancies for discordbot"
cd ~/workspace/discordbot/
sudo python3.5 -m pip install -r requirements.txt
sudo python3.5 -m pip install pymysql
echo "[C9Setup] Installing webapp dependancies"
cd ~/workspace/webapp
sudo pip install -r requirements.txt
sudo pip install alembic pymysql
echo "[C9Setup] Auto populating alembic.ini database url and titan database table"
#sqlalchemy.url = mysql+pymysql://root@localhost/titan
sed -i '32s/.*/sqlalchemy.url = mysql+pymysql:\/\/root@localhost\/titan/' ~/workspace/webapp/alembic.ini
alembic upgrade head
echo "[C9Setup] Setting database uri for discordbot/config.py"
#'database-uri': "mysql+pymysql://root@localhost/titan",
sed -i "4s/.*/\'database-uri\': \"mysql+pymysql:\/\/root@localhost\/titan\",/" ~/workspace/discordbot/config.py
echo "[C9Setup] Setting database uri for webapp/config.py"
sed -i "11s/.*/\'database-uri\': \"mysql+pymysql:\/\/root@localhost\/titan\",/" ~/workspace/webapp/config.py
echo "[C9Setup] Making sure everything can be runned"
sudo chmod -R 777 *
echo "------------------------------"
echo "Cloud9 Installation Done!!!!!"
echo "If there are no errors, then you may proceed by editing the config.py files in the webapp and discordbot directories with your discord bottokens, etc."
echo "Remember that your database uri is: mysql+pymysql://root@localhost/titan"
echo ""
echo "After you finished editing those files, you may right click on run_c9.py and click run in the menu to start the webapp."
echo "To run the discordbot, change your directory to discord bot: cd discordbot/"
echo "and type the following command: python3.5 run.py"
echo "------------------------------"