svprognu/build_svprognu

72 lines
1.4 KiB
Plaintext
Raw Normal View History

2020-08-06 00:23:47 +02:00
#!/bin/bash
# Creation de la clef ./build_svprognu -d /dev/sdX
2022-11-19 19:48:52 +01:00
2020-08-06 00:23:47 +02:00
set -e
2023-11-05 16:51:51 +01:00
ISO="live-svprognu-bullseye_amd64.iso"
2020-10-14 14:20:31 +02:00
2022-11-19 19:42:20 +01:00
2022-11-22 00:21:10 +01:00
while getopts ":r d:" opt; do
2020-08-06 00:23:47 +02:00
case $opt in
2022-11-22 00:21:10 +01:00
r)
2022-11-19 19:42:20 +01:00
# Recuperation iso
echo "Téléchargement de l'iso..."
sleep 5
2023-11-04 22:45:12 +01:00
wget -O ${ISO} https://dl.vermeulen.pro/SVPROGNU/${ISO}
wget -O ${ISO}.md5sum https://dl.vermeulen.pro/SVPROGNU/${ISO}.md5sum
2022-11-19 19:42:20 +01:00
echo "Vérification de l'image..."
if ! md5sum -c ${ISO}.md5sum
then
echo "ISO Corompue. Abandon !!"
rm -f ${ISO} ${ISO}.md5
exit 1
fi
;;
# Copie de l'image iso sur clé
2022-11-22 00:21:10 +01:00
d)
2020-08-06 00:23:47 +02:00
echo "Transfert en cours..."
2022-11-23 21:46:37 +01:00
#Vérification montage support
if mount | grep -q $OPTARG > /dev/null
then
2022-11-23 22:05:04 +01:00
umount $OPTARG* || /bin/true
2022-11-23 21:46:37 +01:00
fi
2022-11-22 00:21:10 +01:00
#Réinitialisation de la clé : Table DOS
printf 'o\nw' | fdisk $OPTARG
#Transfert
2020-08-06 00:23:47 +02:00
dd if=${ISO} of=$OPTARG bs=4M status=progress
sync
# Création de la partition dédiée à la persistence
echo "Création de la persistence..."
2022-11-22 00:21:10 +01:00
sleep 5
2020-08-06 00:23:47 +02:00
printf 'n\np\n\n\n\nw' | fdisk $OPTARG
2021-02-13 17:46:48 +01:00
echo "Formatage..."
sleep 10
2020-08-06 00:23:47 +02:00
mkfs.ext4 -L persistence ${OPTARG}3
# Configuratio de la partition
mkdir -p ./tmp
mount ${OPTARG}3 ./tmp
echo "/ union" > ./tmp/persistence.conf
umount ./tmp
2021-02-13 17:46:48 +01:00
echo "Finalisation..."
sleep 10
2021-02-13 21:49:53 +01:00
rm -rf ./tmp
2020-08-06 00:23:47 +02:00
# Fin
echo "Terminé ! Vous pouvez booter sur la clé USB, la persistence sera auto-configurée lors du premier Boot !"
;;
esac
done
exit 0