添加dd功能

This commit is contained in:
bin456789
2023-06-04 19:12:57 +08:00
parent 270773f473
commit 1b8fe2637f
3 changed files with 39 additions and 4 deletions

View File

@ -3,7 +3,7 @@ confhome=https://raw.githubusercontent.com/bin456789/reinstall/main
localtest_confhome=http://192.168.253.1
usage_and_exit() {
echo "Usage: reinstall.sh centos-7/8/9 alma-8/9 rocky-8/9 fedora-37/38 ubuntu-20.04/22.04 alpine-3.16/3.17/3.18 debian-10/11 windows"
echo "Usage: reinstall.sh centos-7/8/9 alma-8/9 rocky-8/9 fedora-37/38 ubuntu-20.04/22.04 alpine-3.16/3.17/3.18 debian-10/11 windows dd"
exit 1
}
@ -96,6 +96,14 @@ setos() {
eval "${step}_image_name='$image_name'"
}
setos_dd() {
if [ -z "$ddimg" ]; then
echo "dd need --ddimg"
exit 1
fi
eval "${step}_ddimg='$ddimg'"
}
setos_redhat() {
if [ "$localtest" = 1 ]; then
mirror=$confhome/$releasever/
@ -132,13 +140,14 @@ setos() {
alpine) setos_alpine ;;
debian) setos_debian ;;
windows) setos_windows ;;
dd) setos_dd ;;
*) setos_redhat ;;
esac
}
# 检查是否为正确的系统名
verify_os_string() {
for os in 'centos-7|8|9' 'alma|rocky-8|9' 'fedora-37|38' 'ubuntu-20.04|22.04' 'alpine-3.16|3.17|3.18' 'debian-10|11|12' 'windows-'; do
for os in 'centos-7|8|9' 'alma|rocky-8|9' 'fedora-37|38' 'ubuntu-20.04|22.04' 'alpine-3.16|3.17|3.18' 'debian-10|11|12' 'windows-' 'dd-'; do
ds=$(echo $os | cut -d- -f1)
vers=$(echo $os | cut -d- -f2 | sed 's \. \\\. g')
finalos=$(echo "$@" | tr '[:upper:]' '[:lower:]' | sed -n -E "s,^($ds)[ :-]?($vers)$,\1:\2,p")
@ -208,7 +217,7 @@ if [ "$EUID" -ne 0 ]; then
exit 1
fi
if ! opts=$(getopt -a -n $0 --options l --long localtest,iso:,image-name: -- "$@"); then
if ! opts=$(getopt -a -n $0 --options l --long localtest,iso:,image-name:,ddimg: -- "$@"); then
usage_and_exit
fi
@ -220,6 +229,10 @@ while true; do
confhome=$localtest_confhome
shift
;;
--ddimg)
ddimg=$2
shift 2
;;
--iso)
iso=$2
shift 2
@ -262,6 +275,7 @@ esac
if [ "$distro" = "ubuntu" ] ||
[ "$distro" = "alpine" ] ||
[ "$distro" = "windows" ] ||
[ "$distro" = "dd" ] ||
{ [ "$distro_like" = "redhat" ] && [ $releasever -ge 8 ] && [ $ram_size -lt 2048 ]; } ||
{ [ "$distro_like" = "redhat" ] && [ $releasever -eq 7 ] && [ $ram_size -lt 1536 ] && [ $basearch = "aarch64" ]; }; then
# 安装alpine时使用指定的版本。 alpine作为中间系统时使用 3.18