2017-05-31 21:21:14 +02:00
#!/usr/bin/env bash
2018-07-17 00:18:42 +02:00
echo "[C9Setup] Installing postgresql, redis, and creating titan db table"
2017-05-31 21:21:14 +02:00
cd ~/workspace/
2017-09-25 02:02:05 +02:00
sudo service postgresql start
psql -c "CREATE DATABASE titan WITH ENCODING 'UTF8' TEMPLATE template0"
2017-09-03 04:59:08 +02:00
sudo service redis-server start
2017-05-31 21:21:14 +02:00
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
2018-07-16 23:34:08 +02:00
echo "[C9Setup] Updating Python 3.5"
2018-07-15 00:52:40 +02:00
sudo add-apt-repository ppa:deadsnakes/ppa
sudo apt-get update
sudo apt-get install python3.5
2017-08-19 02:33:50 +02:00
echo "[C9Setup] Installing Titan dependencies"
cd ~/workspace/
2017-09-25 02:02:05 +02:00
sudo python3.5 -m pip install --upgrade pip
2018-07-15 01:51:08 +02:00
sudo python3.5 -m pip install --upgrade setuptools
2017-09-25 02:02:05 +02:00
sudo python3.5 -m pip install -U -r requirements.txt
sudo python3.5 -m pip install -U alembic psycopg2 eventlet
2017-05-31 21:21:14 +02:00
echo "[C9Setup] Auto populating alembic.ini database url and titan database table"
2017-08-19 02:33:50 +02:00
cd ~/workspace/webapp
2017-09-25 02:02:05 +02:00
#sqlalchemy.url = postgresql:///titan
sed -i '32s/.*/sqlalchemy.url = postgresql:\/\/\/titan/' ~/workspace/webapp/alembic.ini
2017-05-31 21:21:14 +02:00
alembic upgrade head
echo "[C9Setup] Setting database uri for discordbot/config.py"
2018-07-10 21:06:54 +02:00
#'database-uri': "postgresql:///titan",
sed -i "4s/.*/\'database-uri\': \"postgresql:\/\/\/titan\",/" ~/workspace/discordbot/config.py
2017-05-31 21:21:14 +02:00
2017-05-31 21:27:30 +02:00
echo "[C9Setup] Setting database uri and app location for webapp/config.py"
2018-07-15 00:52:40 +02:00
sed -i "23s/.*/\'database-uri\': \"postgresql+psycopg2:\/\/\/titan?client_encoding=utf8\",/" ~/workspace/webapp/config.py
2017-05-31 21:27:30 +02:00
#'app-location': "/home/ubuntu/workspace/webapp/",
2018-07-15 00:52:40 +02:00
sed -i "20s/.*/\'app-location\': \"\/home\/ubuntu\/workspace\/webapp\/\",/" ~/workspace/webapp/config.py
2017-09-25 02:02:05 +02:00
#'webosockets-mode': "eventlet",
2018-07-15 00:52:40 +02:00
sed -i "25s/.*/\'websockets-mode\': \"eventlet\",/" ~/workspace/webapp/config.py
2017-05-31 21:21:14 +02:00
2018-07-16 23:34:08 +02:00
echo "[C9Setup] Testing..."
2017-08-19 02:33:50 +02:00
cd ~/workspace/
2017-05-31 21:21:14 +02:00
sudo chmod -R 777 *
2017-09-25 02:02:05 +02:00
echo "[C9Setup] Creating Cloud9 Python3.5 runner"
mkdir .c9/runners
touch .c9/runners/Python3.5.run
echo '{ "cmd" : ["python3.5", "$file", "$args"], "info" : "Started $project_path$file_name on Python v3.5", "env" : {}, "selector" : "source.py" }' > .c9/runners/Python3.5.run
echo "[C9Setup] Resetting everything to the master branch"
git reset --hard origin/master
2017-05-31 21:21:14 +02:00
echo "------------------------------"
echo "Cloud9 Installation Done!!!!!"
2017-09-25 02:02:05 +02:00
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 bot tokens, etc."
2017-05-31 21:21:14 +02:00
echo ""
2017-09-25 02:02:05 +02:00
echo "After you finished editing those files, you may (1)Double click run_c9.py in the webapp folder, (2)At the menu bar: hit Run->Run With->Python3.5, to start the webapp"
echo "Do the same thing with run.py in the discordbot folder"
echo "The console will show: wsgi starting up on http://0.0.0.0:8080. Click on that url and hit Open to view the local webapp."
2017-07-20 17:55:31 +02:00
echo "------------------------------"