Commits

Igor Katson committed 4c9444b

Updated install script a bit

Comments (0)

Files changed (1)

 #!/bin/sh
 
+# This will just be set up via apt
+MAIL_AGENT=postfix
+WEBDIR="$WEBDIR"
+WEBUSER=www-data
+MERCURIAL_NAME='Igor Katson <igor.katson@gmail.com>'
+
 # Download vim config
 wget -O ~/.vimrc http://dumpz.org/25712/nixtext/
 
 # apache-utils --> ab
 aptitude install psmisc screen apache-utils whois sudo less -y
 
-aptitude install exim4 -y
-#dpkg-reconfigure exim4-config
+aptitude install $MAIL_AGENT -y
 
 # Nginx
 aptitude install nginx -t sid -y
 /etc/init.d/nginx start
 
 # Web user
-useradd -m web -s /bin/bash
-cp ~/.vimrc /home/web
-mkdir /home/web/.ssh
-cp ~/.ssh/authorized_keys /home/web/.ssh
-mkdir /home/web/.pip-cache
-echo 'export PIP_DOWNLOAD_CACHE="/home/web/.pip-cache"' >> /home/web/.bashrc
-chown -R web:web /home/web
-
-mkdir /web /web/run /web/log
-chown -R web:web /web
+if grep "$WEBUSER" /etc/passwd; then
+    usermod --home "$WEBDIR" --shell /bin/bash --disabled-password "$WEBUSER"
+else
+    adduser --home "$WEBDIR" --shell /bin/bash --disabled-password "$WEBUSER"
+fi
+cp ~/.vimrc "$WEBDIR"
+mkdir "$WEBDIR"/.ssh
+cp ~/.ssh/authorized_keys "$WEBDIR"/.ssh
+mkdir "$WEBDIR"/.pip-cache
+echo 'export PIP_DOWNLOAD_CACHE=""$WEBDIR"/.pip-cache"' >> "$WEBDIR"/.bashrc
+chown -R "$WEBUSER":"$WEBUSER" "$WEBDIR"
 
 # VCS
 aptitude install mercurial subversion git-core -y
 
 # Set up mercurial
-cat > /home/web/.hgrc << EOF
+cat > "$WEBDIR"/.hgrc << EOF
 [ui]
-username = Name Name <box@domain.com>
+username = $MERCURIAL_NAME
 EOF
-chown web:web /home/web/.hgrc
+chown web:web "$WEBDIR"/.hgrc
 
 # python
 aptitude install python python-setuptools python-dev -y
 # Fabric
 pip install -U fabric
 
-# memcached
-aptitude install memcached libmemcached-dev -y
-
 # PIL
 aptitude install libjpeg62-dev libfreetype6-dev -t testing -y
 # Ubuntu hacks:
 aptitude install postgresql python-psycopg2 -y
 # Need to be able build postgresql psycopg2 driver from sources
 aptitude install postgresql-server-dev-8.4 -y
-su postgres -c "cd /; createuser -s web"
+
+# Change postgres ident to trust
+sed -i 's/ ident/ trust/' /etc/postgresql/8.4/main/pg_hba.conf
 
 # Mysql
 # Dependency to build mysql-python package via pip
 aptitude install libmysqld-dev -y
 
-# supervisor
-aptitude install supervisor -y
-cd /etc/supervisor/conf.d
-cat > /etc/supervisor/conf.d/inet.conf << EOF
-[inet_http_server]]
-port=666
-#username=
-#password=
-EOF
-
-cat > /etc/supervisor/conf.d/web.conf << EOF
-#[program:PROJECT]
-#directory=/web/PROJECT
-#command=uwsgi -x uwsgi.xml
-#user=web
-EOF
-
-/etc/init.d/supervisor stop
-/etc/init.d/supervisor start
-
-echo "web    ALL = NOPASSWD: /usr/bin/supervisorctl" >> /etc/sudoers
-
-cat > /etc/nginx/sites-enabled/template << EOF
-server {
-    server_name .HOST;
-
-    error_log /web/log/HOST-error.log warn;
-    access_log /web/log/HOST-access.log;
-
-    location /static/admin-media {
-        alias /web/PROJECT/.env/lib/python2.6/site-packages/django/contrib/admin/media;
-    }   
-
-    location /static/ {
-        root /web/PROJECT;
-    }   
-
-    location /robots.txt {
-        root /web/PROJECT/static;
-    }   
-
-    location /favicon.ico {
-        root /web/PROJECT/static;
-    }   
-
-    location / { 
-        include uwsgi_params;
-        uwsgi_pass unix:/web/run/PROJECT.sock;
-    }   
-}
-
-server {
-    server_name www.HOST;
-    location / { 
-        rewrite (.*) http://HOST$1 permanent;
-    }   
-}
-EOF
+# runit
+aptitude install runit -y