source: lliurex-zero-installers/trunk/fuentes/zero-lliurex-moodle.zmds/install-moodle.zmd @ 383

Last change on this file since 383 was 383, checked in by mabarracus, 5 years ago

Changed invocation to enable site moodle into apache

File size: 5.9 KB
Line 
1#!/bin/bash
2
3zero-center add-pulsating-color install-moodle
4
5MSG_INSTALLING_PROGRESS="Configurator Service for Moodle in LliureX"
6MSG_ADVERTISEMENT="Do you want install and configure Moodle for LliureX?"
7MSG_ZENITY_MOODLE_1="Testing Mysql...."
8MSG_MOODLE_MYSQL_PROBLEM="Mysql is not working properly"
9MSG_ZENITY_MOODLE_2="Creating a token...."
10MSG_MOODLE_AVISO="Activating new token"
11MSG_ZENITY_MOODLE_3="Linking Apache with Moodle...."
12MSG_ZENITY_MOODLE_4="Configuring DNS mask for Moodle in LliureX...."
13MSG_ZENITY_MOODLE_5="Linking LDAP with Moodle...."
14MSG_ZENITY_MOODLE_6="Restarting services to apply new configurations...."
15MSG_MOODLE_INSTALLED="Moodle has been installed in your system. You can check it with firefox in this URL http://moodle"
16
17HELP_PROGRESS_BAR="/tmp/help_moodle_install.txt"
18
19if zenity --question --title="$MSG_INSTALLING_PROGRESS" --width=500 --height=100 --text="$MSG_ADVERTISEMENT"; then
20        touch $HELP_PROGRESS_BAR
21else
22        zero-center remove-pulsating-color install-moodle
23        exit 1
24fi
25
26zero-installer  install lliurex-preseed-moodle
27
28if [ ! -d "/etc/dbconfig-common" ]; then
29     mkdir -p /etc/dbconfig-common   
30fi 
31
32#init DB
33/usr/sbin/lliurex-preseed --update || true
34
35zero-installer -l /usr/share/lliurex-zero-installers/moodle-packages
36
37##if [ ! -d "/var/lib/moodle" ]; then
38##      mkdir -p /var/lib/moodle
39##      chown www-data:www-data /var/lib/moodle || true
40##fi
41
42# Testing it MySQL is alive and the root passwd is available
43# "sudo" is mandatory here, I don't understand the correct reason...
44# if you are reading this comment, and know the answer...please contact with us
45#
46##sudo mysql_root_passwd -i
47
48##if [ $? -ne 0 ] ; then
49##      echo "Mysql is not working properly"
50##      exit 1
51##fi
52
53
54# Since the 0.61 version, which is required by lliurex-pmb the lliurex-sgbd utility uses
55# a simple mechanism to create a token in /tmp/db_is_present , a more useful mechanism that "NO"
56# at STDOUT. 
57##lliurex-sgbd --db_is_present lliurex-moodle
58##if [ -f /tmp/db_is_present ]; then
59##      lliurex-sgbd --install lliurex-moodle
60##else
61##      zenity --info --text="$MSG_AVISO"
62##      lliurex-sgbd --upgrade lliurex-moodle
63##fi
64
65
66##if [ -e /usr/share/apache2/apache2-maintscript-helper ] ; then
67
68##      . /usr/share/apache2/apache2-maintscript-helper
69##      apache2_invoke ensite moodle
70
71##fi
72
73# create file moodle in /var/lib/dnsmasq/config
74##if [ ! -d /var/lib/dnsmasq/config ]; then
75##      mkdir -p /var/lib/dnsmasq/config
76##fi
77
78##INTERNA=$(n4d-vars getvalues INTERNAL_DOMAIN | cut -d"'" -f2)
79##if [ -z $INTERNA ]; then
80##      echo "Error al obtener INTERNAL_DOMAIN"
81##      echo "Se deja sin configurar dnsmasq para moodle"
82##else
83##      if [ ! -d /var/lib/dnsmasq/config ]; then
84##              mkdir -p /var/lib/dnsmasq/config
85##      fi
86##      hostname=$(hostname)
87##      echo "cname=moodle."$INTERNA",$hostname."$INTERNA > /var/lib/dnsmasq/config/moodle
88       
89##fi
90
91#create ldap users in moodle
92##if [ -n $INTERNA ]; then
93##      /usr/bin/python /usr/share/lliurex-moodle/update_moodle_sql.py
94##fi
95
96##a2ensite moodle || true
97
98##service apache2 restart || true
99
100##service dnsmasq restart || true
101
102
103#######MAIN PROGRAM##########
104
105( tail -f $HELP_PROGRESS_BAR
106) |
107zenity --progress \
108  --title="ZERO-MOODLE" \
109  --text="$MSG_INSTALLING_PROGRESS" \
110  --percentage=0 \
111  --auto-close \
112   --width=500 \
113  --auto-kill &
114 
115
116 
117if [ ! -d "/var/lib/moodle" ]; then
118        mkdir -p /var/lib/moodle
119        chown www-data:www-data /var/lib/moodle || true
120fi 
121sleep 2
122echo "10" >> $HELP_PROGRESS_BAR
123echo "# $MSG_ZENITY_MOODLE_1"   >> $HELP_PROGRESS_BAR
124# Testing it MySQL is alive and the root passwd is available
125# "sudo" is mandatory here, I don't understand the correct reason...
126# if you are reading this comment, and know the answer...please contact with us
127#
128sudo mysql_root_passwd -i
129
130if [ $? -ne 0 ] ; then
131        echo "$MSG_MYSQL_PROBLEM"
132        zenity --info --text="$MSG_MOODLE_MYSQL_PROBLEM" &
133        rm $HELP_PROGRESS_BAR
134        zero-center set-non-configured install-moodle   
135        zero-center remove-pulsating-color install-moodle
136        exit 1
137fi
138echo "20" >> $HELP_PROGRESS_BAR
139echo "# $MSG_ZENITY_MOODLE_2"  >> $HELP_PROGRESS_BAR
140# Since the 0.61 version, which is required by lliurex-pmb the lliurex-sgbd utility uses
141# a simple mechanism to create a token in /tmp/db_is_present , a more useful mechanism that "NO"
142# at STDOUT. 
143lliurex-sgbd --db_is_present lliurex-moodle
144if [ ! -f /tmp/db_is_present ]; then
145        lliurex-sgbd --install lliurex-moodle
146else
147        #zenity --info --text="$MSG_MOODLE_AVISO" &
148        lliurex-sgbd --upgrade lliurex-moodle
149fi
150echo "30" >> $HELP_PROGRESS_BAR
151echo "# $MSG_ZENITY_MOODLE_3" >> $HELP_PROGRESS_BAR
152#if [ -e /usr/share/apache2/apache2-maintscript-helper ] ; then
153#       . /usr/share/apache2/apache2-maintscript-helper
154#       apache2_invoke ensite moodle
155#fi
156#maintainer script substitution to userland script
157a2ensite moodle
158
159echo "50" >> $HELP_PROGRESS_BAR
160echo "# $MSG_ZENITY_MOODLE_4" >> $HELP_PROGRESS_BAR
161# create file moodle in /var/lib/dnsmasq/config
162if [ ! -d /var/lib/dnsmasq/config ]; then
163        mkdir -p /var/lib/dnsmasq/config
164fi
165
166INTERNA=$(n4d-vars getvalues INTERNAL_DOMAIN | cut -d"'" -f2)
167if [ -z $INTERNA ]; then
168        echo "Error al obtener INTERNAL_DOMAIN"
169        echo "Se deja sin configurar dnsmasq para moodle"
170else
171        if [ ! -d /var/lib/dnsmasq/config ]; then
172                mkdir -p /var/lib/dnsmasq/config
173        fi
174        hostname=$(hostname)
175        echo "cname=moodle."$INTERNA",$hostname."$INTERNA > /var/lib/dnsmasq/config/moodle
176       
177fi
178echo "70"  >> $HELP_PROGRESS_BAR
179echo "# $MSG_ZENITY_MOODLE_5"  >> $HELP_PROGRESS_BAR
180#create ldap users in moodle
181if [ -n $INTERNA ]; then
182        /usr/bin/python /usr/share/lliurex-moodle/update_moodle_sql.py
183fi
184echo "85"  >> $HELP_PROGRESS_BAR
185echo "# $MSG_ZENITY_MOODLE_6"  >> $HELP_PROGRESS_BAR
186a2ensite moodle || true
187
188service apache2 restart || true
189
190service dnsmasq restart || true
191echo "100"  >> $HELP_PROGRESS_BAR
192
193
194zenity --info --title="ZERO-MOODLE" --text="$MSG_MOODLE_INSTALLED" &
195
196#su $USER firefox http://moodle/ || true
197rm $HELP_PROGRESS_BAR
198zero-center set-configured install-moodle   
199zero-center remove-pulsating-color install-moodle
200
201exit 0
Note: See TracBrowser for help on using the repository browser.