Subversion Repositories slis

Rev

Rev 5499 | Go to most recent revision | Details | Compare with Previous | Last modification | View Log | RSS feed

Rev Author Line No. Line
5461 plb 1
<?PHP
2
/*
3
 
4
This script has been written by Philippe Le Brouster
5
Copyright (C) 2007 Philippe Le Brouster <plb@ac-grenoble.fr>
6
 
7
This script is released under GNU Public Licence (GPL)
8
http://www.gnu.org/licenses/gpl.html
9
 
10
This script is part of the SLIS Project initiated by
11
the CARMI-Internet (Academie de Grenoble - France 38).
12
 
13
SLIS : Serveur de communications Linux pour l'Internet Scolaire.
14
Copyright (C) 1998-2001 Bruno Bzeznik
15
 
16
--------------------------------------------------------------*/
17
 
18
// Slis Update from 2.0.5 to 2.0.5.1
19
 
20
function doUpdate_2_0_5_to_2_0_5_1(){
21
    global $slim_user,$slim_db;
22
 
23
    if ($slim_user->login == "admin") {
24
        $retval=1;
25
        echo ("<br>Updating slim DB from 2.0.5 to 2.0.5.1 ");
26
 
27
        if ($retval) $retval = alter_file_defvalue_key_2_0_5_1();
28
        if ($retval) $retval = insert_slis41_value_2_0_5_1();
29
        if ($retval) $retval = insert_slis41_checkversion_2_0_5_1();
30
 
31
        if ($retval) $retval = pg_exec($slim_db,"UPDATE slim_info set value='2.0.5.1' where key='slim_db_version';");
32
 
33
        return $retval;
34
    }
35
 
36
}
37
 
38
function alter_file_defvalue_key_2_0_5_1() {
39
    global $slim_db;
40
    print "<br/> Update index for file_devalue table";
41
 
42
    $result = 1;
43
    $query  = "BEGIN;";
44
    $query .= "DROP INDEX file_defvalue_key;";
45
    $query .= "CREATE INDEX file_defvalue_key ON file_defvalue USING btree (pop_id,\"type\",variable,file);";
46
    $query .= "COMMIT;";
47
 
48
    if ($result) $result = pg_exec($slim_db,$query);
49
 
50
    return $result;
51
}
52
 
