1
|
<?php
|
2
|
|
3
|
|
4
|
|
5
|
|
6
|
|
7
|
|
8
|
|
9
|
|
10
|
|
11
|
|
12
|
|
13
|
|
14
|
|
15
|
|
16
|
|
17
|
|
18
|
|
19
|
|
20
|
|
21
|
|
22
|
|
23
|
|
24
|
|
25
|
|
26
|
|
27
|
include_once("AbE_API.php");
|
28
|
include_once("AbE_Users.php");
|
29
|
$page = new AbE_Webadmin_Page();
|
30
|
|
31
|
|
32
|
|
33
|
$envoyer = $_REQUEST["envoyer"];
|
34
|
$mac = base64_decode($_REQUEST["mac"]);
|
35
|
$hostname = $_REQUEST["hostname"];
|
36
|
$action = $_REQUEST["action"];
|
37
|
$ip = $_REQUEST["ip"];
|
38
|
$vlan = $_REQUEST["vlan"];
|
39
|
$backupname = $_REQUEST["backupname"];
|
40
|
$restaurename = $_REQUEST["restaurename"];
|
41
|
$adminlocalpass = $_REQUEST["adminlocalpass"];
|
42
|
$admindomainpass = $_REQUEST["admindomainpass"];
|
43
|
$textelocal = "";
|
44
|
|
45
|
|
46
|
if($vlan) {
|
47
|
$comptemachine = $hostname . "." . $vlan;
|
48
|
}
|
49
|
else {
|
50
|
$comptemachine = $hostname;
|
51
|
}
|
52
|
|
53
|
global $conf_rep_syslinux;
|
54
|
if(trim($hostname) != "") {
|
55
|
$tabconftx = recup_infos($comptemachine);
|
56
|
$computerarch = $tabconftx["computerarch"];
|
57
|
}
|
58
|
|
59
|
if(file_exists("/etc/" . $metamode . "/rvd") && ! file_exists("/etc/" . $metamode . "/wifi")) {
|
60
|
$erreurs .= "<img src=\"/images/attention.png\" align=\"absmiddle\"> " . _("Attention, le système wifi n'est pas configuré et ne sera donc pas <a href=\"../internet/chip.php\">automatiquement déployé</a>.");
|
61
|
}
|
62
|
|
63
|
$textelocal .= "<form action=\"$PHP_SELF\" method=\"post\" name=\"form\">
|
64
|
<input type=\"hidden\" name=\"hostname\" value=\"$hostname\">
|
65
|
<input type=\"hidden\" name=\"vlan\" value=\"$vlan\">
|
66
|
<input type=\"hidden\" name=\"computerarch\" value=\"$computerarch\">
|
67
|
<input type=\"hidden\" name=\"mac\" value=\"" . base64_encode($mac) . "\">
|
68
|
<input type=\"hidden\" name=\"ip\" value=\"$ip\">\n";
|
69
|
|
70
|
|
71
|
if(!isset($envoyer)){
|
72
|
$textelocal .= "$erreurs
|
73
|
<h3 style=\"text-align: justify;\">" . sprintf(_("Gestion du mode de démarrage du poste %s :"), $comptemachine) . "</h3>
|
74
|
<select name=\"action\">
|
75
|
<option value=\"startx\" onClick=\"hide(document.getElementById('backupnamezone')); hide(document.getElementById('restaurenamezone'));\">" . _("Démarrer l'ordinateur par le réseau en client léger - TX.") . "</option>
|
76
|
<option value=\"hdd\" onClick=\"hide(document.getElementById('backupnamezone')); hide(document.getElementById('restaurenamezone'));\">" . _("Démarrer l'ordinateur sur le système d'exploitation local (installé sur le disque dur).") . "</option>
|
77
|
<option value=\"backup\" onClick=\"unhide(document.getElementById('backupnamezone')); hide(document.getElementById('restaurenamezone'));\">" . _("Sauvegarder le disque dur du poste sur le serveur pour pouvoir le restaurer ultérieurement.") . "</option>
|
78
|
<option value=\"backupparts\" onClick=\"unhide(document.getElementById('backupnamezone')); hide(document.getElementById('restaurenamezone'));\">" . _("Sauvegarder les deux premieres partitions du disque dur du poste sur le serveur.") . "</option>
|
79
|
<option value=\"restaure\" onClick=\"hide(document.getElementById('backupnamezone')); unhide(document.getElementById('restaurenamezone'));\">" . _("Restaurer le disque dur du poste depuis une image stockée sur le serveur.") . "</option>
|
80
|
<option value=\"restaurelocal\" onClick=\"hide(document.getElementById('backupnamezone')); hide(document.getElementById('restaurenamezone'));\">" . _("Restaurer le disque dur du poste depuis la partition cachée.") . "</option>
|
81
|
<option value=\"\" onClick=\"hide(document.getElementById('backupnamezone')); hide(document.getElementById('restaurenamezone'));\"> " . _("--------- ATTENTION, LES OPTIONS CI-DESSOUS SONT DANGEREUSES ---------") . "</option>
|
82
|
<option value=\"installboot\" onClick=\"hide(document.getElementById('backupnamezone')); hide(document.getElementById('restaurenamezone'));\">" . _("Copier la disquette de démarrage sur le disque dur (écrasement du disque).") . "</option>
|
83
|
<option value=\"backuplocal\" onClick=\"hide(document.getElementById('backupnamezone')); hide(document.getElementById('restaurenamezone'));\">" . _("Sauvegarder le disque dur du poste sur la partition cachée (formatage brutal de la 4° partition).") . "</option>
|
84
|
</select>
|
85
|
|
86
|
<br />
|
87
|
<br />
|
88
|
|
89
|
<div id=\"backupnamezone\" style=\"display: none; visibility: hidden;\">" . _("Nom de la sauvegarde :") . "<input type=\"text\" name=\"backupname\" value=\"\"></div>
|
90
|
|
91
|
<div id=\"restaurenamezone\" style=\"display: none; visibility: hidden;\">
|
92
|
<table>
|
93
|
<tr>
|
94
|
<td>" . _("Choisissez la sauvegarde à restaurer") . "</td>
|
95
|
<td> <select name=\"restaurename\">\n";
|
96
|
|
97
|
|
98
|
$rep = "/home/machines/groups/default/";
|
99
|
$handle=opendir($rep);
|
100
|
while ($file = readdir($handle)){
|
101
|
if(ereg("^imagegeneric",$file)) {
|
102
|
$filename = $file;
|
103
|
$tabimages[] = $filename;
|
104
|
}
|
105
|
}
|
106
|
|
107
|
|
108
|
$rep = "/home/machines/$comptemachine/";
|
109
|
$handle=opendir($rep);
|
110
|
while ($file = readdir($handle)){
|
111
|
if(ereg("^imagedisque",$file)) {
|
112
|
$filename = str_replace("imagedisque-","",$file);
|
113
|
$tabimages[] = $filename;
|
114
|
}
|
115
|
}
|
116
|
|
117
|
if(is_array($tabimages)) {
|
118
|
sort($tabimages);
|
119
|
for($i = 0;$i < count($tabimages); $i++)
|
120
|
$textelocal .= "<option value=\"" . $tabimages[$i] . "\">" . $tabimages[$i] . "</option>\n";
|
121
|
}
|
122
|
|
123
|
$textelocal .= "
|
124
|
</select></td>
|
125
|
</tr>
|
126
|
<tr bgcolor=\"#eaeaea\">
|
127
|
<td>Indiquez ici le mot de passe que vous voulez affecter à l'administrateur local:</td>
|
128
|
<td><input type=\"text\" name=\"adminlocalpass\"></td>
|
129
|
</tr>
|
130
|
<tr>
|
131
|
<td>Mot de passe de l'administrateur du domaine (abuladmin) : </td>
|
132
|
<td><input type=\"text\" name=\"admindomainpass\"></td>
|
133
|
</tr>
|
134
|
</table>
|
135
|
</div>
|
136
|
|
137
|
<br />
|
138
|
|
139
|
<input type=\"submit\" name=\"envoyer\" value=\"" . _("Suivant >>") . "\">\n";
|
140
|
}
|
141
|
else {
|
142
|
$specialcase = "";
|
143
|
if($action == "hdd") {
|
144
|
|
145
|
|
146
|
|
147
|
$syslinuxfile = "$conf_rep_syslinux/01-" . strtolower(strtr($mac,":","-"));
|
148
|
$syslinux = "default local
|
149
|
label local
|
150
|
kernel chain.c32
|
151
|
append hd0
|
152
|
";
|
153
|
|
154
|
if ((!isset($installation_name)) || ($installation_name == "")) {
|
155
|
$installation_name="non_defini";
|
156
|
}
|
157
|
|
158
|
$cmd .= "
|
159
|
#on copie le syslinux original
|
160
|
if [ -f \"/home/machines/" . $comptemachine . "/boot.pxe\" ]; then
|
161
|
cp /home/machines/" . $comptemachine . "/boot.pxe /home/machines/" . $comptemachine . "/boot.normal
|
162
|
rm -f /home/machines/" . $comptemachine . "/boot.pxe
|
163
|
fi
|
164
|
";
|
165
|
|
166
|
$syslinuxsymlink = "/home/machines/" . $comptemachine . "/boot.pxe";
|
167
|
|
168
|
$cmd .= "
|
169
|
if [ ! -e $syslinuxsymlink ]; then
|
170
|
ln $syslinuxfile $syslinuxsymlink
|
171
|
fi
|
172
|
|
173
|
#on ecrase le syslinux [$syslinuxfile] dans tous les cas (nouveau ou modif)
|
174
|
echo \"$syslinux\" > $syslinuxfile || true
|
175
|
chown " . $comptemachine . " /home/machines/" . $comptemachine . "/boot.*
|
176
|
#on pose le flag pour confirmer le backup
|
177
|
touch /home/machines/" . $comptemachine . "/make_backup
|
178
|
chown " . $comptemachine . " /home/machines/" . $comptemachine . "/make_backup
|
179
|
";
|
180
|
|
181
|
fichier_script($cmd,"ltsconf",$textelocal);
|
182
|
}
|
183
|
else {
|
184
|
$imagename = "imagedisque";
|
185
|
if($action == "backup" || $action == "backupparts" ) {
|
186
|
$specialcase = "backup-restaure";
|
187
|
if(trim($backupname) != "") {
|
188
|
$imagename .= "-" . trim($backupname);
|
189
|
}
|
190
|
}
|
191
|
if($action == "restaure") {
|
192
|
$specialcase = "backup-restaure";
|
193
|
if(trim($restaurename) != "") {
|
194
|
|
195
|
if(ereg("^imagegeneric",$restaurename)) {
|
196
|
$imagename = $restaurename;
|
197
|
|
198
|
|
199
|
|
200
|
|
201
|
|
202
|
if($metamode == "abuledu") {
|
203
|
$windowsdomain = "ABULEDU";
|
204
|
$admindomainlogin = "abuladmin";
|
205
|
}
|
206
|
else {
|
207
|
$windowsdomain = "NOUVA";
|
208
|
$admindomainlogin = "servadmin";
|
209
|
}
|
210
|
|
211
|
$windowskey = $tabconftx['windowslicence'];
|
212
|
$sha512pass = exec("mkpasswd -m sha-512 " . $adminlocalpass);
|
213
|
|
214
|
|
215
|
|
216
|
|
217
|
$cmd .= "rm -f /home/machines/" . $comptemachine . "/" . $imagename . " || true
|
218
|
(
|
219
|
cd /home/machines/" . $comptemachine . "
|
220
|
ln -s ../groups/default/" . $imagename . " $imagename
|
221
|
)
|
222
|
|
223
|
cat > /home/machines/" . $comptemachine . "/.maquette << EOF
|
224
|
$imagename
|
225
|
EOF
|
226
|
|
227
|
cat > /home/machines/" . $comptemachine . "/horizon.postrestaure << EOF
|
228
|
#!/bin/bash
|
229
|
|
230
|
mkdir /mnt/windows
|
231
|
|
232
|
if [ -f /home/partimag/$comptemachine/$imagename/sda1.ntfs* -o -f /home/partimag/$comptemachine/$imagename/sda3.ntfs* ]; then
|
233
|
# on est sur un seven (sda1 ou GPT -> sda3)
|
234
|
if [ -e /dev/sda ]; then
|
235
|
if [ -f /home/partimag/$comptemachine/$imagename/sda1.ntfs* ]; then
|
236
|
mount.ntfs-3g /dev/sda1 /mnt/windows
|
237
|
elif [ -f /home/partimag/$comptemachine/$imagename/sda3.ntfs* ]; then
|
238
|
mount.ntfs-3g /dev/sda3 /mnt/windows
|
239
|
fi
|
240
|
elif [ -e /dev/hda ]; then
|
241
|
mount.ntfs-3g /dev/hda1 /mnt/windows
|
242
|
fi
|
243
|
#sur un seven avec une partition de 100Mo en debut de disque
|
244
|
if [ ! -d /mnt/windows/Windows/System32/sysprep/ ]; then
|
245
|
umount /mnt/windows
|
246
|
if [ -e /dev/sda ]; then
|
247
|
mount.ntfs-3g /dev/sda2 /mnt/windows
|
248
|
elif [ -e /dev/hda ]; then
|
249
|
mount.ntfs-3g /dev/hda2 /mnt/windows
|
250
|
fi
|
251
|
fi
|
252
|
|
253
|
if [ -d /mnt/windows/Windows/System32/sysprep/ ]; then
|
254
|
#windows seven
|
255
|
rm /mnt/windows/Windows/Panther/unattend.xml
|
256
|
cd /mnt/windows/Windows/System32/sysprep/
|
257
|
cp -f /home/partimag/$comptemachine/$imagename/unattend.xml unattend.xml
|
258
|
sed -i -e s/HORIZONDOMAIN/" . $windowsdomain . "/ unattend.xml
|
259
|
sed -i -e s/DOMAINPASS/" . $admindomainpass . "/ unattend.xml
|
260
|
sed -i -e s/DOMAINADMIN/" . $admindomainlogin . "/ unattend.xml
|
261
|
sed -i -e s/HORIZONADMINPASS/" . $adminlocalpass . "/ unattend.xml
|
262
|
sed -i -e s/HORIZONWINDOWSKEY/" . $windowskey . "/ unattend.xml
|
263
|
sed -i -e s/HORIZONCOMPUTERNAME/" . $hostname . "/ unattend.xml
|
264
|
sed -i -e s/HZNCOMPUTERNAME/" . $hostname . "/ unattend.xml
|
265
|
sed -i -e s/HORIZONINSTALLATIONNAME/\\\"" . str_replace(" ","-",$installation_name) . "\\\"/ unattend.xml
|
266
|
# cp -f Unattend.xml save.txt
|
267
|
cd /mnt/windows/Windows/Setup/Scripts/
|
268
|
cp -f /home/partimag/$comptemachine/$imagename/SetupComplete.cmd .
|
269
|
sed -i -e s/HORIZONDOMAIN/" . $windowsdomain . "/g SetupComplete.cmd
|
270
|
sed -i -e s/DOMAINPASS/" . $admindomainpass . "/ SetupComplete.cmd
|
271
|
sed -i -e s/DOMAINADMIN/" . $admindomainlogin . "/ SetupComplete.cmd
|
272
|
cp -f /home/partimag/$comptemachine/$imagename/netdom.exe /mnt/windows/Windows/System32/
|
273
|
cp -f /home/partimag/$comptemachine/$imagename/netdom.exe.mui /mnt/windows/Windows/System32/fr-FR/
|
274
|
cd /
|
275
|
elif [ -d /mnt/windows/sysprep ]; then
|
276
|
#windows xp
|
277
|
if [ -e /dev/sda ]; then
|
278
|
mount.ntfs-3g /dev/sda1 /mnt/windows
|
279
|
elif [ -e /dev/hda ]; then
|
280
|
mount.ntfs-3g /dev/hda1 /mnt/windows
|
281
|
fi
|
282
|
if [ -d /mnt/windows/sysprep ]; then
|
283
|
cd /mnt/windows/sysprep
|
284
|
if [ ! -f sysprep.inf -a -f /home/partimag/$comptemachine/$imagename/sysprep.inf ]; then
|
285
|
cp -f /home/partimag/$comptemachine/$imagename/sysprep.inf .
|
286
|
fi
|
287
|
sed -i -e s/'^\([[:space:]]*\)AdminPassword=.'*/'\\1AdminPassword=\"" . $adminlocalpass . "\"'/ sysprep.inf
|
288
|
sed -i -e s/ProductKey=.*/ProductKey=" . $windowskey . "/ sysprep.inf
|
289
|
sed -i -e s/ComputerName=.*/ComputerName=" . $hostname . "/ sysprep.inf
|
290
|
sed -i -e s/JoinDomain=.*/JoinDomain=" . $windowsdomain . "/ sysprep.inf
|
291
|
sed -i -e s/DomainAdmin=.*/DomainAdmin=" . $admindomainlogin . "/ sysprep.inf
|
292
|
sed -i -e s/DomainAdminPassword=.*/DomainAdminPassword=" . $admindomainpass . "/ sysprep.inf
|
293
|
sed -i -e s/'OrgName=.*'/'OrgName=\\\"" . $installation_name . "\\\"'/ sysprep.inf
|
294
|
sed -i -e s/'FullName=.*'/'FullName=\\\"" . $installation_name . "\\\"'/ sysprep.inf
|
295
|
cd /mnt/windows
|
296
|
find Docu* -name BTT* -exec rm -rf {} \;
|
297
|
find Docu* -name McAfee* -exec rm -rf {} \;
|
298
|
cd /
|
299
|
fi
|
300
|
umount /mnt/windows
|
301
|
fi
|
302
|
fi
|
303
|
|
304
|
mkdir /mnt/linux
|
305
|
|
306
|
if [ -f /home/partimag/$comptemachine/$imagename/sda1.ext3* ]; then
|
307
|
if [ -e /dev/sda ]; then
|
308
|
mount -t ext3 /dev/sda1 /mnt/linux
|
309
|
elif [ -e /dev/hda ]; then
|
310
|
mount -t ext3 /dev/hda1 /mnt/linux
|
311
|
fi
|
312
|
PLINUX=1
|
313
|
elif [ -f /home/partimag/$comptemachine/$imagename/sda1.ext* ]; then
|
314
|
if [ -e /dev/sda ]; then
|
315
|
mount -t ext4 /dev/sda1 /mnt/linux
|
316
|
elif [ -e /dev/hda ]; then
|
317
|
mount -t ext4 /dev/hda1 /mnt/linux
|
318
|
fi
|
319
|
PLINUX=1
|
320
|
elif [ -f /home/partimag/$comptemachine/$imagename/sda2.ext3* ]; then
|
321
|
if [ -e /dev/sda ]; then
|
322
|
mount -t ext3 /dev/sda2 /mnt/linux
|
323
|
elif [ -e /dev/hda ]; then
|
324
|
mount -t ext3 /dev/hda2 /mnt/linux
|
325
|
fi
|
326
|
PLINUX=2
|
327
|
elif [ -f /home/partimag/$comptemachine/$imagename/sda2.ext* ]; then
|
328
|
if [ -e /dev/sda ]; then
|
329
|
mount -t ext4 /dev/sda2 /mnt/linux
|
330
|
elif [ -e /dev/hda ]; then
|
331
|
mount -t ext3 /dev/hda2 /mnt/linux
|
332
|
fi
|
333
|
PLINUX=2
|
334
|
elif [ -f /home/partimag/$comptemachine/$imagename/sda3.ext3* ]; then
|
335
|
if [ -e /dev/sda ]; then
|
336
|
mount -t ext3 /dev/sda3 /mnt/linux
|
337
|
elif [ -e /dev/hda ]; then
|
338
|
mount -t ext3 /dev/hda3 /mnt/linux
|
339
|
fi
|
340
|
PLINUX=3
|
341
|
elif [ -f /home/partimag/$comptemachine/$imagename/sda3.ext* ]; then
|
342
|
if [ -e /dev/sda ]; then
|
343
|
mount -t ext4 /dev/sda3 /mnt/linux
|
344
|
elif [ -e /dev/hda ]; then
|
345
|
mount -t ext3 /dev/hda3 /mnt/linux
|
346
|
fi
|
347
|
PLINUX=3
|
348
|
elif [ -f /home/partimag/$comptemachine/$imagename/sda4.ext3* ]; then
|
349
|
if [ -e /dev/sda ]; then
|
350
|
mount -t ext3 /dev/sda4 /mnt/linux
|
351
|
elif [ -e /dev/hda ]; then
|
352
|
mount -t ext3 /dev/hda4 /mnt/linux
|
353
|
fi
|
354
|
PLINUX=4
|
355
|
elif [ -f /home/partimag/$comptemachine/$imagename/sda4.ext* ]; then
|
356
|
if [ -e /dev/sda ]; then
|
357
|
mount -t ext4 /dev/sda4 /mnt/linux
|
358
|
elif [ -e /dev/hda ]; then
|
359
|
mount -t ext3 /dev/hda4 /mnt/linux
|
360
|
fi
|
361
|
PLINUX=4
|
362
|
fi
|
363
|
if [ ! -z \"\\\${PLINUX}\" ]; then
|
364
|
rm -f /mnt/linux/etc/udev/rules.d/*persist*
|
365
|
if [ -f /mnt/linux/etc/abuledu/wifi ]; then
|
366
|
rm -f /mnt/linux/etc/abuledu/wifi
|
367
|
fi
|
368
|
if [ -f /mnt/linux/etc/abuledu/upgradeversion ]; then
|
369
|
rm -f /mnt/linux/etc/abuledu/upgradeversion
|
370
|
fi
|
371
|
if [ -d /mnt/linux/etc ]; then
|
372
|
cd /mnt/linux/etc
|
373
|
cp -a /home/partimag/$comptemachine/$imagename/linux/etc/* .
|
374
|
sed -i -e s\"%\\\(^root\\\):[^:]*\"%\"\\\\1:\"" . escapeshellarg(escapeshellcmd($sha512pass)) . "% shadow
|
375
|
cd /mnt/linux/boot/grub
|
376
|
sed -i -e s%\"^default.*\"%\"default saved\"% menu.lst
|
377
|
sed -i -e s%\"savedefault=.*\"%\"savedefault=true\"% menu.lst
|
378
|
sed -i -e s%\"howmany=.*\"%\"howmany=2\"% menu.lst
|
379
|
cd /
|
380
|
fi
|
381
|
umount /mnt/linux
|
382
|
fi
|
383
|
|
384
|
EOF
|
385
|
|
386
|
chmod +rx /home/machines/" . $comptemachine . "/horizon.postrestaure || true
|
387
|
chmod og+r /home/machines/" . $comptemachine . "/" . $imagename . "/*
|
388
|
chmod +x /home/machines/" . $comptemachine . "/" . $imagename . "/horizon.postrestaure || true
|
389
|
";
|
390
|
|
391
|
|
392
|
|
393
|
$cmd .= "mkdir -p /home/machines/" . $comptemachine . "/" . $imagename . "/linux/etc/" . $metamode . "
|
394
|
chmod 755 /home/machines/" . $comptemachine . "/" . $imagename . "/linux -R
|
395
|
if [ -f /etc/" . $metamode . "/wifi ]; then
|
396
|
cp -a /etc/" . $metamode . "/wifi /home/machines/" . $comptemachine . "/" . $imagename . "/linux/etc/" . $metamode . "/
|
397
|
chown root:machines /home/machines/" . $comptemachine . "/" . $imagename . "/linux/etc/" . $metamode . "/wifi
|
398
|
chmod 640 /home/machines/" . $comptemachine . "/" . $imagename . "/linux/etc/" . $metamode . "/wifi
|
399
|
fi
|
400
|
|
401
|
chown " . $comptemachine . ":machines /home/machines/" . $comptemachine . "/" . $imagename . "/ -R
|
402
|
|
403
|
";
|
404
|
}
|
405
|
|
406
|
else {
|
407
|
$imagename .= "-" . trim($restaurename);
|
408
|
}
|
409
|
|
410
|
|
411
|
$syslinuxfile = "$conf_rep_syslinux/01-" . strtolower(strtr($mac,":","-"));
|
412
|
$syslinux = "default local
|
413
|
label local
|
414
|
kernel chain.c32
|
415
|
append hd0
|
416
|
";
|
417
|
|
418
|
$syslinuxsymlink = "/home/machines/" . $comptemachine . "/boot.pxe";
|
419
|
|
420
|
$cmd .= "
|
421
|
if [ ! -e $syslinuxsymlink ]; then
|
422
|
ln $syslinuxfile $syslinuxsymlink
|
423
|
fi";
|
424
|
|
425
|
$cmd .= "
|
426
|
#on ecrase le syslinux dans tous les cas (nouveau ou modif)
|
427
|
echo \"$syslinux\" > $syslinuxfile || true
|
428
|
";
|
429
|
}
|
430
|
}
|
431
|
|
432
|
|
433
|
$tabconftx["screen_01"] = "startx";
|
434
|
|
435
|
|
436
|
|
437
|
$tabconftx["localstorage"] = "N";
|
438
|
$textelocal .= fixe_tx($tabconftx, $mac, $ip, "", $hostname, 0, 0,"ltsp44");
|
439
|
$passwordpc = trim(`apg -a1 -m 6 -x 8 -n 1 -M NCL -q 2>&1`);
|
440
|
|
441
|
$cmd .= "
|
442
|
if [ -f /home/machines/" . $comptemachine . "/.ssh/id_rsa ]; then
|
443
|
rm -f /home/machines/" . $comptemachine . "/.ssh/id_rsa*
|
444
|
fi
|
445
|
if [ ! -d /opt/ltsp44/i386/etc/ryxeo/$comptemachine ]; then
|
446
|
mkdir -p /opt/ltsp44/i386/etc/ryxeo/$comptemachine
|
447
|
fi
|
448
|
if [ ! -f /home/machines/" . $comptemachine . "/.machinepass ]; then
|
449
|
echo \"" . $passwordpc . "\" > /home/machines/" . $comptemachine . "/.machinepass
|
450
|
chmod 600 /home/machines/" . $comptemachine . "/.machinepass
|
451
|
horizon-modify user --login=" . $comptemachine . " --password=" . $passwordpc . " || true
|
452
|
fi
|
453
|
if [ ! -d /home/machines/" . $comptemachine . "/.ssh ]; then
|
454
|
mkdir /home/machines/" . $comptemachine . "/.ssh
|
455
|
fi
|
456
|
|
457
|
ssh-keygen -t rsa -N '' -f /home/machines/$comptemachine/.ssh/id_rsa
|
458
|
if [ -f /home/machines/" . $comptemachine . "/.ssh/id_rsa ]; then
|
459
|
cp /home/machines/" . $comptemachine . "/.ssh/id_rsa /opt/ltsp44/i386/etc/ryxeo/" . $comptemachine . "/id_rsa
|
460
|
cp /home/machines/" . $comptemachine . "/.ssh/id_rsa.pub /opt/ltsp44/i386/etc/ryxeo/" . $comptemachine . "/id_rsa.pub
|
461
|
cp /home/machines/" . $comptemachine . "/.ssh/id_rsa.pub /home/machines/" . $comptemachine . "/.ssh/authorized_keys
|
462
|
fi
|
463
|
|
464
|
setfacl -b /home/machines/" . $comptemachine . "/.ssh
|
465
|
chown $comptemachine /home/machines/" . $comptemachine . "/.ssh -R
|
466
|
chmod 700 /home/machines/" . $comptemachine . "/.ssh
|
467
|
";
|
468
|
|
469
|
|
470
|
$cmd .= "
|
471
|
rm -f /opt/ltsp44/i386/etc/ryxeo/$comptemachine/backup
|
472
|
echo \"" . $comptemachine . ";nesertplusguylarrieudedicace;" . $imagename . "\" > /opt/ltsp44/i386/etc/ryxeo/$comptemachine/backup
|
473
|
chmod 700 /opt/ltsp44/i386/etc/ryxeo/$comptemachine
|
474
|
chmod 600 /opt/ltsp44/i386/etc/ryxeo/$comptemachine/*
|
475
|
chown $comptemachine /opt/ltsp44/i386/etc/ryxeo/$comptemachine -R
|
476
|
";
|
477
|
|
478
|
|
479
|
$appendopt = " SCREEN_01=" . $action;
|
480
|
|
481
|
$syslinuxfile = "$conf_rep_syslinux/01-" . strtolower(strtr($mac,":","-"));
|
482
|
$syslinux = make_syslinux_block($computerarch,$tabconftx["appendopt"] . $appendopt, $specialcase, $imagename, $action);
|
483
|
|
484
|
$cmd .= "
|
485
|
#on copie le syslinux original
|
486
|
if [ -f \"/home/machines/" . $comptemachine . "/boot.pxe\" ]; then
|
487
|
cp /home/machines/" . $comptemachine . "/boot.pxe /home/machines/" . $comptemachine . "/boot.normal
|
488
|
fi
|
489
|
";
|
490
|
|
491
|
$syslinuxsymlink = "/home/machines/" . $comptemachine . "/boot.pxe";
|
492
|
|
493
|
$cmd .= "
|
494
|
if [ ! -e $syslinuxsymlink ]; then
|
495
|
ln $syslinuxfile $syslinuxsymlink
|
496
|
fi
|
497
|
|
498
|
#on ecrase le syslinux dans tous les cas (nouveau ou modif)
|
499
|
echo \"$syslinux\" > $syslinuxfile || true
|
500
|
|
501
|
#gestion des droits ad-hoc
|
502
|
chown " . $comptemachine . ":machines /home/machines/" . $comptemachine . "/boot.*
|
503
|
horizon-check user $comptemachine -b
|
504
|
";
|
505
|
|
506
|
fichier_script($cmd,"ltsconf",$textelocal);
|
507
|
}
|
508
|
$textelocal .= "<p>" . _("Veuillez redémarrer votre ordinateur en amorçage réseau...") . "</p>\n";
|
509
|
$textelocal .= "<p><a href=\"./\">" . _("Cliquez ici pour retourner au menu de gestion des postes clients.") . "</a></p>\n";
|
510
|
}
|
511
|
|
512
|
$textelocal .= "</form>";
|
513
|
|
514
|
$page->addCentralFrame($textelocal);
|
515
|
$page->render();
|
516
|
?>
|