Verified Commit 8abbc27a authored by Luc Didry's avatar Luc Didry
Browse files

Add an option to download the latest Debian amd64 netinst ISO image

parent 2dd99dd2
......@@ -9,18 +9,82 @@ Preseed Creator (c) Luc Didry 2017, WTFPL
-o <preseeded_image.iso> output preseeded ISO image. Default to preseed_creator/debian-netinst-latest-preseed.ISO
-p <preseed_file.cfg> preseed file. If not provided, the script will put "d-i debian-installer/locale string fr_BE" in the preseed.cfg file
-x Use xorriso instead of genisoimage, to create an iso-hybrid
-d download the latest Debian amd64 netinst ISO image in the current folder
-g download the latest Debian stable example preseed file into preseed_example.cfg and exit
-h print this help and exit
EOF
exit
}
function download_latest_iso {
ONLY_DOWNLOAD=$1
if [ $ONLY_DOWNLOAD == 1 ]
then
echo -ne 'Getting Debian GPG keys [========> ](25%)\r'
else
echo -ne 'Getting Debian GPG keys [> ](0%)\r'
fi
for i in F41D30342F3546695F65C66942468F4009EA8AC3 DF9B9C49EAA9298432589D76DA87E80D6294BE9B 10460DAD76165AD81FBC0CE9988021A964E6EA7D
do
gpg --list-keys $i > /dev/null 2>&1
if [ $? != 0 ]
then
gpg --keyserver keyring.debian.org --recv-keys 0x$i > /dev/null 2>&1
fi
done
if [ $ONLY_DOWNLOAD == 1 ]
then
echo -ne 'Downloading latest Debian amd64 netinst ISO [==============> ](50%)\r'
else
echo -ne 'Downloading latest Debian amd64 netinst ISO [===> ](10%)\r'
fi
export LATEST=$(wget -q -O - https://cdimage.debian.org/debian-cd/current/amd64/iso-cd/ | grep "netinst.iso" | grep -v "debian-mac" | grep -v "debian-edu" | sed -e 's@.*a href="\([^"]*\)".*@\1@')
wget -q https://cdimage.debian.org/debian-cd/current/amd64/iso-cd/$LATEST -O debian-netinst-latest.iso
wget -q https://cdimage.debian.org/debian-cd/current/amd64/iso-cd/SHA512SUMS -O SHA512SUMS
wget -q https://cdimage.debian.org/debian-cd/current/amd64/iso-cd/SHA512SUMS.sign -O SHA512SUMS.sign
if [ $ONLY_DOWNLOAD == 1 ]
then
echo -ne 'Verifying GPG signature [======================> ](75%)\r'
else
echo -ne 'Verifying GPG signature [======> ](20%)\r'
fi
gpg --verify SHA512SUMS.sign SHA512SUMS > /dev/null 2>&1
if [ $? -ne 0 ]
then
echo "Bad SHA512SUMS GPG signature. Aborting"
exit 1
fi
if [ $ONLY_DOWNLOAD == 1 ]
then
echo -ne 'Veryfying sha512sum [=============================>](100%)\r'
else
echo -ne 'Veryfying sha512sum [=========> ](30%)\r'
fi
sed -e "s@${LATEST}@debian-netinst-latest.iso@" -i SHA512SUMS
sha512sum --ignore-missing -c SHA512SUMS > /dev/null 2>&1
if [ $? -ne 0 ]
then
echo "Bad ISO checksum. Aborting"
exit 1
fi
if [ $ONLY_DOWNLOAD == 1 ]
then
exit 0
fi
}
INPUT=""
PRESEED=""
MYPWD=$(pwd)
OUTPUT=""
XORRISO=""
while getopts ":i:o:p:xgh" opt; do
while getopts ":i:o:p:xdgh" opt; do
case $opt in
i)
INPUT=$OPTARG
......@@ -34,6 +98,10 @@ while getopts ":i:o:p:xgh" opt; do
x)
XORRISO='yes'
;;
d)
echo "Downloading latest Debian amd64 netinst ISO image"
download_latest_iso 1
;;
g)
echo "Downloading latest Debian stable example preseed file into preseed_example.cfg"
wget -q http://www.debian.org/releases/stable/example-preseed.txt -O preseed_example.cfg
......@@ -84,39 +152,7 @@ fi
if [[ -z $INPUT ]]
then
echo "No ISO image provided, will download the latest Debian amd64 netinst ISO image"
echo -ne 'Getting Debian GPG keys [> ](0%)\r'
for i in F41D30342F3546695F65C66942468F4009EA8AC3 DF9B9C49EAA9298432589D76DA87E80D6294BE9B 10460DAD76165AD81FBC0CE9988021A964E6EA7D
do
gpg --list-keys $i > /dev/null 2>&1
if [ $? != 0 ]
then
gpg --keyserver keyring.debian.org --recv-keys 0x$i > /dev/null 2>&1
fi
done
echo -ne 'Downloading latest Debian amd64 netinst ISO [===> ](10%)\r'
export LATEST=$(wget -q -O - https://cdimage.debian.org/debian-cd/current/amd64/iso-cd/ | grep "netinst.iso" | grep -v "debian-mac" | grep -v "debian-edu" | sed -e 's@.*a href="\([^"]*\)".*@\1@')
wget -q https://cdimage.debian.org/debian-cd/current/amd64/iso-cd/$LATEST -O debian-netinst-latest.iso
wget -q https://cdimage.debian.org/debian-cd/current/amd64/iso-cd/SHA512SUMS -O SHA512SUMS
wget -q https://cdimage.debian.org/debian-cd/current/amd64/iso-cd/SHA512SUMS.sign -O SHA512SUMS.sign
echo -ne 'Verifying GPG signature [======> ](20%)\r'
gpg --verify SHA512SUMS.sign SHA512SUMS > /dev/null 2>&1
if [ $? -ne 0 ]
then
echo "Bad SHA512SUMS GPG signature. Aborting"
exit 1
fi
echo -ne 'Veryfying sha512sum [=========> ](30%)\r'
sed -e "s@${LATEST}@debian-netinst-latest.iso@" -i SHA512SUMS
sha512sum --ignore-missing -c SHA512SUMS > /dev/null 2>&1
if [ $? -ne 0 ]
then
echo "Bad ISO checksum. Aborting"
exit 1
fi
download_latest_iso 0
INPUT="debian-netinst-latest.iso"
else
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment