1 | #!/bin/bash
|
---|
2 | set -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 |
|
---|
9 | f_Quick() {
|
---|
10 | MODE="quick"
|
---|
11 | }
|
---|
12 | f_Medium() {
|
---|
13 | MODE="medium"
|
---|
14 | }
|
---|
15 | f_Full() {
|
---|
16 | MODE="full"
|
---|
17 | }
|
---|
18 |
|
---|
19 | if [[ -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
|
---|
40 | elif [[ "$1" = "quick" ]]; then
|
---|
41 | # Set the option direct
|
---|
42 | MODE="quick"
|
---|
43 | elif [[ "$1" = "medium" ]]; then
|
---|
44 | # Set the option direct
|
---|
45 | MODE="medium"
|
---|
46 | elif [[ "$1" = "full" ]]; then
|
---|
47 | # Set the option direct
|
---|
48 | MODE="full"
|
---|
49 | else
|
---|
50 | echo >&2 "$1 is not a valid option!\nPlease use either 'quick', 'medium' or 'full'"
|
---|
51 | exit 1
|
---|
52 | fi
|
---|
53 |
|
---|
54 | #Update the repos
|
---|
55 | sudo apt-get update
|
---|
56 | # Install Git
|
---|
57 | sudo apt-get install git-core
|
---|
58 | # Install Python Libs
|
---|
59 | #sudo apt-get install -y python2.7 python-dateutil
|
---|
60 | sudo apt-get install -y python-lxml python-shapely python-dateutil
|
---|
61 |
|
---|
62 | if [[ "$MODE" = "medium" ]]; then
|
---|
63 | sudo apt-get -y install python-reportlab python-xlrd python-xlwt
|
---|
64 | elif [[ "$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
|
---|
68 | fi
|
---|
69 |
|
---|
70 | # Install Web2Py
|
---|
71 | cd /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
|
---|
87 | git 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 |
|
---|
94 | cat << EOF > /home/web2py/routes.py
|
---|
95 | #!/usr/bin/python
|
---|
96 | default_application = 'eden'
|
---|
97 | default_controller = 'default'
|
---|
98 | default_function = 'index'
|
---|
99 | routes_onerror = [
|
---|
100 | ('eden/400', '!'),
|
---|
101 | ('eden/401', '!'),
|
---|
102 | ('eden/*', '/eden/errors/index'),
|
---|
103 | ('*/*', '/eden/errors/index'),
|
---|
104 | ]
|
---|
105 | EOF
|
---|
106 |
|
---|
107 | # Install Eden
|
---|
108 | cd /home/web2py/applications
|
---|
109 | git clone git://github.com/flavour/eden.git
|
---|
110 |
|
---|
111 | cp /home/web2py/applications/eden/modules/templates/000_config.py /home/web2py/applications/eden/models
|
---|
112 | sed -i 's|EDITING_CONFIG_FILE = False|EDITING_CONFIG_FILE = True|' /home/web2py/applications/eden/models/000_config.py
|
---|
113 |
|
---|
114 | echo -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
|
---|
116 | read username
|
---|
117 |
|
---|
118 | if 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 |
|
---|
126 | else
|
---|
127 | echo "username entered doesn't seem to be valid."
|
---|
128 | fi
|
---|
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 |
|
---|