aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--documentation/deployment.rst27
-rwxr-xr-x[-rw-r--r--]install.sh29
2 files changed, 29 insertions, 27 deletions
diff --git a/documentation/deployment.rst b/documentation/deployment.rst
index 6d1b119c..c95dfe91 100644
--- a/documentation/deployment.rst
+++ b/documentation/deployment.rst
@@ -82,39 +82,20 @@ Deploying the application on a traditional server
.. code-block:: bash
$ git clone https://bitbucket.org/cedricbonhomme/pyaggr3g470r.git
- $ cd pyaggr3g470r
- $ ./install.sh
+ $ cd pyaggr3g470r/
If you want to use PostgreSQL
'''''''''''''''''''''''''''''
-
.. code-block:: bash
- $ sudo apt-get install postgresql postgresql-server-dev-9.3 postgresql-client
- $ sudo pip install psycopg2
- $ echo "127.0.0.1:5432:aggregator:pgsqluser:pgsqlpwd" > ~/.pgpass
- $ chmod 700 ~/.pgpass
- $ sudo -u postgres createuser pgsqluser --no-superuser --createdb --no-createrole
- $ createdb aggregator --no-password
- $ echo "ALTER USER pgsqluser WITH ENCRYPTED PASSWORD 'pgsqlpwd';" | sudo -u postgres psql
- $ echo "GRANT ALL PRIVILEGES ON DATABASE aggregator TO pgsqluser;" | sudo -u postgres psql
-
-Edit the configuration file with the line:
-
-.. code-block:: cfg
-
- [database]
- uri = postgres://pgsqluser:pgsqlpwd@127.0.0.1:5433/aggregator
+ $ ./install.sh postgre
If you want to use SQLite
'''''''''''''''''''''''''
-Just edit the configuration file with the line:
-
-.. code-block:: cfg
+.. code-block:: bash
- [database]
- uri = sqlite+pysqlite:///pyAggr3g470r.db
+ $ ./install.sh sqlite
Finally:
diff --git a/install.sh b/install.sh
index 8d62a0b6..232e3902 100644..100755
--- a/install.sh
+++ b/install.sh
@@ -1,10 +1,7 @@
-#! /usr/bin/env sh
+#! /usr/bin/env bash
#
# This script install all dependencies for pyAggr3g470r.
-# psycopg2 is removed from the requirements.txt file since it is only required
-# if the user wants to use Postgres. Postgres is generally used on the Heroku
-# platform.
#
sudo apt-get install python libpq-dev python-dev python-pip build-essential git
@@ -13,4 +10,28 @@ sudo apt-get install libxml2-dev libxslt1-dev # for lxml
sed -i '/psycopg2/d' requirements.txt
sudo pip install --upgrade -r requirements.txt
+# Initializes the configuration file
cp conf/conf.cfg-sample conf/conf.cfg
+
+# Delete default database configuration
+sed -i '/database/d' conf/conf.cfg
+sed -i '/uri/d' conf/conf.cfg
+
+if [ "$1" == postgre ]; then
+ sudo apt-get install -y postgresql postgresql-server-dev-9.3 postgresql-client
+ sudo pip install psycopg2
+ echo "127.0.0.1:5432:aggregator:pgsqluser:pgsqlpwd" > ~/.pgpass
+ chmod 700 ~/.pgpass
+ sudo -u postgres createuser pgsqluser --no-superuser --createdb --no-createrole
+ createdb aggregator --no-password
+ echo "ALTER USER pgsqluser WITH ENCRYPTED PASSWORD 'pgsqlpwd';" | sudo -u postgres psql
+ echo "GRANT ALL PRIVILEGES ON DATABASE aggregator TO pgsqluser;" | sudo -u postgres psql
+
+ # Add configuration lines for PostgreSQL
+ echo '[database]' >> conf/conf.cfg
+ echo 'uri = postgres://pgsqluser:pgsqlpwd@127.0.0.1:5432/aggregator' >> conf/conf.cfg
+elif [ "$1" == sqlite ]; then
+ # Add configuration lines for SQLite
+ echo '[database]' >> conf/conf.cfg
+ echo 'uri = sqlite+pysqlite:///pyAggr3g470r.db' >> conf/conf.cfg
+fi
bgstack15