InstallationGuidelines/Linux/Developer/Script: debian_ubuntu_eden_dev.3.2.2.sh

File debian_ubuntu_eden_dev.3.2.2.sh, 4.6 KB (added by Arnav Sharma, 10 years ago)

Debian Installation Script after moving templates

Line 
1#!/bin/bash
2set -e
3
4#
5# Install a Sahana Eden Developer environment in Ubuntu/Debian
6# - tested on Ubuntu 10.04 and 11.10, and Debian Wheezy
7#
8
9f_Quick() {
10 MODE="quick"
11}
12f_Medium() {
13 MODE="medium"
14}
15f_Full() {
16 MODE="full"
17}
18
19if [[ -z "$1" ]]; then
20 # Offer a menu
21 echo "Welcome to the Sahana Eden Dev Installation script for Ubuntu/Debian."
22 echo "This will install a working verion of Sahana Eden into /home/web2py, and chown the directory to give the specified user access."
23 echo
24 echo "Select the Installation Type:"
25 echo
26 echo "1. Medium - installs all mandatory and some common optional dependencies. It is the normal recommended option."
27 echo "2. Quick - installs only mandatory dependencies. This is recommended if you are on a slow Internet connection or need to get operational quickly."
28 echo "3. Full - installs all optional dependencies & the Eclipse debugger. It is only recommended if you are on a fast Internet connection & are prepared to be patient."
29 echo
30 # I have explicitly mentioned what the user is supposed to write,People have been trying to write things like "Full/full/Medium/medium etc" instead of 1/2/3.
31 echo -n "Your choice (Enter 1/2/3 depending on your requirements) ? : "
32 read choice
33
34 case "$choice" in
35 1) f_Medium ;;
36 2) f_Quick ;;
37 3) f_Full ;;
38 *) echo "\"$choice\" is not valid" ; exit ;;
39 esac
40elif [[ "$1" = "quick" ]]; then
41 # Set the option direct
42 MODE="quick"
43elif [[ "$1" = "medium" ]]; then
44 # Set the option direct
45 MODE="medium"
46elif [[ "$1" = "full" ]]; then
47 # Set the option direct
48 MODE="full"
49else
50 echo >&2 "$1 is not a valid option!\nPlease use either 'quick', 'medium' or 'full'"
51 exit 1
52fi
53
54#Update the repos
55sudo apt-get update
56# Install Git
57sudo apt-get install git-core
58# Install Python Libs
59#sudo apt-get install -y python2.7 python-dateutil
60sudo apt-get install -y python-lxml python-shapely python-dateutil
61
62if [[ "$MODE" = "medium" ]]; then
63 sudo apt-get -y install python-reportlab python-xlrd python-xlwt
64elif [[ "$MODE" = "full" ]]; then
65 sudo apt-get -y install python-reportlab python-xlrd python-xlwt
66 sudo apt-get -y install python-matplotlib python-numpy
67 sudo apt-get -y install eclipse-platform
68fi
69
70# Install Web2Py
71cd /home
72
73# Problem faced earlier:
74# Suppose the user enters wrong username, the script would just exit, leaving behind web2py folder in /home.
75# When the user tries to rerun the script , he would get an error message reading something like this
76# "Fatal error , web2py already exists in the path and is not an empty directory"
77# This is caused as we tried to clone the same repository, in the same previous location , where it already is present.
78
79# Fix:
80# Just deleted web2py already present and cloned it later. This solves the issue.
81# A better solution would be to add a check if the dir exists and
82# ask the user if he wants to delete it or not
83#rm -rf web2py
84
85#if [[ "$MODE" = "full" ]]; then
86# Currently need trunk
87git clone git://github.com/web2py/web2py.git
88#else
89# # Install the stable version
90# wget http://www.web2py.com/examples/static/web2py_src.zip
91# unzip web2py_src.zip
92#fi
93
94cat << EOF > /home/web2py/routes.py
95#!/usr/bin/python
96default_application = 'eden'
97default_controller = 'default'
98default_function = 'index'
99routes_onerror = [
100 ('eden/400', '!'),
101 ('eden/401', '!'),
102 ('eden/*', '/eden/errors/index'),
103 ('*/*', '/eden/errors/index'),
104 ]
105EOF
106
107# Install Eden
108cd /home/web2py/applications
109git clone git://github.com/flavour/eden.git
110
111cp /home/web2py/applications/eden/modules/templates/000_config.py /home/web2py/applications/eden/models
112sed -i 's|EDITING_CONFIG_FILE = False|EDITING_CONFIG_FILE = True|' /home/web2py/applications/eden/models/000_config.py
113
114echo -n "What is your username ( Please enter your computer's username, and not your web2py username )? : "
115# Maybe we should consider checking validity of username entered first , before running chown -R $username /home/web2py
116read username
117
118if id -u $username >/dev/null 2>&1; then
119 chown -R $username /home/web2py
120
121 echo "Installation is now complete - you can run Sahana either by using the Eclipse debugger or else by running:"
122 echo "cd /home/web2py; python web2py.py -a eden"
123 echo "Then run Sahana by pointing your web browser at http://127.0.0.1:8000"
124 echo "Be patient on the 1st run as the database needs to be created"
125
126else
127 echo "username entered doesn't seem to be valid."
128fi
129
130#if ! `chown -R $username /home/web2py` ;then
131# echo "You probably entered an invalid username"
132#else
133#fi 2>/dev/null
134