|  | @@ -0,0 +1,32 @@
 | 
	
		
			
			|  | 1 | +#!/usr/bin/env bash
 | 
	
		
			
			|  | 2 | +
 | 
	
		
			
			|  | 3 | +# TODO: Données de postgreSQL dans un volume
 | 
	
		
			
			|  | 4 | +# TODO: Mettre des variable d'environn pour la config
 | 
	
		
			
			|  | 5 | +# TODO: Supporter le changement des variables d'environnement ? (actuellement utilisé pour générer le .ini)
 | 
	
		
			
			|  | 6 | +# TODO: Fichiers de config link ls -s dans un dossier pour VOLUME
 | 
	
		
			
			|  | 7 | +# TODO: README QQCH pour les ports ? 80, 3060 et 5333
 | 
	
		
			
			|  | 8 | +
 | 
	
		
			
			|  | 9 | +# Start PostgreSQL
 | 
	
		
			
			|  | 10 | +service postgresql start
 | 
	
		
			
			|  | 11 | +
 | 
	
		
			
			|  | 12 | +# Init database if needed
 | 
	
		
			
			|  | 13 | +if ! [ "$( su - postgres -s /bin/bash -c "psql -tAc \"SELECT 1 FROM pg_database WHERE datname='tracim'\"" )" = '1' ]; then
 | 
	
		
			
			|  | 14 | +    su - postgres -s /bin/bash -c "psql -c \"CREATE DATABASE tracim;\""
 | 
	
		
			
			|  | 15 | +    su - postgres -s /bin/bash -c "psql -c \"CREATE USER tracim WITH PASSWORD 'tracim';\""
 | 
	
		
			
			|  | 16 | +    su - postgres -s /bin/bash -c "psql -c \"GRANT ALL PRIVILEGES ON DATABASE tracim TO tracim;\""
 | 
	
		
			
			|  | 17 | +fi
 | 
	
		
			
			|  | 18 | +
 | 
	
		
			
			|  | 19 | +# Create config.ini file if no exist
 | 
	
		
			
			|  | 20 | +if [ ! -f /tracim/tracim/config.ini ]; then
 | 
	
		
			
			|  | 21 | +    cp /tracim/tracim/development.ini.base /tracim/tracim/config.ini
 | 
	
		
			
			|  | 22 | +    sed -i "s/\(sqlalchemy.url *= *\).*/\1postgresql:\/\/tracim:tracim@127.0.0.1:5432\/tracim?client_encoding=utf8/" /tracim/tracim/config.ini
 | 
	
		
			
			|  | 23 | +    # TODO: ENV VAR
 | 
	
		
			
			|  | 24 | +fi
 | 
	
		
			
			|  | 25 | +
 | 
	
		
			
			|  | 26 | +# Create wsgidav.conf file if no exist
 | 
	
		
			
			|  | 27 | +if [ ! -f /tracim/tracim/wsgidav.conf ]; then
 | 
	
		
			
			|  | 28 | +    cp /tracim/tracim/wsgidav.conf.sample /tracim/tracim/wsgidav.conf
 | 
	
		
			
			|  | 29 | +fi
 | 
	
		
			
			|  | 30 | +
 | 
	
		
			
			|  | 31 | +# Start with uwsgi
 | 
	
		
			
			|  | 32 | +uwsgi --http-socket 0.0.0.0:80 /etc/uwsgi/apps-available/tracim.ini
 |