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

Last change on this file since 1269 was 1269, checked in by jrpelegrina, 5 years ago

WIP in compatibility moodle-php5-lliurex

File size: 6.2 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
157#a2ensite moodle
158ENSITE="/usr/local/sbin/a2ensite-lliurex"
159${ENSITE} moodle
160# create a redirect config from apache2 to apache2-lliurex for moodle
161                             
162a2ensite moodle
163a2enmod proxy
164a2enmod proxy_http
165 
166systemctl restart apache2-lliurex
167systemctl restart apache2
168
169echo "50" >> $HELP_PROGRESS_BAR
170echo "# $MSG_ZENITY_MOODLE_4" >> $HELP_PROGRESS_BAR
171# create file moodle in /var/lib/dnsmasq/config
172if [ ! -d /var/lib/dnsmasq/config ]; then
173        mkdir -p /var/lib/dnsmasq/config
174fi
175
176INTERNA=$(n4d-vars getvalues INTERNAL_DOMAIN | cut -d"'" -f2)
177if [ -z $INTERNA ]; then
178        echo "Error al obtener INTERNAL_DOMAIN"
179        echo "Se deja sin configurar dnsmasq para moodle"
180else
181        if [ ! -d /var/lib/dnsmasq/config ]; then
182                mkdir -p /var/lib/dnsmasq/config
183        fi
184        hostname=$(hostname)
185        echo "cname=moodle."$INTERNA",$hostname."$INTERNA > /var/lib/dnsmasq/config/moodle
186       
187fi
188echo "70"  >> $HELP_PROGRESS_BAR
189echo "# $MSG_ZENITY_MOODLE_5"  >> $HELP_PROGRESS_BAR
190#create ldap users in moodle
191if [ -n $INTERNA ]; then
192        /usr/bin/python /usr/share/lliurex-moodle/update_moodle_sql.py
193fi
194echo "85"  >> $HELP_PROGRESS_BAR
195echo "# $MSG_ZENITY_MOODLE_6"  >> $HELP_PROGRESS_BAR
196
197#a2ensite moodle || true
198${ENSITE} moodle || true
199
200#service apache2 restart || true
201systemctl restart apache2-lliurex
202
203service dnsmasq restart || true
204echo "100"  >> $HELP_PROGRESS_BAR
205
206
207zenity --info --title="ZERO-MOODLE" --text="$MSG_MOODLE_INSTALLED" &
208
209#su $USER firefox http://moodle/ || true
210rm $HELP_PROGRESS_BAR
211zero-center set-configured install-moodle   
212zero-center remove-pulsating-color install-moodle
213
214exit 0
Note: See TracBrowser for help on using the repository browser.