Advertisement
Guest User

Untitled

a guest
May 20th, 2017
93
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Bash 19.71 KB | None | 0 0
  1. #!/bin/bash
  2.  
  3. # USB-Installer for user Live-System
  4. # Version 10.02.07 by Markus Mandalka
  5. #
  6. # Format and encrypt the choosen USB-Device and install user into it
  7.  
  8.  
  9. # print error message and abbort installing
  10.  error()
  11. {
  12.   $DIALOG --title "Error" --msgbox "$@" 0 0;
  13.   exit 1;
  14. }
  15.  
  16.  
  17. unmount_device()
  18. {
  19.   # unmount device
  20.   # FIX IT1 : 1tik 10rako bukle bat egin
  21.   # FIX IT2: udev erabili aukeratutako usb-giltza desmontatzeko.
  22.    umount $@1
  23.   umount $@2
  24.   umount $@3
  25.   umount $@4
  26. }
  27.  
  28.  
  29. if [ -e /usr/bin/Xdialog ]
  30. then
  31.     DIALOG="Xdialog"
  32. else
  33.     DIALOG="dialog"
  34. fi
  35.  
  36. installer_dir=$(dirname $0)
  37.  
  38. mount_target="/tmp/user-install-$$";
  39. mount_base="/tmp/squashfs-$$";
  40.  
  41.  
  42.  
  43. # Language and messages
  44.  
  45. title_select="Install user Live-System";
  46. msg_select="\nChoose an usb-device (usb-key or external harddisk),
  47. on which user will be installed:"
  48.  
  49. menuitem_none="None"
  50. menuitem_none_description="No device"
  51.  
  52. msg_error_password="Error: The passwords did not match!"
  53. title_password="Password";
  54.  msg_password_1="Password"
  55. msg_password_2="Checking password"
  56.  
  57. title_password_admin="Admin-Password";
  58. msg_password_admin_1="Password for software-administration:"
  59. msg_password_admin_2="Checking admin-password:"
  60.  
  61.  
  62.  
  63.  
  64. title_done="Installation done"
  65. msg_done="Installation done.
  66.  
  67. You can now boot user from the usb-device."
  68. msg_overwrite_ask_title="Overwrite old data?"
  69. msg_overwrite_ask="
  70. Overwrite old data on the device with random data?
  71.  
  72. This may take long time.
  73.  
  74. If you don't do it,
  75. - parts of the data, that were on the device before
  76. the installation could be restored by others very easy.
  77. - others can find out, how much data is saved
  78. inside the encrypted partition.
  79.  
  80. If it is not only a test installation,
  81. choose [yes] here !
  82.  
  83. Overwrite old data?";
  84. title_overwrite="Deleting old data";
  85.  msg_overwrite="\nOverwriting device with random data ...";
  86. title_are_you_sure="Danger: Data on this device will be deleted!!!";
  87. msg_are_you_sure1="Are you absoluteley sure, that data on this device
  88. should be overwritten?
  89.  
  90. "
  91. msg_are_you_sure2="
  92.  
  93. If you selected the wrong device you will loose all data
  94. on the usb-key or on the external harddisk!
  95.  
  96. If you choose < Yes >, there will be no return!
  97.  
  98. Realy continue and overwrite the selected device?";
  99.  
  100. msg_error_mounted="The selected device is mounted!
  101.  
  102. Please unmount it and start again!";
  103.  
  104.  
  105. # Messages not used by the gui
  106. # You don't have to translate them to support another language
  107.  msg_error_luksformat="Error while luksformat!";
  108. msg_error_luksopen="Error while luksopen!";
  109.  
  110. msg_overwrite_done="Overwrite done.";
  111. msg_luksformat="Encrypting device ...";
  112.  msg_luksopen="Opening encrypted device ...";
  113. msg_umount_rootcrypt="Unmounting root-filesystem ...";
  114. msg_syncing="Syncing unwritten data. Please wait ...";
  115. msg_error_mkfs_root="Error while making filesystem on /dev/mapper/root_crypt ! Abort.";
  116.  msg_error_mount_boot="Error mounting boot-partition! Abort.";
  117. msg_error_mount_root="Error mounting /dev/mapper/root_crypt ! Abort.";
  118. msg_error_copy_root="Error while copy system to target! Maybe this parts of the cd-rom are not readable or there is not enough space on your usb-device.";
  119.  msg_error_umount_boot="Error while umount boot-partition ! Abort.";
  120. msg_error_umount_root="Error while umount /dev/mapper/root_crypt ! Abort.";
  121. msg_error_luksclose="Error while closing devicemaper with luksClose! Abort.";
  122.  msg_update_grub="
  123. Writing bootmenu ...";
  124. msg_copy_root="
  125. Copy system into the encrypted partition.
  126. This may take a while. Please wait ...";
  127.  
  128. msg_mkfs_root="
  129.  
  130. Formating root-filesystem:
  131.  
  132. ";
  133. msg_sfdisk="Writing partitiontable ...";
  134. msg_mount_boot="
  135. Mount boot-partition ...";
  136. msg_mkfssetup="Setup crypttab and fstab";
  137. msg_copy_boot="
  138. Copy kernel to bootpartition. Please wait ...";
  139.  msg_grub_install="
  140. Installing bootloader ...
  141.  
  142. "
  143. msg_mkfs_boot="
  144. Formating boot filesystem:
  145. ";
  146. msg_error_copy_boot="
  147. Error while copying! Abort.
  148.  
  149. Maybe the cd-rom is not readable.
  150. ";
  151. msg_mount_proc="Mounting /proc ...";
  152. msg_mount_dev="Mounting /dev ...";
  153. msg_update_initramfs="
  154. Creating Initramdisks with cryptroot setup ...";
  155. msg_mkbootiso="
  156.  
  157. Creating boot-cd-iso ...";
  158. msg_umount_proc="Unmounting /proc ...";
  159. msg_umount_dev="Unmounting /dev ...";
  160. msg_umount_boot="Unmounting /boot ...";
  161. msg_error_grub_install="Error while grub-install! Abort.";
  162.  msg_error_update_grub="Error while update-grub ! Abort.";
  163. msg_error_update_initramfs="Error while update-initramfs! Abort.";
  164. msg_error_sfdisk="Error while writing partition table with sfdisk !
  165.  
  166. Abort.";
  167. msg_error_mount_proc="Error while mounting /proc to target! Abort.";
  168. msg_error_mount_dev="Error while mounting /dev to target. Abort.";
  169. msg_error_mount_base="Error mounting squashfs! Abort.";
  170.  msg_error_mkfs_boot="Error creating filesystem (mkfs.vfat on boot)! Abort.";
  171.  
  172. msg_mkfs_doc="Create filesystem for windows ...";
  173. msg_error_mkfs_doc="Error while formating windows-filesystem!";
  174.  msg_mount_doc="Mounting windows readable filesystem ...";
  175. msg_umount_doc="Unmounting windows readable filesystem ...";
  176. msg_error_umount_doc="Error while unmounting windows readable filesystem!";
  177.  
  178. case "$LANG" in
  179. de*|at*|ch*)
  180.  
  181. title_select="user Installation";
  182. msg_select="Wählen Sie das Gerät
  183. (Speicherkarte, USB-Stick oder externe Festplatte),
  184. auf dem user installiert werden soll:"
  185.  
  186. menuitem_none="None"
  187. menuitem_none_description="Kein Gerät"
  188.  
  189. title_done="Installation abgeschlossen"
  190. msg_done="Die Installation wurde erfolgreich abgeschlossen.
  191.  
  192. Sie können user nun vom eben eingerichteten Datenträger booten."
  193.  
  194. msg_error_password="Fehler: Das Passwort stimmt nicht überein!"
  195. title_password="Passwort";
  196. msg_password_1="Verschlüsselungspasswort eingeben:"
  197. msg_password_2="Bitte das Verschlüsselungspasswort wiederholen:"
  198.  
  199. title_password_admin="Admin-Passwort";
  200. msg_password_admin_1="Admin-Passwort für zukünftige Einstellungen eingeben:"
  201. msg_password_admin_2="Bitte das Admin-Passwort wiederholen:"
  202.  
  203.  
  204. msg_error_luksformat="Fehler beim Aufruf von luksformat!";
  205. msg_error_luksopen="Fehler beim Aufruf von luksopen!";
  206.  
  207. msg_overwrite_ask_title="Alte Daten überschreiben?"
  208. msg_overwrite_ask="
  209. Soll der Datenträger mit Zufallsdaten überschrieben werden?
  210.  
  211. Dieser Schritt dauert bei grossen Festplatten sehr lange.
  212.  
  213. Wird das Überschreiben jedoch nicht durchgeführt,
  214. - können Teile der Daten, die sich vor der Installation
  215. auf diesem Datenträger befunden haben, mit einfachsten Mitteln
  216. wieder her gestellt werden
  217. - kann evtl. herausgefunden werden, wie viel Speicherplatz
  218. im verschlüsselten Bereich tatsächlich belegt ist.
  219.  
  220. Wenn es sich nicht um eine reine Testinstallation handelt,
  221. sollten Sie unbedingt [Ja] wählen!
  222.  
  223. Sollen vor der Installation alte Daten überschrieben werden?";
  224. title_overwrite="Lösche alte Daten";
  225. msg_overwrite="\nDer Datenträger wird mit Zufallsdaten überschrieben ...";
  226.  msg_overwrite_done="Das Überschreiben ist abgeschlossen.";
  227. msg_luksformat="Verschlüssele das Gerät ...";
  228. msg_luksopen="Öffne verschlüsseltes Gerät ...";
  229. msg_umount_rootcrypt="Hänge das Root-Filesystem wieder aus ...";
  230.  msg_syncing="Synchronisiere noch ungeschriebene Daten. Bitte warten ...";
  231. msg_error_mkfs_root="Fehler beim Anlegen des Filesystems auf /dev/mapper/root_crypt ! Abbruch.";
  232. msg_error_mount_boot="Fehler beim Mounten der Boot-Partition ! Abbruch.";
  233.  msg_error_mount_root="Fehler beim Mounten von /dev/mapper/root_crypt ! Abbruch.";
  234. msg_error_copy_root="Fehler beim Kopieren auf das Ziel!
  235. Vielleicht kann die CD nicht richtig gelesen werden
  236. oder auf dem Datenträger war zu wenig
  237. freier Speicherplatz verfügbar.";
  238. msg_error_umount_boot="Fehler beim Aushängen (umount) der Boot-Partition ! Abbruch.";
  239. msg_error_umount_root="Fehler beim Aushängen (umount) von /dev/mapper/root_crypt ! Abbruch.";
  240.  msg_error_luksclose="Fehler beim Schliessen des Devicemappers mit luksClose! Abbruch.";
  241. title_are_you_sure="Achtung: Daten auf diesem Datenträger werden gelöscht!!!";
  242. msg_update_grub="
  243. Schreibe Bootmenu ...";
  244.  msg_copy_root="
  245.  
  246. Kopiere das System in die verschlüsselte Partition.
  247.  
  248. Dies kann eine Weile dauern. Bitte warten ...";
  249. msg_mkfs_root="
  250.  
  251. Formatiere Root-Dateisystem:
  252.  
  253. ";
  254. msg_sfdisk="Lege Partitionstabelle an ...";
  255.  msg_mount_boot="
  256. Mounte Boot-Partition ...";
  257. msg_mkfssetup="
  258. Erstelle crypttab und fstab ...";
  259. msg_copy_boot="
  260. Kopiere Kernel in die Bootpartition. Bitte warten ...";
  261. msg_grub_install="
  262. Installiere den Bootloader ...
  263.  
  264. "
  265. msg_mkfs_boot="
  266. Formatiere Boot-Dateisystem:
  267. ";
  268. msg_error_copy_boot="
  269. Fehler beim Kopieren! Abbruch.
  270.  
  271. Vielleicht kann die CD nicht richtig gelesen werden?
  272. ";
  273. msg_mount_proc="Mounte /proc in Target ...";
  274. msg_mount_dev="Mounte /dev in Target ...";
  275. msg_update_initramfs="
  276. Aktualisiere Initramdisks mit Cryptroot-Einstellungen ...";
  277.  msg_mkbootiso="
  278.  
  279. Erstelle CD-Abbild der Boot-CD ...";
  280. msg_umount_proc="Hänge im Target /proc wieder aus...";
  281. msg_umount_dev="Hänge im Target /dev wieder aus...";
  282. msg_umount_boot="Hänge das Boot-Filesystem wieder aus ...";
  283.  msg_error_grub_install="Fehler beim Aufruf von grub-install! Abbruch.";
  284. msg_error_update_grub="Fehler beim Aufruf von update-grub ! Abbruch.";
  285. msg_error_update_initramfs="Fehler bei update-initramfs! Abbruch.";
  286.  msg_error_sfdisk="Fehler beim Schreiben der Partitionstabelle mit sfdisk !
  287.  
  288. Abbruch.";
  289. msg_error_mount_proc="Fehler beim Mounten von /proc in Target! Abbruch.";
  290. msg_error_mount_dev="Fehler beim Mounten von /dev in Target. Abbruch.";
  291.  msg_error_mount_base="Fehler beim Mounten des squashfs! Abbruch.";
  292. msg_error_mkfs_boot="Fehler beim Anlegen des Filesystems (mkfs.vfat) auf boot! Abbruch.";
  293.  
  294.  
  295. msg_mkfs_doc="Lege das unter Windows lesbare Dateisystem für die Dokumentation an ...";
  296.  msg_error_mkfs_doc="Fehler beim Anlegen des unter Windows lesbaren Dateisystems";
  297. msg_mount_doc="Hänge unter Windows lesbares Dateisystem ein ...";
  298. msg_umount_doc="Hänge unter Windows lesbares Dateisystem aus ...";
  299.  msg_error_umount_doc="Fehler beim Aushängen des Windows-Dateisystems";
  300.  
  301. msg_are_you_sure1="Sind Sie sich absolut sicher, dass der nachfolgende Datenträger
  302. verwendet werden soll?
  303.  
  304. ";
  305. msg_are_you_sure2="
  306.  
  307. Falls Sie das falsche Gerät gewählt haben,
  308. werden Daten auf einem anderen USB-Speicher
  309. oder einer externen Festplatte überschrieben!
  310.  
  311. Wenn Sie mit < Ja > bestätigen, gibt es kein Zurück mehr
  312. und auf dem gewählten Datenträger vorhandenen Daten sind verloren!
  313.  
  314. Wirklich fortfahren und den Datenträger formatieren?";
  315.  
  316. msg_error_mounted="Der zu verschlüsselnde Datenträger ist noch eingehängt
  317. und wird offenbar noch genutzt!
  318.  
  319. Bitte schliessen Sie alle Programme, die auf Dateien des Datenträgers zugreifen,
  320. hängen Sie den Datenträger aus und führen Sie dann dieses Programm erneut aus!";
  321.  
  322. ;;
  323. esac
  324.  
  325. modprobe dm-crypt
  326.  
  327. # Select USB-Device
  328. filter="usb-devices"
  329. TEMPFILE=/tmp/selection.$$
  330.  
  331. if ! partsel -d $DIALOG -f $filter -o $TEMPFILE -t "$title_select" -m "$msg_select" -nt "$menuitem_none" -nd "$menuitem_none_description"
  332. then
  333.   exit
  334. fi
  335.  
  336. choice=`cat $TEMPFILE`
  337.  rm $TEMPFILE
  338.  
  339. if [ "$choice" == "$menuitem_none" ];
  340. then
  341.    exit
  342. fi
  343.  
  344. device=$choice;
  345.  
  346. # Get infos about the device to ask, if it is the right one
  347. model=$(udevadm --query=env -p `udevadm -q path -n $device` 2>/dev/null | grep "ID_MODEL=" | cut -f 2 -d "=" | sed s/_/\ /g| tr -d [:punct:])
  348.  bus=$(udevadm --query=env -p `udevadm -q path -n $device` 2>/dev/null | grep "ID_BUS=" | cut -f 2 -d "=" | sed s/_/\ /g)
  349. size=$(LC_ALL=C fdisk -l $device 2>/dev/null | grep Disk | grep -i bytes | cut -f 1 -d "," | cut -f 3,4 -d " ");
  350.  vendor=$(udevadm --query=env -p ${partition} 2>/dev/null | grep "ID_VENDOR=" | cut -f2 -d'='|sed s/_/\ /g| tr -d [:punct:])
  351.  
  352. modelandvendor="$model";
  353. [ -n "$vendor" ] && modelandvendor="$modelandvendor ($vendor)";
  354.  msg_are_you_sure="$msg_are_you_sure1$device: $modelandvendor - $size$msg_are_you_sure2"
  355.  
  356. if ! $DIALOG --title "$title_are_you_sure" --yesno "$msg_are_you_sure" 0 0;
  357.   then
  358.     exit
  359.  fi;
  360.  
  361.  
  362. # Ask password for normal user
  363. PASSWORD1=$($DIALOG --stdout --title $title_password --passwordbox "$msg_password_1" 0 0) || exit
  364. PASSWORD2=$($DIALOG --stdout --title $title_password --passwordbox "$msg_password_2" 0 0) || exit
  365.  
  366. if [ "$PASSWORD1" != "$PASSWORD2" ]
  367. then
  368.   error "$msg_error_password";
  369.   exit 1;
  370. fi
  371. PASSWORD2="";
  372.  
  373. # Ask password for root (admin)
  374. PASSWORDADMIN1=$($DIALOG --stdout --title $title_password_admin --passwordbox "$msg_password_admin_1" 0 0) || exit
  375.  PASSWORDADMIN2=$($DIALOG --stdout --title $title_password_admin --passwordbox "$msg_password_admin_2" 0 0) || exit
  376.  
  377. if [ "$PASSWORDADMIN1" != "$PASSWORDADMIN2" ]
  378. then
  379.   error "$msg_error_password";
  380.    exit 1;
  381. fi
  382. PASSWORDADMIN2="";
  383.  
  384. # $device = /dev/sdX
  385. unmount_device $device;
  386.  
  387. # check if the device or a parition on the device is mounted
  388. if cat /etc/mtab | grep $device && echo $?
  389.    then
  390.     error "$msg_error_mounted";
  391. fi
  392.  
  393. # ask if overwrite old data
  394. if $DIALOG --title "$msg_overwrite_ask_title" --yesno "$msg_overwrite_ask" 0 0;
  395. then
  396.  
  397.   # Overwrite old data
  398.    dd bs=2M if=/dev/urandom count=1| pv -n --size=$(fdisk -s $device)k 2>&1 >$device | $DIALOG --title "$title_overwrite" --gauge "$msg_overwrite" 0 0;
  399.  
  400.   clear;
  401.   echo $msg_overwrite_done;
  402.  
  403. else
  404.   # Overwrite begin of the old partition
  405.   # so that the system won't try to mount it
  406.   # after following initialize of the new partition table
  407.   dd bs=2M count=1 if=/dev/zero of=$device
  408.  
  409.   clear;
  410.  fi;
  411.  
  412.  
  413. # Create partitions
  414. echo "$msg_sfdisk";
  415. if ! sfdisk $device -uM <<EOF
  416. ,32,b
  417. ,96,L
  418. ,,L
  419. EOF
  420. then
  421.  error "$msg_error_sfdisk";
  422. fi
  423.  
  424. # Read the new partition table
  425.  partprobe $device
  426.  
  427. # Yet existing (if not overwritten) filesystems could be mounted again after rereading new partition table, so we unmount it again
  428. unmount_device $device;
  429.  
  430. clear;
  431.  
  432. device_doc=${device}1
  433.  device_boot=${device}2
  434. device_root=${device}3
  435.  
  436. # crypt device
  437. echo "$msg_luksformat";
  438. if ! echo -n "$PASSWORD1" | cryptsetup --batch-mode luksFormat $device_root
  439. then
  440.  error "$msg_error_luksformat";
  441.  fi;
  442.  
  443.  
  444. # open crypted device
  445. echo "$msg_luksopen";
  446. if ! echo -n "$PASSWORD1" | cryptsetup luksOpen $device_root root_crypt
  447. then
  448.  error "$msg_error_luksopen";
  449. fi;
  450.  
  451.  PASSWORD1="";
  452.  
  453. #mount_target="/tmp/user-install-$$";
  454. #mount_base="/tmp/squashfs-$$";
  455.  
  456. # create filesystem
  457. echo "$msg_mkfs_root"
  458. if ! mkfs.ext3 -L sistema /dev/mapper/root_crypt
  459.  
  460.  then
  461.  error "$msg_error_mkfs_root";
  462. fi;
  463.  
  464. mkdir $mount_target
  465. if ! mount /dev/mapper/root_crypt $mount_target
  466. then
  467.   error "$msg_error_mount_root";
  468. fi
  469.  
  470. # mount the squashfs and copy system to target
  471.  echo "$msg_copy_root";
  472. mkdir $mount_base
  473. if ! mount -o loop /live/image/live/filesystem.squashfs $mount_base
  474. then
  475.   error "$msg_error_mount_base";
  476. fi;
  477.  
  478. if ! cp -a $mount_base/* $mount_target/
  479.  then
  480.   error "$msg_error_copy_root";
  481. fi;
  482.  
  483. # /boot at root_crypt only as mount directory for the unencrypted boot-partition
  484. #rm -R $mount_target/boot
  485.  
  486. # Remove installer
  487.  #rm $mount_target/home/user/Desktop/Installation.desktop
  488. #rm $mount_target/usr/local/sbin/installer
  489. # Remove builder
  490. #rm -R $mount_target/usr/local/src/user
  491.  
  492. echo "$msg_syncing";
  493. sync
  494.  
  495. umount $device_boot >/dev/null 2>/dev/null
  496.  
  497. echo "$msg_mkfs_boot"
  498. if ! mkfs.ext3 -L boot $device_boot
  499. then
  500.   error "$msg_error_mkfs_boot";
  501. fi;
  502.  
  503. # $mount_target = $mount_base-n dagoena $mount_target dagenaren antzekoa. USBan koiatuko dena.
  504.  # $mount_base=squashfs-n dauden datuak ditu lerroa 467
  505.  
  506. echo "$msg_mount_boot";
  507.  
  508. if ! mount $device_boot $mount_target/syslinux
  509. then
  510.   error "Error mounting $device_boot on $mount_target/syslinux ! Abort."
  511.  fi
  512.  
  513.  
  514. #echo "$msg_copy_boot";
  515. mkdir $mount_target/syslinux
  516. if ! cp /syslinux/* $mount_target/syslinux
  517. then
  518.   error "$msg_error_copy_boot";
  519. fi
  520.  
  521. echo "$msg_syncing";
  522. sync
  523.  
  524.  
  525. umount $device_doc >/dev/null 2>/dev/null
  526.  
  527. echo "$msg_mkfs_doc"
  528. if ! mkfs.vfat -n debsec $device_doc
  529. then
  530.   error "$msg_error_mkfs_doc";
  531. fi;
  532.  
  533. echo 'VFAT OK!!!!!'
  534.  
  535. echo "$msg_mount_doc";
  536.  
  537. mkdir $mount_target/win
  538.  
  539. if ! mount $device_doc $mount_target/win
  540. then
  541.   error "Error mounting $device_doc on $mount_target/win ! Abort."
  542. fi
  543.  
  544. mkdir $mount_target/win/boot
  545.  
  546. if ! cp /boot/* $mount_target/win/boot
  547. then
  548.   echo "dos";
  549.   error "$msg_error_copy_boot";
  550.  
  551. fi
  552.  
  553. mkdir $mount_target/win/syslinux
  554.  
  555. if ! cp /syslinux/* $mount_target/win/syslinux
  556. then
  557.   echo "tres";
  558.   error "$msg_error_copy_boot";
  559.  
  560. fi
  561.  
  562. umount $mount_base
  563. rmdir $mount_base
  564.  
  565.  
  566. echo "$msg_mkfssetup";
  567.  
  568. root_uuid=`/lib/udev/vol_id -u $device_root`
  569. boot_uuid=`/lib/udev/vol_id -u $device_boot`
  570. doc_uuid=`/lib/udev/vol_id -u $device_doc`
  571.  
  572. # Create fstab
  573. echo "# /etc/fstab: static file system information.
  574. #
  575. # <file system> <mount point>   <type>  <options>       <dump>  <pass>
  576. proc            /proc           proc    defaults        0       0
  577. /dev/mapper/root_crypt /               ext3    errors=remount-ro 0       1
  578. /dev/disk/by-uuid/$boot_uuid /boot ext3 defaults 0 1
  579. /dev/disk/by-uuid/$doc_uuid /win vfat noauto,ro,noexec,nosuid 0 1" >$mount_target/etc/fstab
  580.  
  581. # Create crypttab
  582. echo "root_crypt /dev/disk/by-uuid/$root_uuid none luks" >$mount_target/etc/crypttab
  583.  
  584. # Create kernel-img.conf
  585. echo "do_initrd = yes" >>$mount_target/etc/kernel-img.conf
  586.  
  587. # Set hostname
  588. echo "user" > $mount_target/etc/hostname
  589.  
  590. # Set hosts
  591. cat >> $mount_target/etc/hosts << EOF
  592.  127.0.0.1 localhost
  593. 127.0.1.1 user
  594.  
  595. # The following lines are desirable for IPv6 capable hosts
  596. ::1     ip6-localhost ip6-loopback
  597. fe00::0 ip6-localnet
  598. ff00::0 ip6-mcastprefix
  599. ff02::1 ip6-allnodes
  600. ff02::2 ip6-allrouters
  601.  ff02::3 ip6-allhosts
  602. EOF
  603.  
  604.  
  605. echo "$msg_grub_install";
  606.  
  607. #mkdir $mount_target/boot/syslinux
  608.  
  609. #echo "(hd0) $device" >$mount_target/boot/grub/device.map;
  610.  
  611. #if ! /usr/sbin/grub-install --no-floppy --root-directory=$mount_target $device
  612.  
  613.  
  614. dd if=/syslinux/mbr.bin of=$device bs=440
  615. fdisk $device
  616. #a1w
  617.  
  618.  
  619. # FIX IT: al crear la imagen quemado meter el nuevo syslinux.cfg en syslinux y el
  620. # boot que viene del squashfs en particion debsec
  621.  
  622. # if ! syslinux $device_doc
  623. #then
  624. #  error "$msg_error_grub_install";
  625. #fi
  626.  
  627. echo "$msg_mount_proc";
  628. if ! mount -t proc /proc $mount_target/proc
  629. then
  630.   error "$msg_error_mount_proc";
  631.  fi;
  632.  
  633. echo "$msg_mount_dev";
  634. if ! mount -o bind /dev $mount_target/dev
  635. then
  636.   error "$msg_error_mount_dev";
  637. fi;
  638.  
  639. #echo "$msg_update_grub";
  640. #if ! chroot $mount_target update-grub
  641.  #then
  642. #  error "$msg_error_update_grub";
  643. #fi
  644.  
  645. echo "$msg_update_initramfs";
  646. # Create new initramdisk because of changed crypttab
  647. if ! chroot $mount_target update-initramfs -u
  648. then
  649.    error "$msg_error_update_initramfs";
  650. fi;
  651.  
  652. echo "$msg_mkbootiso";
  653. # Create boot.iso containing this ramdisk with our crypttab
  654. chroot $mount_target/ /usr/local/sbin/mkbootiso
  655.  
  656. # Delete packages that are not needet on usb-device
  657.  chroot $mount_target/ apt-get -y purge live-helper
  658. chroot $mount_target/ apt-get -y autoremove
  659.  
  660. # set root- and user-password
  661. chroot $mount_target/ chpasswd -c MD5 <<EOF
  662. root:$PASSWORDADMIN1
  663. user:$PASSWORD1
  664. EOF
  665.  
  666. # Copy doc to windows-readable partition
  667. cp /win/image/usb.html $mount_target/win/index.html
  668. cp /win/image/style.css $mount_target/win
  669. cp /win/image/autorun.bat $mount_target/win
  670. cp /win/image/autorun.inf $mount_target/win
  671. cp $mount_target/boot/boot.iso $mount_target/win
  672.  
  673. echo "$msg_umount_dev";
  674. umount $mount_target/dev
  675. echo "$msg_umount_proc";
  676. umount $mount_target/proc
  677.  
  678. echo "$msg_umount_doc";
  679.  if ! umount $device_doc
  680. then
  681.   error "$msg_error_umount_doc";
  682. fi
  683.  
  684.  
  685. echo "$msg_umount_boot";
  686. if ! umount $device_boot
  687. then
  688.   error "$msg_error_umount_boot";
  689. fi
  690.  
  691. echo "$msg_umount_rootcrypt";
  692. if ! umount /dev/mapper/root_crypt
  693. then
  694.   error "$msg_error_umount_root";
  695. fi
  696.  
  697. if ! cryptsetup luksClose root_crypt
  698. then
  699.   error "$msg_error_luksclose";
  700.  fi
  701.  
  702. rmdir $mount_target
  703. $DIALOG --title "$title_done" --msgbox "$msg_done" 0 0
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement