finition des script d'installation et de désinstallation

This commit is contained in:
Benjamin Dauvergne 2012-04-10 20:34:26 +02:00
parent 4b0bc86ca5
commit d6a3a1fbb5
5 changed files with 156 additions and 20 deletions

View File

@ -0,0 +1 @@
900913,PROJCS["Google Maps Global Mercator",GEOGCS["WGS84",DATUM["WGS_1984",SPHEROID["WGS84",6378137,298.257223563,AUTHORITY["EPSG","7030"]],AUTHORITY["EPSG","6326"]],PRIMEM["Greenwich",0,AUTHORITY["EPSG","8901"]],UNIT["degree",0.01745329251994328,AUTHORITY["EPSG","9122"]],AUTHORITY["EPSG","4326"]],PROJECTION["Mercator_2SP"],PARAMETER["standard_parallel_1",0],PARAMETER["latitude_of_origin",0],PARAMETER["central_meridian",0],PARAMETER["false_easting",0],PARAMETER["false_northing",0],UNIT["Meter",1],EXTENSION["PROJ4","+proj=merc +a=6378137 +b=6378137 +lat_ts=0.0 +lon_0=0.0 +x_0=0.0 +y_0=0 +k=1.0 +units=m +nadgrids=@null +wktext +no_defs"]]

76
init.d Executable file
View File

@ -0,0 +1,76 @@
#!/bin/sh
#
# logement Startup script for logement
#
# chkconfig: - 85 15
# processname: logement
# pidfile: /var/run/logement.pid
# description: application logement de l'universite paris dauphine
#
### BEGIN INIT INFO
# Provides: logement
# Required-Start: $local_fs $remote_fs $network
# Required-Stop: $local_fs $remote_fs $network
# Default-Start: 2 3 4 5
# Default-Stop: 0 1 6
# Short-Description: start and stop nginx
### END INIT INFO
# Source function library.
. /etc/rc.d/init.d/functions
prog=logement
pidfile=${PIDFILE-/var/run/logement/pid}
logement="/home/logement/virtualenv/bin/python /home/logement/src/appli_project/manage.py runfcgi host=localhost port=8000 pidfile=$pidfile"
SLEEPMSEC=100000
RETVAL=0
start() {
echo -n $"Starting $prog: "
daemon --user logement ${logement}
RETVAL=$?
echo
return $RETVAL
}
stop() {
echo -n $"Stopping $prog: "
killproc -p ${pidfile} ${prog}
RETVAL=$?
echo
[ $RETVAL = 0 ] && rm -f ${pidfile}
}
reload() {
echo -n $"Reloading $prog: "
killproc -p ${pidfile} ${prog} -HUP
RETVAL=$?
echo
}
rh_status() {
status -p ${pidfile} ${nginx}
}
# See how we were called.
case "$1" in
start)
start
;;
stop)
stop
;;
restart)
stop
start
;;
force-reload|reload)
reload
;;
*)
echo $"Usage: $prog {start|stop|restart|reload|help}"
RETVAL=2
esac
exit $RETVAL

View File

