Changes between Version 16 and Version 17 of doc/TorBOX/Dev/ModifyISO


Ignore:
Timestamp:
Sep 27, 2012, 11:38:27 PM (7 years ago)
Author:
proper
Comment:

--

Legend:

Unmodified
Added
Removed
Modified
  • doc/TorBOX/Dev/ModifyISO

    v16 v17  
    1 {{{
    2 #!/bin/bash
    3 # Safe as /home/username/TorBOX_source/TorBOX_ModifyISO
     1TorBOX has been renamed to Whonix.
    42
    5 # Version: TorBOX 0.2.1
     3This page has been moved. The History of this page might still be interesting.
    64
    7 # Copyright: proper
    8 #
    9 # License: GPL v3 or any later
    10 #
    11 # Any changes you pull changes into this source will be also licensed
    12 # under GPL v3 or any later. Additionally you grant proper the right to
    13 # re-license your work under a different license. If that is not acceptable,
    14 # you can either fork this source under GPL v3 or any later or contact proper.
    15 # Contact proper, if you require this source code under different license.
    16 
    17 script_help() {
    18 echo "
    19 # TorBOX_ModifyISO available commands:
    20 #
    21 # -create
    22 #  creates preseed.iso
    23 #
    24 # -delete
    25 #  unmounts and deletes ISO and build folder
    26 #
    27 # -help
    28 #  shows this help
    29 "
    30 }
    31 
    32 
    33 
    34 # Enable debugging.
    35 set -x
    36 
    37 # Exit if there is an error
    38 set -e
    39 
    40 USERNAME="user"
    41 
    42 # Thanks to
    43 # http://askubuntu.com/questions/122505/how-do-i-create-completely-unattended-install-for-ubuntu
    44 
    45 
    46 
    47 ##############################################################################################
    48 # error_handler
    49 ##############################################################################################
    50 error_handler() {
    51 echo "
    52 #!!! ERROR in TorBOX_ModifyISO !!!#
    53 #!!! ERROR in TorBOX_ModifyISO !!!#
    54 #!!! ERROR in TorBOX_ModifyISO !!!#
    55 "
    56 
    57 echo "TorBOX_ModifyISO: unmounting iso..."
    58 unmount_iso
    59 echo "TorBOX_ModifyISO: Done."
    60 
    61 touch /home/$USERNAME/TorBOX_binary/TORBOX_BUILD_FAILED
    62 exit 1
    63 }
    64 
    65 
    66 
    67 root_check() {
    68 ######################################################
    69 # Checking script environment
    70 ######################################################
    71 # Check if we are root
    72   if [ "$(id -u)" != "0" ]; then
    73        echo "ERROR: This must be run as root (sudo)!"
    74        exit 1
    75   else
    76        echo "INFO: Script running as root."
    77   fi
    78 }
    79 
    80 
    81 
    82 ##############################################################################################
    83 # mount_and_copy_iso
    84 ##############################################################################################
    85 
    86 mount_and_copy_iso() {
    87    trap "error_handler" ERR INT TERM
    88 
    89    mkdir -p /home/$USERNAME/TorBOX_binary/original_iso
    90    # Ubuntu:
    91    mount -o loop /home/$USERNAME/TorBOX_binary/ubuntu-12.04-server-i386.iso /home/$USERNAME/TorBOX_binary/original_iso
    92    # Debian:
    93    #mount -o loop /home/$USERNAME/TorBOX_binary/debian-6.0.5-i386-CD-1.iso /home/$USERNAME/TorBOX_binary/original_iso
    94    mkdir -p /home/$USERNAME/TorBOX_binary/modified_iso
    95    cp -rT /home/$USERNAME/TorBOX_binary/original_iso /home/$USERNAME/TorBOX_binary/modified_iso
    96 }
    97 
    98 
    99 
    100 ##############################################################################################
    101 # unmount_iso
    102 ##############################################################################################
    103 
    104 unmount_iso() {
    105    umount /home/user/TorBOX_binary/original_iso
    106    rm -r /home/user/TorBOX_binary/original_iso
    107 }
    108 
    109 
    110 
    111 ##############################################################################################
    112 # modify_iso_general
    113 ##############################################################################################
    114 
    115 modify_iso_general() {
    116 trap "error_handler" ERR INT TERM
    117 
    118 # This function...
    119 # Is suboptimal, but it works.
    120 #
    121 # Please, if you make changes to this file, document your changes.
    122 # Preseeding is not the most bugfree or easy thing.
    123 # Changes my break it.
    124 # If you make changes, please test if they are working!
    125 
    126 #################################################################################
    127 # lang
    128 #################################################################################
    129 
    130 echo en > /home/$USERNAME/TorBOX_binary/modified_iso/isolinux/lang
    131 
    132 #################################################################################
    133 # isolinux.cfg
    134 #################################################################################
    135 
    136 echo '
    137 #Generated by TorBOX
    138 
    139 default 1
    140 prompt 1
    141 timeout 5
    142 label 1
    143 # Ubuntu Precise
    144 kernel /install/vmlinuz
    145 append file=/cdrom/preseed/ubuntu-server.seed initrd=/install/initrd.gz ks=cdrom:/ks.cfg preseed/file=/cdrom/preseed.cfg --
    146 
    147 # Or Debian Squeeze NOT WORKING YET
    148 #kernel /install.386/vmlinuz
    149 #append preseed/file=/cdrom/preseed.cfg initrd=/install.386/initrd.gz --
    150 ' > /home/$USERNAME/TorBOX_binary/modified_iso/isolinux/isolinux.cfg
    151 
    152 #################################################################################
    153 # ks.cfg
    154 #################################################################################
    155 
    156 # Create kickstart configuration file.
    157 # Due to bugs in Ubuntu preseed we have to combine kickstart with preseed.
    158 # Bugs such as choosing the language does not work with preseed alone.
    159 echo '
    160 #Generated by TorBOX
    161 
    162 #Generated by Kickstart Configurator
    163 #platform=x86
    164 
    165 #System language
    166 lang en_US
    167 #Language modules to install
    168 langsupport en_US
    169 #System keyboard
    170 keyboard us
    171 #System mouse
    172 mouse
    173 #System timezone
    174 timezone --utc America/New_York
    175 #Root password
    176 rootpw --disabled
    177 #Initial user
    178 user user --fullname "user" --iscrypted --password $1$FfTFybF6$FCXsl5qUXudXAapnGj2mB/
    179 #Use text mode install
    180 text
    181 #Install OS instead of upgrade
    182 install
    183 #Use CDROM installation media
    184 cdrom
    185 #System bootloader configuration
    186 bootloader --location=mbr
    187 #Clear the Master Boot Record
    188 #zerombr yes
    189 #Partition clearing information
    190 #clearpart --all --initlabel
    191 #Disk partitioning information
    192 #part / --fstype ext4 --size 1 --grow --asprimary
    193 #System authorization infomation
    194 auth  --useshadow  --enablemd5
    195 #Firewall configuration
    196 firewall --disabled
    197 #Do not configure the X Window System
    198 skipx
    199 ' > /home/$USERNAME/TorBOX_binary/modified_iso/ks.cfg
    200 
    201 #################################################################################
    202 # preseed.cfg
    203 #################################################################################
    204 
    205 # Comment (proper):
    206 #   This file could look better. As soon as we move to file separeated source,
    207 #   we can keep more comments.
    208 #
    209 # Note:
    210 #   "" and $$ must be escaped!
    211 #
    212 # Thanks to:
    213 #   http://ubuntuforums.org/showthread.php?t=1145188
    214 
    215 echo "
    216 ### Misc
    217 d-i hw-detect/load_firmware boolean true
    218 d-i pkgsel/install-language-support     boolean false
    219 d-i debian-installer/quiet      boolean false
    220 d-i debian-installer/splash     boolean false
    221 d-i pkgsel/update-policy select none
    222 d-i popularity-contest popularity-contest/participate boolean false
    223 
    224 ### Network settings
    225 #d-i netcfg/no_interfaces boolean true
    226 #d-i netcfg/enable boolean false
    227 #d-i netcfg/dhcp_failed note
    228 #d-i netcfg/disable_dhcp boolean true
    229 #d-i netcfg/dhcp_options select \"Do not configure the network at this time\"
    230 #d-i netcfg/choose_interface select eth1
    231 #
    232 # This is a workaround.
    233 # Only one network adapter attached while installing with preseed.
    234 # The network cable is NOT attached.
    235 # We still need to configure the network manually to *something*,
    236 # due to limitations in upstream preseed netcfg.
    237 # ("Do not configure network at this time" does not work.)
    238 #
    239 d-i netcfg/dhcp_failed note
    240 d-i netcfg/disable_dhcp boolean true
    241 d-i netcfg/dhcp_options select Configure network manually
    242 d-i netcfg/get_nameservers string 192.168.0.1
    243 d-i netcfg/get_ipaddress string 192.168.0.2
    244 d-i netcfg/get_netmask string 255.255.255.0
    245 d-i netcfg/get_gateway string 192.168.0.1
    246 d-i netcfg/confirm_static boolean true
    247 
    248 ### Localization
    249 # Preseeding only locale sets language, country and locale.
    250 d-i debian-installer/country string US
    251 d-i debian-installer/language string en
    252 d-i debian-installer/locale string en_US.UTF-8
    253 
    254 ### Keyboard selection.
    255 d-i console-setup/ask_detect boolean false
    256 d-i keyboard-configuration/layoutcode string us
    257 #d-i keyboard-configuration/variantcode string dvorak
    258 
    259 ### Mirror settings
    260 #d-i mirror/protocol string ftp
    261 #d-i mirror/country string manual
    262 #d-i mirror/http/hostname string archive.ubuntu.com
    263 #d-i mirror/http/directory string /ubuntu
    264 #d-i mirror/http/proxy string
    265 
    266 ### Apt settings
    267 d-i apt-setup/use_mirror boolean false
    268 
    269 ### Clock settings
    270 d-i clock-setup/utc boolean true
    271 d-i time/zone string UTC
    272 d-i clock-setup/ntp boolean false
    273 #d-i clock-setup/ntp-server string ntp.example.com
    274 
    275 ### Partitioning
    276 d-i partman-auto/init_automatically_partition select biggest_free
    277 d-i partman-auto/method string regular
    278 d-i partman-lvm/device_remove_lvm boolean true
    279 d-i partman-md/device_remove_md boolean true
    280 d-i partman-lvm/confirm boolean true
    281 
    282 # Thanks to https://bugs.launchpad.net/omsk/+bug/551947/comments/3
    283 d-i partman-basicfilesystems/no_swap boolean false
    284 
    285 # First example in partman-auto-recipe.txt without swap.
    286 d-i partman-auto/expert_recipe string                         \
    287 partman-auto/text/atomic_scheme :: \
    288 500 10000 1000000 ext4 \
    289 $primary{ } \
    290 $bootable{ } \
    291 method{ format } \
    292 format{ } \
    293 use_filesystem{ } \
    294 filesystem{ ext4 } \
    295 mountpoint{ / } .
    296 
    297 d-i partman-partitioning/confirm_write_new_label boolean true
    298 d-i partman/choose_partition select finish
    299 d-i partman/confirm boolean true
    300 d-i partman/confirm_nooverwrite boolean true
    301 
    302 ### Base system installation
    303 d-i base-installer/install-recommends boolean false
    304 #d-i base-installer/kernel/image string linux-generic
    305 
    306 ### Account setup
    307 #d-i passwd/root-login boolean false
    308 #d-i passwd/make-user boolean false
    309 d-i passwd/user-fullname string user
    310 d-i passwd/username string user
    311 d-i passwd/user-password password changeme
    312 d-i passwd/user-password-again password changeme
    313 d-i user-setup/allow-password-weak boolean true
    314 d-i user-setup/encrypt-home boolean false
    315 
    316 ### Grub
    317 d-i grub-installer/only_debian boolean true
    318 d-i grub-installer/with_other_os boolean true
    319 d-i grub-installer/timeout      string 2
    320 
    321 ### Finishing up the installation
    322 d-i finish-install/reboot_in_progress note
    323 d-i debian-installer/exit/poweroff boolean true
    324 
    325 ### X configuration
    326 xserver-xorg xserver-xorg/config/device/driver select vesa
    327 xserver-xorg xserver-xorg/autodetect_mouse boolean true
    328 xserver-xorg xserver-xorg/autodetect_monitor boolean true
    329 xserver-xorg xserver-xorg/config/monitor/selection-method \
    330        select medium
    331 xserver-xorg xserver-xorg/config/monitor/mode-list \
    332        select 1024x768 @ 60 Hz
    333 
    334 " > /home/$USERNAME/TorBOX_binary/modified_iso/preseed.cfg
    335 }
    336 
    337 
    338 
    339 ##############################################################################################
    340 # rebuild_iso
    341 ##############################################################################################
    342 
    343 rebuild_iso() {
    344 trap "error_handler" ERR INT TERM
    345 
    346 mkisofs -D -r -V "ATTENDLESS_UBUNTU" -cache-inodes -J -l -b isolinux/isolinux.bin -c isolinux/boot.cat -no-emul-boot -boot-load-size 4 -boot-info-table -o /home/$USERNAME/TorBOX_binary/$ISO_NAME /home/$USERNAME/TorBOX_binary/modified_iso/
    347 }
    348 
    349 
    350 
    351 ################################################################
    352 # -create                                                      #
    353 ################################################################
    354 if [[ "$1" = "-create" ]]; then
    355    root_check
    356    mount_and_copy_iso
    357    unmount_iso
    358    modify_iso_general
    359    ISO_NAME="preseed.iso"
    360    rebuild_iso
    361    echo "BUILD INFO: Done, if success, next stept should be sudo ./TorBOX_CreateVM -tg-pre"
    362    exit 0
    363 fi
    364 
    365 
    366 
    367 ################################################################
    368 # -delete                                                      #
    369 ################################################################
    370 if [[ "$1" = "-delete" ]]; then
    371    root_check
    372    unmount_iso
    373    rm -r /home/$USERNAME/TorBOX_binary/modified_iso
    374    rm /home/$USERNAME/TorBOX_binary/preseed.iso
    375    echo "Done."
    376    exit 0
    377 fi
    378 
    379 
    380 
    381 ################################################################
    382 # -help                                                        #
    383 ################################################################
    384 if [[ "$1" = "-help" ]]; then
    385    script_help
    386    exit 0
    387 fi
    388 
    389 
    390 
    391 ################################################################
    392 # no option chosen                                             #
    393 ################################################################
    394 echo "No option choosen. Use -help for help."
    395 touch /home/$USERNAME/TorBOX_binary/TORBOX_BUILD_FAILED
    396 exit 1
    397 }}}
     5http://sourceforge.net/projects/whonix/files/old-development-only/old-development-only.tar.gz/download