path 自己改一改就會動了
#!/usr/bin/bash
function dl_debian() {
local base_url
local ver="$1" # stable, testing
case "$ver" in
stable)
base_url="http://ftp.tw.debian.org/debian-cd/current-live/amd64/iso-hybrid/"
;;
testing)
base_url="https://cdimage.debian.org/cdimage/weekly-live-builds/amd64/iso-hybrid/"
;;
esac
local variant="$2" # gnome, kde, lxde, cinnamon, lxqt, mate, xfxe, standard
shift;shift
local dir="/boot/live/${ver}/${variant}"
mkdir -p "$dir"
echo -n "Downloading hashsum file... "
curl -4sSL "${base_url}SHA512SUMS" -o "${dir}/SHA512SUMS.NEW" || {
echo "failed."
return 1
}
echo done.
if [[ -f "${dir}/SHA512SUMS" ]]; then
if cmp -s "${dir}/SHA512SUMS" "${dir}/SHA512SUMS.NEW"; then
echo "No new image found."
rm -f "${dir}/SHA512SUMS.NEW"
return 0
fi
fi
local fn="$(grep "amd64-${variant}\\.iso\$" "${dir}/SHA512SUMS.NEW" | awk '{print $2}')"
wget -c -4O "${dir}/${fn}" "${base_url}${fn}" || {
echo "Download failed."
rm -f "${dir}/SHA512SUMS.NEW"
return 1
}
echo -n "Verifying checksum... "
(cd "$dir" && sha512sum -c --ignore-missing SHA512SUMS.NEW) > /dev/null 2>&1 || {
echo "failed."
return 1
}
echo done.
(
cd "$dir"
echo -n "Extracting kernel... "
7z x -aoa "$fn" "live/vmlinuz" > /dev/null 2>&1 || {
echo "failed."
return 1
}
echo done.
echo -n "Extracting initrd... "
7z x -aoa "$fn" "live/initrd.img" > /dev/null 2>&1 || {
echo "failed."
return 1
}
echo done.
echo -n "Extracting filesystem... "
7z x -aoa "$fn" "live/filesystem.squashfs" > /dev/null 2>&1 || {
echo "failed."
return 1
}
echo done.
) || return $?
# cleanup
mv "${dir}/SHA512SUMS.NEW" "${dir}/SHA512SUMS"
rm -f "${dir}/${fn}"
}
echo "Processing Debian stable gnome..."
dl_debian stable gnome
echo "Processing Debian testing gnome..."
dl_debian testing gnome