@ -4,6 +4,13 @@ if [ ! -d /home/logement ]; then
echo Création de l\'utilisateur logement
adduser logement
fi
if ! rpm -qa | grep epel-release-5; then
wget http://dl.fedoraproject.org/pub/epel/5/i386/epel-release-5-4.noarch.rpm
rpm -i epel-release-5-4.noarch.rpm
rm epel-release-5-4.noarch.rpm
fi
if ! rpm -qa | grep pgdg-centos-8.4 >/dev/null; then
wget http://yum.postgresql.org/8.4/redhat/rhel-5-x86_64/pgdg-centos-8.4-3.noarch.rpm
rpm -i pgdg-centos-8.4-3.noarch.rpm
@ -16,37 +23,65 @@ if ! rpm -qa | grep rpmforge-release >/dev/null; then
rm rpmforge-release-0.5.2-2.el5.rf.x86_64.rpm
fi
yum erase postgres-libs httpd
yum install postgresql84 postgresql84-server postgis memcached python26-imaging \
python26-ldap python26-numpy geos-3.1.0 postgis proj gdal proj-devel nginx
if [ ! -f /etc/yum.repos.d/nginx.repo ]; then
cat >/etc/yum.repos.d/nginx.repo <<EOF
[nginx]
name=nginx repo
baseurl=http://nginx.org/packages/centos/5/x86_64/
gpgcheck=0
enabled=1
EOF
fi
if [ ! -d /var/lib/pgsql/data/ ]; then
yum makecache
yum erase postgres-libs httpd
yum install python26 git gcc python26-virtualenv python26-devel nginx \
postgresql84 postgresql84-server postgis memcached python26-imaging \
python26-ldap python26-numpy geos-3.1.0 postgis proj gdal-1.4.4 proj-devel \
postgresql84-devel proj-epsg
# FIX missing Google Mercator Projection
if ! grep -q 900913 /usr/share/gdal/cubewerx_extra.wkt; then
cat cubewerx_extra.wkt.addendum >>/usr/share/gdal/cubewerx_extra.wkt
fi
if [ ! -d /var/lib/pgsql/data/base/ ]; then
service postgresql initdb
fi
service postgresql start
# Creation du template pour les bases postgis
sudo -u postgres createdb -E UTF8 template_postgis
sudo -u postgres createlang -d template_postgis plpgsql
sudo -u postgres psql -d postgres -c "UPDATE pg_database SET datistemplate='true' WHERE datname='template_postgis';"
sudo -u postgres psql -d template_postgis -f /usr/share/pgsql/contrib/lwpostgis-64.sql
sudo -u postgres psql -d template_postgis -f /usr/share/pgsql/contrib/spatial_ref_sys.sql
sudo -u postgres psql -d template_postgis -c "GRANT ALL ON geometry_columns TO PUBLIC;"
sudo -u postgres psql -d template_postgis -c "GRANT ALL ON geography_columns TO PUBLIC;"
sudo -u postgres psql -d template_postgis -c "GRANT ALL ON spatial_ref_sys TO PUBLIC;"
if ! sudo -u postgres psql -c \\l | grep -q template_postgis; then
sudo -u postgres createdb -E UTF8 template_postgis
sudo -u postgres createlang -d template_postgis plpgsql
sudo -u postgres psql -d postgres -c "UPDATE pg_database SET datistemplate='true' WHERE datname='template_postgis';"
sudo -u postgres psql -d template_postgis -f /usr/share/pgsql/contrib/lwpostgis-64.sql
sudo -u postgres psql -d template_postgis -f /usr/share/pgsql/contrib/spatial_ref_sys.sql
sudo -u postgres psql -d template_postgis -c "GRANT ALL ON geometry_columns TO PUBLIC;"
sudo -u postgres psql -d template_postgis -c "GRANT ALL ON geography_columns TO PUBLIC;"
sudo -u postgres psql -d template_postgis -c "GRANT ALL ON spatial_ref_sys TO PUBLIC;"
fi
# Creation de la base pour l'application
sudo -u postgres createuser -d -R -S logement
sudo -u postgres createdb -T template_postgis -O logement logement
if ! sudo -u postgres psql -c \\dg | grep -q logement; then
sudo -u postgres createuser -d -R -S logement
fi
# Crée l'utilisateur
if ! sudo -u postgres psql -c \\l | grep -q logement; then
sudo -u postgres dropdb logement
sudo -u postgres createdb -T template_postgis -O logement logement
fi
# Crée l'utilisater
cp -R `pwd` /home/logement/src/
chown -R logement.logement /home/logement/src/
cd /home/logement
virtualenv-2.6 virtualenv
if [ ! -d virtualenv ]; then
virtualenv-2.6 virtualenv
fi
. ./virtualenv/bin/activate
pip install --upgrade pip
pip install -r src/requirements
pip install --upgrade -r src/requirements
chown -R logement.logement src/ virtualenv/
cd src
if ! -f local_settings_dev.py; then
echo 'STATIC_ROOT = "/home/logement/static/"' >>local_settings_dev.py
@ -55,10 +90,17 @@ fi
# Install nginx configuration
ln -f `pwd`/nginx.conf /etc/nginx/conf.d/default.conf
cp init.d /etc/init.d/logement
# Create static
cd appli_project
python manage.py collectstatic -l --noinput
sudo -u logement ../../virtualenv/bin/python manage.py syncdb
sudo -u logement ../../virtualenv/bin/python manage.py collectstatic -l --noinput
# Reload nginx
service nginx reload
usermod -a -G logement nginx
service nginx restart
service memcached restart
chmod g+rX /home/logement
chmod -R g+rX /home/logement/static
service logement start

View File

@ -5,6 +5,9 @@ server {
location /static/ {
alias /home/logement/static/;
}
location /favicon.ico {
alias /home/logement/static/img/favicon.ico;
}
location / {
fastcgi_pass_header Authorization;

14
uninstall.sh Executable file
View File

@ -0,0 +1,14 @@
#!/bin/bash
userdel logement
groupdel logement
rm -rf /home/logement
yum erase python26 git gcc python26-virtualenv python26-devel nginx \
postgresql84 postgresql84-server postgis memcached python26-imaging \
python26-ldap python26-numpy geos-3.1.0 postgis proj gdal-1.4.4 proj-devel
yum erase epel-release pgdg-centos rpmforge-release
rm /etc/yum.repos.d/nginx.repo
rm -rf /var/lib/pgsql
rm -rf /etc/nginx