Browse Source

first commit

master
Yorick Barbanneau 3 years ago
commit
14867d5900
5 changed files with 261 additions and 0 deletions
  1. 7
    0
      .gitignore
  2. 164
    0
      init.sh
  3. 26
    0
      partman
  4. 57
    0
      preseed.cfg
  5. 7
    0
      syslinux/syslinux.cfg

+ 7
- 0
.gitignore View File

@@ -0,0 +1,7 @@
tmp/
syslinux/*.c32
syslinux/ldlinux.*
EFI
debian-8.5.0-amd64-netinst.iso
vmlinuz
initrd.gz

+ 164
- 0
init.sh View File

@@ -0,0 +1,164 @@
#!/bin/bash
#
# Script de creation d'un media bootable Debian
# Pour l'ACAQB
#
# Dépend : syslinux,wget
#
OPTIND=1
DEBIAN_VERSION="8.5.0"
DEBIAN_ARCH="amd64"
BOOT_TYPE="efi64"
SYSLINUX_VERSION="6.03"
SYSLINUX_FILES="com32/menu/menu.c32 com32/menu/vesamenu.c32 com32/libutil/libutil.c32 com32/lib/libcom32.c32"
SYSLINUX_BIOS_FILES="core/ldlinux.sys com32/elflink/ldlinux/ldlinux.c32"
SYSLINUX_EFI_FILES="com32/elflink/ldlinux/ldlinux.e64"
TMP_DIR="tmp"
MOUNT_DIR="/mnt/usbstick"

usage() {
cat << EOF
USAGE: ${0} [-a architecture] [-b]
-a amd64 | i386 CPU architecture
-b bios boot type (default is efi64)
-d device_block USB key to write
${0} initialize an usb key fot debian automatic install with preseed and a partman recipe.
EOF
}

download (){
#Download function
# $1 : filename
# $2 : url
# $3 : 1 if abort download if file exist
echo -ne "Downloading $1 ... "
if [[ -f $1 && $3 == "1" ]]
then
echo file already downloaded.
return
fi
wget ‐‐no-clobber -4 $2/$1 &> /dev/null
echo "done!"
}

create_dir(){
# $1 directory to create
if [ ! -d $1 ]; then mkdir -p $1; fi
}

# Arguments ...
while getopts "ha:bd:" opt; do
case "$opt" in
h)
usage
exit 0
;;
a)
if [[ $OPTARG == "amd64" || $OPTARG == "i386" ]]
then
DEBIAN_ARCH=$OPTARG
else
echo "CPU architecture must be amd64 of i386, bye."
exit 1
fi
;;
b)
BOOT_TYPE="bios"
;;
d)
if [ -b $OPTARG ]
then
dest=$OPTARG
else
echo "Destinatioj is not a block device, bye."
exit 1
fi
;;
esac
done

# Création du répertoire temporaire
if [ ! -d $TMP_DIR ]; then mkdir $TMP_DIR; fi

if [[ -z $dest ]]
then
echo "No destination device specified, USB key will not be created."
fi

bootfiles_Debian="http://ftp.debian.org/debian/dists/jessie/main/installer-${DEBIAN_ARCH}/current/images/hd-media"
iso_Debian="http://cdimage.debian.org/debian-cd/${DEBIAN_VERSION}/${DEBIAN_ARCH}/iso-cd/"
iso_file="debian-${DEBIAN_VERSION}-${DEBIAN_ARCH}-netinst.iso "
syslinux_url="https://www.kernel.org/pub/linux/utils/boot/syslinux/"
syslinux_archive="syslinux-${SYSLINUX_VERSION}.tar.gz"
current_dir=`pwd`

# Download Debian file (kernel, initrd and iso)
echo -e "\nPrepare Debian files\n---"
for file in "vmlinuz" "initrd.gz"
do
download $file $bootfiles_Debian 1
done
download ${iso_Debian} $iso_file 1

# Get Syslinux archive
echo -e "\nPrepare syslinux files\n---"
if [ ! -d "/tmp/syslinux-${SYSLINUX_VERSION}" ]
then
cd $TMP_DIR
if [ ! -f $syslinux_archive ]; then download $syslinux_archive $syslinux_url 1; fi
tar -xf $syslinux_archive
cd $current_dir
fi

# Copy wanted syslinux file from archive
for file in $SYSLINUX_FILES
do
echo "copie de $file"
cp ${TMP_DIR}/syslinux-${SYSLINUX_VERSION}/${BOOT_TYPE}/${file} ./syslinux/
done
case $BOOT_TYPE in
efi64)
for file in $SYSLINUX_EFI_FILES
do
echo "copying $file ..."
cp ${TMP_DIR}/syslinux-${SYSLINUX_VERSION}/${BOOT_TYPE}/${file} ./syslinux/
done
create_dir "EFI/syslinux"
cp ${TMP_DIR}/syslinux-${SYSLINUX_VERSION}/${BOOT_TYPE}/efi/syslinux.efi ./EFI/boot/bootx64.efi
;;
bios)
for file in $SYSLINUX_BIOS_FILES
do
echo "copying $file ..."
cp ${TMP_DIR}/syslinux-${SYSLINUX_VERSION}/${BOOT_TYPE}/${file} ./syslinux/
done
;;
esac

if [[ -n $dest ]]
then
read -p "[WARNING] Disk $dest will be erased continue [Y/N]? " -n 1 -r
if [[ ! $REPLY =~ ^[Yy]$ ]]
then
exit 1
fi
#dd if=/dev/zero of=${dest} bs=512 count=1 conv=notrunc &> /dev/null
echo -e "\nCreating partition"
parted -s ${dest} mklabel msdos mkpart primary fat32 1MiB 100% set 1 boot on
mkfs.vfat ${dest}1 -n debian &> /dev/null
if [[ $BOOT_TYPE == "bios" ]]
then
# In bis mode, we need to write syslinux MBR.
echo "Writing syslinux mbr.ini fo $dest"
dd bs=440 count=1 conv=notrunc if=${TMP_DIR}/syslinux-${SYSLINUX_VERSION}/bios/mbr/mbr.bin of=${dest}
fi
create_dir $MOUNT_DIR
mount ${dest}1 $MOUNT_DIR
echo "copying all file to USB drive"
cp * $MOUNT_DIR &> /dev/null
cp -R syslinux $MOUNT_DIR &> /dev/null
cp -R EFI $MOUNT_DIR &> /dev/null
umount $MOUNT_DIR
exit 0
fi

+ 26
- 0
partman View File

@@ -0,0 +1,26 @@
partman-auto/text/atomic_scheme ::

100 100 200 EFS
label{ EFI }
method{ efi }
format{ }
use_filesystem{ }
filesystem{ EFS }
mountpoint{ /boot/efi }
.
15000 4000 20000 ext4
method{ format }
format{ }
use_filesystem{ }
filesystem{ ext4 }
mountpoint{ / }
.
100 10000 -1 ext4
method{ format }
format{ }
use_filesystem{ }
filesystem{ ext4 }
mountpoint{ /home }
.

+ 57
- 0
preseed.cfg View File

@@ -0,0 +1,57 @@
d-i debian-installer/locale string fr_FR
d-i keyboard-configuration/xkb-keymap select fr(latin9)
d-i netcfg/choose_interface select eth0
d-i netcfg/get_hostname string unassigned-hostname
d-i netcfg/get_domain string unassigned-domain

#
# MIRROR
#
d-i mirror/country string manual
d-i mirror/http/hostname string http.fr.debian.org
d-i mirror/http/directory string /debian
d-i mirror/http/proxy string

#
# USER ACCOUNT
#
d-i passwd/root-login boolean true
d-i passwd/make-user boolean false
#Create the root password...
d-i passwd/root-password password test
d-i passwd/root-password-again password test

#
# CLOCK
#
d-i clock-setup/utc boolean true
d-i time/zone string Europe/Paris
d-i clock-setup/ntp boolean true

#
# PARTITIONS
#
d-i partman-auto/disk string /dev/sda
d-i partman-auto/method string regular
d-i partman-auto/purge_lvm_from_device boolean true
d-i partman-lvm/device_remove_lvm boolean true
d-i partman-md/device_remove_md boolean true
d-i partman-lvm/confirm boolean true
d-i partman-auto/choose_recipe select atomic
d-i partman-auto/expert_recipe_file string /hd-media/partman
d-i partman-partitioning/confirm_write_new_label boolean true
d-i partman/choose_partition select finish
d-i partman/confirm boolean true
d-i partman/confirm_nooverwrite boolean true

#
# PACKAGES
#
tasksel tasksel/first multiselect none

#
# GRUB
#
d-i grub-installer/only_debian boolean true
d-i grub-installer/with_other_os boolean true


+ 7
- 0
syslinux/syslinux.cfg View File

@@ -0,0 +1,7 @@
Timeout 0
default vesamenu.c32
menu Title ACAQB Debian Install disk
label install
menu label Installer Debian w/ Preseed
kernel /vmlinuz
append shared/ask_device=manual install auto=true priority=critical shared/enter_device=/dev/disk/by-label/debian file=/hd-media/preseed.cfg locale=fr_FR.UTF-8 keymap=fr DEBCONF_DEBUG=5 initrd=/initrd.gz

Loading…
Cancel
Save