53
function insert_slis41_value_2_0_5_1() {
54
    global $slim_db;
55
    print "<br/> Insert the new default values for slis 4.1 configuration generation.";
56
 
57
 
58
    $slis41_slis = array(
59
        'ADSL_PASS' => '%gateway_passwd%',
60
        'ADSL_TYPE' => 'pppoe',
61
        'ADSL_USER' => '%gateway_user%',
62
        'ALLOWED_SMTP' => '194.250.105.1,195.101.206.1,212.208.23.6,212.198.0.221',
63
        'DMZ_IF' => '1',
64
        'DMZ_IF_DEV' => 'eth2',
65
        'DMZ_IF_IP' => '192.168.234.1',
66
        'DMZ_IF_MASK' => '255.255.255.0',
67
        'DNS_PRIMARY' => '%dns_primary_ip%',
68
        'DNS_SECONDARY' => '%dns_secondary_ip%',
69
        'DOMAIN' => '%slis_name%.ac-grenoble.fr',
70
        'EXTERNAL_IF_DEV' => 'eth0',
71
        'EXTERNAL_IF_IP' => '%slis_wan_ip%',
72
        'EXTERNAL_IF_MASK' => '%slis_wan_netmask%',
73
        'GATEWAY' => '%slis_gateway%',
74
        'HOSTNAME' => '%slis_name%',
75
        'INTERNAL_IF_DEV' => 'eth1',
76
        'INTERNAL_IF_IP' => '%slis_lan_ip%',
77
        'INTERNAL_IF_MASK' => '%slis_lan_netmask%',
78
        'IP_DEBIAN' => '192.168.234.4',
79
        'IP_DOM0' => '192.168.234.2',
80
        'IP_LCS' => '192.168.234.6',
81
        'IP_TUN_SLIS' => '%vtun_tunnel_slis_ip%',
82
        'IP_TUN_SVR' => '%vtun_tunnel_server_ip%',
5498 plb 83
        'LDAP_ADMIN_PW' => 'AUTO',
5461 plb 84
        'LDAP_ADMIN_RDN' => 'admin',
85
        'LDAP_BASE_DN' => 'ou=%site_code%,ou=ac-grenoble,ou=education,o=gouv,c=fr',
86
        'LDAP_COMPUTERS_RDN' => 'Computers',
87
        'LDAP_GROUPS_RDN' => 'Groups',
88
        'LDAP_MAIL_DOMAIN' => '%slis_name%.ac-grenoble.fr',
89
        'LDAP_PARKS_RDN' => 'Parcs',
90
        'LDAP_PEOPLE_RDN' => 'People',
91
        'LDAP_RIGHTS_RDN' => 'Rights',
92
        'LDAP_SERVER' => '192.168.234.6',
93
        'LDAP_TLS' => '1',
94
        'LDAP_TRASH_RDN' => 'Trash',
95
        'LOCAL_ADMIN_PW' => '%slis_admin_pass%',
96
        'LOCAL_PROXY_PORT' => '3128',
97
        'LOCAL_ZONE_NAME' => 'intranet.local',
98
        'LOG_FACILITY' => 'local5',
99
        'MAX_MESSAGE_SIZE' => '2000000',
100
        'MDA_IP' => '192.168.234.6',
101
        'MONITOR_ENABLE' => 'true',
102
        'MONITOR_FREQUENCY' => 'HOURLY',
103
        'MTA_IP' => '192.168.234.6',
104
        'NREDIR' => '15',
105
        'NTP_SERVER' => 'ntp.ac-grenoble.fr',
106
        'PARENT_ICP_PORT' => '3130',
107
        'PARENT_PORT' => '3128',
5500 plb 108
        'PASS' => '\$1\$m9qQQMXn\$qoWTahZHGVwHp3hdSaz5b.',
5461 plb 109
        'PING_HOST' => '193.54.149.10',
110
        'PROXY_CACHE' => 'na',
111
        'PROXYON' => '1',
112
        'PROXY_TRANS' => '0',
113
        'REDIR_BASE' => 'http://www.ac-grenoble.fr/redir',
114
        'RELAY_HOST' => 'smtp.ac-grenoble.fr',
115
        'ROUTER_TYPE' => '0',
116
        'ROUTE_TUN_MASK' => '255.255.255.255',
117
        'ROUTE_TUN_NET' => '193.54.149.10',
118
        'RSYNC_HOST' => '193.54.149.10',
119
        'RSYNC_MODULE' => 'slis-update_4.1',
120
        'SECRET' => '%vtun_secret%',
121
        'SENDMAILON' => '1',
122
        'SLIM_HOST' => '195.221.235.245',
123
        'SLIM_MAX_AGE' => '36000',
124
        'SLIM_MONITOR_PATH' => 'slim/scripts/monitor/get',
125
        'SLIM_RETRY_TIME' => '5',
126
        'SLISMASTER' => 'slismaster@ac-grenoble.fr',
127
        'SQUID_AUTH' => '0',
128
        'UPDATE_TIME_WINDOW' => '01-03',
129
        'USER' => '%vtun_user%',
130
        'VERSION_NUM' => '4.1',
131
        'VTUN_RETRIES' => '0',
132
        'VTUN_SVR_PORT' => '%vtun_server_port%',
133
        'VTUN_SVR' => '%vtun_server_ip%',
134
        'VTUN' => '%vtun%'
135
    );
136
 
137
    $slis41_lcs = array(
138
        'BROADCAST' => '192.168.234.255',
139
        'CACHEDIRSIZE' => '100',
140
        'COUNTRYNAME' => 'FR',
141
        'DEFAULT_SHELL' => '/bin/true',
142
        'DNS_PRIMARY' => '192.168.234.1',
143
        'DNS_SECONDARY' => '192.168.234.1',
144
        'DOMAIN' => '%slis_name%.ac-grenoble.fr',
145
        'EXTERNAL_IF_DEV' => 'eth0',
146
        'GATEWAY' => '192.168.234.1',
147
        'HOSTNAME' => 'lcs',
148
        'IPADDR0' =>  '192.168.234.6',
5498 plb 149
        'LCSMGRPASS' => 'AUTO',
150
        'LDAP_ADMIN_PW' => 'AUTO',
5461 plb 151
        'LDAP_ADMIN_RDN' => 'admin',
152
        'LDAP_BASE_DN' => 'ou=%site_code%,ou=ac-grenoble,ou=education,o=gouv,c=fr',
153
        'LDAP_COMPUTERS_RDN' => 'Computers',
154
        'LDAP_GROUPS_RDN' => 'Groups',
155
        'LDAP_MAIL_DOMAIN' => '%slis_name%.ac-grenoble.fr',
156
        'LDAP_MASTER_SERVER' => '127.0.0.1',
157
        'LDAP_PARKS_RDN' => 'Parcs',
158
        'LDAP_PEOPLE_RDN' => 'People',
159
        'LDAP_PORT' => '389',
160
        'LDAP_RID' => '123',
161
        'LDAP_RIGHTS_RDN' => 'Rights',
162
        'LDAP_SERVER' => '127.0.0.1',
163
        'LDAP_TRASH_RDN' => 'Trash',
164
        'LOCAL_ADMIN_PW' => '%slis_admin_pass%',
165
        'LOCALITYNAME' => 'Academie de Grenoble',
166
        'MONITOR_ENABLE' => 'true',
167
        'MONITOR_FREQUENCY' => 'HOURLY',
168
        'MTA_IP' => '192.168.234.6',
5499 plb 169
        'MYSQLPW' => 'AUTO',
5461 plb 170
        'NETMASK0' => '255.255.255.0',
171
        'NETWORK' => '192.168.234.0',
172
        'NTP_SERVER' => '192.168.234.1',
173
        'ORGANIZATIONALUNITNAME' => '%site_name%',
174
        'ORGANIZATIONNAME' => 'CARMI',
175
        'PROVINCENAME' => 'Academie de Grenoble',
176
        'RELAY_HOST' => 'smtp.ac-grenoble.fr',
177
        'SLIM_HOST' => '195.221.235.245',
178
        'SLIM_MAX_AGE' => '36000',
179
        'SLIM_MONITOR_PATH' => 'slim/scripts/monitor/get',
180
        'SLIM_RETRY_TIME' => '5',
181
        'SLISMASTER' => 'slismaster@ac-grenoble.fr',
182
        'TYPE_GROUPS' => 'posixGroup',
183
        'UID_POLICY' => '4',
184
        'URL_MAJMD5' => 'ftp://193.49.66.4/LcsMajMD5-ETCH',
185
        'URL_MAJMOD' => 'http://linux.crdp.ac-caen.fr/modulesLcsEtchXP/',
186
        'URL_MAJPLUG' => 'http://linux.crdp.ac-caen.fr/pluginsLcs/',
187
        'URL_MAJTGZ' => 'ftp://debian.crdp.ac-caen.fr/debian/LcsMaj/LcsMajTGZ-ETCH',
188
        'VERSION_NUM' => '2.0',
189
        'VLANSC' => '192.168.234.0/24',
190
        'SE3_IP' => '172.16.0.11',
191
        'SE3_DOMAIN' => '%site_code%',
192
        'SE3_NETBIOS' => 'SRV01'
193
    );
194
 
195
    /*
196
     * Retrieve possible values that already exist.
197
     */
198
    $query = "SELECT variable FROM file_defvalue WHERE file='slis41_slis.conf' and pop_id='0' and type='' and method='';";
199
    $result = pg_exec($slim_db, $query);
200
    if (! $result ) {
201
        print pg_last_error();
202
        return false;
203
    }
204
    $query = "SELECT variable FROM file_defvalue WHERE file='slis41_lcs.conf' and pop_id='0' and type='' and method='';";
205
    $result2 = pg_exec($slim_db, $query);
206
    if (! $result2 ) {
207
        print pg_last_error();
208
        return false;
209
    }
210
 
211
    $arRes = pg_fetch_array($result);
212
    $arRes2 = pg_fetch_array($result2);
213
 
214
    $arSLIS41Values = array();
215
    foreach ($arRes as $ar) {
216
        array_push($arSLIS41Values,$ar[0]);
217
    }
218
 
219
    $arLCS20Values = array();
220
    foreach ($arRes2 as $ar) {
221
        array_push($arLCS20Values, $ar[0]);
222
    }
223
 
224
    /*
225
     * Add the new parameters.
226
     */
227
    foreach($slis41_slis as $key => $value) {
228
        if ( ! in_array($key, $arSLIS41Values)) {
229
            $query = "INSERT INTO file_defvalue VALUES(DEFAULT,'$key','','0','$value','','slis41_slis.conf');";
230
            pg_exec($slim_db,$query);
231
        }
232
    }
233
 
234
    foreach($slis41_lcs as $key => $value) {
235
        if ( ! in_array($key, $arLCS20Values)) {
236
            $query = "INSERT INTO file_defvalue VALUES(DEFAULT,'$key','','0','$value','','slis41_lcs.conf');";
237
            pg_exec($slim_db,$query);
238
        }
239
    }
240
 
241
    return true;
242
}
243
 
244
function insert_slis41_checkversion_2_0_5_1() {
245
    global $slim_db;
246
 
247
    echo "<br/>Add slis4.1, host4.1 & lcs2.0 monitoring versions if needed";
248
 
249
    $vers= array('slis4.1','host4.1','lcs2.0');
250
    foreach ($vers as $ver) {
251
        $query = "select count(*) from version_slis where version_name='$ver'";
252
        $result = pg_exec($slim_db,$query);
253
        if ( ! $result ) {
254
            print pg_last_error();
255
            return false;
256
        }
257
 
258
        $count = pg_fetch_result($result,0);
259
        if ( $count == 0 ) {
260
            $query = "insert into version_slis values ('$ver')";
261
            $result = pg_exec($slim_db,$query);
262
        }
263
    }
264
 
265
    return true;
266
}
267