|
@@ -1,165 +1,82 @@
|
|
|
|
|
|
-
|
|
|
+
|
|
|
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
+
|
|
|
+
|
|
|
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-underLine='\033[4m'
|
|
|
-aoiBlue='\033[36m'
|
|
|
-blue='\033[34m'
|
|
|
-yellow='\033[33m'
|
|
|
-green='\033[32m'
|
|
|
-red='\033[31m'
|
|
|
-plain='\033[0m'
|
|
|
+
|
|
|
|
|
|
export tmpVER=''
|
|
|
export tmpDIST=''
|
|
|
export tmpURL=''
|
|
|
export tmpWORD=''
|
|
|
export tmpMirror=''
|
|
|
-export tmpDHCP=''
|
|
|
-export targetRelese=''
|
|
|
-export targetLang='cn'
|
|
|
-export TimeZone=''
|
|
|
-export setIpStack=''
|
|
|
export ipAddr=''
|
|
|
export ipMask=''
|
|
|
export ipGate=''
|
|
|
-export ipDNS='8.8.8.8 1.1.1.1'
|
|
|
-export ip6Addr=''
|
|
|
-export ip6Mask=''
|
|
|
-export ip6Gate=''
|
|
|
-export ip6DNS='2001:4860:4860::8888 2606:4700:4700::1111'
|
|
|
-export IncDisk=''
|
|
|
+export ipDNS='8.8.8.8'
|
|
|
+export IncDisk='default'
|
|
|
export interface=''
|
|
|
export interfaceSelect=''
|
|
|
-export setInterfaceName='0'
|
|
|
-export autoPlugAdapter='0'
|
|
|
-export IsCN=''
|
|
|
export Relese=''
|
|
|
-export sshPORT=''
|
|
|
+export sshPORT='22'
|
|
|
export ddMode='0'
|
|
|
export setNet='0'
|
|
|
-export setNetbootXyz='0'
|
|
|
export setRDP='0'
|
|
|
-export tmpSetIPv6=''
|
|
|
-export setIPv6='1'
|
|
|
-export setRaid=''
|
|
|
-export setDisk=''
|
|
|
-export partitionTable='mbr'
|
|
|
-export setMemCheck='1'
|
|
|
+export setIPv6='0'
|
|
|
export isMirror='0'
|
|
|
export FindDists='0'
|
|
|
-export setFileType=''
|
|
|
export loaderMode='0'
|
|
|
-export LANG="en_US.UTF-8"
|
|
|
export IncFirmware='0'
|
|
|
export SpikCheckDIST='0'
|
|
|
+export setInterfaceName='0'
|
|
|
export UNKNOWHW='0'
|
|
|
export UNVER='6.4'
|
|
|
export GRUBDIR=''
|
|
|
export GRUBFILE=''
|
|
|
export GRUBVER=''
|
|
|
export VER=''
|
|
|
-export setCMD=""
|
|
|
-export setConsole=''
|
|
|
-export setAutoConfig='1'
|
|
|
-export FirmwareImage=''
|
|
|
-export AddNum='1'
|
|
|
-export DebianModifiedProcession=''
|
|
|
+export setCMD=''
|
|
|
|
|
|
while [[ $# -ge 1 ]]; do
|
|
|
case $1 in
|
|
|
- -version)
|
|
|
+ -v|--ver)
|
|
|
shift
|
|
|
tmpVER="$1"
|
|
|
shift
|
|
|
;;
|
|
|
- -debian|-Debian)
|
|
|
+ -d|--debian)
|
|
|
shift
|
|
|
Relese='Debian'
|
|
|
tmpDIST="$1"
|
|
|
shift
|
|
|
;;
|
|
|
- -ubuntu|-Ubuntu)
|
|
|
- shift
|
|
|
- ddMode='1'
|
|
|
- finalDIST="$1"
|
|
|
- targetRelese='Ubuntu'
|
|
|
- shift
|
|
|
- ;;
|
|
|
- -kali|-Kali)
|
|
|
+ -u|--ubuntu)
|
|
|
shift
|
|
|
- Relese='Kali'
|
|
|
+ Relese='Ubuntu'
|
|
|
tmpDIST="$1"
|
|
|
shift
|
|
|
;;
|
|
|
- -centos|-CentOS|-cent|-Cent)
|
|
|
+ -c|--centos)
|
|
|
shift
|
|
|
Relese='CentOS'
|
|
|
tmpDIST="$1"
|
|
|
shift
|
|
|
;;
|
|
|
- -rocky|-rockylinux|-RockyLinux)
|
|
|
- shift
|
|
|
- Relese='RockyLinux'
|
|
|
- tmpDIST="$1"
|
|
|
- shift
|
|
|
- ;;
|
|
|
- -alma|-almalinux|-AlmaLinux)
|
|
|
- shift
|
|
|
- Relese='AlmaLinux'
|
|
|
- tmpDIST="$1"
|
|
|
- shift
|
|
|
- ;;
|
|
|
- -fedora|-Fedora)
|
|
|
- shift
|
|
|
- Relese='Fedora'
|
|
|
- tmpDIST="$1"
|
|
|
- shift
|
|
|
- ;;
|
|
|
- -alpine|-alpinelinux|-AlpineLinux|-alpineLinux)
|
|
|
- shift
|
|
|
- Relese='AlpineLinux'
|
|
|
- tmpDIST="$1"
|
|
|
- shift
|
|
|
- ;;
|
|
|
- -win|-windows)
|
|
|
+ -dd|--image)
|
|
|
shift
|
|
|
ddMode='1'
|
|
|
- finalDIST="$1"
|
|
|
- targetRelese='Windows'
|
|
|
- shift
|
|
|
- ;;
|
|
|
- -lang|-language)
|
|
|
- shift
|
|
|
- targetLang="$1"
|
|
|
+ tmpURL="$1"
|
|
|
shift
|
|
|
;;
|
|
|
- -dd|--image)
|
|
|
+ -p|--password)
|
|
|
shift
|
|
|
- ddMode='1'
|
|
|
- tmpURL="$1"
|
|
|
+ tmpWORD="$1"
|
|
|
shift
|
|
|
;;
|
|
|
- --networkstack)
|
|
|
+ -i|--interface)
|
|
|
shift
|
|
|
- setIpStack="$1"
|
|
|
+ interfaceSelect="$1"
|
|
|
shift
|
|
|
;;
|
|
|
--ip-addr)
|
|
@@ -182,49 +99,15 @@ while [[ $# -ge 1 ]]; do
|
|
|
ipDNS="$1"
|
|
|
shift
|
|
|
;;
|
|
|
- --ip6-addr)
|
|
|
- shift
|
|
|
- ip6Addr="$1"
|
|
|
- shift
|
|
|
- ;;
|
|
|
- --ip6-mask)
|
|
|
- shift
|
|
|
- ip6Mask="$1"
|
|
|
- shift
|
|
|
- ;;
|
|
|
- --ip6-gate)
|
|
|
- shift
|
|
|
- ip6Gate="$1"
|
|
|
- shift
|
|
|
- ;;
|
|
|
- --ip6-dns)
|
|
|
- shift
|
|
|
- ip6DNS="$1"
|
|
|
- shift
|
|
|
- ;;
|
|
|
- --network)
|
|
|
- shift
|
|
|
- tmpDHCP="$1"
|
|
|
- shift
|
|
|
- ;;
|
|
|
- --adapter)
|
|
|
- shift
|
|
|
- interfaceSelect="$1"
|
|
|
- shift
|
|
|
- ;;
|
|
|
- --netdevice-unite)
|
|
|
+ --dev-net)
|
|
|
shift
|
|
|
setInterfaceName='1'
|
|
|
;;
|
|
|
- --autoplugadapter)
|
|
|
- shift
|
|
|
- autoPlugAdapter='1'
|
|
|
- ;;
|
|
|
--loader)
|
|
|
shift
|
|
|
loaderMode='1'
|
|
|
;;
|
|
|
- -mirror)
|
|
|
+ -apt|-yum|--mirror)
|
|
|
shift
|
|
|
isMirror='1'
|
|
|
tmpMirror="$1"
|
|
@@ -236,117 +119,38 @@ while [[ $# -ge 1 ]]; do
|
|
|
WinRemote="$1"
|
|
|
shift
|
|
|
;;
|
|
|
- -raid)
|
|
|
- shift
|
|
|
- setRaid="$1"
|
|
|
- shift
|
|
|
- ;;
|
|
|
- -setdisk)
|
|
|
- shift
|
|
|
- setDisk="$1"
|
|
|
- shift
|
|
|
- ;;
|
|
|
- -partition)
|
|
|
- shift
|
|
|
- partitionTable="$1"
|
|
|
- shift
|
|
|
- ;;
|
|
|
- -timezone)
|
|
|
- shift
|
|
|
- TimeZone="$1"
|
|
|
- shift
|
|
|
- ;;
|
|
|
-cmd)
|
|
|
shift
|
|
|
setCMD="$1"
|
|
|
shift
|
|
|
;;
|
|
|
- -console)
|
|
|
- shift
|
|
|
- setConsole="$1"
|
|
|
- shift
|
|
|
- ;;
|
|
|
-firmware)
|
|
|
shift
|
|
|
IncFirmware="1"
|
|
|
- shift
|
|
|
- ;;
|
|
|
- -filetype)
|
|
|
- shift
|
|
|
- setFileType="$1"
|
|
|
- shift
|
|
|
;;
|
|
|
-port)
|
|
|
shift
|
|
|
sshPORT="$1"
|
|
|
shift
|
|
|
;;
|
|
|
- -pwd)
|
|
|
- shift
|
|
|
- tmpWORD="$1"
|
|
|
- shift
|
|
|
- ;;
|
|
|
- --setipv6)
|
|
|
- shift
|
|
|
- tmpSetIPv6="$1"
|
|
|
- shift
|
|
|
- ;;
|
|
|
- --allbymyself)
|
|
|
- shift
|
|
|
- setAutoConfig='0'
|
|
|
- ;;
|
|
|
- --nomemcheck)
|
|
|
+ --noipv6)
|
|
|
shift
|
|
|
- setMemCheck='0'
|
|
|
+ setIPv6='1'
|
|
|
;;
|
|
|
- -netbootxyz)
|
|
|
- shift
|
|
|
- setNetbootXyz='1'
|
|
|
+ -a|--auto|-m|--manual|-ssl)
|
|
|
shift
|
|
|
;;
|
|
|
*)
|
|
|
if [[ "$1" != 'error' ]]; then echo -ne "\nInvaild option: '$1'\n\n"; fi
|
|
|
- echo -ne " Usage:\n\tbash $(basename $0)\t-debian [${underLine}${yellow}dists-name${plain}]\n\t\t\t\t-ubuntu [${underLine}dists-name${plain}]\n\t\t\t\t-kali [${underLine}dists-name${plain}]\n\t\t\t\t-alpine [${underLine}dists-name${plain}]\n\t\t\t\t-centos [${underLine}dists-name${plain}]\n\t\t\t\t-rockylinux [${underLine}dists-name${plain}]\n\t\t\t\t-almalinux [${underLine}dists-name${plain}]\n\t\t\t\t-fedora [${underLine}dists-name${plain}]\n\t\t\t\t-version [32/i386|64/${underLine}${yellow}amd64${plain}|arm/${underLine}${yellow}arm64${plain}] [${underLine}${yellow}dists-verison${plain}]\n\t\t\t\t--ip-addr/--ip-gate/--ip-mask\n\t\t\t\t-apt/-yum/-mirror\n\t\t\t\t-dd/--image\n\t\t\t\t-pwd [linux password]\n\t\t\t\t-port [linux ssh port]\n"
|
|
|
- exit 1
|
|
|
+ echo -ne " Usage:\n\tbash $(basename $0)\t-d/--debian [\033[33m\033[04mdists-name\033[0m]\n\t\t\t\t-u/--ubuntu [\033[04mdists-name\033[0m]\n\t\t\t\t-c/--centos [\033[04mdists-name\033[0m]\n\t\t\t\t-v/--ver [32/i386|64/\033[33m\033[04mamd64\033[0m] [\033[33m\033[04mdists-verison\033[0m]\n\t\t\t\t--ip-addr/--ip-gate/--ip-mask\n\t\t\t\t-apt/-yum/--mirror\n\t\t\t\t-dd/--image\n\t\t\t\t-p [linux password]\n\t\t\t\t-port [linux ssh port]\n"
|
|
|
+ exit 1;
|
|
|
;;
|
|
|
esac
|
|
|
done
|
|
|
|
|
|
-
|
|
|
-[[ "$EUID" -ne '0' || $(id -u) != '0' ]] && echo -ne "\n[${red}Error${plain}] This script must be executed as root!\n\nTry to type:\n${yellow}sudo -s\n${plain}\nAfter entering the password, switch to root dir to execute this script:\n${yellow}cd ~${plain}\n\n" && exit 1
|
|
|
-
|
|
|
-
|
|
|
-function checkCN() {
|
|
|
- for TestUrl in "$2" "$3" "$4" "$5"; do
|
|
|
-
|
|
|
- IPv4PingDelay=`ping -4 -c 2 -w 2 "$TestUrl" | grep "rtt\|round-trip" | cut -d'/' -f5 | awk -F'.' '{print $NF}' | sed -E '/^[0-9]\+\(\.[0-9]\+\)\?$/p'`
|
|
|
- IPv6PingDelay=`ping -6 -c 2 -w 2 "$TestUrl" | grep "rtt\|round-trip" | cut -d'/' -f5 | awk -F'.' '{print $NF}' | sed -E '/^[0-9]\+\(\.[0-9]\+\)\?$/p'`
|
|
|
- if [[ "$1"="BiStack" ]]; then
|
|
|
- [[ "$IPv4PingDelay" != "" || "$IPv6PingDelay" != "" ]] && tmpIsCN+="" || tmpIsCN+="cn"
|
|
|
- elif [[ "$1"="IPv4Stack" ]]; then
|
|
|
- [[ "$IPv4PingDelay" != "" ]] && tmpIsCN+="" || tmpIsCN+="cn"
|
|
|
- elif [[ "$1"="IPv6Stack" ]]; then
|
|
|
- [[ "$IPv6PingDelay" != "" ]] && tmpIsCN+="" || tmpIsCN+="cn"
|
|
|
- fi
|
|
|
- done
|
|
|
-
|
|
|
- [[ $(echo $tmpIsCN | grep -o "cn" | wc -l) == "4" ]] && { IsCN="cn"; ipDNS="119.29.29.29 223.6.6.6"; ip6DNS="2402:4e00:: 2400:3200::1"; }
|
|
|
-}
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-function checkDNS() {
|
|
|
- if [[ "$linux_relese" == 'centos' ]] || [[ "$linux_relese" == 'rockylinux' ]] || [[ "$linux_relese" == 'almalinux' ]] || [[ "$linux_relese" == 'fedora' ]]; then
|
|
|
- tmpDNS=`echo $1 | sed 's/ /,/g'`
|
|
|
- echo "$tmpDNS"
|
|
|
- else
|
|
|
- echo "$1"
|
|
|
- fi
|
|
|
-}
|
|
|
+[[ "$EUID" -ne '0' ]] && echo "Error:This script must be run as root!" && exit 1;
|
|
|
|
|
|
-function dependence() {
|
|
|
+function dependence(){
|
|
|
Full='0';
|
|
|
for BIN_DEP in `echo "$1" |sed 's/,/\n/g'`
|
|
|
do
|
|
@@ -361,185 +165,49 @@ function dependence() {
|
|
|
fi
|
|
|
done
|
|
|
if [ "$Found" == '1' ]; then
|
|
|
- echo -en "[${green}ok${plain}]\t";
|
|
|
+ echo -en "[\033[32mok\033[0m]\t";
|
|
|
else
|
|
|
Full='1';
|
|
|
- echo -en "[${red}Not Install${plain}]";
|
|
|
+ echo -en "[\033[31mNot Install\033[0m]";
|
|
|
fi
|
|
|
echo -en "\t$BIN_DEP\n";
|
|
|
fi
|
|
|
done
|
|
|
if [ "$Full" == '1' ]; then
|
|
|
- echo -ne "\n[${red}Error${plain}] Please use '${yellow}apt-get${plain}' or '${yellow}yum / dnf${plain}' install it. \n\n"
|
|
|
+ echo -ne "\n\033[31mError! \033[0mPlease use '\033[33mapt-get\033[0m' or '\033[33myum\033[0m' install it.\n\n\n"
|
|
|
exit 1;
|
|
|
fi
|
|
|
}
|
|
|
|
|
|
-function selectMirror() {
|
|
|
+function selectMirror(){
|
|
|
[ $# -ge 3 ] || exit 1
|
|
|
Relese=$(echo "$1" |sed -r 's/(.*)/\L\1/')
|
|
|
DIST=$(echo "$2" |sed 's/\ //g' |sed -r 's/(.*)/\L\1/')
|
|
|
VER=$(echo "$3" |sed 's/\ //g' |sed -r 's/(.*)/\L\1/')
|
|
|
New=$(echo "$4" |sed 's/\ //g')
|
|
|
[ -n "$Relese" ] && [ -n "$DIST" ] && [ -n "$VER" ] || exit 1
|
|
|
- if [ "$Relese" == "debian" ] || [ "$Relese" == "ubuntu" ] || [ "$Relese" == "kali" ]; then
|
|
|
+ if [ "$Relese" == "debian" ] || [ "$Relese" == "ubuntu" ]; then
|
|
|
[ "$DIST" == "focal" ] && legacy="legacy-" || legacy=""
|
|
|
TEMP="SUB_MIRROR/dists/${DIST}/main/installer-${VER}/current/${legacy}images/netboot/${Relese}-installer/${VER}/initrd.gz"
|
|
|
- [[ "$Relese" == "kali" ]] && TEMP="SUB_MIRROR/dists/${DIST}/main/installer-${VER}/current/images/netboot/debian-installer/${VER}/initrd.gz"
|
|
|
- elif [ "$Relese" == "centos" ] || [ "$Relese" == "rockylinux" ] || [ "$Relese" == "almalinux" ]; then
|
|
|
- if [ "$Relese" == "centos" ] && [[ "$RedHatSeries" -le "7" ]]; then
|
|
|
- TEMP="SUB_MIRROR/${DIST}/os/${VER}/images/pxeboot/initrd.img"
|
|
|
- else
|
|
|
- TEMP="SUB_MIRROR/${DIST}/BaseOS/${VER}/os/images/pxeboot/initrd.img"
|
|
|
- fi
|
|
|
- elif [ "$Relese" == "fedora" ]; then
|
|
|
- TEMP="SUB_MIRROR/releases/${DIST}/Server/${VER}/os/images/pxeboot/initrd.img"
|
|
|
- elif [ "$Relese" == "alpinelinux" ]; then
|
|
|
- TEMP="SUB_MIRROR/${DIST}/releases/${VER}/netboot/initramfs-lts"
|
|
|
+ elif [ "$Relese" == "centos" ]; then
|
|
|
+ TEMP="SUB_MIRROR/${DIST}/os/${VER}/isolinux/initrd.img"
|
|
|
fi
|
|
|
[ -n "$TEMP" ] || exit 1
|
|
|
mirrorStatus=0
|
|
|
declare -A MirrorBackup
|
|
|
- if [[ "$IsCN" == "cn" ]]; then
|
|
|
- MirrorBackup=(["debian0"]="" ["debian1"]="http://ftp.cn.debian.org/debian" ["debian2"]="http://mirror.nju.edu.cn/debian" ["debian3"]="http://mirrors.ustc.edu.cn/debian" ["debian4"]="https://mirrors.aliyun.com/debian-archive/debian" ["ubuntu0"]="" ["ubuntu1"]="https://mirrors.ustc.edu.cn/ubuntu" ["ubuntu2"]="http://mirrors.xjtu.edu.cn/ubuntu" ["kali0"]="" ["kali1"]="https://mirrors.tuna.tsinghua.edu.cn/kali" ["kali2"]="http://mirrors.zju.edu.cn/kali" ["alpinelinux0"]="" ["alpinelinux1"]="http://mirror.nju.edu.cn/alpine" ["alpinelinux2"]="http://mirrors.tuna.tsinghua.edu.cn/alpine" ["centos0"]="" ["centos1"]="https://mirrors.ustc.edu.cn/centos-stream" ["centos2"]="https://mirrors.bfsu.edu.cn/centos-stream" ["centos3"]="https://mirrors.tuna.tsinghua.edu.cn/centos" ["centos4"]="http://mirror.nju.edu.cn/centos-altarch" ["centos5"]="https://mirrors.tuna.tsinghua.edu.cn/centos-vault" ["fedora0"]="" ["fedora1"]="https://mirrors.tuna.tsinghua.edu.cn/fedora" ["fedora2"]="https://mirrors.bfsu.edu.cn/fedora" ["rockylinux0"]="" ["rockylinux1"]="http://mirror.nju.edu.cn/rocky" ["rockylinux2"]="http://mirrors.sdu.edu.cn/rocky" ["almalinux0"]="" ["almalinux1"]="https://mirror.sjtu.edu.cn/almalinux" ["almalinux2"]="http://mirrors.neusoft.edu.cn/almalinux")
|
|
|
- else
|
|
|
- MirrorBackup=(["debian0"]="" ["debian1"]="http://deb.debian.org/debian" ["debian2"]="http://mirrors.ocf.berkeley.edu/debian" ["debian3"]="http://ftp.yz.yamagata-u.ac.jp/pub/linux/debian" ["debian4"]="http://archive.debian.org/debian" ["ubuntu0"]="" ["ubuntu1"]="http://archive.ubuntu.com/ubuntu" ["ubuntu2"]="http://ports.ubuntu.com" ["kali0"]="" ["kali1"]="https://mirrors.ocf.berkeley.edu/kali" ["kali2"]="http://ftp.yz.yamagata-u.ac.jp/pub/linux/kali" ["alpinelinux0"]="" ["alpinelinux1"]="http://dl-cdn.alpinelinux.org/alpine" ["alpinelinux2"]="https://mirrors.edge.kernel.org/alpine" ["centos0"]="" ["centos1"]="http://mirror.stream.centos.org" ["centos2"]="http://mirrors.ocf.berkeley.edu/centos-stream" ["centos3"]="http://mirror.centos.org/centos" ["centos4"]="http://mirror.centos.org/altarch" ["centos5"]="http://vault.centos.org" ["fedora0"]="" ["fedora1"]="http://mirrors.rit.edu/fedora/fedora/linux" ["fedora2"]="http://ftp.iij.ad.jp/pub/linux/Fedora/fedora/linux" ["rockylinux0"]="" ["rockylinux1"]="http://download.rockylinux.org/pub/rocky" ["rockylinux2"]="http://mirrors.iu13.net/rocky" ["almalinux0"]="" ["almalinux1"]="http://repo.almalinux.org/almalinux" ["almalinux2"]="http://ftp.iij.ad.jp/pub/linux/almalinux")
|
|
|
- fi
|
|
|
- echo "$New" | grep -q '^http://\|^https://\|^ftp://' && MirrorBackup[${Relese}0]="${New%*/}"
|
|
|
- for mirror in $(echo "${!MirrorBackup[@]}" |sed 's/\ /\n/g' |sort -n |grep "^$Relese"); do
|
|
|
- Current="${MirrorBackup[$mirror]}"
|
|
|
- [ -n "$Current" ] || continue
|
|
|
- MirrorURL=`echo "$TEMP" |sed "s#SUB_MIRROR#${Current}#g"`
|
|
|
- wget --no-check-certificate --spider --timeout=3 -o /dev/null "$MirrorURL"
|
|
|
- [ $? -eq 0 ] && mirrorStatus=1 && break
|
|
|
- done
|
|
|
+ MirrorBackup=(["debian0"]="" ["debian1"]="http://deb.debian.org/debian" ["debian2"]="http://archive.debian.org/debian" ["ubuntu0"]="" ["ubuntu1"]="http://archive.ubuntu.com/ubuntu" ["ubuntu2"]="http://ports.ubuntu.com" ["centos0"]="" ["centos1"]="http://mirror.centos.org/centos" ["centos2"]="http://vault.centos.org")
|
|
|
+ echo "$New" |grep -q '^http://\|^https://\|^ftp://' && MirrorBackup[${Relese}0]="$New"
|
|
|
+ for mirror in $(echo "${!MirrorBackup[@]}" |sed 's/\ /\n/g' |sort -n |grep "^$Relese")
|
|
|
+ do
|
|
|
+ Current="${MirrorBackup[$mirror]}"
|
|
|
+ [ -n "$Current" ] || continue
|
|
|
+ MirrorURL=`echo "$TEMP" |sed "s#SUB_MIRROR#${Current}#g"`
|
|
|
+ wget --no-check-certificate --spider --timeout=3 -o /dev/null "$MirrorURL"
|
|
|
+ [ $? -eq 0 ] && mirrorStatus=1 && break
|
|
|
+ done
|
|
|
[ $mirrorStatus -eq 1 ] && echo "$Current" || exit 1
|
|
|
}
|
|
|
|
|
|
-function getIPv4Address() {
|
|
|
-
|
|
|
- iAddr=`ip -4 addr show | grep -wA 5 "$interface" | grep -wv "lo\|host" | grep -w "inet" | grep -w "scope global*\|link*" | head -n 1 | awk -F " " '{for (i=2;i<=NF;i++)printf("%s ", $i);print ""}' | awk '{print$1}'`
|
|
|
- [[ -n "$interface4" && -n "$interface6" && "$interface4" != "$interface6" ]] && iAddr=`ip -4 addr show | grep -wA 5 "$interface4" | grep -wv "lo\|host" | grep -w "inet" | grep -w "scope global*\|link*" | head -n 1 | awk -F " " '{for (i=2;i<=NF;i++)printf("%s ", $i);print ""}' | awk '{print$1}'`
|
|
|
- ipAddr=`echo ${iAddr} | cut -d'/' -f1`
|
|
|
- ipPrefix=`echo ${iAddr} | cut -d'/' -f2`
|
|
|
- ipMask=`netmask "$ipPrefix"`
|
|
|
-
|
|
|
- ip4RouteScopeLink=`ip -4 route show scope link | grep -iv "warp\|wgcf\|wg[0-9]\|docker[0-9]" | grep -w "$interface4" | grep -w "$ipAddr" | grep -m1 -oE '[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}' | head -n 1`
|
|
|
- actualIp4Prefix=`ip -4 route show scope link | grep -iv "warp\|wgcf\|wg[0-9]\|docker[0-9]" | grep -w "$interface4" | grep -w "$ip4RouteScopeLink" | head -n 1 | awk '{print $1}' | awk -F '/' '{print $2}'`
|
|
|
- [[ -z "$actualIp4Prefix" ]] && actualIp4Prefix="$ipPrefix"
|
|
|
- actualIp4Subnet=`netmask "$actualIp4Prefix"`
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
- FirstRoute=`ip -4 route show default | grep -iv "warp\|wgcf\|wg[0-9]\|docker[0-9]" | grep -w "via" | grep -w "dev $interface4*" | head -n 1 | awk -F " " '{for (i=3;i<=NF;i++)printf("%s ", $i);print ""}' | awk '{print$1}'`
|
|
|
-
|
|
|
- RouterMac=`arp -n | grep "$FirstRoute" | awk '{print$3}'`
|
|
|
- FrFirst=`echo "$FirstRoute" | cut -d'.' -f 1,2`
|
|
|
- FrThird=`echo "$FirstRoute" | cut -d'.' -f 3`
|
|
|
-
|
|
|
- ipGates=`ip -4 route show | grep -iv "warp\|wgcf\|wg[0-9]\|docker[0-9]" | grep -v "via" | grep -w "dev $interface4*" | grep -w "proto*" | grep -w "scope global\|link src $ipAddr*" | awk '{print$1}'`
|
|
|
-
|
|
|
- ipGateLine=`echo "$ipGates" | wc -l`
|
|
|
-
|
|
|
- for ((i=1; i<="$ipGateLine"; i++)) do
|
|
|
-
|
|
|
- tmpIpGate=`echo "$ipGates" | sed -n ''$i'p'`
|
|
|
-
|
|
|
- tmpIgAddr=`echo $tmpIpGate | cut -d'/' -f1`
|
|
|
-
|
|
|
- tmpIgPrefix=`echo $tmpIpGate | cut -d'/' -f2`
|
|
|
-
|
|
|
- minIpGate=`ipv4Calc "$tmpIgAddr" "$tmpIgPrefix" | grep "FirstIP:" | awk '{print$2}'`
|
|
|
-
|
|
|
- tmpIpGateFirst=`echo "$minIpGate" | cut -d'.' -f 1,2`
|
|
|
- tmpIpGateThird=`echo "$minIpGate" | cut -d'.' -f 3`
|
|
|
-
|
|
|
- [[ "$FrFirst" == "$tmpIpGateFirst" ]] && {
|
|
|
- if [[ "$FrThird" == "$tmpIpGateThird" ]]; then
|
|
|
- ipGate="$FirstRoute"
|
|
|
- break
|
|
|
- elif [[ "$FrThird" != "$tmpIpGateThird" ]]; then
|
|
|
-
|
|
|
- tmpMigFirst=`echo $minIpGate | cut -d'.' -f 1,2,3`
|
|
|
-
|
|
|
- ipGate=`arp -n | grep "$tmpMigFirst" | grep "$RouterMac" | awk '{print$1}'`
|
|
|
- break
|
|
|
- fi
|
|
|
- }
|
|
|
- done
|
|
|
-
|
|
|
- [[ "$ipGates" == "" || "$ipGate" == "" ]] && ipGate="$FirstRoute"
|
|
|
- transferIPv4AddressFormat "$ipAddr" "$ipGate"
|
|
|
-}
|
|
|
-
|
|
|
-
|
|
|
-function transferIPv4AddressFormat() {
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
- ipv4SubnetCertificate "$1" "$2"
|
|
|
- ipPrefix="$tmpIpMask"
|
|
|
- ipMask=`netmask "$tmpIpMask"`
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
- ip4AddrFirst=`echo $1 | cut -d'.' -f1`
|
|
|
- ip4AddrSecond=`echo $1 | cut -d'.' -f2`
|
|
|
- ip4GateFirst=`echo $2 | cut -d'.' -f1`
|
|
|
- ip4GateSecond=`echo $2 | cut -d'.' -f2`
|
|
|
- ip4GateThird=`echo $2 | cut -d'.' -f3`
|
|
|
-
|
|
|
-
|
|
|
- [[ "$ip4AddrFirst""$ip4AddrSecond" != "$ip4GateFirst""$ip4GateSecond" ]] && {
|
|
|
- [[ "$ip4GateFirst" == "169" && "$ip4GateSecond" == "254" ]] || [[ "$ip4GateFirst" == "172" && "$ip4GateSecond" -ge "16" && "$ip4GateSecond" -le "31" ]] || [[ "$ip4GateFirst" == "192" && "$ip4GateSecond" == "168" ]] || [[ "$ip4GateFirst" == "100" && "$ip4GateSecond" -ge "64" && "$ip4GateSecond" -le "127" ]] || [[ "$ip4GateFirst" == "10" && "$ip4GateSecond" -ge "0" && "$ip4GateSecond" -le "255" ]] || [[ "$ip4GateFirst" == "127" && "$ip4GateSecond" -ge "0" && "$ip4GateSecond" -le "255" ]] || [[ "$ip4GateFirst" == "198" && "$ip4GateSecond" -ge "18" && "$ip4GateSecond" -le "19" ]] || [[ "$ip4GateFirst" == "192" && "$ip4GateSecond" == "0" && "$ip4GateThird" == "0" || "$ip4GateThird" == "2" ]] || [[ "$ip4GateFirst" == "198" && "$ip4GateSecond" == "51" && "$ip4GateThird" == "100" ]] || [[ "$ip4GateFirst" == "203" && "$ip4GateSecond" == "0" && "$ip4GateThird" == "113" ]] || [[ "$ip4AddrFirst" != "$ip4GateFirst" ]] && {
|
|
|
-
|
|
|
- if [[ "$linux_relese" == 'debian' ]] || [[ "$linux_relese" == 'kali' ]]; then
|
|
|
- ipPrefix="$actualIp4Prefix"
|
|
|
- ipMask="$actualIp4Subnet"
|
|
|
- Network4Config="isStatic"
|
|
|
-
|
|
|
- setInterfaceName='1'
|
|
|
- fi
|
|
|
-
|
|
|
- [[ "$IPStackType" == "BiStack" ]] && BiStackPreferIpv6Status='1'
|
|
|
-
|
|
|
- [[ "$IPStackType" == "IPv4Stack" ]] && BurnIrregularIpv4Status='1'
|
|
|
- }
|
|
|
- }
|
|
|
-}
|
|
|
-
|
|
|
function netmask() {
|
|
|
n="${1:-32}"
|
|
|
b=""
|
|
@@ -554,3308 +222,564 @@ function netmask() {
|
|
|
echo "$m"
|
|
|
}
|
|
|
|
|
|
-
|
|
|
-function ipv4Calc() {
|
|
|
- tmpIp4="$1"
|
|
|
- tmpIp4Mask=`netmask "$2"`
|
|
|
-
|
|
|
- IFS=. read -r i1 i2 i3 i4 <<< "$tmpIp4"
|
|
|
- IFS=. read -r m1 m2 m3 m4 <<< "$tmpIp4Mask"
|
|
|
-
|
|
|
- tmpNetwork="$((i1 & m1)).$((i2 & m2)).$((i3 & m3)).$((i4 & m4))"
|
|
|
- tmpBroadcast="$((i1 & m1 | 255-m1)).$((i2 & m2 | 255-m2)).$((i3 & m3 | 255-m3)).$((i4 & m4 | 255-m4))"
|
|
|
- tmpFirstIP="$((i1 & m1)).$((i2 & m2)).$((i3 & m3)).$(((i4 & m4)+1))"
|
|
|
- tmpFiLast="$(echo "$tmpFirstIP" | cut -d'.' -f 4)"
|
|
|
- FirstIP="$tmpFirstIP"
|
|
|
- tmpLastIP="$((i1 & m1 | 255-m1)).$((i2 & m2 | 255-m2)).$((i3 & m3 | 255-m3)).$(((i4 & m4 | 255-m4)-1))"
|
|
|
- tmpLiLast="$(echo "$tmpLastIP" | cut -d'.' -f 4)"
|
|
|
- LastIP="$tmpLastIP"
|
|
|
- [[ "$tmpFiLast" > "$tmpLiLast" ]] && {
|
|
|
- FirstIP="$tmpLastIP"
|
|
|
- LastIP="$tmpFirstIP"
|
|
|
- }
|
|
|
- [[ "$2" > "31" ]] && {
|
|
|
- FirstIP="$tmpNetwork"
|
|
|
- LastIP="$tmpNetwork"
|
|
|
- }
|
|
|
- echo -e "Network: $tmpNetwork\nBroadcast: $tmpBroadcast\nFirstIP: $FirstIP\nLastIP: $LastIP\n"
|
|
|
+function getInterface(){
|
|
|
+ interface=""
|
|
|
+ Interfaces=`cat /proc/net/dev |grep ':' |cut -d':' -f1 |sed 's/\s//g' |grep -iv '^lo\|^sit\|^stf\|^gif\|^dummy\|^vmnet\|^vir\|^gre\|^ipip\|^ppp\|^bond\|^tun\|^tap\|^ip6gre\|^ip6tnl\|^teql\|^ocserv\|^vpn'`
|
|
|
+ defaultRoute=`ip route show default |grep "^default"`
|
|
|
+ for item in `echo "$Interfaces"`
|
|
|
+ do
|
|
|
+ [ -n "$item" ] || continue
|
|
|
+ echo "$defaultRoute" |grep -q "$item"
|
|
|
+ [ $? -eq 0 ] && interface="$item" && break
|
|
|
+ done
|
|
|
+ echo "$interface"
|
|
|
}
|
|
|
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-function ipv4SubnetCertificate() {
|
|
|
-
|
|
|
-
|
|
|
- [[ `echo $1 | cut -d'.' -f 1` != `echo $2 | cut -d'.' -f 1` ]] && tmpIpMask="1"
|
|
|
-
|
|
|
-
|
|
|
- [[ `echo $1 | cut -d'.' -f 1` == `echo $2 | cut -d'.' -f 1` ]] && tmpIpMask="8"
|
|
|
-
|
|
|
-
|
|
|
- [[ `echo $1 | cut -d'.' -f 1,2` == `echo $2 | cut -d'.' -f 1,2` ]] && tmpIpMask="16"
|
|
|
-
|
|
|
-
|
|
|
- [[ `echo $1 | cut -d'.' -f 1,2,3` == `echo $2 | cut -d'.' -f 1,2,3` ]] && tmpIpMask="24"
|
|
|
-
|
|
|
+function getDisk(){
|
|
|
+ disks=`lsblk | sed 's/[[:space:]]*$//g' |grep "disk$" |cut -d' ' -f1 |grep -v "fd[0-9]*\|sr[0-9]*" |head -n1`
|
|
|
+ [ -n "$disks" ] || echo ""
|
|
|
+ echo "$disks" |grep -q "/dev"
|
|
|
+ [ $? -eq 0 ] && echo "$disks" || echo "/dev/$disks"
|
|
|
}
|
|
|
|
|
|
-
|
|
|
-function getDisk() {
|
|
|
-
|
|
|
- rootPart=`lsblk -ip | grep -v "fd[0-9]*\|sr[0-9]*\|ram[0-9]*\|loop[0-9]*" | sed 's/[[:space:]]*$//g' | grep -w "part /\|part /boot" | head -n 1 | cut -d' ' -f1 | sed 's/..//'`
|
|
|
-
|
|
|
- diskSuffix=${rootPart: -4}
|
|
|
-
|
|
|
-
|
|
|
- [[ -n `echo $diskSuffix | grep -o "[0-9]p[0-9]"` ]] && disks=`echo $rootPart | sed 's/p[0-9]*.$//'` || disks=`echo $rootPart | sed 's/[0-9]*.$//'`
|
|
|
-
|
|
|
- [[ -z "$disks" ]] && disks=`lsblk -ip | grep -v "fd[0-9]*\|sr[0-9]*\|ram[0-9]*\|loop[0-9]*" | sed 's/[[:space:]]*$//g' | grep -w "disk /\|disk /boot" | head -n 1 | cut -d' ' -f1`
|
|
|
- [[ -z "$disks" ]] && disks=`lsblk -ip | grep -v "fd[0-9]*\|sr[0-9]*\|ram[0-9]*\|loop[0-9]*" | sed 's/[[:space:]]*$//g' | grep -w "disk" | grep -i "[0-9]g\|[0-9]t\|[0-9]p\|[0-9]e\|[0-9]z\|[0-9]y" | head -n 1 | cut -d' ' -f1`
|
|
|
- [ -n "$disks" ] || echo ""
|
|
|
- echo "$disks" | grep -q "/dev"
|
|
|
- [ $? -eq 0 ] && IncDisk="$disks" || IncDisk="/dev/$disks"
|
|
|
- AllDisks=""
|
|
|
-
|
|
|
- for Count in `lsblk -ipd | grep -v "fd[0-9]*\|sr[0-9]*\|ram[0-9]*\|loop[0-9]*" | sed 's/[[:space:]]*$//g' | grep -w "disk" | grep -i "[0-9]g\|[0-9]t\|[0-9]p\|[0-9]e\|[0-9]z\|[0-9]y" | cut -d' ' -f1`; do
|
|
|
- AllDisks+="$Count "
|
|
|
- done
|
|
|
- AllDisks=$(echo "$AllDisks" | sed 's/.$//')
|
|
|
-
|
|
|
- disksNum=$(echo $AllDisks | grep -o "/dev/*" | wc -l)
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
- for (( d=1; d<=$disksNum; d++ )); do
|
|
|
- currentDisk=$(echo "$AllDisks" | cut -d' ' -f$d)
|
|
|
- checkIfIsoPartition=$(lsblk -ipf | grep "$currentDisk" | head -n 1 | awk '{print $2}' | grep -i "iso")
|
|
|
- [[ -z "$checkIfIsoPartition" ]] && tmpAllDisks+="$currentDisk "
|
|
|
- done
|
|
|
- tmpAllDisks=$(echo "$tmpAllDisks" | sed 's/.$//')
|
|
|
+function diskType(){
|
|
|
+ echo `udevadm info --query all "$1" 2>/dev/null |grep 'ID_PART_TABLE_TYPE' |cut -d'=' -f2`
|
|
|
+}
|
|
|
|
|
|
- [[ "$AllDisks" != "$tmpAllDisks" ]] && {
|
|
|
- AllDisks="$tmpAllDisks"
|
|
|
- disksNum=$(echo $AllDisks | grep -o "/dev/*" | wc -l)
|
|
|
- [[ "$IncDisk" =~ "$AllDisks" ]] || IncDisk=$(echo "$AllDisks" | cut -d' ' -f1)
|
|
|
- }
|
|
|
+function getGrub(){
|
|
|
+ Boot="${1:-/boot}"
|
|
|
+ folder=`find "$Boot" -type d -name "grub*" 2>/dev/null |head -n1`
|
|
|
+ [ -n "$folder" ] || return
|
|
|
+ fileName=`ls -1 "$folder" 2>/dev/null |grep '^grub.conf$\|^grub.cfg$'`
|
|
|
+ if [ -z "$fileName" ]; then
|
|
|
+ ls -1 "$folder" 2>/dev/null |grep -q '^grubenv$'
|
|
|
+ [ $? -eq 0 ] || return
|
|
|
+ folder=`find "$Boot" -type f -name "grubenv" 2>/dev/null |xargs dirname |grep -v "^$folder" |head -n1`
|
|
|
+ [ -n "$folder" ] || return
|
|
|
+ fileName=`ls -1 "$folder" 2>/dev/null |grep '^grub.conf$\|^grub.cfg$'`
|
|
|
+ fi
|
|
|
+ [ -n "$fileName" ] || return
|
|
|
+ [ "$fileName" == "grub.cfg" ] && ver="0" || ver="1"
|
|
|
+ echo "${folder}:${fileName}:${ver}"
|
|
|
+}
|
|
|
|
|
|
-
|
|
|
- [[ -n "$1" && "$1" =~ ^[a-z0-9]+$ && "$1" != "all" ]] && {
|
|
|
- [[ "$1" =~ "/dev/" ]] && IncDisk="$1" || IncDisk="/dev/$1"
|
|
|
- }
|
|
|
+function lowMem(){
|
|
|
+ mem=`grep "^MemTotal:" /proc/meminfo 2>/dev/null |grep -o "[0-9]*"`
|
|
|
+ [ -n "$mem" ] || return 0
|
|
|
+ [ "$mem" -le "524288" ] && return 1 || return 0
|
|
|
}
|
|
|
|
|
|
-function diskType() {
|
|
|
- echo `udevadm info --query all "$1" 2>/dev/null |grep 'ID_PART_TABLE_TYPE' |cut -d'=' -f2`
|
|
|
+if [[ "$loaderMode" == "0" ]]; then
|
|
|
+ Grub=`getGrub "/boot"`
|
|
|
+ [ -z "$Grub" ] && echo -ne "Error! Not Found grub.\n" && exit 1;
|
|
|
+ GRUBDIR=`echo "$Grub" |cut -d':' -f1`
|
|
|
+ GRUBFILE=`echo "$Grub" |cut -d':' -f2`
|
|
|
+ GRUBVER=`echo "$Grub" |cut -d':' -f3`
|
|
|
+fi
|
|
|
+
|
|
|
+[ -n "$Relese" ] || Relese='Debian'
|
|
|
+linux_relese=$(echo "$Relese" |sed 's/\ //g' |sed -r 's/(.*)/\L\1/')
|
|
|
+clear && echo -e "\n\033[36m# Check Dependence\033[0m\n"
|
|
|
+
|
|
|
+if [[ "$ddMode" == '1' ]]; then
|
|
|
+ dependence iconv;
|
|
|
+ linux_relese='debian';
|
|
|
+ tmpDIST='bullseye';
|
|
|
+ tmpVER='amd64';
|
|
|
+fi
|
|
|
+
|
|
|
+[ -n "$ipAddr" ] && [ -n "$ipMask" ] && [ -n "$ipGate" ] && setNet='1';
|
|
|
+if [ "$setNet" == "0" ]; then
|
|
|
+ dependence ip
|
|
|
+ [ -n "$interface" ] || interface=`getInterface`
|
|
|
+ iAddr=`ip addr show dev $interface |grep "inet.*" |head -n1 |grep -o '[0-9]\{1,3\}\.[0-9]\{1,3\}\.[0-9]\{1,3\}\.[0-9]\{1,3\}\/[0-9]\{1,2\}'`
|
|
|
+ ipAddr=`echo ${iAddr} |cut -d'/' -f1`
|
|
|
+ ipMask=`netmask $(echo ${iAddr} |cut -d'/' -f2)`
|
|
|
+ ipGate=`ip route show default |grep "^default" |grep -o '[0-9]\{1,3\}\.[0-9]\{1,3\}\.[0-9]\{1,3\}\.[0-9]\{1,3\}' |head -n1`
|
|
|
+fi
|
|
|
+if [ -z "$interface" ]; then
|
|
|
+ dependence ip
|
|
|
+ [ -n "$interface" ] || interface=`getInterface`
|
|
|
+fi
|
|
|
+IPv4="$ipAddr"; MASK="$ipMask"; GATE="$ipGate";
|
|
|
+
|
|
|
+[ -n "$IPv4" ] && [ -n "$MASK" ] && [ -n "$GATE" ] && [ -n "$ipDNS" ] || {
|
|
|
+ echo -ne '\nError: Invalid network config\n\n'
|
|
|
+ bash $0 error;
|
|
|
+ exit 1;
|
|
|
}
|
|
|
|
|
|
-
|
|
|
-function setRaidRecipe() {
|
|
|
- [[ -n "$1" ]] && {
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
- if [[ "$1" == "0" || "$1" == "1" || "$1" == "5" || "$1" == "6" || "$1" == "10" ]]; then
|
|
|
- [[ "$1" == "0" || "$1" == "1" ]] && [[ "$2" -lt "2" ]] && {
|
|
|
- echo -ne "\n[${red}Error${plain}] There are $2 drives on your machine, Raid $1 partition recipe only supports a basic set of dual drive or more!\n"
|
|
|
- exit 1
|
|
|
- }
|
|
|
- [[ "$1" == "5" ]] && [[ "$2" -lt "3" ]] && {
|
|
|
- echo -ne "\n[${red}Error${plain}] There are $2 drives on your machine, Raid $1 partition recipe only supports a basic set of triple drive or more!\n"
|
|
|
- exit 1
|
|
|
+if [[ "$Relese" == 'Debian' ]] || [[ "$Relese" == 'Ubuntu' ]]; then
|
|
|
+ dependence wget,awk,grep,sed,cut,cat,lsblk,cpio,gzip,find,dirname,basename;
|
|
|
+elif [[ "$Relese" == 'CentOS' ]]; then
|
|
|
+ dependence wget,awk,grep,sed,cut,cat,lsblk,cpio,gzip,find,dirname,basename,file,xz;
|
|
|
+fi
|
|
|
+[ -n "$tmpWORD" ] && dependence openssl
|
|
|
+[[ -n "$tmpWORD" ]] && myPASSWORD="$(openssl passwd -1 "$tmpWORD")";
|
|
|
+[[ -z "$myPASSWORD" ]] && myPASSWORD='$1$4BJZaD0A$y1QykUnJ6mXprENfwpseH0';
|
|
|
+
|
|
|
+tempDisk=`getDisk`; [ -n "$tempDisk" ] && IncDisk="$tempDisk"
|
|
|
+
|
|
|
+case `uname -m` in aarch64|arm64) VER="arm64";; x86|i386|i686) VER="i386";; x86_64|amd64) VER="amd64";; *) VER="";; esac
|
|
|
+tmpVER="$(echo "$tmpVER" |sed -r 's/(.*)/\L\1/')";
|
|
|
+if [[ "$VER" != "arm64" ]] && [[ -n "$tmpVER" ]]; then
|
|
|
+ case "$tmpVER" in i386|i686|x86|32) VER="i386";; amd64|x86_64|x64|64) [[ "$Relese" == 'CentOS' ]] && VER='x86_64' || VER='amd64';; *) VER='';; esac
|
|
|
+fi
|
|
|
+
|
|
|
+if [[ ! -n "$VER" ]]; then
|
|
|
+ echo "Error! Not Architecture."
|
|
|
+ bash $0 error;
|
|
|
+ exit 1;
|
|
|
+fi
|
|
|
+
|
|
|
+if [[ -z "$tmpDIST" ]]; then
|
|
|
+ [ "$Relese" == 'Debian' ] && tmpDIST='buster';
|
|
|
+ [ "$Relese" == 'Ubuntu' ] && tmpDIST='bionic';
|
|
|
+ [ "$Relese" == 'CentOS' ] && tmpDIST='6.10';
|
|
|
+fi
|
|
|
+
|
|
|
+if [[ -n "$tmpDIST" ]]; then
|
|
|
+ if [[ "$Relese" == 'Debian' ]]; then
|
|
|
+ SpikCheckDIST='0'
|
|
|
+ DIST="$(echo "$tmpDIST" |sed -r 's/(.*)/\L\1/')";
|
|
|
+ echo "$DIST" |grep -q '[0-9]';
|
|
|
+ [[ $? -eq '0' ]] && {
|
|
|
+ isDigital="$(echo "$DIST" |grep -o '[\.0-9]\{1,\}' |sed -n '1h;1!H;$g;s/\n//g;$p' |cut -d'.' -f1)";
|
|
|
+ [[ -n $isDigital ]] && {
|
|
|
+ [[ "$isDigital" == '7' ]] && DIST='wheezy';
|
|
|
+ [[ "$isDigital" == '8' ]] && DIST='jessie';
|
|
|
+ [[ "$isDigital" == '9' ]] && DIST='stretch';
|
|
|
+ [[ "$isDigital" == '10' ]] && DIST='buster';
|
|
|
+ [[ "$isDigital" == '11' ]] && DIST='bullseye';
|
|
|
}
|
|
|
- [[ "$1" == "6" || "$1" == "10" ]] && [[ "$2" -lt "4" ]] && {
|
|
|
- echo -ne "\n[${red}Error${plain}] There are $2 drives on your machine, Raid $1 partition recipe only supports a basic set of quad drive or more!\n"
|
|
|
- exit 1
|
|
|
+ }
|
|
|
+ LinuxMirror=$(selectMirror "$Relese" "$DIST" "$VER" "$tmpMirror")
|
|
|
+ fi
|
|
|
+ if [[ "$Relese" == 'Ubuntu' ]]; then
|
|
|
+ SpikCheckDIST='0'
|
|
|
+ DIST="$(echo "$tmpDIST" |sed -r 's/(.*)/\L\1/')";
|
|
|
+ echo "$DIST" |grep -q '[0-9]';
|
|
|
+ [[ $? -eq '0' ]] && {
|
|
|
+ isDigital="$(echo "$DIST" |grep -o '[\.0-9]\{1,\}' |sed -n '1h;1!H;$g;s/\n//g;$p')";
|
|
|
+ [[ -n $isDigital ]] && {
|
|
|
+ [[ "$isDigital" == '12.04' ]] && DIST='precise';
|
|
|
+ [[ "$isDigital" == '14.04' ]] && DIST='trusty';
|
|
|
+ [[ "$isDigital" == '16.04' ]] && DIST='xenial';
|
|
|
+ [[ "$isDigital" == '18.04' ]] && DIST='bionic';
|
|
|
+ [[ "$isDigital" == '20.04' ]] && DIST='focal';
|
|
|
}
|
|
|
- else
|
|
|
- echo -ne "\n[${red}Error${plain}] Raid $1 partition recipe is not suitable, only Raid 0, 1, 5, 6 or 10 is supported!\n"
|
|
|
- exit 1
|
|
|
- fi
|
|
|
- if [[ "$4" == 'debian' ]] || [[ "$4" == 'kali' ]]; then
|
|
|
- for (( r=1;r<="$2";r++ )); do
|
|
|
- tmpAllDisksPart=`echo "$3" | cut -d ' ' -f"$r"`
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
- echo "${tmpAllDisksPart: -1}" | [[ -n "`sed -n '/^[0-9][0-9]*$/p'`" ]] && tmpAllDisksPart="$tmpAllDisksPart""p" || tmpAllDisksPart="$tmpAllDisksPart"
|
|
|
- AllDisksPart1+="$tmpAllDisksPart""1#"
|
|
|
- AllDisksPart2+="$tmpAllDisksPart""2#"
|
|
|
- AllDisksPart3+="$tmpAllDisksPart""3#"
|
|
|
- done
|
|
|
- AllDisksPart1=`echo "$AllDisksPart1" | sed 's/.$//'`
|
|
|
- AllDisksPart2=`echo "$AllDisksPart2" | sed 's/.$//'`
|
|
|
- AllDisksPart3=`echo "$AllDisksPart3" | sed 's/.$//'`
|
|
|
-
|
|
|
-
|
|
|
- RaidRecipes=`echo -e "d-i partman-md/confirm boolean true
|
|
|
-d-i partman-md/confirm_nooverwrite boolean true
|
|
|
-d-i partman-md/confirm_nochanges boolean false
|
|
|
-d-i partman-basicfilesystems/no_swap boolean false
|
|
|
-d-i partman-auto/method string raid
|
|
|
-d-i partman-auto/disk string $3
|
|
|
-d-i mdadm/boot_degraded boolean true"`
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
- if [[ "$EfiSupport" == "enabled" ]]; then
|
|
|
- FormatDisk=`echo -e "$RaidRecipes
|
|
|
-d-i partman-auto-raid/recipe string \
|
|
|
- 1 $2 0 ext4 /boot $AllDisksPart2 . \
|
|
|
- $1 $2 0 ext4 / $AllDisksPart3 .
|
|
|
-d-i partman-auto/expert_recipe string multiraid :: \
|
|
|
- 1075 100 2150 free \\$bootable{ } \\$primary{ } method{ efi } \\$iflabel{ gpt } \\$reusemethod{ } format{ } . \
|
|
|
- 269 150 538 raid \\$primary{ } method{ raid } . \
|
|
|
- 100 200 -1 raid \\$primary{ } method{ raid } .
|
|
|
-d-i partman-efi/non_efi_system boolean true
|
|
|
-d-i partman-partitioning/choose_label select gpt
|
|
|
-d-i partman-partitioning/default_label string gpt"`
|
|
|
- else
|
|
|
-
|
|
|
- FormatDisk=`echo -e "$RaidRecipes
|
|
|
-d-i partman-auto-raid/recipe string \
|
|
|
- 1 $2 0 ext4 /boot $AllDisksPart1 . \
|
|
|
- $1 $2 0 ext4 / $AllDisksPart2 .
|
|
|
-d-i partman-auto/expert_recipe string multiraid :: \
|
|
|
- 1075 100 2150 raid \\$bootable{ } \\$primary{ } method{ raid } . \
|
|
|
- 100 200 -1 raid \\$primary{ } method{ raid } .
|
|
|
-"`
|
|
|
- fi
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
- elif [[ "$4" == 'centos' ]] || [[ "$4" == 'rockylinux' ]] || [[ "$4" == 'almalinux' ]] || [[ "$4" == 'fedora' ]]; then
|
|
|
- tmpKsAllDisks=$(echo "$3" | sed 's/\/dev\///g')
|
|
|
- ksRaidVolumes=()
|
|
|
- ksRaidConfigs=""
|
|
|
- ksRaidRecipes=""
|
|
|
- if [[ "$EfiSupport" == "enabled" ]]; then
|
|
|
- for (( partitionIndex=0; partitionIndex<="2"; partitionIndex++ )); do
|
|
|
- disksIndex="1"
|
|
|
- for currentDisk in $tmpKsAllDisks; do
|
|
|
- tmpKsRaidVolumes="raid."$partitionIndex""$disksIndex""
|
|
|
- if [[ "$partitionIndex" == "0" ]]; then
|
|
|
- tmpKsRaidConfigs="part "$tmpKsRaidVolumes" --size="512" --ondisk="$currentDisk""
|
|
|
- elif [[ "$partitionIndex" == "1" ]]; then
|
|
|
- tmpKsRaidConfigs="part "$tmpKsRaidVolumes" --size="1024" --ondisk="$currentDisk""
|
|
|
- elif [[ "$partitionIndex" == "2" ]]; then
|
|
|
- tmpKsRaidConfigs="part "$tmpKsRaidVolumes" --size="0" --grow --ondisk="$currentDisk""
|
|
|
- fi
|
|
|
- disksIndex=$(expr "$disksIndex" + 1)
|
|
|
- ksRaidVolumes[$partitionIndex]+=""$tmpKsRaidVolumes" "
|
|
|
- ksRaidConfigs+=""$tmpKsRaidConfigs"\n"
|
|
|
- done
|
|
|
- done
|
|
|
- ksRaidConfigs=$(echo -e "$ksRaidConfigs")
|
|
|
- ksRaidRecipes=`echo -e "raid /boot --fstype="xfs" --device="boot" --level="1" ${ksRaidVolumes[0]}
|
|
|
-raid /boot/efi --fstype="efi" --device="boot-efi" --level="1" ${ksRaidVolumes[1]}
|
|
|
-raid / --fstype="xfs" --device="root" --level="$1" ${ksRaidVolumes[2]}
|
|
|
-"`
|
|
|
- else
|
|
|
- for (( partitionIndex=0; partitionIndex<="2"; partitionIndex++ )); do
|
|
|
- disksIndex="1"
|
|
|
- for currentDisk in $tmpKsAllDisks; do
|
|
|
- tmpKsRaidVolumes="raid."$partitionIndex""$disksIndex""
|
|
|
- if [[ "$partitionIndex" == "0" ]]; then
|
|
|
- tmpKsRaidConfigs="part biosboot --fstype="biosboot" --size="1" --ondisk="$currentDisk""
|
|
|
- elif [[ "$partitionIndex" == "1" ]]; then
|
|
|
- tmpKsRaidConfigs="part "$tmpKsRaidVolumes" --size="1024" --ondisk="$currentDisk""
|
|
|
- elif [[ "$partitionIndex" == "2" ]]; then
|
|
|
- tmpKsRaidConfigs="part "$tmpKsRaidVolumes" --size="0" --grow --ondisk="$currentDisk""
|
|
|
- fi
|
|
|
- disksIndex=$(expr "$disksIndex" + 1)
|
|
|
- ksRaidVolumes[$partitionIndex]+=""$tmpKsRaidVolumes" "
|
|
|
- ksRaidConfigs+=""$tmpKsRaidConfigs"\n"
|
|
|
- done
|
|
|
- done
|
|
|
- ksRaidConfigs=$(echo -e "$ksRaidConfigs")
|
|
|
- ksRaidRecipes=`echo -e "raid /boot --fstype="xfs" --device="boot" --level="1" ${ksRaidVolumes[1]}
|
|
|
-raid / --fstype="xfs" --device="root" --level="$1" ${ksRaidVolumes[2]}
|
|
|
-"`
|
|
|
- fi
|
|
|
- FormatDisk="${ksRaidConfigs}
|
|
|
-${ksRaidRecipes}"
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
- else
|
|
|
- echo -ne "\n[${red}Warning${plain}] Raid $1 recipe is not supported by target system!\n"
|
|
|
- exit 1
|
|
|
- fi
|
|
|
- }
|
|
|
-}
|
|
|
+ }
|
|
|
+ LinuxMirror=$(selectMirror "$Relese" "$DIST" "$VER" "$tmpMirror")
|
|
|
+ fi
|
|
|
+ if [[ "$Relese" == 'CentOS' ]]; then
|
|
|
+ SpikCheckDIST='1'
|
|
|
+ DISTCheck="$(echo "$tmpDIST" |grep -o '[\.0-9]\{1,\}' |head -n1)";
|
|
|
+ LinuxMirror=$(selectMirror "$Relese" "$DISTCheck" "$VER" "$tmpMirror")
|
|
|
+ ListDIST="$(wget --no-check-certificate -qO- "$LinuxMirror/dir_sizes" |cut -f2 |grep '^[0-9]')"
|
|
|
+ DIST="$(echo "$ListDIST" |grep "^$DISTCheck" |head -n1)"
|
|
|
+ [[ -z "$DIST" ]] && {
|
|
|
+ echo -ne '\nThe dists version not found in this mirror, Please check it! \n\n'
|
|
|
+ bash $0 error;
|
|
|
+ exit 1;
|
|
|
+ }
|
|
|
+ wget --no-check-certificate -qO- "$LinuxMirror/$DIST/os/$VER/.treeinfo" |grep -q 'general';
|
|
|
+ [[ $? != '0' ]] && {
|
|
|
+ echo -ne "\nThe version not found in this mirror, Please change mirror try again! \n\n";
|
|
|
+ exit 1;
|
|
|
+ }
|
|
|
+ fi
|
|
|
+fi
|
|
|
|
|
|
-
|
|
|
-function getUserTimeZone() {
|
|
|
- if [[ ! "$TimeZone" =~ ^[a-zA-Z] ]]; then
|
|
|
- loginUser=`who am i | awk '{print $1}' | sed 's/(//g' | sed 's/)//g'`
|
|
|
- [[ -z "$loginUser" ]] && loginUser="root"
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
- GuestIP=`netstat -naputeoW | grep -i 'established' | grep -i 'sshd: '$loginUser'' | grep -iw '^tcp\|udp' | awk '{print $3,$5}' | sort -t ' ' -k 1 -rn | awk '{print $2}' | head -n 1 | cut -d':' -f'1'`
|
|
|
- [[ "$GuestIP" == "" ]] && GuestIP=`netstat -naputeoW | grep -i 'established' | grep -i 'sshd: '$loginUser'' | grep -iw '^tcp6\|udp6' | awk '{print $3,$5}' | sort -t ' ' -k 1 -rn | awk '{print $2}' | head -n 1 | awk -F':' '{for (i=1;i<=NF-1;i++)printf("%s:", $i);print ""}' | sed 's/.$//'`
|
|
|
- for Count in "$2$GuestIP" "$3$GuestIP" "$4$GuestIP" "$5$GuestIP/json/" "$6" "$7" "$8"; do
|
|
|
- [[ "$TimeZone" == "Asia/Shanghai" ]] && break
|
|
|
- if [[ "$Count" =~ ^[a-zA-Z0-9]+$ ]]; then
|
|
|
- tmpApi=`echo -n "$Count" | base64 -d`
|
|
|
- Count="https://api.ipgeolocation.io/timezone?apiKey=$tmpApi&ip=$GuestIP"
|
|
|
- fi
|
|
|
- TimeZone=`curl -s "$Count" -A firefox | jq '.timezone, .time_zone' | grep -v "null" | tr -d '"'`
|
|
|
- checkTz=`echo $TimeZone | cut -d'/' -f 1`
|
|
|
- [[ -n "$checkTz" && "$checkTz" =~ ^[a-zA-Z] ]] && break
|
|
|
+if [[ -z "$LinuxMirror" ]]; then
|
|
|
+ echo -ne "\033[31mError! \033[0mInvaild mirror! \n"
|
|
|
+ [ "$Relese" == 'Debian' ] && echo -en "\033[33mexample:\033[0m http://deb.debian.org/debian\n\n";
|
|
|
+ [ "$Relese" == 'Ubuntu' ] && echo -en "\033[33mexample:\033[0m http://archive.ubuntu.com/ubuntu\n\n";
|
|
|
+ [ "$Relese" == 'CentOS' ] && echo -en "\033[33mexample:\033[0m http://mirror.centos.org/centos\n\n";
|
|
|
+ bash $0 error;
|
|
|
+ exit 1;
|
|
|
+fi
|
|
|
+
|
|
|
+if [[ "$SpikCheckDIST" == '0' ]]; then
|
|
|
+ DistsList="$(wget --no-check-certificate -qO- "$LinuxMirror/dists/" |grep -o 'href=.*/"' |cut -d'"' -f2 |sed '/-\|old\|Debian\|experimental\|stable\|test\|sid\|devel/d' |grep '^[^/]' |sed -n '1h;1!H;$g;s/\n//g;s/\//\;/g;$p')";
|
|
|
+ for CheckDEB in `echo "$DistsList" |sed 's/;/\n/g'`
|
|
|
+ do
|
|
|
+ [[ "$CheckDEB" == "$DIST" ]] && FindDists='1' && break;
|
|
|
done
|
|
|
- [[ -z "$TimeZone" ]] && TimeZone="Asia/Tokyo"
|
|
|
+ [[ "$FindDists" == '0' ]] && {
|
|
|
+ echo -ne '\nThe dists version not found, Please check it! \n\n'
|
|
|
+ bash $0 error;
|
|
|
+ exit 1;
|
|
|
+ }
|
|
|
+fi
|
|
|
+
|
|
|
+if [[ "$ddMode" == '1' ]]; then
|
|
|
+ if [[ -n "$tmpURL" ]]; then
|
|
|
+ DDURL="$tmpURL"
|
|
|
+ echo "$DDURL" |grep -q '^http://\|^ftp://\|^https://';
|
|
|
+ [[ $? -ne '0' ]] && echo 'Please input vaild URL,Only support http://, ftp:// and https:// !' && exit 1;
|
|
|
else
|
|
|
- echo `timedatectl list-timezones` >> "$1"
|
|
|
- [[ `grep -c "$TimeZone" "$1"` == "0" || ! "/usr/share/zoneinfo/$1" ]] && TimeZone="Asia/Tokyo"
|
|
|
- rm -rf "$1"
|
|
|
+ echo 'Please input vaild image URL! ';
|
|
|
+ exit 1;
|
|
|
fi
|
|
|
-}
|
|
|
+fi
|
|
|
|
|
|
-function checkEfi() {
|
|
|
- EfiStatus=`efibootmgr l`
|
|
|
- EfiVars=""
|
|
|
- for Count in "$1" "$2" "$3" "$4"; do
|
|
|
- EfiVars=`ls -Sa $Count | wc -l`
|
|
|
- [[ "$EfiVars" -ge "1" ]] && break
|
|
|
- done
|
|
|
- if [[ "$EfiStatus" == "" ]] || [[ "$EfiVars" == "0" ]]; then
|
|
|
- EfiSupport="disabled"
|
|
|
- elif [[ -n `echo "$EfiStatus" | grep -i "bootcurrent" | awk '{print $2}' | sed -n '/^[[:xdigit:]]*$/p' | head -n 1` || -n `echo "$EfiStatus" | grep -i "bootorder" | awk '{print $2}' | awk -F ',' '{print $NF}' | sed -n '/^[[:xdigit:]]*$/p' | head -n 1` ]] && [[ "$EfiVars" != "0" ]]; then
|
|
|
- EfiSupport="enabled"
|
|
|
- else
|
|
|
- echo -ne "\n[${red}Error${plain}] UEFI boot firmware of your system could not be confirmed!\n"
|
|
|
- exit 1
|
|
|
+clear && echo -e "\n\033[36m# Install\033[0m\n"
|
|
|
+
|
|
|
+[[ "$ddMode" == '1' ]] && echo -ne "\033[34mAuto Mode\033[0m insatll \033[33mWindows\033[0m\n[\033[33m$DDURL\033[0m]\n"
|
|
|
+
|
|
|
+if [ -z "$interfaceSelect" ]; then
|
|
|
+ if [[ "$linux_relese" == 'debian' ]] || [[ "$linux_relese" == 'ubuntu' ]]; then
|
|
|
+ interfaceSelect="auto"
|
|
|
+ elif [[ "$linux_relese" == 'centos' ]]; then
|
|
|
+ interfaceSelect="link"
|
|
|
fi
|
|
|
-}
|
|
|
+fi
|
|
|
|
|
|
-
|
|
|
-function checkGrub() {
|
|
|
- GRUBDIR=""
|
|
|
- GRUBFILE=""
|
|
|
- for Count in "$1" "$2" "$3"; do
|
|
|
-
|
|
|
- if [[ -f "$Count""$4" ]] && [[ `grep -c "insmod*" $Count$4` -ge "1" ]]; then
|
|
|
- GRUBDIR="$Count"
|
|
|
- GRUBFILE="$4"
|
|
|
- elif [[ -f "$Count""$5" ]] && [[ `grep -c "insmod*" $Count$5` -ge "1" ]]; then
|
|
|
- GRUBDIR="$Count"
|
|
|
- GRUBFILE="$5"
|
|
|
+if [[ "$linux_relese" == 'centos' ]]; then
|
|
|
+ if [[ "$DIST" != "$UNVER" ]]; then
|
|
|
+ awk 'BEGIN{print '${UNVER}'-'${DIST}'}' |grep -q '^-'
|
|
|
+ if [ $? != '0' ]; then
|
|
|
+ UNKNOWHW='1';
|
|
|
+ echo -en "\033[33mThe version lower then \033[31m$UNVER\033[33m may not support in auto mode! \033[0m\n";
|
|
|
fi
|
|
|
- done
|
|
|
- if [[ -z "$GRUBFILE" ]] || [[ `grep -c "insmod*" $GRUBDIR$GRUBFILE` == "0" ]]; then
|
|
|
- for Count in "$4" "$5"; do
|
|
|
- GRUBFILE=`find "$6" -name "$Count"`
|
|
|
- if [[ -n "$GRUBFILE" ]]; then
|
|
|
- GRUBDIR=`echo "$GRUBFILE" | sed "s/$Count//g"`
|
|
|
- GRUBFILE="$Count"
|
|
|
- break
|
|
|
- fi
|
|
|
- done
|
|
|
- fi
|
|
|
- GRUBDIR=`echo ${GRUBDIR%?}`
|
|
|
- if [[ `awk '/menuentry*/{print NF}' $GRUBDIR/$GRUBFILE | head -n 1` -ge "1" ]] || [[ `awk '/feature*/{print $a}' $GRUBDIR/$GRUBFILE | head -n 1` != "" ]]; then
|
|
|
- if [[ -n `grep -w "grub2-mkconfig" $GRUBDIR/$GRUBFILE` ]] || [[ `type grub2-mkconfig` != "" ]]; then
|
|
|
- GRUBTYPE="isGrub2"
|
|
|
- elif [[ -n `grep -w "grub-mkconfig" $GRUBDIR/$GRUBFILE` ]] || [[ `type grub-mkconfig` != "" ]]; then
|
|
|
- GRUBTYPE="isGrub1"
|
|
|
- elif [[ "$CurrentOS" == "CentOS" || "$CurrentOS" == "OracleLinux" ]] && [[ "$CurrentOSVer" -le "6" ]]; then
|
|
|
- GRUBTYPE="isGrub1"
|
|
|
+ awk 'BEGIN{print '${UNVER}'-'${DIST}'+0.59}' |grep -q '^-'
|
|
|
+ if [ $? == '0' ]; then
|
|
|
+ echo -en "\n\033[31mThe version higher then \033[33m6.10 \033[31mis not support in current! \033[0m\n\n"
|
|
|
+ exit 1;
|
|
|
fi
|
|
|
fi
|
|
|
-}
|
|
|
+fi
|
|
|
|
|
|
-
|
|
|
-function checkMem() {
|
|
|
- TotalMem1=$(cat /proc/meminfo | grep "^MemTotal:" | sed 's/kb//i' | grep -o "[0-9]*" | awk -F' ' '{print $NF}')
|
|
|
- TotalMem2=$(free -k | grep -wi "mem*" | awk '{printf $2}')
|
|
|
-
|
|
|
- [[ "$1" == 'debian' ]] || [[ "$1" == 'ubuntu' ]] || [[ "$1" == 'kali' ]] && {
|
|
|
- [[ "$TotalMem1" -ge "2558072" || "$TotalMem2" -ge "2558072" ]] && lowmemLevel="" || lowmemLevel="lowmem=+1"
|
|
|
- [[ "$setMemCheck" == '1' ]] && {
|
|
|
- [[ "$TotalMem1" -le "329760" || "$TotalMem2" -le "329760" ]] && {
|
|
|
- echo -ne "\n[${red}Error${plain}] Minimum system memory requirement is 384MB!\n"
|
|
|
- exit 1
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
- [[ "$setMemCheck" == '1' ]] && {
|
|
|
- [[ "$1" == 'fedora' || "$1" == 'rockylinux' || "$1" == 'almalinux' || "$1" == 'centos' ]] && {
|
|
|
- if [[ "$1" == 'rockylinux' || "$1" == 'almalinux' || "$1" == 'centos' ]]; then
|
|
|
- if [[ "$2" == "8" ]] || [[ "$1" == 'centos' && "$2" -ge "9" ]]; then
|
|
|
- [[ "$TotalMem1" -le "2198342" || "$TotalMem2" -le "2198342" ]] && {
|
|
|
- echo -ne "\n[${red}Error${plain}] Minimum system memory requirement is 2.5GB!\n"
|
|
|
- exit 1
|
|
|
- }
|
|
|
- elif [[ "$2" -ge "9" ]]; then
|
|
|
- [[ "$TotalMem1" -le "1740800" || "$TotalMem2" -le "1740800" ]] && {
|
|
|
- echo -ne "\n[${red}Error${plain}] Minimum system memory requirement is 2GB!\n"
|
|
|
- exit 1
|
|
|
- }
|
|
|
- elif [[ "$2" == "7" ]]; then
|
|
|
- [[ "$TotalMem1" -le "1319006" || "$TotalMem2" -le "1319006" ]] && {
|
|
|
- echo -ne "\n[${red}Error${plain}] Minimum system memory requirement is 1.5GB!\n"
|
|
|
- exit 1
|
|
|
- }
|
|
|
- fi
|
|
|
- elif [[ "$1" == 'fedora' ]]; then
|
|
|
- [[ "$TotalMem1" -le "1740800" || "$TotalMem2" -le "1740800" ]] && {
|
|
|
- echo -ne "\n[${red}Error${plain}] Minimum system memory requirement is 2GB!\n"
|
|
|
- exit 1
|
|
|
- }
|
|
|
- fi
|
|
|
+echo -e "\n[\033[33m$Relese\033[0m] [\033[33m$DIST\033[0m] [\033[33m$VER\033[0m] Downloading..."
|
|
|
+
|
|
|
+if [[ "$linux_relese" == 'debian' ]] || [[ "$linux_relese" == 'ubuntu' ]]; then
|
|
|
+ [ "$DIST" == "focal" ] && legacy="legacy-" || legacy=""
|
|
|
+ wget --no-check-certificate -qO '/tmp/initrd.img' "${LinuxMirror}/dists/${DIST}/main/installer-${VER}/current/${legacy}images/netboot/${linux_relese}-installer/${VER}/initrd.gz"
|
|
|
+ [[ $? -ne '0' ]] && echo -ne "\033[31mError! \033[0mDownload 'initrd.img' for \033[33m$linux_relese\033[0m failed! \n" && exit 1
|
|
|
+ wget --no-check-certificate -qO '/tmp/vmlinuz' "${LinuxMirror}/dists/${DIST}${inUpdate}/main/installer-${VER}/current/${legacy}images/netboot/${linux_relese}-installer/${VER}/linux"
|
|
|
+ [[ $? -ne '0' ]] && echo -ne "\033[31mError! \033[0mDownload 'vmlinuz' for \033[33m$linux_relese\033[0m failed! \n" && exit 1
|
|
|
+ MirrorHost="$(echo "$LinuxMirror" |awk -F'://|/' '{print $2}')";
|
|
|
+ MirrorFolder="$(echo "$LinuxMirror" |awk -F''${MirrorHost}'' '{print $2}')";
|
|
|
+ [ -n "$MirrorFolder" ] || MirrorFolder="/"
|
|
|
+elif [[ "$linux_relese" == 'centos' ]]; then
|
|
|
+ wget --no-check-certificate -qO '/tmp/initrd.img' "${LinuxMirror}/${DIST}/os/${VER}/isolinux/initrd.img"
|
|
|
+ [[ $? -ne '0' ]] && echo -ne "\033[31mError! \033[0mDownload 'initrd.img' for \033[33m$linux_relese\033[0m failed! \n" && exit 1
|
|
|
+ wget --no-check-certificate -qO '/tmp/vmlinuz' "${LinuxMirror}/${DIST}/os/${VER}/isolinux/vmlinuz"
|
|
|
+ [[ $? -ne '0' ]] && echo -ne "\033[31mError! \033[0mDownload 'vmlinuz' for \033[33m$linux_relese\033[0m failed! \n" && exit 1
|
|
|
+else
|
|
|
+ bash $0 error;
|
|
|
+ exit 1;
|
|
|
+fi
|
|
|
+if [[ "$linux_relese" == 'debian' ]]; then
|
|
|
+ if [[ "$IncFirmware" == '1' ]]; then
|
|
|
+ wget --no-check-certificate -qO '/tmp/firmware.cpio.gz' "http://cdimage.debian.org/cdimage/unofficial/non-free/firmware/${DIST}/current/firmware.cpio.gz"
|
|
|
+ [[ $? -ne '0' ]] && echo -ne "\033[31mError! \033[0mDownload 'firmware' for \033[33m$linux_relese\033[0m failed! \n" && exit 1
|
|
|
+ fi
|
|
|
+ if [[ "$ddMode" == '1' ]]; then
|
|
|
+ vKernel_udeb=$(wget --no-check-certificate -qO- "http://$DISTMirror/dists/$DIST/main/installer-$VER/current/images/udeb.list" |grep '^acpi-modules' |head -n1 |grep -o '[0-9]\{1,2\}.[0-9]\{1,2\}.[0-9]\{1,2\}-[0-9]\{1,2\}' |head -n1)
|
|
|
+ [[ -z "vKernel_udeb" ]] && vKernel_udeb="4.19.0-17"
|
|
|
+ fi
|
|
|
+fi
|
|
|
+
|
|
|
+if [[ "$loaderMode" == "0" ]]; then
|
|
|
+ [[ ! -f "${GRUBDIR}/${GRUBFILE}" ]] && echo "Error! Not Found ${GRUBFILE}. " && exit 1;
|
|
|
+
|
|
|
+ [[ ! -f "${GRUBDIR}/${GRUBFILE}.old" ]] && [[ -f "${GRUBDIR}/${GRUBFILE}.bak" ]] && mv -f "${GRUBDIR}/${GRUBFILE}.bak" "${GRUBDIR}/${GRUBFILE}.old";
|
|
|
+ mv -f "${GRUBDIR}/${GRUBFILE}" "${GRUBDIR}/${GRUBFILE}.bak";
|
|
|
+ [[ -f "${GRUBDIR}/${GRUBFILE}.old" ]] && cat "${GRUBDIR}/${GRUBFILE}.old" >"${GRUBDIR}/${GRUBFILE}" || cat "${GRUBDIR}/${GRUBFILE}.bak" >"${GRUBDIR}/${GRUBFILE}";
|
|
|
+else
|
|
|
+ GRUBVER='-1'
|
|
|
+fi
|
|
|
+
|
|
|
+[[ "$GRUBVER" == '0' ]] && {
|
|
|
+ READGRUB='/tmp/grub.read'
|
|
|
+ cat $GRUBDIR/$GRUBFILE |sed -n '1h;1!H;$g;s/\n/%%%%%%%/g;$p' |grep -om 1 'menuentry\ [^{]*{[^}]*}%%%%%%%' |sed 's/%%%%%%%/\n/g' >$READGRUB
|
|
|
+ LoadNum="$(cat $READGRUB |grep -c 'menuentry ')"
|
|
|
+ if [[ "$LoadNum" -eq '1' ]]; then
|
|
|
+ cat $READGRUB |sed '/^$/d' >/tmp/grub.new;
|
|
|
+ elif [[ "$LoadNum" -gt '1' ]]; then
|
|
|
+ CFG0="$(awk '/menuentry /{print NR}' $READGRUB|head -n 1)";
|
|
|
+ CFG2="$(awk '/menuentry /{print NR}' $READGRUB|head -n 2 |tail -n 1)";
|
|
|
+ CFG1="";
|
|
|
+ for tmpCFG in `awk '/}/{print NR}' $READGRUB`
|
|
|
+ do
|
|
|
+ [ "$tmpCFG" -gt "$CFG0" -a "$tmpCFG" -lt "$CFG2" ] && CFG1="$tmpCFG";
|
|
|
+ done
|
|
|
+ [[ -z "$CFG1" ]] && {
|
|
|
+ echo "Error! read $GRUBFILE. ";
|
|
|
+ exit 1;
|
|
|
}
|
|
|
- [[ "$1" == 'alpinelinux' || "$3" == 'Ubuntu' ]] && {
|
|
|
- [[ "$TotalMem1" -le "895328" || "$TotalMem2" -le "895328" ]] && {
|
|
|
- echo -ne "\n[${red}Error${plain}] Minimum system memory requirement is 1GB!\n"
|
|
|
- exit 1
|
|
|
- }
|
|
|
+
|
|
|
+ sed -n "$CFG0,$CFG1"p $READGRUB >/tmp/grub.new;
|
|
|
+ [[ -f /tmp/grub.new ]] && [[ "$(grep -c '{' /tmp/grub.new)" -eq "$(grep -c '}' /tmp/grub.new)" ]] || {
|
|
|
+ echo -ne "\033[31mError! \033[0mNot configure $GRUBFILE. \n";
|
|
|
+ exit 1;
|
|
|
}
|
|
|
- }
|
|
|
+ fi
|
|
|
+ [ ! -f /tmp/grub.new ] && echo "Error! $GRUBFILE. " && exit 1;
|
|
|
+ sed -i "/menuentry.*/c\menuentry\ \'Install OS \[$DIST\ $VER\]\'\ --class debian\ --class\ gnu-linux\ --class\ gnu\ --class\ os\ \{" /tmp/grub.new
|
|
|
+ sed -i "/echo.*Loading/d" /tmp/grub.new;
|
|
|
+ INSERTGRUB="$(awk '/menuentry /{print NR}' $GRUBDIR/$GRUBFILE|head -n 1)"
|
|
|
}
|
|
|
|
|
|
-function checkVirt() {
|
|
|
- virtType=""
|
|
|
- for Count in $(dmidecode -s system-manufacturer | awk '{print $1}' | sed 's/[A-Z]/\l&/g') $(systemd-detect-virt | sed 's/[A-Z]/\l&/g') $(lscpu | grep -i "hypervisor vendor" | cut -d ':' -f 2 | sed 's/^[ \t]*//g' | sed 's/[A-Z]/\l&/g'); do
|
|
|
- virtType+="$Count"
|
|
|
- done
|
|
|
- virtWhat=$(virt-what)
|
|
|
+[[ "$GRUBVER" == '1' ]] && {
|
|
|
+ CFG0="$(awk '/title[\ ]|title[\t]/{print NR}' $GRUBDIR/$GRUBFILE|head -n 1)";
|
|
|
+ CFG1="$(awk '/title[\ ]|title[\t]/{print NR}' $GRUBDIR/$GRUBFILE|head -n 2 |tail -n 1)";
|
|
|
+ [[ -n $CFG0 ]] && [ -z $CFG1 -o $CFG1 == $CFG0 ] && sed -n "$CFG0,$"p $GRUBDIR/$GRUBFILE >/tmp/grub.new;
|
|
|
+ [[ -n $CFG0 ]] && [ -z $CFG1 -o $CFG1 != $CFG0 ] && sed -n "$CFG0,$[$CFG1-1]"p $GRUBDIR/$GRUBFILE >/tmp/grub.new;
|
|
|
+ [[ ! -f /tmp/grub.new ]] && echo "Error! configure append $GRUBFILE. " && exit 1;
|
|
|
+ sed -i "/title.*/c\title\ \'Install OS \[$DIST\ $VER\]\'" /tmp/grub.new;
|
|
|
+ sed -i '/^#/d' /tmp/grub.new;
|
|
|
+ INSERTGRUB="$(awk '/title[\ ]|title[\t]/{print NR}' $GRUBDIR/$GRUBFILE|head -n 1)"
|
|
|
}
|
|
|
|
|
|
-function checkSys() {
|
|
|
- CurrentOSVer=`cat /etc/os-release | grep -w "VERSION_ID=*" | awk -F '=' '{print $2}' | sed 's/\"//g' | cut -d'.' -f 1`
|
|
|
-
|
|
|
- apt update -y
|
|
|
-
|
|
|
- if [[ $? -ne 0 ]]; then
|
|
|
- apt update -y > /root/apt_execute.log
|
|
|
- if [[ `grep -i "debian" /root/apt_execute.log` ]] && [[ `grep -i "err:[0-9]" /root/apt_execute.log` || `grep -i "404 not found" /root/apt_execute.log` ]]; then
|
|
|
- currentDebianMirror=$(sed -n '/^deb /'p /etc/apt/sources.list | head -n 1 | awk '{print $2}' | sed -e 's|^[^/]*//||' -e 's|/.*$||')
|
|
|
- if [[ "$CurrentOSVer" -gt "9" ]]; then
|
|
|
-
|
|
|
- sed -ri "s/$currentDebianMirror/deb.debian.org/g" /etc/apt/sources.list
|
|
|
- else
|
|
|
-
|
|
|
- sed -ri "s/$currentDebianMirror/archive.debian.org/g" /etc/apt/sources.list
|
|
|
- fi
|
|
|
-
|
|
|
- sed -ri 's/^deb-src/# deb-src/g' /etc/apt/sources.list
|
|
|
- apt update -y
|
|
|
- fi
|
|
|
- rm -rf /root/apt_execute.log
|
|
|
+if [[ "$loaderMode" == "0" ]]; then
|
|
|
+ [[ -n "$(grep 'linux.*/\|kernel.*/' /tmp/grub.new |awk '{print $2}' |tail -n 1 |grep '^/boot/')" ]] && Type='InBoot' || Type='NoBoot';
|
|
|
+
|
|
|
+ LinuxKernel="$(grep 'linux.*/\|kernel.*/' /tmp/grub.new |awk '{print $1}' |head -n 1)";
|
|
|
+ [[ -z "$LinuxKernel" ]] && echo "Error! read grub config! " && exit 1;
|
|
|
+ LinuxIMG="$(grep 'initrd.*/' /tmp/grub.new |awk '{print $1}' |tail -n 1)";
|
|
|
+ [ -z "$LinuxIMG" ] && sed -i "/$LinuxKernel.*\//a\\\tinitrd\ \/" /tmp/grub.new && LinuxIMG='initrd';
|
|
|
+
|
|
|
+ [[ "$setInterfaceName" == "1" ]] && Add_OPTION="net.ifnames=0 biosdevname=0" || Add_OPTION=""
|
|
|
+ [[ "$setIPv6" == "1" ]] && Add_OPTION="$Add_OPTION ipv6.disable=1"
|
|
|
+
|
|
|
+ lowMem || Add_OPTION="$Add_OPTION lowmem=+0"
|
|
|
+
|
|
|
+ if [[ "$linux_relese" == 'debian' ]] || [[ "$linux_relese" == 'ubuntu' ]]; then
|
|
|
+ BOOT_OPTION="auto=true $Add_OPTION hostname=$linux_relese domain= -- quiet"
|
|
|
+ elif [[ "$linux_relese" == 'centos' ]]; then
|
|
|
+ BOOT_OPTION="ks=file://ks.cfg $Add_OPTION ksdevice=$interfaceSelect"
|
|
|
fi
|
|
|
- apt install lsb-release -y
|
|
|
|
|
|
-
|
|
|
- [[ `grep -wri "elrepo.org" /etc/yum.repos.d/` != "" ]] && {
|
|
|
- elrepoFile=`grep -wri "elrepo.org" /etc/yum.repos.d/ | head -n 1 | cut -d':' -f 1`
|
|
|
- mv "$elrepoFile" "$elrepoFile.bak"
|
|
|
+ [[ "$Type" == 'InBoot' ]] && {
|
|
|
+ sed -i "/$LinuxKernel.*\//c\\\t$LinuxKernel\\t\/boot\/vmlinuz $BOOT_OPTION" /tmp/grub.new;
|
|
|
+ sed -i "/$LinuxIMG.*\//c\\\t$LinuxIMG\\t\/boot\/initrd.img" /tmp/grub.new;
|
|
|
}
|
|
|
- yum install redhat-lsb -y
|
|
|
- OsLsb=`lsb_release -d | awk '{print$2}'`
|
|
|
-
|
|
|
- RedHatRelease=""
|
|
|
- for Count in `cat /etc/redhat-release | awk '{print$1}'` `cat /etc/system-release | awk '{print$1}'` `cat /etc/os-release | grep -w "ID=*" | awk -F '=' '{print $2}' | sed 's/\"//g'` "$OsLsb"; do
|
|
|
- [[ -n "$Count" ]] && RedHatRelease=`echo -e "$Count"`"$RedHatRelease"
|
|
|
- done
|
|
|
+
|
|
|
+ [[ "$Type" == 'NoBoot' ]] && {
|
|
|
+ sed -i "/$LinuxKernel.*\//c\\\t$LinuxKernel\\t\/vmlinuz $BOOT_OPTION" /tmp/grub.new;
|
|
|
+ sed -i "/$LinuxIMG.*\//c\\\t$LinuxIMG\\t\/initrd.img" /tmp/grub.new;
|
|
|
+ }
|
|
|
+
|
|
|
+ sed -i '$a\\n' /tmp/grub.new;
|
|
|
|
|
|
- DebianRelease=""
|
|
|
- IsUbuntu=`uname -a | grep -i "ubuntu"`
|
|
|
- IsDebian=`uname -a | grep -i "debian"`
|
|
|
- IsKali=`uname -a | grep -i "kali"`
|
|
|
- for Count in `cat /etc/os-release | grep -w "ID=*" | awk -F '=' '{print $2}'` `cat /etc/issue | awk '{print $1}'` "$OsLsb"; do
|
|
|
- [[ -n "$Count" ]] && DebianRelease=`echo -e "$Count"`"$DebianRelease"
|
|
|
- done
|
|
|
-
|
|
|
- AlpineRelease=""
|
|
|
- apk update
|
|
|
- for Count in `cat /etc/os-release | grep -w "ID=*" | awk -F '=' '{print $2}'` `cat /etc/issue | awk '{print $3}' | head -n 1` `uname -v | awk '{print $1}' | sed 's/[^a-zA-Z]//g'`; do
|
|
|
- [[ -n "$Count" ]] && AlpineRelease=`echo -e "$Count"`"$AlpineRelease"
|
|
|
- done
|
|
|
-
|
|
|
- if [[ `echo "$RedHatRelease" | grep -i 'centos'` != "" ]]; then
|
|
|
- CurrentOS="CentOS"
|
|
|
- elif [[ `echo "$RedHatRelease" | grep -i 'cloudlinux'` != "" ]]; then
|
|
|
- CurrentOS="CloudLinux"
|
|
|
- elif [[ `echo "$RedHatRelease" | grep -i 'alma'` != "" ]]; then
|
|
|
- CurrentOS="AlmaLinux"
|
|
|
- elif [[ `echo "$RedHatRelease" | grep -i 'rocky'` != "" ]]; then
|
|
|
- CurrentOS="RockyLinux"
|
|
|
- elif [[ `echo "$RedHatRelease" | grep -i 'fedora'` != "" ]]; then
|
|
|
- CurrentOS="Fedora"
|
|
|
- elif [[ `echo "$RedHatRelease" | grep -i 'virtuozzo'` != "" ]]; then
|
|
|
- CurrentOS="Vzlinux"
|
|
|
- elif [[ `echo "$RedHatRelease" | grep -i 'ol\|oracle'` != "" ]]; then
|
|
|
- CurrentOS="OracleLinux"
|
|
|
- elif [[ `echo "$RedHatRelease" | grep -i 'opencloud'` != "" ]]; then
|
|
|
- CurrentOS="OpenCloudOS"
|
|
|
- elif [[ `echo "$RedHatRelease" | grep -i 'alibaba\|alinux\|aliyun'` != "" ]]; then
|
|
|
- CurrentOS="AlibabaCloudLinux"
|
|
|
- elif [[ `echo "$RedHatRelease" | grep -i 'amazon\|amzn'` != "" ]]; then
|
|
|
- CurrentOS="AmazonLinux"
|
|
|
- amazon-linux-extras install epel -y
|
|
|
- elif [[ `echo "$RedHatRelease" | grep -i 'red\|rhel'` != "" ]]; then
|
|
|
- CurrentOS="RedHatEnterpriseLinux"
|
|
|
- elif [[ `echo "$RedHatRelease" | grep -i 'anolis'` != "" ]]; then
|
|
|
- CurrentOS="OpenAnolis"
|
|
|
- elif [[ `echo "$RedHatRelease" | grep -i 'scientific'` != "" ]]; then
|
|
|
- CurrentOS="ScientificLinux"
|
|
|
- elif [[ `echo "$AlpineRelease" | grep -i 'alpine'` != "" ]]; then
|
|
|
- CurrentOS="AlpineLinux"
|
|
|
- elif [[ "$IsUbuntu" ]] || [[ `echo "$DebianRelease" | grep -i 'ubuntu'` != "" ]]; then
|
|
|
- CurrentOS="Ubuntu"
|
|
|
- CurrentOSVer=`lsb_release -r | awk '{print$2}' | cut -d'.' -f1`
|
|
|
- elif [[ "$IsDebian" ]] || [[ `echo "$DebianRelease" | grep -i 'debian'` != "" ]]; then
|
|
|
- CurrentOS="Debian"
|
|
|
- CurrentOSVer=`lsb_release -r | awk '{print$2}' | cut -d'.' -f1`
|
|
|
- elif [[ "$IsKali" ]] || [[ `echo "$DebianRelease" | grep -i 'kali'` != "" ]]; then
|
|
|
- CurrentOS="Kali"
|
|
|
- CurrentOSVer=`lsb_release -r | awk '{print$2}' | cut -d'.' -f1`
|
|
|
- else
|
|
|
- echo -ne "\n[${red}Error${plain}] Does't support your system!\n"
|
|
|
- exit 1
|
|
|
- fi
|
|
|
-
|
|
|
- if [[ "$CurrentOS" == "CentOS" || "$CurrentOS" == "OracleLinux" ]] && [[ "$CurrentOSVer" -le "6" ]]; then
|
|
|
- echo -e "Does't support your system!\n"
|
|
|
- exit 1
|
|
|
- fi
|
|
|
-
|
|
|
-
|
|
|
- apt purge inetutils-ping -y
|
|
|
-
|
|
|
- apt install cpio curl dnsutils efibootmgr fdisk file gzip iputils-ping jq net-tools openssl subnetcalc tuned virt-what wget xz-utils -y
|
|
|
-
|
|
|
-
|
|
|
- yum install epel-release -y
|
|
|
- yum install dnf -y
|
|
|
- if [[ $? -eq 0 ]]; then
|
|
|
-
|
|
|
-
|
|
|
- [[ "$CurrentOS" == "CentOS" && "$CurrentOSVer" == "8" ]] && dnf install python3-librepo -y
|
|
|
-
|
|
|
- dnf install bind-utils cpio curl dnsutils efibootmgr file gzip ipcalc jq net-tools openssl redhat-lsb syslinux tuned util-linux virt-what wget xz --skip-broken -y
|
|
|
-
|
|
|
- else
|
|
|
- yum install dnf -y > /root/yum_execute.log 2>&1
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
- if [[ `grep -i "failed to synchronize" /root/yum_execute.log` || `grep -i "no urls in mirrorlist" /root/yum_execute.log` ]]; then
|
|
|
- if [[ "$CurrentOS" == "CentOS" ]]; then
|
|
|
- cd /etc/yum.repos.d/
|
|
|
- sed -i 's/mirrorlist/#mirrorlist/g' /etc/yum.repos.d/CentOS-*
|
|
|
- sed -i 's|#baseurl=http://mirror.centos.org|baseurl=http://vault.centos.org|g' /etc/yum.repos.d/CentOS-*
|
|
|
- [[ "$CurrentOSVer" == "8" ]] && dnf install python3-librepo -y
|
|
|
- fi
|
|
|
- yum install epel-release -y
|
|
|
- yum install dnf -y
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
- dnf install bind-utils cpio curl dnsutils efibootmgr file gzip ipcalc jq net-tools openssl redhat-lsb syslinux tuned util-linux virt-what wget xz --skip-broken -y
|
|
|
-
|
|
|
-
|
|
|
- elif [[ `grep -i "no package" /root/yum_execute.log` ]]; then
|
|
|
- yum install bind-utils cpio curl dnsutils efibootmgr file gzip ipcalc jq net-tools openssl redhat-lsb syslinux tuned util-linux virt-what wget xz --skip-broken -y
|
|
|
-
|
|
|
- fi
|
|
|
- rm -rf /root/yum_execute.log
|
|
|
- fi
|
|
|
-
|
|
|
-
|
|
|
- [[ "$CurrentOS" == "AlpineLinux" ]] && {
|
|
|
-
|
|
|
- CurrentAlpineVer=$(cut -d. -f1,2 </etc/alpine-release)
|
|
|
-
|
|
|
- sed -i 's/#//' /etc/apk/repositories
|
|
|
-
|
|
|
- [[ ! `grep -i "community" /etc/apk/repositories` ]] && sed -i '$a\http://ftp.udx.icscoe.jp/Linux/alpine/v'${CurrentAlpineVer}'/community' /etc/apk/repositories
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
- apk update
|
|
|
- apk add bash bind-tools coreutils cpio curl efibootmgr file gawk grep gzip ipcalc jq net-tools openssl sed shadow tzdata util-linux virt-what wget xz
|
|
|
-
|
|
|
- sed -i 's/root:\/bin\/ash/root:\/bin\/bash/g' /etc/passwd
|
|
|
- }
|
|
|
-}
|
|
|
-
|
|
|
-
|
|
|
-function checkIpv4OrIpv6() {
|
|
|
- for ((w=1; w<=2; w++)); do
|
|
|
- IPv4DNSLookup=`timeout 0.3s dig -4 TXT +short o-o.myaddr.l.google.com @ns1.google.com | sed 's/\"//g'`
|
|
|
- [[ "$IPv4DNSLookup" == "" ]] && IPv4DNSLookup=`timeout 0.3s dig -4 TXT CH +short whoami.cloudflare @1.1.1.1 | sed 's/\"//g'`
|
|
|
- [[ "$IPv4DNSLookup" != "" ]] && break
|
|
|
- done
|
|
|
- for ((x=1; x<=2; x++)); do
|
|
|
- IPv6DNSLookup=`timeout 0.3s dig -6 TXT +short o-o.myaddr.l.google.com @ns1.google.com | sed 's/\"//g'`
|
|
|
- [[ "$IPv6DNSLookup" == "" ]] && IPv6DNSLookup=`timeout 0.3s dig -6 TXT CH +short whoami.cloudflare @2606:4700:4700::1111 | sed 's/\"//g'`
|
|
|
- [[ "$IPv6DNSLookup" != "" ]] && break
|
|
|
- done
|
|
|
- for y in "$3" "$4" "$5" "$6"; do
|
|
|
- IPv4PingDNS=`timeout 0.3s ping -4 -c 1 "$y" | grep "rtt\|round-trip" | cut -d'/' -f5 | awk -F'.' '{print $NF}' | sed -E '/^[0-9]\+\(\.[0-9]\+\)\?$/p'`"$IPv4PingDNS"
|
|
|
- [[ "$IPv4PingDNS" != "" ]] && break
|
|
|
- done
|
|
|
- for z in "$7" "$8" "$9" "$10"; do
|
|
|
- IPv6PingDNS=`timeout 0.3s ping -6 -c 1 "$z" | grep "rtt\|round-trip" | cut -d'/' -f5 | awk -F'.' '{print $NF}' | sed -E '/^[0-9]\+\(\.[0-9]\+\)\?$/p'`"$IPv6PingDNS"
|
|
|
- [[ "$IPv6PingDNS" != "" ]] && break
|
|
|
- done
|
|
|
-
|
|
|
-
|
|
|
- [[ "$IPv4PingDNS" =~ ^[0-9] && "$IPv6PingDNS" =~ ^[0-9] ]] && IPStackType="BiStack"
|
|
|
- [[ "$IPv4PingDNS" =~ ^[0-9] && ! "$IPv6PingDNS" =~ ^[0-9] ]] && IPStackType="IPv4Stack"
|
|
|
- [[ ! "$IPv4PingDNS" =~ ^[0-9] && "$IPv6PingDNS" =~ ^[0-9] ]] && IPStackType="IPv6Stack"
|
|
|
- [[ -n "$1" || -n "$2" ]] && {
|
|
|
- if [[ -n "$1" && -z "$2" ]]; then
|
|
|
- for ipCheck in "$1" "$ipGate"; do
|
|
|
- verifyIPv4FormatLawfulness "$ipCheck"
|
|
|
- done
|
|
|
- elif [[ -n "$1" && -n "$2" ]]; then
|
|
|
- for ipCheck in "$1" "$ipGate"; do
|
|
|
- verifyIPv4FormatLawfulness "$ipCheck"
|
|
|
- done
|
|
|
- for ipCheck in "$2" "$ip6Gate"; do
|
|
|
- verifyIPv6FormatLawfulness "$ipCheck"
|
|
|
- done
|
|
|
- IPStackType="BiStack"
|
|
|
- elif [[ -z "$1" && -n "$2" ]]; then
|
|
|
- for ipCheck in "$2" "$ip6Gate"; do
|
|
|
- verifyIPv6FormatLawfulness "$ipCheck"
|
|
|
- done
|
|
|
- fi
|
|
|
- }
|
|
|
-
|
|
|
- [[ $(echo "$setIpStack" | grep -i "bi\|bistack\|dual\|two") ]] && IPStackType="BiStack"
|
|
|
- [[ $(echo "$setIpStack" | grep -i "4\|i4\|ip4\|ipv4") ]] && IPStackType="IPv4Stack"
|
|
|
- [[ $(echo "$setIpStack" | grep -i "6\|i6\|ip6\|ipv6") ]] && IPStackType="IPv6Stack"
|
|
|
-
|
|
|
-
|
|
|
- [[ "$tmpSetIPv6" == "0" ]] && setIPv6="0" || setIPv6="1"
|
|
|
-}
|
|
|
-
|
|
|
-function verifyIPv4FormatLawfulness() {
|
|
|
- [[ -n "$1" ]] && IP_Check="$1"
|
|
|
- if expr "$IP_Check" : '[0-9][0-9]*\.[0-9][0-9]*\.[0-9][0-9]*\.[0-9][0-9]*$' >/dev/null; then
|
|
|
- for i in 1 2 3 4; do
|
|
|
- if [ $(echo "$IP_Check" | cut -d. -f$i) -gt 255 ]; then
|
|
|
- echo "fail ($IP_Check)"
|
|
|
- exit 1
|
|
|
- fi
|
|
|
- done
|
|
|
- IP_Check="isIPv4"
|
|
|
- fi
|
|
|
- [[ "$IP_Check" != "isIPv4" ]] && {
|
|
|
- echo -ne "\n[${red}Error${plain}] Invalid inputted IPv4 format!\n"
|
|
|
- exit 1
|
|
|
- }
|
|
|
-}
|
|
|
-
|
|
|
-function verifyIPv6FormatLawfulness() {
|
|
|
- [[ -n "$1" ]] && IPv6_Check="$1"
|
|
|
-
|
|
|
- [[ "${IPv6_Check: -1}" == ":" ]] && IPv6_Check=$(echo "$IPv6_Check" | sed 's/.$/0/')
|
|
|
-
|
|
|
- [[ "${IPv6_Check:0:1}" == ":" ]] && IPv6_Check=$(echo "$IPv6_Check" | sed 's/^./0/')
|
|
|
-
|
|
|
- IP6_Check_Temp="$IPv6_Check"":"
|
|
|
-
|
|
|
- IP6_Hex_Num=`echo "$IP6_Check_Temp" | tr -cd ":" | wc -c`
|
|
|
-
|
|
|
- IP6_Hex_Abbr="0"
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
- if [[ `echo "$IPv6_Check" | grep -i '[[:xdigit:]]' | grep ':'` ]] && [[ "$IP6_Hex_Num" -le "8" ]]; then
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
- [[ `echo "$1" | grep -o ":::" | wc -l` -gt "0" ]] || [[ `echo "$1" | grep -o "::" | wc -l` -gt "1" || `echo "$1" | grep -o ":" | wc -l` -gt "7" ]] || [[ "$IP6_Hex_Num" -le "7" && `echo "$1" | grep -o "::" | wc -l` -lt "1" ]] || [[ "${1: -2}" != "::" && "${1: -1}" == ":" ]] && { echo -ne "\n[${red}Error${plain}] Invalid inputted IPv6 format!\n"; exit 1; }
|
|
|
-
|
|
|
- for ((i=1; i<="$IP6_Hex_Num"; i++)); do
|
|
|
-
|
|
|
- IP6_Hex=$(echo "$IP6_Check_Temp" | cut -d: -f$i)
|
|
|
-
|
|
|
- [[ "$IP6_Hex" == "" ]] && IP6_Hex_Abbr=`expr $IP6_Hex_Abbr + 1`
|
|
|
-
|
|
|
- if [[ `echo "$IP6_Hex" | wc -m` -le "5" ]]; then
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
- [[ `echo "$IP6_Hex" | grep -iE '[^0-9a-f]'` || "$IP6_Hex_Abbr" -gt "1" ]] && { echo -ne "\n[${red}Error${plain}] Invalid inputted IPv6 format!\n"; exit 1; }
|
|
|
- else
|
|
|
- echo -ne "\n[${red}Error${plain}] Invalid inputted IPv6 format!\n"; exit 1;
|
|
|
- fi
|
|
|
- done
|
|
|
- IP6_Check="isIPv6"
|
|
|
- fi
|
|
|
- [[ "$IP6_Check" != "isIPv6" ]] && { echo -ne "\n[${red}Error${plain}] Invalid inputted IPv6 format!\n"; exit 1; }
|
|
|
-}
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-function checkWarp() {
|
|
|
- warpConfFiles=$(find / -maxdepth 6 -name "$1" -print -or -name "$2" -print -or -name "$3" -print)
|
|
|
- sysctlWarpProcess=$(systemctl 2>&1 | grep -i "$4\|$5\|$6" | wc -l)
|
|
|
- rcWarpProcess=$(rc-status 2>&1 | grep -i "$4\|$5\|$6" | wc -l)
|
|
|
- [[ "$IPStackType" == "BiStack" ]] && {
|
|
|
- [[ -n "$warpConfFiles" ]] && {
|
|
|
- for warpConfFile in $(find / -maxdepth 6 -name "$1" -print -or -name "$2" -print -or -name "$3" -print); do
|
|
|
- if [[ $(grep -ic "$7" "$warpConfFile") -ge "1" || $(grep -ic "$8" "$warpConfFile") -ge "1" ]]; then
|
|
|
- warpStatic="1"
|
|
|
- break
|
|
|
- fi
|
|
|
- done
|
|
|
- }
|
|
|
- [[ "$sysctlWarpProcess" -gt "0" || "$rcWarpProcess" -gt "0" ]] && warpStatic="1"
|
|
|
- }
|
|
|
- [[ "$warpStatic" == "1" ]] && {
|
|
|
- [[ -z "$ipGate" ]] && IPStackType="IPv6Stack"
|
|
|
- [[ -z "$ip6Gate" ]] && IPStackType="IPv4Stack"
|
|
|
- }
|
|
|
-}
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-function fillAbbrOfIpv6() {
|
|
|
- inputIpv6="$1"
|
|
|
-
|
|
|
- delimiterNum=$(echo $inputIpv6 | awk '{print gsub(/:/, "")}')
|
|
|
- replaceStr=""
|
|
|
-
|
|
|
- for ((i=0; i<=$((7-$delimiterNum)); i++)); do
|
|
|
- replaceStr="$replaceStr"":0"
|
|
|
- done
|
|
|
-
|
|
|
- replaceStr="$replaceStr"":"
|
|
|
-
|
|
|
- ipv6Expanded=${inputIpv6/::/$replaceStr}
|
|
|
-
|
|
|
- [[ "$ipv6Expanded" == *: ]] && ipv6Expanded="$ipv6Expanded""0"
|
|
|
-
|
|
|
- [[ "$ipv6Expanded" == :* ]] && ipv6Expanded="0""$ipv6Expanded"
|
|
|
-
|
|
|
- echo "$ipv6Expanded"
|
|
|
-}
|
|
|
+ sed -i ''${INSERTGRUB}'i\\n' $GRUBDIR/$GRUBFILE;
|
|
|
+ sed -i ''${INSERTGRUB}'r /tmp/grub.new' $GRUBDIR/$GRUBFILE;
|
|
|
+ [[ -f $GRUBDIR/grubenv ]] && sed -i 's/saved_entry/#saved_entry/g' $GRUBDIR/grubenv;
|
|
|
+fi
|
|
|
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-function ultimateFormatOfIpv6() {
|
|
|
- abbrExpandedOfIpv6=$(fillAbbrOfIpv6 "$1")
|
|
|
-
|
|
|
- ipv6Hex=(${abbrExpandedOfIpv6//:/ })
|
|
|
- for ((j=0; j<8; j++)); do
|
|
|
-
|
|
|
- length="${#ipv6Hex[j]}"
|
|
|
-
|
|
|
- for ((k=4; k>$length; k--)); do
|
|
|
-
|
|
|
- ipv6Hex[j]="0${ipv6Hex[j]}"
|
|
|
- done
|
|
|
- done
|
|
|
-
|
|
|
- echo ${ipv6Hex[@]} | sed 's/ /\:/g'
|
|
|
-}
|
|
|
+[[ -d /tmp/boot ]] && rm -rf /tmp/boot;
|
|
|
+mkdir -p /tmp/boot;
|
|
|
+cd /tmp/boot;
|
|
|
|
|
|
-function getIPv6Address() {
|
|
|
-
|
|
|
- allI6Addrs=`ip -6 addr show | grep -wA 65536 "$interface\|$interface6" | grep -wv "lo" | grep -wv "link\|host" | grep -w "inet6" | grep "scope" | grep "global" | awk -F " " '{for (i=2;i<=NF;i++)printf("%s ", $i);print ""}' | awk '{print $1}'`
|
|
|
- i6Addr=`echo "$allI6Addrs" | head -n 1`
|
|
|
- i6AddrNum=`echo "$allI6Addrs" | wc -l`
|
|
|
- collectAllIpv6Addresses "$i6AddrNum"
|
|
|
- ip6Addr=`echo ${i6Addr} | cut -d'/' -f1`
|
|
|
- ip6Mask=`echo ${i6Addr} | cut -d'/' -f2`
|
|
|
- ip6Gate=`ip -6 route show default | grep -iv "warp\|wgcf\|wg[0-9]\|docker[0-9]" | grep -w "$interface\|$interface6" | grep -w "via" | grep "dev" | head -n 1 | awk -F " " '{for (i=3;i<=NF;i++)printf("%s ", $i);print ""}' | awk '{print$1}'`
|
|
|
-
|
|
|
- actualIp6Prefix=`ip -6 route show | grep -iv "warp\|wgcf\|wg[0-9]\|docker[0-9]" | grep -w "$interface\|$interface6" | grep -v "default" | grep -v "multicast" | grep -P '../[0-9]{1,3}' | head -n 1 | awk '{print $1}' | awk -F '/' '{print $2}'`
|
|
|
- [[ -z "$actualIp6Prefix" || "$i6AddrNum" -ge "2" ]] && actualIp6Prefix="$ip6Mask"
|
|
|
- transferIPv6AddressFormat "$ip6Addr" "$ip6Gate"
|
|
|
-}
|
|
|
-
|
|
|
-
|
|
|
-function transferIPv6AddressFormat() {
|
|
|
-
|
|
|
-
|
|
|
- [[ "$BiStackPreferIpv6Status" == "1" ]] && Network6Config="isStatic"
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
- [[ "$Network6Config" == "isStatic" ]] && {
|
|
|
-
|
|
|
- ip6AddrWhole=`ultimateFormatOfIpv6 "$1"`
|
|
|
- ip6GateWhole=`ultimateFormatOfIpv6 "$2"`
|
|
|
- tmpIp6AddrFirst=`echo $ip6AddrWhole | sed 's/\(.\{4\}\).*/\1/' | sed 's/[a-z]/\u&/g'`
|
|
|
- tmpIp6GateFirst=`echo $ip6GateWhole | sed 's/\(.\{4\}\).*/\1/' | sed 's/[a-z]/\u&/g'`
|
|
|
- if [[ "$tmpIp6AddrFirst" != "$tmpIp6GateFirst" ]]; then
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
- if [[ "$((16#$tmpIp6GateFirst))" -ge "$((16#FE80))" && "$((16#$tmpIp6GateFirst))" -le "$((16#FEBF))" ]] || [[ "$((16#$tmpIp6GateFirst))" -ge "$((16#FC00))" && "$((16#$tmpIp6GateFirst))" -le "$((16#FDFF))" ]]; then
|
|
|
- tmpIp6Mask="64"
|
|
|
+if [[ "$linux_relese" == 'debian' ]] || [[ "$linux_relese" == 'ubuntu' ]]; then
|
|
|
+ COMPTYPE="gzip";
|
|
|
+elif [[ "$linux_relese" == 'centos' ]]; then
|
|
|
+ COMPTYPE="$(file ../initrd.img |grep -o ':.*compressed data' |cut -d' ' -f2 |sed -r 's/(.*)/\L\1/' |head -n1)"
|
|
|
+ [[ -z "$COMPTYPE" ]] && echo "Detect compressed type fail." && exit 1;
|
|
|
+fi
|
|
|
+CompDected='0'
|
|
|
+for COMP in `echo -en 'gzip\nlzma\nxz'`
|
|
|
+ do
|
|
|
+ if [[ "$COMPTYPE" == "$COMP" ]]; then
|
|
|
+ CompDected='1'
|
|
|
+ if [[ "$COMPTYPE" == 'gzip' ]]; then
|
|
|
+ NewIMG="initrd.img.gz"
|
|
|
else
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
- tmpIp6Mask="1"
|
|
|
- fi
|
|
|
- else
|
|
|
- ipv6SubnetCertificate "$ip6AddrWhole" "$ip6GateWhole"
|
|
|
- fi
|
|
|
- ip6Mask="$tmpIp6Mask"
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
- ipv6SubnetCalc "$ip6Mask"
|
|
|
-
|
|
|
- }
|
|
|
-}
|
|
|
-
|
|
|
-
|
|
|
-function ipv6SubnetCertificate() {
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
- [[ `echo $1 | cut -d':' -f 1` == `echo $2 | cut -d':' -f 1` ]] && tmpIp6Mask="16"
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
- [[ `echo $1 | cut -d':' -f 1,2` == `echo $2 | cut -d':' -f 1,2` ]] && tmpIp6Mask="32"
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
- [[ `echo $1 | cut -d':' -f 1,2,3` == `echo $2 | cut -d':' -f 1,2,3` ]] && tmpIp6Mask="48"
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
- [[ `echo $1 | cut -d':' -f 1,2,3,4` == `echo $2 | cut -d':' -f 1,2,3,4` ]] && tmpIp6Mask="64"
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
- [[ `echo $1 | cut -d':' -f 1,2,3,4,5` == `echo $2 | cut -d':' -f 1,2,3,4,5` ]] && tmpIp6Mask="80"
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
- [[ `echo $1 | cut -d':' -f 1,2,3,4,5,6` == `echo $2 | cut -d':' -f 1,2,3,4,5,6` ]] && tmpIp6Mask="96"
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
- [[ `echo $1 | cut -d':' -f 1,2,3,4,5,6,7` == `echo $2 | cut -d':' -f 1,2,3,4,5,6,7` ]] && tmpIp6Mask="112"
|
|
|
-}
|
|
|
-
|
|
|
-
|
|
|
-function ipv6SubnetCalc() {
|
|
|
- tmpIp6Subnet=""
|
|
|
- ip6Subnet=""
|
|
|
- ip6SubnetEleNum=`expr $1 / 4`
|
|
|
- ip6SubnetEleNumRemain=`expr $1 - $ip6SubnetEleNum \* 4`
|
|
|
- if [[ "$ip6SubnetEleNumRemain" == 0 ]]; then
|
|
|
- ip6SubnetHex="0"
|
|
|
- elif [[ "$ip6SubnetEleNumRemain" == 1 ]]; then
|
|
|
- ip6SubnetHex="8"
|
|
|
- elif [[ "$ip6SubnetEleNumRemain" == 2 ]]; then
|
|
|
- ip6SubnetHex="c"
|
|
|
- elif [[ "$ip6SubnetEleNumRemain" == 3 ]]; then
|
|
|
- ip6SubnetHex="e"
|
|
|
- fi
|
|
|
- for ((i=1; i<="$ip6SubnetEleNum"; i++)); do
|
|
|
- tmpIp6Subnet+="f"
|
|
|
- done
|
|
|
- tmpIp6Subnet=$tmpIp6Subnet$ip6SubnetHex
|
|
|
- for ((j=1; j<=`expr 32 - $ip6SubnetEleNum`; j++)); do
|
|
|
- tmpIp6Subnet+="0"
|
|
|
- done
|
|
|
- if [[ `echo $tmpIp6Subnet | wc -c` -ge "33" ]]; then
|
|
|
- tmpIp6Subnet=`echo $tmpIp6Subnet | sed 's/.$//'`
|
|
|
- fi
|
|
|
- for ((k=0; k<=7; k++)); do
|
|
|
- ip6Subnet+=$(echo ${tmpIp6Subnet:`expr $k \* 4`:4})":"
|
|
|
- done
|
|
|
- ip6Subnet=`echo ${ip6Subnet%?}`
|
|
|
-}
|
|
|
-
|
|
|
-
|
|
|
-function collectAllIpv6Addresses() {
|
|
|
- [[ "$1" -ge "2" && "$IPStackType" != "IPv4Stack" ]] && {
|
|
|
- Network6Config="isStatic"
|
|
|
- i6Addrs=()
|
|
|
- for tmpIp6 in $allI6Addrs; do
|
|
|
-
|
|
|
-
|
|
|
- i6Addrs[${#i6Addrs[@]}]=$tmpIp6
|
|
|
- done
|
|
|
- if [[ "$IPStackType" == "IPv6Stack" ]] || [[ "$IPStackType" == "BiStack" && -n "$interface4" && -n "$interface6" && "$interface4" != "$interface6" ]]; then
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
- allI6AddrsWithoutSuffix=()
|
|
|
- for tmpIp6 in ${i6Addrs[@]}; do
|
|
|
- tmpIp6=$(echo $tmpIp6 | cut -d'/' -f1)
|
|
|
- allI6AddrsWithoutSuffix[${#allI6AddrsWithoutSuffix[@]}]=$tmpIp6
|
|
|
- done
|
|
|
- allI6AddrsWithUltimateFormat=()
|
|
|
- for tmpIp6 in ${allI6AddrsWithoutSuffix[@]}; do
|
|
|
- tmpIp6=$(ultimateFormatOfIpv6 "$tmpIp6")
|
|
|
- allI6AddrsWithUltimateFormat[${#allI6AddrsWithUltimateFormat[@]}]=$tmpIp6
|
|
|
- done
|
|
|
- allI6AddrsWithOmittedClassesNum=()
|
|
|
- for tmpIp6 in ${allI6AddrsWithUltimateFormat[@]}; do
|
|
|
- tmpIp6=$(echo $tmpIp6 | grep -oi "0000" | wc -l)
|
|
|
- allI6AddrsWithOmittedClassesNum[${#allI6AddrsWithOmittedClassesNum[@]}]=$tmpIp6
|
|
|
- done
|
|
|
- omittedClassesMaxNum=${allI6AddrsWithOmittedClassesNum[0]}
|
|
|
- for tmpIp6 in ${!allI6AddrsWithOmittedClassesNum[@]}; do
|
|
|
- if [[ "$omittedClassesMaxNum" -le "${allI6AddrsWithOmittedClassesNum[${tmpIp6}]}" ]]; then
|
|
|
- omittedClassesMaxNum=${allI6AddrsWithOmittedClassesNum[${tmpIp6}]}
|
|
|
- fi
|
|
|
- done
|
|
|
- getArrItemIdx "${allI6AddrsWithOmittedClassesNum[*]}" "$omittedClassesMaxNum"
|
|
|
- mainIp6Index="$index"
|
|
|
- i6Addr=${i6Addrs[$mainIp6Index]}
|
|
|
- fi
|
|
|
- }
|
|
|
-}
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-function writeMultipleIpv6Addresses() {
|
|
|
- [[ "$1" -ge "2" && "$IPStackType" != "IPv4Stack" ]] && {
|
|
|
-
|
|
|
-
|
|
|
- if [[ "$linux_relese" == 'debian' ]] || [[ "$linux_relese" == 'kali' ]]; then
|
|
|
- if [[ "$IPStackType" == "IPv6Stack" ]] || [[ "$IPStackType" == "BiStack" && -n "$interface4" && -n "$interface6" && "$interface4" != "$interface6" ]]; then
|
|
|
- unset i6Addrs[$mainIp6Index]
|
|
|
- fi
|
|
|
- for writeIp6s in ${i6Addrs[@]}; do
|
|
|
- [[ "$IPStackType" == "BiStack" && -n "$interface4" && -n "$interface6" && "$interface4" != "$interface6" ]] && ip6AddrItem="up ip -6 addr add $writeIp6s dev $interface6" || ip6AddrItem="up ip addr add $writeIp6s dev $interface6"
|
|
|
- tmpWriteIp6sCmd+=''$2' sed -i '\''$a\\t'$ip6AddrItem''\'' '$3'; '
|
|
|
- done
|
|
|
- writeIp6sCmd=$(echo $tmpWriteIp6sCmd)
|
|
|
- writeIp6GateCmd=''$2' sed -i '\''$a\\tup ip -6 route add '$ip6Gate' dev '$interface6''\'' '$3'; '$2' sed -i '\''$a\\tup ip -6 route add default via '$ip6Gate' dev '$interface6''\'' '$3';'
|
|
|
- addIpv6DnsForPreseed=''$2' sed -ri '\''s/'$ipDNS'/'$ipDNS' '$ip6DNS'/g'\'' '$3';'
|
|
|
- preferIpv6Access=''$2' sed -i '\''$alabel 2002::/16'\'' /etc/gai.conf; '$2' sed -i '\''$alabel 2001:0::/32'\'' /etc/gai.conf;'
|
|
|
- SupportIPv6orIPv4=''$writeIp6sCmd' '$writeIp6GateCmd' '$addIpv6DnsForPreseed' '$preferIpv6Access''
|
|
|
- [[ "$IPStackType" == "IPv6Stack" ]] && SupportIPv6orIPv4=''$writeIp6sCmd' '$preferIpv6Access''
|
|
|
- [[ "$IPStackType" == "BiStack" && -n "$interface4" && -n "$interface6" && "$interface4" != "$interface6" ]] && {
|
|
|
- addIpv6Adapter=''$2' sed -i '\''$a\ '\'' '$3'; '$2' sed -i '\''$aallow-hotplug '$interface6''\'' '$3';'
|
|
|
- addFirstIpv6Config=''$2' sed -i '\''$aiface '$interface6' inet6 static'\'' '$3'; '$2' sed -i '\''$a\\taddress '$i6Addr''\'' '$3'; '$2' sed -i '\''$a\\tgateway '$ip6Gate''\'' '$3'; '$2' sed -i '\''$a\\tdns-nameservers '$ip6DNS''\'' '$3';'
|
|
|
- SupportIPv6orIPv4=''$addIpv6Adapter' '$addFirstIpv6Config' '$writeIp6sCmd' '$preferIpv6Access''
|
|
|
- }
|
|
|
- elif [[ "$linux_relese" == 'centos' ]] || [[ "$linux_relese" == 'rockylinux' ]] || [[ "$linux_relese" == 'almalinux' ]] || [[ "$linux_relese" == 'fedora' ]]; then
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
- for (( tmpI6Index="0"; tmpI6Index<"$1"; tmpI6Index++ )); do
|
|
|
- writeIp6s="${i6Addrs[$tmpI6Index]}"
|
|
|
- ipv6AddressOrder=$(expr $tmpI6Index + 1)
|
|
|
- ip6AddrItem+='address'$ipv6AddressOrder'='$writeIp6s','$ip6Gate'\n'
|
|
|
- done
|
|
|
- ip6AddrItems=''$ip6AddrItem''
|
|
|
- addIpv6DnsForRedhat='dns='$ip6DNS1';'$ip6DNS2';'
|
|
|
- addIpv6AddrsForRedhat='sed -i '\''/addr-gen-mode=eui64/a\'$ip6AddrItems''$addIpv6DnsForRedhat''\'' '$3''
|
|
|
- setIpv6ConfigMethodForRedhat='sed -ri '\''s/method=auto/method=manual/g'\'' '$3''
|
|
|
- [[ "$IPStackType" == "IPv6Stack" ]] && { ip6AddrItems=$(echo $ip6AddrItem | sed 's/..$//'); deleteOriginalIpv6Coning='sed -ri '\''/address1.*/d'\'' '$3''; addIpv6AddrsForRedhat='sed -i '\''/addr-gen-mode=eui64/a\'$ip6AddrItems''\'' '$3''; setIpv6ConfigMethodForRedhat=""; }
|
|
|
- fi
|
|
|
- }
|
|
|
-}
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-function sortFileSize() {
|
|
|
- FilesDirArr=()
|
|
|
- FilesLineArr=()
|
|
|
- FilesDir="$1"
|
|
|
-
|
|
|
- for Count in $FilesDir; do
|
|
|
- FilesDirArr+=($Count)
|
|
|
- FilesDirNum=`cat $Count | wc -c`
|
|
|
- FilesLineArr+=($FilesDirNum)
|
|
|
- done
|
|
|
-
|
|
|
- tmpSizeArray=(`echo ${FilesLineArr[*]} | tr ' ' '\n' | $2`)
|
|
|
-}
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-function getArrItemIdx() {
|
|
|
- arr=$1
|
|
|
- item=$2
|
|
|
- index=0
|
|
|
-
|
|
|
- for i in ${arr[*]}; do
|
|
|
- [[ $item == $i ]] && {
|
|
|
- echo $index >>/dev/null 2>&1
|
|
|
- return
|
|
|
- }
|
|
|
- index=$(( $index + 1 ))
|
|
|
- done
|
|
|
-}
|
|
|
-
|
|
|
-
|
|
|
-function splitDirAndFile() {
|
|
|
- FileName=`echo $1 | awk -F/ '{print $NF}'`
|
|
|
- FileDirection=`echo $1 | sed "s/$FileName//g"`
|
|
|
-}
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-function getLargestOrSmallestFile() {
|
|
|
- for Count in "$1"; do
|
|
|
- sortFileSize "$Count" "$2"
|
|
|
- getArrItemIdx "${FilesLineArr[*]}" "${tmpSizeArray[0]}"
|
|
|
- fullFilePath="${FilesDirArr[$index]}"
|
|
|
- [[ "$fullFilePath" != "" ]] && {
|
|
|
- splitDirAndFile "$fullFilePath"
|
|
|
- break
|
|
|
- }
|
|
|
- done
|
|
|
-}
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-function parseYaml() {
|
|
|
- prefix=$2
|
|
|
- s='[[:space:]]*' w='[a-zA-Z0-9_]*'
|
|
|
- fs=$(echo @|tr @ '\034')
|
|
|
- sed -ne "s|,$s\]$s\$|]|" \
|
|
|
- -e ":1;s|^\($s\)\($w\)$s:$s\[$s\(.*\)$s,$s\(.*\)$s\]|\1\2: [\3]\n\1 - \4|;t1" \
|
|
|
- -e "s|^\($s\)\($w\)$s:$s\[$s\(.*\)$s\]|\1\2:\n\1 - \3|;p" $1 | \
|
|
|
- sed -ne "s|,$s}$s\$|}|" \
|
|
|
- -e ":1;s|^\($s\)-$s{$s\(.*\)$s,$s\($w\)$s:$s\(.*\)$s}|\1- {\2}\n\1 \3: \4|;t1" \
|
|
|
- -e "s|^\($s\)-$s{$s\(.*\)$s}|\1-\n\1 \2|;p" | \
|
|
|
- sed -ne "s|^\($s\):|\1|" \
|
|
|
- -e "s|^\($s\)-$s[\"']\(.*\)[\"']$s\$|\1$fs$fs\2|p" \
|
|
|
- -e "s|^\($s\)-$s\(.*\)$s\$|\1$fs$fs\2|p" \
|
|
|
- -e "s|^\($s\)\($w\)$s:$s[\"']\(.*\)[\"']$s\$|\1$fs\2$fs\3|p" \
|
|
|
- -e "s|^\($s\)\($w\)$s:$s\(.*\)$s\$|\1$fs\2$fs\3|p" | \
|
|
|
- awk -F$fs '{
|
|
|
- indent=length($1)/2
|
|
|
- vname[indent]=$2
|
|
|
- for (i in vname) {if (i>indent) {delete vname[i]; idx[i]=0}}
|
|
|
- if (length($2)==0) {vname[indent]= ++idx[indent]}
|
|
|
- if (length($3)>0) {
|
|
|
- vn=""
|
|
|
- for (i=0;i<indent;i++) {vn=(vn)(vname[i])("_")}
|
|
|
- printf("%s%s%s=\"%s\"\n","'$prefix'",vn,vname[indent],$3)
|
|
|
- }
|
|
|
- }'
|
|
|
-}
|
|
|
-
|
|
|
-
|
|
|
-function getInterface() {
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
- interface=""
|
|
|
- Interfaces=`cat /proc/net/dev |grep ':' | cut -d':' -f1 | sed 's/\s//g' | grep -iv '^lo\|^sit\|^stf\|^gif\|^dummy\|^vmnet\|^vir\|^gre\|^ipip\|^ppp\|^bond\|^tun\|^tap\|^ip6gre\|^ip6tnl\|^teql\|^ocserv\|^vpn'`
|
|
|
-
|
|
|
- default4Route=`ip -4 route show default | grep "^default"`
|
|
|
-
|
|
|
- default6Route=`ip -6 route show default | grep "^default"`
|
|
|
- for item in `echo "$Interfaces"`; do
|
|
|
- [ -n "$item" ] || continue
|
|
|
- echo "$default4Route" | grep -q "$item"
|
|
|
- [ $? -eq 0 ] && interface4="$item" && break
|
|
|
- done
|
|
|
- for item in `echo "$Interfaces"`; do
|
|
|
- [ -n "$item" ] || continue
|
|
|
- echo "$default6Route" | grep -q "$item"
|
|
|
- [ $? -eq 0 ] && interface6="$item" && break
|
|
|
- done
|
|
|
- interface="$interface4 $interface6"
|
|
|
- [[ "$interface4" == "$interface6" ]] && interface=`echo "$interface" | cut -d' ' -f 1`
|
|
|
- [[ -z "$interface4" || -z "$interface6" ]] && {
|
|
|
- interface=`echo "$interface" | sed 's/[[:space:]]//g'`
|
|
|
- [[ -z "$interface4" ]] && interface4="$interface"
|
|
|
- [[ -z "$interface6" ]] && interface6="$interface"
|
|
|
- }
|
|
|
- echo "$interface" > /dev/null
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
- GrubCmdLine=`grep "GRUB_CMDLINE_LINUX" /etc/default/grub | grep -v "#" | grep "net.ifnames=0\|biosdevname=0"`
|
|
|
-
|
|
|
- if [[ -n "$GrubCmdLine" && -z "$interfaceSelect" ]] || [[ "$interface4" == "eth0" ]] || [[ "$interface6" == "eth0" ]]|| [[ "$linux_relese" == 'kali' ]] || [[ "$linux_relese" == 'alpinelinux' ]]; then
|
|
|
- setInterfaceName='1'
|
|
|
- fi
|
|
|
- if [[ "$1" == 'CentOS' || "$1" == 'AlmaLinux' || "$1" == 'RockyLinux' || "$1" == 'Fedora' || "$1" == 'Vzlinux' || "$1" == 'OracleLinux' || "$1" == 'OpenCloudOS' || "$1" == 'AlibabaCloudLinux' || "$1" == 'ScientificLinux' || "$1" == 'AmazonLinux' || "$1" == 'RedHatEnterpriseLinux' || "$1" == 'OpenAnolis' || "$1" == 'CloudLinux' ]]; then
|
|
|
- [[ ! $(find / -maxdepth 5 -path /*network-scripts -type d -print -or -path /*system-connections -type d -print) ]] && {
|
|
|
- echo -ne "\n[${red}Error${plain}] Invalid network configuration!\n"
|
|
|
- exit 1
|
|
|
- }
|
|
|
- NetCfgWhole=()
|
|
|
- tmpNetCfgFiles=""
|
|
|
- for Count in $(find / -maxdepth 5 -path /*network-scripts -type d -print -or -path /*system-connections -type d -print); do
|
|
|
- NetCfgDir="$Count""/"
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
- NetCfgFiles=`ls -Sl $NetCfgDir 2>/dev/null | awk -F' ' '{print $NF}' | grep -iv 'readme\|ifcfg-lo\|ifcfg-bond\|ifup\|ifdown\|vpn\|init.ipv6-global\|network-functions' | grep -s "ifcfg\|nmconnection"`
|
|
|
- for Files in $NetCfgFiles; do
|
|
|
- if [[ `grep -w "$interface4\|$interface6" "$NetCfgDir$Files"` != "" ]]; then
|
|
|
- tmpNetCfgFiles+=$(echo -e "\n""$NetCfgDir$Files")
|
|
|
- fi
|
|
|
- done
|
|
|
- getLargestOrSmallestFile "$tmpNetCfgFiles" "sort -hr"
|
|
|
- NetCfgFile="$FileName"
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
- if [[ ! -z "$NetCfgFile" && ! -f "$NetCfgDir$NetCfgFile" ]]; then
|
|
|
- tmpNetcfgDir="/root/tmp/installNetcfgCollections/"
|
|
|
- [[ ! -d "$tmpNetcfgDir" ]] && mkdir -p "$tmpNetcfgDir"
|
|
|
- if [[ "$NetCfgFile" =~ "nmconnection" ]]; then
|
|
|
- NetCfgFile="$interface.nmconnection"
|
|
|
- grep -wr "$interface\|\[ipv4\]\|\[ipv6\]\|\[connection\]\|\[ethernet\]\|id=*\|interface-name=*\|type=*\|method=*" "$NetCfgDir" | cut -d ':' -f 2 | tee -a "$tmpNetcfgDir$NetCfgFile"
|
|
|
- NetCfgDir="$tmpNetcfgDir"
|
|
|
- elif [[ "$NetCfgFile" =~ "ifcfg" ]]; then
|
|
|
- NetCfgFile="$ifcfg-$interface"
|
|
|
- grep -wr "$interface\|BOOTPROTO=*\|DEVICE=*\|ONBOOT=*\|TYPE=*\|HWADDR=*\|IPV6_AUTOCONF=*\|DHCPV6C=*" "$NetCfgDir" | cut -d ':' -f 2 | tee -a "$tmpNetcfgDir$NetCfgFile"
|
|
|
- NetCfgDir="$tmpNetcfgDir"
|
|
|
- fi
|
|
|
+ NewIMG="initrd.img.$COMPTYPE"
|
|
|
fi
|
|
|
-
|
|
|
- [[ `grep -wcs "$interface4\|$interface6\|BOOTPROTO=*\|DEVICE=*\|ONBOOT=*\|TYPE=*\|HWADDR=*\|id=*\|\[connection\]\|interface-name=*\|type=*\|method=*" $NetCfgDir$NetCfgFile` -ge "3" ]] && {
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
- NetCfgWhole+=("$NetCfgDir$NetCfgFile")
|
|
|
- }
|
|
|
- done
|
|
|
-
|
|
|
- if [[ "${NetCfgWhole[1]}" != "" ]]; then
|
|
|
- for c in "${NetCfgWhole[@]}"; do
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
- [[ `sed -e "4"p "$c" | grep " by " | grep -c "#"` -ge "1" ]] && {
|
|
|
- NetCfgWhole="$c"
|
|
|
- break
|
|
|
- }
|
|
|
- done
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
- [[ `declare -p NetCfgWhole 2>/dev/null | grep -iw '^declare -a'` ]] && {
|
|
|
- NetCfgWhole="${NetCfgWhole[0]}"
|
|
|
- }
|
|
|
- fi
|
|
|
- splitDirAndFile "$NetCfgWhole"
|
|
|
- NetCfgFile="$FileName"
|
|
|
- NetCfgDir="$FileDirection"
|
|
|
- else
|
|
|
- readNetplan=$(find $(echo `find / -maxdepth 4 -path /*netplan`) -maxdepth 1 -name "*.yaml" -print)
|
|
|
- readIfupdown=$(find / -maxdepth 5 -path /*network -type d -print | grep -v "lib\|systemd")
|
|
|
- if [[ ! -z "$readNetplan" ]]; then
|
|
|
-
|
|
|
- networkManagerType="netplan"
|
|
|
- tmpNetCfgFiles=""
|
|
|
- for Count in $readNetplan; do
|
|
|
- tmpNetCfgFiles+=$(echo -e "\n"`grep -wrl "network" | grep -wrl "ethernets" | grep -wrl "$interface4\|$interface6" | grep -wrl "version" "$Count" 2>/dev/null`)
|
|
|
- done
|
|
|
- getLargestOrSmallestFile "$tmpNetCfgFiles" "sort -hr"
|
|
|
- NetCfgFile="$FileName"
|
|
|
- NetCfgDir="$FileDirection"
|
|
|
- NetCfgWhole="$NetCfgDir$NetCfgFile"
|
|
|
- elif [[ ! -z "$readIfupdown" ]]; then
|
|
|
-
|
|
|
-
|
|
|
- networkManagerType="ifupdown"
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
- tmpNetCfgFiles=""
|
|
|
- for Count in $readIfupdown; do
|
|
|
- if [[ "$IPStackType" == "IPv4Stack" ]]; then
|
|
|
- NetCfgFiles=`grep -wrl 'iface' | grep -wrl "auto\|dhcp\|static\|manual" | grep -wrl 'inet\|ip addr\|ip route' "$Count""/" 2>/dev/null | grep -v "if-*" | grep -v "state" | grep -v "helper" | grep -v "template"`
|
|
|
- elif [[ "$IPStackType" == "BiStack" ]] || [[ "$IPStackType" == "IPv6Stack" ]]; then
|
|
|
- NetCfgFiles=`grep -wrl 'iface' | grep -wrl "auto\|dhcp\|static\|manual" | grep -wrl 'inet\|ip addr\|ip route\|inet6\|ip -6' "$Count""/" 2>/dev/null | grep -v "if-*" | grep -v "state" | grep -v "helper" | grep -v "template"`
|
|
|
- fi
|
|
|
- for Files in $NetCfgFiles; do
|
|
|
- if [[ `grep -w "$interface4\|$interface6" "$Files"` != "" ]]; then
|
|
|
- tmpNetCfgFiles+=$(echo -e "\n""$Files")
|
|
|
- fi
|
|
|
- done
|
|
|
- done
|
|
|
- getLargestOrSmallestFile "$tmpNetCfgFiles" "sort -hr"
|
|
|
- NetCfgFile="$FileName"
|
|
|
- NetCfgDir="$FileDirection"
|
|
|
- NetCfgWhole="$NetCfgDir$NetCfgFile"
|
|
|
- else
|
|
|
- echo -ne "\n[${red}Error${plain}] Invalid network configuration!\n"
|
|
|
- exit 1
|
|
|
- fi
|
|
|
- fi
|
|
|
-}
|
|
|
-
|
|
|
-
|
|
|
-function acceptIPv4AndIPv6SubnetValue() {
|
|
|
- [[ -n "$1" ]] && {
|
|
|
- if [[ `echo "$1" | grep '^[[:digit:]]*$'` && "$1" -ge "1" && "$1" -le "32" ]]; then
|
|
|
- ipPrefix="$1"
|
|
|
- actualIp4Prefix="$ipPrefix"
|
|
|
- ipMask=`netmask "$1"`
|
|
|
- actualIp4Subnet=`netmask "$1"`
|
|
|
- else
|
|
|
- echo -ne "\n[${red}Warning${plain}] Only accept prefix format of IPv4 address, length from 1 to 32."
|
|
|
- echo -ne "\nIPv4 CIDR Calculator: https://www.vultr.com/resources/subnet-calculator/\n"
|
|
|
- exit 1
|
|
|
- fi
|
|
|
- }
|
|
|
- [[ -n "$2" ]] && {
|
|
|
- if [[ `echo "$2" | grep '^[[:digit:]]*$'` && "$2" -ge "1" && "$2" -le "128" ]]; then
|
|
|
- actualIp6Prefix="$2"
|
|
|
- ipv6SubnetCalc "$2"
|
|
|
- else
|
|
|
- echo -ne "\n[${red}Warning${plain}] Only accept prefix format of IPv6 address, length from 1 to 128."
|
|
|
- echo -ne "\nIPv6 CIDR Calculator: https://en.rakko.tools/tools/27/\n"
|
|
|
- exit 1
|
|
|
+ mv -f "/tmp/initrd.img" "/tmp/$NewIMG"
|
|
|
+ break;
|
|
|
fi
|
|
|
- }
|
|
|
-}
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-function checkIpv4OrIpv6ConfigForRedhat9Later() {
|
|
|
- IpTypeLine="`awk '/\['$3'\]/{print NR}' $1/$2 | head -n 2 | tail -n 1`"
|
|
|
- ConnectTypeArray=()
|
|
|
- CtaSpace=()
|
|
|
- for tmpConnectType in `awk '/'$4'/{print NR}' $1/$2`; do
|
|
|
- ConnectTypeArray+=("$tmpConnectType" "$ConnectTypeArray")
|
|
|
- [[ `expr $tmpConnectType - $IpTypeLine` -gt "0" ]] && CtaSpace+=(`expr "$tmpConnectType" - "$IpTypeLine"` "$CtaSpace")
|
|
|
- done
|
|
|
- minArray=${CtaSpace[0]}
|
|
|
- for ((i=1;i<=`grep -io "$4" $1/$2 | wc -l`;i++)); do
|
|
|
- for j in ${CtaSpace[@]}; do
|
|
|
- [[ "$minArray" -gt "$j" ]] && minArray=$j
|
|
|
- done
|
|
|
done
|
|
|
- NetCfgLineNum=`expr $minArray + $IpTypeLine`
|
|
|
-}
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-function ipv6ForRedhatGrub() {
|
|
|
- if [[ "$IPStackType" == "IPv6Stack" ]]; then
|
|
|
- ipv6NameserverForKsGrub="nameserver=$ip6DNS1 nameserver=$ip6DNS2"
|
|
|
- if [[ "$Network6Config" == "isStatic" ]]; then
|
|
|
- ipv6StaticConfForKsGrub="noipv4 ip=[$ip6Addr]::[$ip6Gate]:$actualIp6Prefix::$interface:none $ipv6NameserverForKsGrub"
|
|
|
- else
|
|
|
- ipv6StaticConfForKsGrub="noipv4 $ipv6NameserverForKsGrub"
|
|
|
- fi
|
|
|
- fi
|
|
|
-}
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-function checkDHCP() {
|
|
|
- getInterface "$1"
|
|
|
- if [[ "$1" == 'CentOS' || "$1" == 'AlmaLinux' || "$1" == 'RockyLinux' || "$1" == 'Fedora' || "$1" == 'Vzlinux' || "$1" == 'OracleLinux' || "$1" == 'OpenCloudOS' || "$1" == 'AlibabaCloudLinux' || "$1" == 'ScientificLinux' || "$1" == 'AmazonLinux' || "$1" == 'RedHatEnterpriseLinux' || "$1" == 'OpenAnolis' || "$1" == 'CloudLinux' ]]; then
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
- if [[ "$NetCfgFile" =~ "ifcfg" ]]; then
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
- if [[ "$3" == "IPv4Stack" ]]; then
|
|
|
- Network6Config="isDHCP"
|
|
|
- [[ -n `grep -Ewirn "BOOTPROTO=none|BOOTPROTO=\"none\"|BOOTPROTO=\'none\'|BOOTPROTO=NONE|BOOTPROTO=\"NONE\"|BOOTPROTO=\'NONE\'|BOOTPROTO=static|BOOTPROTO=\"static\"|BOOTPROTO=\'static\'|BOOTPROTO=STATIC|BOOTPROTO=\"STATIC\"|BOOTPROTO=\'STATIC\'" $NetCfgWhole` ]] && Network4Config="isStatic" || Network4Config="isDHCP"
|
|
|
- elif [[ "$3" == "BiStack" ]]; then
|
|
|
- [[ -n `grep -Ewirn "BOOTPROTO=none|BOOTPROTO=\"none\"|BOOTPROTO=\'none\'|BOOTPROTO=NONE|BOOTPROTO=\"NONE\"|BOOTPROTO=\'NONE\'|BOOTPROTO=static|BOOTPROTO=\"static\"|BOOTPROTO=\'static\'|BOOTPROTO=STATIC|BOOTPROTO=\"STATIC\"|BOOTPROTO=\'STATIC\'" $NetCfgWhole` ]] && Network4Config="isStatic" || Network4Config="isDHCP"
|
|
|
- [[ -n `grep -Ewirn "IPV6_AUTOCONF=yes|IPV6_AUTOCONF=\"yes\"|IPV6_AUTOCONF=YES|IPV6_AUTOCONF=\"YES\"|DHCPV6C=yes|DHCPV6C=\"yes\"" $NetCfgWhole` ]] && Network6Config="isDHCP" || Network6Config="isStatic"
|
|
|
- elif [[ "$3" == "IPv6Stack" ]]; then
|
|
|
- Network4Config="isDHCP"
|
|
|
- [[ -n `grep -Ewirn "IPV6_AUTOCONF=yes|IPV6_AUTOCONF=\"yes\"|IPV6_AUTOCONF=YES|IPV6_AUTOCONF=\"YES\"|DHCPV6C=yes|DHCPV6C=\"yes\"" $NetCfgWhole` ]] && Network6Config="isDHCP" || Network6Config="isStatic"
|
|
|
- fi
|
|
|
- elif [[ "$NetCfgFile" =~ "nmconnection" ]]; then
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
- checkIpv4OrIpv6ConfigForRedhat9Later "$NetCfgDir" "$NetCfgFile" "ipv4" "method="
|
|
|
- NetCfg4LineNum="$NetCfgLineNum"
|
|
|
- checkIpv4OrIpv6ConfigForRedhat9Later "$NetCfgDir" "$NetCfgFile" "ipv6" "method="
|
|
|
- NetCfg6LineNum="$NetCfgLineNum"
|
|
|
- if [[ "$3" == "IPv4Stack" ]]; then
|
|
|
- Network6Config="isDHCP"
|
|
|
- [[ `sed -n "$NetCfg4LineNum"p $NetCfgWhole` == "method=auto" ]] && Network4Config="isDHCP" || Network4Config="isStatic"
|
|
|
- elif [[ "$3" == "BiStack" ]]; then
|
|
|
- [[ `sed -n "$NetCfg4LineNum"p $NetCfgWhole` == "method=auto" ]] && Network4Config="isDHCP" || Network4Config="isStatic"
|
|
|
- [[ `sed -n "$NetCfg6LineNum"p $NetCfgWhole` == "method=auto" ]] && Network6Config="isDHCP" || Network6Config="isStatic"
|
|
|
- elif [[ "$3" == "IPv6Stack" ]]; then
|
|
|
- Network4Config="isDHCP"
|
|
|
- [[ `sed -n "$NetCfg6LineNum"p $NetCfgWhole` == "method=auto" ]] && Network6Config="isDHCP" || Network6Config="isStatic"
|
|
|
- fi
|
|
|
- fi
|
|
|
- elif [[ "$1" == 'Debian' ]] || [[ "$1" == 'Kali' ]] || [[ "$1" == 'Ubuntu' && "$networkManagerType" == "ifupdown" ]] || [[ "$1" == 'AlpineLinux' ]]; then
|
|
|
-
|
|
|
-
|
|
|
- if [[ "$3" == "IPv4Stack" ]]; then
|
|
|
- Network6Config="isDHCP"
|
|
|
- [[ `grep -iw "iface" $NetCfgWhole | grep -iw "$interface4" | grep -iw "inet" | grep -ic "auto\|dhcp"` -ge "1" ]] && Network4Config="isDHCP" || Network4Config="isStatic"
|
|
|
- elif [[ "$3" == "BiStack" ]]; then
|
|
|
- [[ `grep -iw "iface" $NetCfgWhole | grep -iw "$interface4" | grep -iw "inet" | grep -ic "auto\|dhcp"` -ge "1" ]] && Network4Config="isDHCP" || Network4Config="isStatic"
|
|
|
- [[ `grep -iw "iface" $NetCfgWhole | grep -iw "$interface6" | grep -iw "inet6" | grep -ic "auto\|dhcp"` -ge "1" ]] && Network6Config="isDHCP" || Network6Config="isStatic"
|
|
|
- elif [[ "$3" == "IPv6Stack" ]]; then
|
|
|
- Network4Config="isDHCP"
|
|
|
- [[ `grep -iw "iface" $NetCfgWhole | grep -iw "$interface6" | grep -iw "inet6" | grep -ic "auto\|dhcp"` -ge "1" ]] && Network6Config="isDHCP" || Network6Config="isStatic"
|
|
|
- fi
|
|
|
- elif [[ "$1" == 'Ubuntu' && "$networkManagerType" == "netplan" ]]; then
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
- dhcpStatus=$(parseYaml "$NetCfgWhole" | grep "$interface" | grep "dhcp")
|
|
|
- if [[ "$3" == "IPv4Stack" ]]; then
|
|
|
- Network6Config="isDHCP"
|
|
|
- [[ "$dhcpStatus" =~ "dhcp4=\"true\"" || "$dhcpStatus" =~ "dhcp4=\"yes\"" ]] && Network4Config="isDHCP" || Network4Config="isStatic"
|
|
|
- elif [[ "$3" == "BiStack" ]]; then
|
|
|
- [[ "$dhcpStatus" =~ "dhcp4=\"true\"" || "$dhcpStatus" =~ "dhcp4=\"yes\"" ]] && Network4Config="isDHCP" || Network4Config="isStatic"
|
|
|
- [[ "$dhcpStatus" =~ "dhcp6=\"true\"" || "$dhcpStatus" =~ "dhcp6=\"yes\"" ]] && Network6Config="isDHCP" || Network6Config="isStatic"
|
|
|
- elif [[ "$3" == "IPv6Stack" ]]; then
|
|
|
- Network4Config="isDHCP"
|
|
|
- [[ "$dhcpStatus" =~ "dhcp6=\"true\"" || "$dhcpStatus" =~ "dhcp6=\"yes\"" ]] && Network6Config="isDHCP" || Network6Config="isStatic"
|
|
|
- fi
|
|
|
- fi
|
|
|
- [[ "$Network4Config" == "" ]] && Network4Config="isStatic"
|
|
|
- [[ "$Network6Config" == "" ]] && Network6Config="isStatic"
|
|
|
- rm -rf "$tmpNetcfgDir"
|
|
|
-}
|
|
|
+[[ "$CompDected" != '1' ]] && echo "Detect compressed type not support." && exit 1;
|
|
|
+[[ "$COMPTYPE" == 'lzma' ]] && UNCOMP='xz --format=lzma --decompress';
|
|
|
+[[ "$COMPTYPE" == 'xz' ]] && UNCOMP='xz --decompress';
|
|
|
+[[ "$COMPTYPE" == 'gzip' ]] && UNCOMP='gzip -d';
|
|
|
|
|
|
-
|
|
|
-function setDhcpOrStatic() {
|
|
|
- [[ "$1" == "dhcp" || "$1" == "auto" || "$1" == "automatic" || "$1" == "true" || "$1" == "yes" || "$1" == "1" ]] && {
|
|
|
- Network4Config="isDHCP"
|
|
|
- Network6Config="isDHCP"
|
|
|
- }
|
|
|
- [[ "$1" == "static" || "$1" == "manual" || "$1" == "none" || "$1" == "false" || "$1" == "no" || "$1" == "0" ]] && {
|
|
|
- Network4Config="isStatic"
|
|
|
- Network6Config="isStatic"
|
|
|
- }
|
|
|
-}
|
|
|
+$UNCOMP < /tmp/$NewIMG | cpio --extract --verbose --make-directories --no-absolute-filenames >>/dev/null 2>&1
|
|
|
|
|
|
-
|
|
|
-function DebianModifiedPreseed() {
|
|
|
- if [[ "$linux_relese" == 'debian' ]] || [[ "$linux_relese" == 'kali' ]]; then
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
- if [[ "$DebianDistNum" -ge "9" && "$DebianDistNum" -le "11" ]]; then
|
|
|
- DebianVimVer="vim"`expr ${DebianDistNum} + 71`
|
|
|
- elif [[ "$DebianDistNum" -ge "12" ]]; then
|
|
|
- DebianVimVer="vim"`expr ${DebianDistNum} + 78`
|
|
|
- elif [[ "$DIST" =~ "kali-" ]]; then
|
|
|
- DebianVimVer="vim90"
|
|
|
- else
|
|
|
- DebianVimVer=""
|
|
|
- fi
|
|
|
-
|
|
|
- VimSupportCopy="$1 sed -i 's/set mouse=a/set mouse-=a/g' /usr/share/vim/${DebianVimVer}/defaults.vim;"
|
|
|
-
|
|
|
-
|
|
|
- VimIndentEolStart="$1 sed -i 's/set compatible/set nocompatible/g' /etc/vim/vimrc.tiny; $1 sed -i '/set nocompatible/a\set backspace=2' /etc/vim/vimrc.tiny;"
|
|
|
- [[ "$DebianVimVer" == "" ]] && { VimSupportCopy=""; VimIndentEolStart=""; }
|
|
|
- AptUpdating="$1 apt update -y;"
|
|
|
-
|
|
|
-
|
|
|
- InstallComponents="$1 apt install apt-transport-https ca-certificates cron curl dnsutils dpkg fail2ban file lrzsz lsb-release net-tools sudo traceroute unzip vim wget xz-utils -y;"
|
|
|
-
|
|
|
- DisableCertExpiredCheck="$1 sed -i '/^mozilla\/DST_Root_CA_X3/s/^/!/' /etc/ca-certificates.conf; $1 update-ca-certificates -f;"
|
|
|
- if [[ "$IsCN" == "cn" ]]; then
|
|
|
-
|
|
|
- ChangeBashrc="$1 rm -rf /root/.bashrc; $1 wget --no-check-certificate -qO /root/.bashrc 'https://gitee.com/mb9e8j2/Tools/raw/master/Linux_reinstall/Debian/.bashrc';"
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
- SetDNS="CNResolvHead"
|
|
|
- DnsChangePermanently="$1 mkdir -p /etc/resolvconf/resolv.conf.d/; $1 wget --no-check-certificate -qO /etc/resolvconf/resolv.conf.d/head 'https://gitee.com/mb9e8j2/Tools/raw/master/Linux_reinstall/Debian/network/${SetDNS}';"
|
|
|
-
|
|
|
- ModifyMOTD="$1 rm -rf /etc/update-motd.d/ /etc/motd /run/motd.dynamic; $1 mkdir -p /etc/update-motd.d/; $1 wget --no-check-certificate -qO /etc/update-motd.d/00-header 'https://gitee.com/mb9e8j2/Tools/raw/master/Linux_reinstall/Debian/updatemotd/00-header'; $1 wget --no-check-certificate -qO /etc/update-motd.d/10-sysinfo 'https://gitee.com/mb9e8j2/Tools/raw/master/Linux_reinstall/Debian/updatemotd/10-sysinfo'; $1 wget --no-check-certificate -qO /etc/update-motd.d/90-footer 'https://gitee.com/mb9e8j2/Tools/raw/master/Linux_reinstall/Debian/updatemotd/90-footer'; $1 chmod +x /etc/update-motd.d/00-header; $1 chmod +x /etc/update-motd.d/10-sysinfo; $1 chmod +x /etc/update-motd.d/90-footer;"
|
|
|
-
|
|
|
- ChangeSecurityMirror="$1 sed -i 's/security.debian.org/mirrors.tuna.tsinghua.edu.cn/g' /etc/apt/sources.list;"
|
|
|
- else
|
|
|
- ChangeBashrc="$1 rm -rf /root/.bashrc; $1 wget --no-check-certificate -qO /root/.bashrc 'https://raw.githubusercontent.com/leitbogioro/Tools/master/Linux_reinstall/Debian/.bashrc';"
|
|
|
-
|
|
|
- SetDNS="NomalResolvHead"
|
|
|
- DnsChangePermanently="$1 mkdir -p /etc/resolvconf/resolv.conf.d/; $1 wget --no-check-certificate -qO /etc/resolvconf/resolv.conf.d/head 'https://raw.githubusercontent.com/leitbogioro/Tools/master/Linux_reinstall/Debian/network/${SetDNS}';"
|
|
|
- ModifyMOTD="$1 rm -rf /etc/update-motd.d/ /etc/motd /run/motd.dynamic; $1 mkdir -p /etc/update-motd.d/; $1 wget --no-check-certificate -qO /etc/update-motd.d/00-header 'https://raw.githubusercontent.com/leitbogioro/Tools/master/Linux_reinstall/Debian/updatemotd/00-header'; $1 wget --no-check-certificate -qO /etc/update-motd.d/10-sysinfo 'https://raw.githubusercontent.com/leitbogioro/Tools/master/Linux_reinstall/Debian/updatemotd/10-sysinfo'; $1 wget --no-check-certificate -qO /etc/update-motd.d/90-footer 'https://raw.githubusercontent.com/leitbogioro/Tools/master/Linux_reinstall/Debian/updatemotd/90-footer'; $1 chmod +x /etc/update-motd.d/00-header; $1 chmod +x /etc/update-motd.d/10-sysinfo; $1 chmod +x /etc/update-motd.d/90-footer;"
|
|
|
- ChangeSecurityMirror=""
|
|
|
- fi
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
- [[ "$autoPlugAdapter" == "1" ]] && AutoPlugInterfaces="$1 sed -ri \"s/allow-hotplug $interface4/auto $interface4/g\" /etc/network/interfaces; $1 sed -ri \"s/allow-hotplug $interface6/auto $interface6/g\" /etc/network/interfaces;" || AutoPlugInterfaces=""
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
- SupportIPv6orIPv4=""
|
|
|
- ReplaceActualIpPrefix=""
|
|
|
- if [[ "$IPStackType" == "IPv4Stack" ]]; then
|
|
|
- [[ "$BurnIrregularIpv4Status" == "1" ]] && BurnIrregularIpv4Gate="$1 sed -i '\$a\\\tgateway $actualIp4Gate' /etc/network/interfaces;"
|
|
|
-
|
|
|
- SupportIPv6orIPv4="$1 sed -i '\$aprecedence ::ffff:0:0/96' /etc/gai.conf;"
|
|
|
- ReplaceActualIpPrefix="$1 sed -ri \"s/address $ipAddr\/$ipPrefix/address $ipAddr\/$actualIp4Prefix/g\" /etc/network/interfaces;"
|
|
|
- elif [[ "$IPStackType" == "BiStack" ]]; then
|
|
|
-
|
|
|
- if [[ "$BiStackPreferIpv6Status" == "1" ]]; then
|
|
|
- if [[ "$Network4Config" == "isDHCP" ]]; then
|
|
|
- SupportIPv6orIPv4="$1 sed -i '\$aiface $interface inet dhcp' /etc/network/interfaces; $1 sed -i '\$alabel 2002::/16' /etc/gai.conf; $1 sed -i '\$alabel 2001:0::/32' /etc/gai.conf;"
|
|
|
- [[ -n "$interface4" && -n "$interface6" && "$interface4" != "$interface6" ]] && SupportIPv6orIPv4="$1 sed -i '\$a\ ' /etc/network/interfaces; $1 sed -i '\$aallow-hotplug $interface4' /etc/network/interfaces; $1 sed -i '\$aiface $interface4 inet dhcp' /etc/network/interfaces; $1 sed -i '\$alabel 2002::/16' /etc/gai.conf; $1 sed -i '\$alabel 2001:0::/32' /etc/gai.conf;"
|
|
|
- ReplaceActualIpPrefix="$1 sed -ri \"s/address $ip6Addr\/$ip6Mask/address $ip6Addr\/$actualIp6Prefix/g\" /etc/network/interfaces;"
|
|
|
- elif [[ "$Network4Config" == "isStatic" ]]; then
|
|
|
- SupportIPv6orIPv4="$1 sed -i '\$aiface $interface inet static' /etc/network/interfaces; $1 sed -i '\$a\\\taddress $ipAddr' /etc/network/interfaces; $1 sed -i '\$a\\\tnetmask $MASK' /etc/network/interfaces; $1 sed -i '\$a\\\tgateway $GATE' /etc/network/interfaces; $1 sed -i '\$a\\\tdns-nameservers $ipDNS' /etc/network/interfaces; $1 sed -i '\$alabel 2002::/16' /etc/gai.conf; $1 sed -i '\$alabel 2001:0::/32' /etc/gai.conf;"
|
|
|
- [[ -n "$interface4" && -n "$interface6" && "$interface4" != "$interface6" ]] && SupportIPv6orIPv4="$1 sed -i '\$a\ ' /etc/network/interfaces; $1 sed -i '\$aallow-hotplug $interface4' /etc/network/interfaces; $1 sed -i '\$aiface $interface4 inet static' /etc/network/interfaces; $1 sed -i '\$a\\\taddress $ipAddr' /etc/network/interfaces; $1 sed -i '\$a\\\tnetmask $MASK' /etc/network/interfaces; $1 sed -i '\$a\\\tgateway $GATE' /etc/network/interfaces; $1 sed -i '\$a\\\tdns-nameservers $ipDNS' /etc/network/interfaces; $1 sed -i '\$alabel 2002::/16' /etc/gai.conf; $1 sed -i '\$alabel 2001:0::/32' /etc/gai.conf;"
|
|
|
- ReplaceActualIpPrefix="$1 sed -ri \"s/address $ip6Addr\/$ip6Mask/address $ip6Addr\/$actualIp6Prefix/g\" /etc/network/interfaces; $1 sed -ri \"s/netmask $MASK/netmask $actualIp4Subnet/g\" /etc/network/interfaces;"
|
|
|
- fi
|
|
|
- else
|
|
|
- [[ "$BurnIrregularIpv4Status" == "1" ]] && BurnIrregularIpv4Gate="$1 sed -i '\$a\\\tgateway $actualIp4Gate' /etc/network/interfaces;"
|
|
|
- if [[ "$Network6Config" == "isDHCP" ]]; then
|
|
|
-
|
|
|
- SupportIPv6orIPv4="$1 sed -i '\$aiface $interface inet6 dhcp' /etc/network/interfaces; $1 sed -i '\$alabel 2002::/16' /etc/gai.conf; $1 sed -i '\$alabel 2001:0::/32' /etc/gai.conf;"
|
|
|
- [[ -n "$interface4" && -n "$interface6" && "$interface4" != "$interface6" ]] && SupportIPv6orIPv4="$1 sed -i '\$a\ ' /etc/network/interfaces; $1 sed -i '\$aallow-hotplug $interface6' /etc/network/interfaces; $1 sed -i '\$aiface $interface6 inet6 dhcp' /etc/network/interfaces; $1 sed -i '\$alabel 2002::/16' /etc/gai.conf; $1 sed -i '\$alabel 2001:0::/32' /etc/gai.conf;"
|
|
|
- ReplaceActualIpPrefix="$1 sed -ri \"s/address $ipAddr\/$ipPrefix/address $ipAddr\/$actualIp4Prefix/g\" /etc/network/interfaces;"
|
|
|
- elif [[ "$Network6Config" == "isStatic" ]]; then
|
|
|
- SupportIPv6orIPv4="$1 sed -i '\$aiface $interface inet6 static' /etc/network/interfaces; $1 sed -i '\$a\\\taddress $ip6Addr' /etc/network/interfaces; $1 sed -i '\$a\\\tnetmask $ip6Mask' /etc/network/interfaces; $1 sed -i '\$a\\\tgateway $ip6Gate' /etc/network/interfaces; $1 sed -i '\$a\\\tdns-nameservers $ip6DNS' /etc/network/interfaces; $1 sed -i '\$alabel 2002::/16' /etc/gai.conf; $1 sed -i '\$alabel 2001:0::/32' /etc/gai.conf;"
|
|
|
- [[ -n "$interface4" && -n "$interface6" && "$interface4" != "$interface6" ]] && SupportIPv6orIPv4="$1 sed -i '\$a\ ' /etc/network/interfaces; $1 sed -i '\$aallow-hotplug $interface6' /etc/network/interfaces; $1 sed -i '\$aiface $interface6 inet6 static' /etc/network/interfaces; $1 sed -i '\$a\\\taddress $ip6Addr' /etc/network/interfaces; $1 sed -i '\$a\\\tnetmask $ip6Mask' /etc/network/interfaces; $1 sed -i '\$a\\\tgateway $ip6Gate' /etc/network/interfaces; $1 sed -i '\$a\\\tdns-nameservers $ip6DNS' /etc/network/interfaces; $1 sed -i '\$alabel 2002::/16' /etc/gai.conf; $1 sed -i '\$alabel 2001:0::/32' /etc/gai.conf;"
|
|
|
- ReplaceActualIpPrefix="$1 sed -ri \"s/address $ipAddr\/$ipPrefix/address $ipAddr\/$actualIp4Prefix/g\" /etc/network/interfaces; $1 sed -ri \"s/netmask $ip6Mask/netmask $actualIp6Prefix/g\" /etc/network/interfaces;"
|
|
|
- fi
|
|
|
- fi
|
|
|
- writeMultipleIpv6Addresses "$i6AddrNum" "$1" '/etc/network/interfaces'
|
|
|
- elif [[ "$IPStackType" == "IPv6Stack" ]]; then
|
|
|
-
|
|
|
- SupportIPv6orIPv4="$1 sed -i '\$alabel 2002::/16' /etc/gai.conf; $1 sed -i '\$alabel 2001:0::/32' /etc/gai.conf;"
|
|
|
- ReplaceActualIpPrefix="$1 sed -ri \"s/address $ip6Addr\/$ip6Mask/address $ip6Addr\/$actualIp6Prefix/g\" /etc/network/interfaces;"
|
|
|
- writeMultipleIpv6Addresses "$i6AddrNum" "$1" '/etc/network/interfaces'
|
|
|
- fi
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
- [[ "$linux_relese" == 'kali' ]] && {
|
|
|
- ChangeBashrc=""
|
|
|
-
|
|
|
- EnableSSH="$1 update-rc.d ssh enable; $1 /etc/init.d/ssh restart;"
|
|
|
-
|
|
|
- ReviseMOTD="$1 sed -ri 's/Debian/Kali/g' /etc/update-motd.d/00-header;"
|
|
|
- SupportZSH="$1 apt install zsh -y; $1 chsh -s /bin/zsh; $1 rm -rf /root/.bashrc.original;"
|
|
|
- }
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
- EnableFail2ban="$1 sed -i '/\[Definition\]/a allowipv6 = auto' /etc/fail2ban/fail2ban.conf; $1 sed -ri 's/backend.*/backend = systemd/g' /etc/fail2ban/jail.conf; $1 update-rc.d fail2ban enable; $1 /etc/init.d/fail2ban restart;"
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
- CreateSoftLinkToGrub2FromGrub1="$1 ln -s /boot/grub/ /boot/grub2;"
|
|
|
- export DebianModifiedProcession="${AptUpdating} ${InstallComponents} ${DisableCertExpiredCheck} ${ChangeBashrc} ${VimSupportCopy} ${VimIndentEolStart} ${DnsChangePermanently} ${ModifyMOTD} ${ChangeSecurityMirror} ${AutoPlugInterfaces} ${BurnIrregularIpv4Gate} ${SupportIPv6orIPv4} ${ReplaceActualIpPrefix} ${EnableSSH} ${ReviseMOTD} ${SupportZSH} ${EnableFail2ban} ${CreateSoftLinkToGrub2FromGrub1}"
|
|
|
- fi
|
|
|
-}
|
|
|
-
|
|
|
-function DebianPreseedProcess() {
|
|
|
- if [[ "$setAutoConfig" == "1" ]]; then
|
|
|
- ddWindowsEarlyCommandsOfAnna='anna-install libfuse2-udeb fuse-udeb ntfs-3g-udeb libcrypto3-udeb libpcre2-8-0-udeb libssl3-udeb libuuid1-udeb zlib1g-udeb wget-udeb'
|
|
|
- tmpDdWinsEarlyCommandsOfAnna="$ddWindowsEarlyCommandsOfAnna"
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
- if [[ "$disksNum" -gt "1" && "$setDisk" == "all" ]]; then
|
|
|
- [[ "$partitionTable" == "gpt" ]] && FormatDisk=`echo -e "d-i partman-auto/disk string $AllDisks\nd-i partman-auto/method string regular\nd-i partman-auto/init_automatically_partition select Guided - use entire disk\nd-i partman-auto/choose_recipe select All files in one partition (recommended for new users)\nd-i partman-basicfilesystems/choose_label string gpt\nd-i partman-basicfilesystems/default_label string gpt\nd-i partman-partitioning/choose_label string gpt\nd-i partman-partitioning/default_label string gpt\nd-i partman/choose_label string gpt\nd-i partman/default_label string gpt"` || FormatDisk=`echo -e "d-i partman-auto/disk string $AllDisks\nd-i partman-auto/method string regular\nd-i partman-auto/init_automatically_partition select Guided - use entire disk\nd-i partman-auto/choose_recipe select All files in one partition (recommended for new users)"`
|
|
|
- PartmanEarlyCommand='debconf-set partman-auto/disk '${AllDisks}';'
|
|
|
- else
|
|
|
- [[ "$partitionTable" == "gpt" ]] && FormatDisk=`echo -e "d-i partman-auto/disk string $IncDisk\nd-i partman-auto/method string regular\nd-i partman-auto/init_automatically_partition select Guided - use entire disk\nd-i partman-auto/choose_recipe select All files in one partition (recommended for new users)\nd-i partman-basicfilesystems/choose_label string gpt\nd-i partman-basicfilesystems/default_label string gpt\nd-i partman-partitioning/choose_label string gpt\nd-i partman-partitioning/default_label string gpt\nd-i partman/choose_label string gpt\nd-i partman/default_label string gpt"` || FormatDisk=`echo -e "d-i partman-auto/disk string $IncDisk\nd-i partman-auto/method string regular\nd-i partman-auto/init_automatically_partition select Guided - use entire disk\nd-i partman-auto/choose_recipe select All files in one partition (recommended for new users)"`
|
|
|
- PartmanEarlyCommand='debconf-set partman-auto/disk "$(list-devices disk | grep '${IncDisk}' | head -n 1)";'
|
|
|
- fi
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
- setRaidRecipe "$setRaid" "$disksNum" "$AllDisks" "$linux_relese"
|
|
|
-
|
|
|
- if [[ "$BiStackPreferIpv6Status" == "1" ]]; then
|
|
|
- if [[ "$linux_relese" == 'debian' && "$DebianDistNum" -le "11" ]] || [[ "$ddMode" == '1' ]]; then
|
|
|
- BiStackPreferIpv6Status=""
|
|
|
- BurnIrregularIpv4Status='1'
|
|
|
- fi
|
|
|
- fi
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
- [[ Network4Config == "isDHCP" || "$interfaceSelect" != "auto" ]] && BurnIrregularIpv4Status='0'
|
|
|
- [[ "$BurnIrregularIpv4Status" == "1" ]] && {
|
|
|
- actualIp4Gate="$GATE"
|
|
|
- GATE="none"
|
|
|
- if [[ "$IPStackType" == "IPv4Stack" ]]; then
|
|
|
- writeDnsByForce='echo '\''nameserver '$ipDNS1''\'' > /etc/resolv.conf && echo '\''nameserver '$ipDNS2''\'' >> /etc/resolv.conf'
|
|
|
- elif [[ "$IPStackType" == "BiStack" ]]; then
|
|
|
- writeDnsByForce='echo '\''nameserver '$ipDNS1''\'' > /etc/resolv.conf && echo '\''nameserver '$ip6DNS1''\'' >> /etc/resolv.conf && echo '\''nameserver '$ipDNS2''\'' >> /etc/resolv.conf && echo '\''nameserver '$ip6DNS2''\'' >> /etc/resolv.conf'
|
|
|
- fi
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
- [[ "$ddMode" == '0' ]] && tmpDdWinsEarlyCommandsOfAnna=''
|
|
|
- BurnIrregularIpv4ByForce=`echo -e 'd-i preseed/early_command string ip link set '$interface4' up; ip addr add '$IPv4'/'$ipPrefix' dev '$interface4'; echo "(ip route add '$actualIp4Gate' dev '$interface4' || true) && (ip route add default via '$actualIp4Gate' dev '$interface4' onlink || true) && '$writeDnsByForce'" > /bin/ethdetect; echo "(test -x /bin/ethdetect && /bin/ethdetect) || true" >> /usr/share/debconf/confmodule; '$tmpDdWinsEarlyCommandsOfAnna''`
|
|
|
- }
|
|
|
-
|
|
|
- if [[ "$IPStackType" == "IPv4Stack" ]] || [[ "$IPStackType" == "BiStack" && "$BiStackPreferIpv6Status" != "1" ]]; then
|
|
|
- [[ "$Network4Config" == "isStatic" ]] && NetConfigManually=`echo -e "d-i netcfg/disable_autoconfig boolean true\nd-i netcfg/dhcp_failed note\nd-i netcfg/dhcp_options select Configure network manually\nd-i netcfg/get_ipaddress string $IPv4\nd-i netcfg/get_netmask string $MASK\nd-i netcfg/get_gateway string $GATE\nd-i netcfg/get_nameservers string $ipDNS\nd-i netcfg/no_default_route boolean true\nd-i netcfg/confirm_static boolean true"` || NetConfigManually=""
|
|
|
-
|
|
|
-
|
|
|
- elif [[ "$IPStackType" == "IPv6Stack" ]] || [[ "$IPStackType" == "BiStack" && "$BiStackPreferIpv6Status" == "1" ]]; then
|
|
|
- [[ "$Network6Config" == "isStatic" ]] && NetConfigManually=`echo -e "d-i netcfg/disable_autoconfig boolean true\nd-i netcfg/dhcp_failed note\nd-i netcfg/dhcp_options select Configure network manually\nd-i netcfg/get_ipaddress string $ip6Addr\nd-i netcfg/get_netmask string $ip6Subnet\nd-i netcfg/get_gateway string $ip6Gate\nd-i netcfg/get_nameservers string $ip6DNS\nd-i netcfg/no_default_route boolean true\nd-i netcfg/confirm_static boolean true"` || NetConfigManually=""
|
|
|
- fi
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
- DebianModifiedPreseed "in-target"
|
|
|
- cat >/tmp/boot/preseed.cfg<<EOF
|
|
|
-
|
|
|
-d-i auto-install/enable boolean true
|
|
|
-d-i debconf/priority select critical
|
|
|
-
|
|
|
-
|
|
|
-d-i debian-installer/locale string en_US.UTF-8
|
|
|
-d-i debian-installer/country string US
|
|
|
-d-i debian-installer/language string en
|
|
|
-d-i debian-installer/allow_unauthenticated boolean true
|
|
|
+if [[ "$linux_relese" == 'debian' ]] || [[ "$linux_relese" == 'ubuntu' ]]; then
|
|
|
+cat >/tmp/boot/preseed.cfg<<EOF
|
|
|
+d-i debian-installer/locale string en_US
|
|
|
d-i console-setup/layoutcode string us
|
|
|
-d-i keyboard-configuration/xkb-keymap string us
|
|
|
-
|
|
|
-
|
|
|
-d-i lowmem/low boolean true
|
|
|
|
|
|
-
|
|
|
-d-i apt-setup/services-select multiselect
|
|
|
-
|
|
|
-
|
|
|
-d-i apt-setup/enable-source-repositories boolean false
|
|
|
+d-i keyboard-configuration/xkb-keymap string us
|
|
|
|
|
|
-
|
|
|
-d-i apt-setup/non-free boolean true
|
|
|
-d-i apt-setup/contrib boolean true
|
|
|
+d-i netcfg/choose_interface select $interfaceSelect
|
|
|
|
|
|
-
|
|
|
-d-i apt-setup/cdrom/set-first boolean false
|
|
|
-d-i apt-setup/cdrom/set-next boolean false
|
|
|
-d-i apt-setup/cdrom/set-failed boolean false
|
|
|
+d-i netcfg/disable_autoconfig boolean true
|
|
|
+d-i netcfg/dhcp_failed note
|
|
|
+d-i netcfg/dhcp_options select Configure network manually
|
|
|
+d-i netcfg/get_ipaddress string $IPv4
|
|
|
+d-i netcfg/get_netmask string $MASK
|
|
|
+d-i netcfg/get_gateway string $GATE
|
|
|
+d-i netcfg/get_nameservers string $ipDNS
|
|
|
+d-i netcfg/no_default_route boolean true
|
|
|
+d-i netcfg/confirm_static boolean true
|
|
|
|
|
|
-
|
|
|
-d-i netcfg/choose_interface select $interfaceSelect
|
|
|
-${NetConfigManually}
|
|
|
d-i hw-detect/load_firmware boolean true
|
|
|
-${BurnIrregularIpv4ByForce}
|
|
|
|
|
|
-
|
|
|
d-i mirror/country string manual
|
|
|
d-i mirror/http/hostname string $MirrorHost
|
|
|
d-i mirror/http/directory string $MirrorFolder
|
|
|
d-i mirror/http/proxy string
|
|
|
|
|
|
-
|
|
|
d-i passwd/root-login boolean ture
|
|
|
d-i passwd/make-user boolean false
|
|
|
d-i passwd/root-password-crypted password $myPASSWORD
|
|
|
d-i user-setup/allow-password-weak boolean true
|
|
|
d-i user-setup/encrypt-home boolean false
|
|
|
|
|
|
-
|
|
|
d-i clock-setup/utc boolean true
|
|
|
-d-i time/zone string ${TimeZone}
|
|
|
-d-i clock-setup/ntp boolean true
|
|
|
-d-i clock-setup/ntp-server string ntp.nict.jp
|
|
|
-
|
|
|
-
|
|
|
-d-i preseed/early_command string ${ddWindowsEarlyCommandsOfAnna}
|
|
|
-d-i partman/early_command string \
|
|
|
-lvremove --select all -ff -y; \
|
|
|
-vgremove --select all -ff -y; \
|
|
|
-pvremove /dev/* -ff -y; \
|
|
|
-[[ -n "\$(blkid -t TYPE='vfat' -o device)" ]] && umount "\$(blkid -t TYPE='vfat' -o device)"; \
|
|
|
-${PartmanEarlyCommand} \
|
|
|
-wget -qO- '$DDURL' | $DEC_CMD | /bin/dd of=\$(list-devices disk | grep ${IncDisk} | head -n 1); \
|
|
|
-/bin/ntfs-3g \$(list-devices partition | grep ${IncDisk} | head -n 1) /mnt; \
|
|
|
+d-i time/zone string US/Eastern
|
|
|
+d-i clock-setup/ntp boolean false
|
|
|
+
|
|
|
+d-i preseed/early_command string anna-install libfuse2-udeb fuse-udeb ntfs-3g-udeb libcrypto1.1-udeb libpcre2-8-0-udeb libssl1.1-udeb libuuid1-udeb zlib1g-udeb wget-udeb
|
|
|
+d-i partman/early_command string [[ -n "\$(blkid -t TYPE='vfat' -o device)" ]] && umount "\$(blkid -t TYPE='vfat' -o device)"; \
|
|
|
+debconf-set partman-auto/disk "\$(list-devices disk |head -n1)"; \
|
|
|
+wget -qO- '$DDURL' |gunzip -dc |/bin/dd of=\$(list-devices disk |head -n1); \
|
|
|
+mount.ntfs-3g \$(list-devices partition |head -n1) /mnt; \
|
|
|
cd '/mnt/ProgramData/Microsoft/Windows/Start Menu/Programs'; \
|
|
|
cd Start* || cd start*; \
|
|
|
cp -f '/net.bat' './net.bat'; \
|
|
|
/sbin/reboot; \
|
|
|
umount /media || true; \
|
|
|
|
|
|
-
|
|
|
+d-i partman-partitioning/confirm_write_new_label boolean true
|
|
|
+d-i partman/mount_style select uuid
|
|
|
+d-i partman/choose_partition select finish
|
|
|
+d-i partman-auto/method string regular
|
|
|
+d-i partman-auto/init_automatically_partition select Guided - use entire disk
|
|
|
+d-i partman-auto/choose_recipe select All files in one partition (recommended for new users)
|
|
|
+d-i partman-md/device_remove_md boolean true
|
|
|
d-i partman-lvm/device_remove_lvm boolean true
|
|
|
-d-i partman-lvm/device_remove_lvm_span boolean true
|
|
|
d-i partman-lvm/confirm boolean true
|
|
|
d-i partman-lvm/confirm_nooverwrite boolean true
|
|
|
-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
|
|
|
-d-i partman/default_filesystem string ext4
|
|
|
-d-i partman/mount_style select uuid
|
|
|
-d-i partman-md/device_remove_md boolean true
|
|
|
-${FormatDisk}
|
|
|
|
|
|
-
|
|
|
-tasksel tasksel/first multiselect minimal
|
|
|
-d-i pkgsel/include string openssh-server
|
|
|
+d-i debian-installer/allow_unauthenticated boolean true
|
|
|
|
|
|
-
|
|
|
+tasksel tasksel/first multiselect minimal
|
|
|
d-i pkgsel/update-policy select none
|
|
|
+d-i pkgsel/include string openssh-server
|
|
|
d-i pkgsel/upgrade select none
|
|
|
|
|
|
-
|
|
|
popularity-contest popularity-contest/participate boolean false
|
|
|
|
|
|
-
|
|
|
d-i grub-installer/only_debian boolean true
|
|
|
-d-i grub-installer/with_other_os boolean true
|
|
|
-d-i grub-installer/bootdev string ${IncDisk}
|
|
|
+d-i grub-installer/bootdev string $IncDisk
|
|
|
d-i grub-installer/force-efi-extra-removable boolean true
|
|
|
-d-i debian-installer/add-kernel-opts string net.ifnames=0 biosdevname=0 ipv6.disable=1
|
|
|
-
|
|
|
-
|
|
|
d-i finish-install/reboot_in_progress note
|
|
|
d-i debian-installer/exit/reboot boolean true
|
|
|
-
|
|
|
-
|
|
|
d-i preseed/late_command string \
|
|
|
sed -ri 's/^#?Port.*/Port ${sshPORT}/g' /target/etc/ssh/sshd_config; \
|
|
|
sed -ri 's/^#?PermitRootLogin.*/PermitRootLogin yes/g' /target/etc/ssh/sshd_config; \
|
|
|
sed -ri 's/^#?PasswordAuthentication.*/PasswordAuthentication yes/g' /target/etc/ssh/sshd_config; \
|
|
|
echo '@reboot root cat /etc/run.sh 2>/dev/null |base64 -d >/tmp/run.sh; rm -rf /etc/run.sh; sed -i /^@reboot/d /etc/crontab; bash /tmp/run.sh' >>/target/etc/crontab; \
|
|
|
echo '' >>/target/etc/crontab; \
|
|
|
-echo '${setCMD}' >/target/etc/run.sh; \
|
|
|
-${DebianModifiedProcession}
|
|
|
+echo '${setCMD}' >/target/etc/run.sh;
|
|
|
EOF
|
|
|
- fi
|
|
|
-}
|
|
|
-
|
|
|
-alpineInstallOrDdAdditionalFiles() {
|
|
|
- AlpineInitFile="$1"
|
|
|
- AlpineDnsFile="$2"
|
|
|
- AlpineMotd="$3"
|
|
|
- AlpineInitFileName="alpineConf.start"
|
|
|
- if [[ "$targetRelese" == 'Ubuntu' ]]; then
|
|
|
- if [[ "$ubuntuVER" == "amd64" ]]; then
|
|
|
- targetLinuxMirror="$4"
|
|
|
- elif [[ "$ubuntuVER" == "arm64" ]]; then
|
|
|
- targetLinuxMirror="$5"
|
|
|
- fi
|
|
|
- AlpineInitFile="$6"
|
|
|
- AlpineInitFileName="ubuntuConf.start"
|
|
|
- [[ "$setIPv6" == "0" ]] && setIPv6="0" || setIPv6="1"
|
|
|
- elif [[ "$targetRelese" == 'Windows' ]]; then
|
|
|
- AlpineInitFile="$7"
|
|
|
- AlpineInitFileName="windowsConf.start"
|
|
|
- windowsStaticConfigCmd="$8"
|
|
|
- fi
|
|
|
-}
|
|
|
-
|
|
|
-
|
|
|
-verifyUrlValidationOfDdImages() {
|
|
|
- echo "$1" | grep -q '^http://\|^ftp://\|^https://'
|
|
|
- [[ $? -ne '0' ]] && echo -ne "\n[${red}Error${plain}] Please input a vaild URL, only support http://, ftp:// and https:// ! \n" && exit 1
|
|
|
- tmpURLCheck=$(echo $(curl -s -I -X GET $1) | grep -wi "http/[0-9]*" | awk '{print $2}')
|
|
|
- [[ -z "$tmpURLCheck" || ! "$tmpURLCheck" =~ ^[0-9]+$ ]] && {
|
|
|
- echo -ne "\n[${red}Error${plain}] The mirror of DD images is temporarily unavailable!\n"
|
|
|
- exit 1
|
|
|
- }
|
|
|
- DDURL="$1"
|
|
|
-
|
|
|
- if [[ "$setFileType" == "gz" ]]; then
|
|
|
- DEC_CMD="gunzip -dc"
|
|
|
- [[ $(echo "$DDURL" | grep -o ...$) == ".xz" ]] && DEC_CMD="xzcat"
|
|
|
- elif [[ "$setFileType" == "xz" ]]; then
|
|
|
- DEC_CMD="xzcat"
|
|
|
- [[ $(echo "$DDURL" | grep -o ...$) == ".gz" ]] && DEC_CMD="gunzip -dc"
|
|
|
- else
|
|
|
- [[ $(echo "$DDURL" | grep -o ...$) == ".xz" ]] && DEC_CMD="xzcat"
|
|
|
- [[ $(echo "$DDURL" | grep -o ...$) == ".gz" ]] && DEC_CMD="gunzip -dc"
|
|
|
- fi
|
|
|
-}
|
|
|
-
|
|
|
-checkSys
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-checkIpv4OrIpv6 "$ipAddr" "$ip6Addr" "208.67.220.220" "9.9.9.9" "64.6.65.6" "101.102.103.104" "2620:0:ccc::2" "2620:fe::9" "2620:74:1b::1:1" "2001:de4::101"
|
|
|
-
|
|
|
-
|
|
|
-checkCN "$IPStackType" "www.youtube.com" "www.instagram.com" "www.wikipedia.org" "bbc.com"
|
|
|
-
|
|
|
-checkEfi "/sys/firmware/efi/efivars/" "/sys/firmware/efi/vars/" "/sys/firmware/efi/runtime-map/" "/sys/firmware/efi/mok-variables/"
|
|
|
-
|
|
|
-checkVirt
|
|
|
|
|
|
-if [[ "$sshPORT" ]];then
|
|
|
- if [[ ! ${sshPORT} -ge "1" ]] || [[ ! ${sshPORT} -le "65535" ]] || [[ `grep '^[[:digit:]]*$' <<< '${sshPORT}'` ]]; then
|
|
|
- sshPORT='22'
|
|
|
- fi
|
|
|
-else
|
|
|
- sshPORT=$(grep -Ei "^port|^#port" /etc/ssh/sshd_config | head -n 1 | awk -F' ' '{print $2}')
|
|
|
- [[ "$sshPORT" == "" ]] && sshPORT=$(netstat -anp | grep -i 'sshd: root' | grep -iw 'tcp' | awk '{print $4}' | head -n 1 | cut -d':' -f'2')
|
|
|
- [[ "$sshPORT" == "" ]] && sshPORT=$(netstat -anp | grep -i 'sshd: root' | grep -iw 'tcp6' | awk '{print $4}' | head -n 1 | awk -F':' '{print $NF}')
|
|
|
- if [[ "$sshPORT" == "" ]] || [[ ! ${sshPORT} -ge "1" ]] || [[ ! ${sshPORT} -le "65535" ]] || [[ `grep '^[[:digit:]]*$' <<< '${sshPORT}'` ]]; then
|
|
|
- sshPORT='22'
|
|
|
- fi
|
|
|
-fi
|
|
|
-
|
|
|
-
|
|
|
-[[ -f /etc/selinux/config ]] && {
|
|
|
- SELinuxStatus=$(sestatus -v | grep "SELinux status:" | grep enabled)
|
|
|
- [[ "$SELinuxStatus" != "" ]] && echo -ne "\n${aoiBlue}# Disabled SELinux${plain}" && setenforce 0
|
|
|
-}
|
|
|
-
|
|
|
-[[ ! -d "/tmp/" ]] && mkdir /tmp
|
|
|
-
|
|
|
-if [[ "$loaderMode" == "0" ]]; then
|
|
|
- checkGrub "/boot/grub/" "/boot/grub2/" "/etc/" "grub.cfg" "grub.conf" "/boot/efi/EFI/"
|
|
|
- if [[ -z "$GRUBTYPE" ]]; then
|
|
|
- echo -ne "\n[${red}Error${plain}] Not Found grub.\n"
|
|
|
- exit 1
|
|
|
- fi
|
|
|
-fi
|
|
|
-
|
|
|
-[[ "$ddMode" == '1' ]] && {
|
|
|
- if [[ "$targetRelese" == 'Ubuntu' ]] || [[ "$targetRelese" == 'Windows' ]]; then
|
|
|
- Relese='AlpineLinux'
|
|
|
- tmpDIST='edge'
|
|
|
- if [[ "$targetRelese" == 'Windows' ]]; then
|
|
|
- [[ "$VER" == "aarch64" || "$VER" == "arm64" ]] && {
|
|
|
- echo -ne "\n[${red}Error${plain}] ${targetRelese} doesn't support ${VER} architecture.\n"
|
|
|
- exit 1
|
|
|
- }
|
|
|
- fi
|
|
|
- else
|
|
|
- Relese='Debian'
|
|
|
- tmpDIST='12'
|
|
|
- fi
|
|
|
-}
|
|
|
-
|
|
|
-[[ -n "$Relese" ]] || Relese='Debian'
|
|
|
-linux_relese=$(echo "$Relese" |sed 's/\ //g' |sed -r 's/(.*)/\L\1/')
|
|
|
-
|
|
|
-clear && echo -ne "\n${aoiBlue}# Check Dependence${plain}\n\n"
|
|
|
-
|
|
|
-dependence awk,basename,cat,cpio,curl,cut,dig,dirname,file,find,grep,gzip,iconv,ip,lsblk,openssl,sed,wget,xz;
|
|
|
-
|
|
|
-ipDNS1=$(echo $ipDNS | cut -d ' ' -f 1)
|
|
|
-ipDNS2=$(echo $ipDNS | cut -d ' ' -f 2)
|
|
|
-ip6DNS1=$(echo $ip6DNS | cut -d ' ' -f 1)
|
|
|
-ip6DNS2=$(echo $ip6DNS | cut -d ' ' -f 2)
|
|
|
-ipDNS=$(checkDNS "$ipDNS")
|
|
|
-ip6DNS=$(checkDNS "$ip6DNS")
|
|
|
-
|
|
|
-if [[ -n "$ipAddr" && -n "$ipMask" && -n "$ipGate" ]] && [[ -z "$ip6Addr" && -z "$ip6Mask" && -z "$ip6Gate" ]]; then
|
|
|
- setNet='1'
|
|
|
- checkDHCP "$CurrentOS" "$CurrentOSVer" "$IPStackType"
|
|
|
- Network4Config="isStatic"
|
|
|
- acceptIPv4AndIPv6SubnetValue "$ipMask" ""
|
|
|
- [[ "$IPStackType" != "IPv4Stack" ]] && getIPv6Address
|
|
|
-elif [[ -n "$ipAddr" && -n "$ipMask" && -n "$ipGate" ]] && [[ -n "$ip6Addr" && -n "$ip6Mask" && -n "$ip6Gate" ]]; then
|
|
|
- setNet='1'
|
|
|
- [[ -z "$interfaceSelect" ]] && getInterface "$CurrentOS"
|
|
|
- Network4Config="isStatic"
|
|
|
- Network6Config="isStatic"
|
|
|
- acceptIPv4AndIPv6SubnetValue "$ipMask" "$ip6Mask"
|
|
|
-elif [[ -z "$ipAddr" && -z "$ipMask" && -z "$ipGate" ]] && [[ -n "$ip6Addr" && -n "$ip6Mask" && -n "$ip6Gate" ]]; then
|
|
|
- setNet='1'
|
|
|
- checkDHCP "$CurrentOS" "$CurrentOSVer" "$IPStackType"
|
|
|
- Network6Config="isStatic"
|
|
|
- acceptIPv4AndIPv6SubnetValue "" "$ip6Mask"
|
|
|
- getIPv4Address
|
|
|
-fi
|
|
|
-
|
|
|
-if [[ "$setNet" == "0" ]]; then
|
|
|
- [[ -z "$tmpDHCP" ]] && checkDHCP "$CurrentOS" "$CurrentOSVer" "$IPStackType"
|
|
|
- getIPv4Address
|
|
|
- [[ "$IPStackType" != "IPv4Stack" ]] && getIPv6Address
|
|
|
- if [[ "$IPStackType" == "BiStack" && "$i6AddrNum" -ge "2" ]]; then
|
|
|
- Network4Config="isStatic"
|
|
|
- [[ "$BiStackPreferIpv6Status" == "1" ]] && {
|
|
|
- BiStackPreferIpv6Status=""
|
|
|
- BurnIrregularIpv4Status='1'
|
|
|
- }
|
|
|
- fi
|
|
|
-fi
|
|
|
-
|
|
|
-setDhcpOrStatic "$tmpDHCP"
|
|
|
-
|
|
|
-checkWarp "warp*.conf" "wgcf*.conf" "wg[0-9].conf" "warp*" "wgcf*" "wg[0-9]" "privatekey" "publickey"
|
|
|
-
|
|
|
-IPv4="$ipAddr"; MASK="$ipMask"; GATE="$ipGate";
|
|
|
-if [[ -z "$IPv4" && -z "$MASK" && -z "$GATE" ]] && [[ -z "$ip6Addr" && -z "$ip6Mask" && -z "$ip6Gate" ]]; then
|
|
|
- echo -ne "\n[${red}Error${plain}] The network of your machine may not be available!\n"
|
|
|
- bash $0 error
|
|
|
- exit 1
|
|
|
+if [[ "$loaderMode" != "0" ]] && [[ "$setNet" == '0' ]]; then
|
|
|
+ sed -i '/netcfg\/disable_autoconfig/d' /tmp/boot/preseed.cfg
|
|
|
+ sed -i '/netcfg\/dhcp_options/d' /tmp/boot/preseed.cfg
|
|
|
+ sed -i '/netcfg\/get_.*/d' /tmp/boot/preseed.cfg
|
|
|
+ sed -i '/netcfg\/confirm_static/d' /tmp/boot/preseed.cfg
|
|
|
fi
|
|
|
|
|
|
-echo -ne "\n${aoiBlue}# Network Details${plain}\n"
|
|
|
-[[ -n "$interfaceSelect" ]] && echo -ne "\n[${yellow}Adapter Name${plain}] $interfaceSelect" || echo -ne "\n[${yellow}Adapter Name${plain}] $interface"
|
|
|
-[[ -n "$NetCfgWhole" ]] && echo -ne "\n[${yellow}Network File${plain}] $NetCfgWhole" || echo -ne "\n[${yellow}Network File${plain}] N/A"
|
|
|
-echo -ne "\n[${yellow}Server Stack${plain}] $IPStackType\n"
|
|
|
-[[ "$IPStackType" != "IPv6Stack" ]] && echo -ne "\n[${yellow}IPv4 Method${plain}] $Network4Config\n" || echo -ne "\n[${yellow}IPv4 Method${plain}] N/A\n"
|
|
|
-[[ "$IPv4" && "$IPStackType" != "IPv6Stack" ]] && echo -e "[${yellow}IPv4 Address${plain}] ""$IPv4" || echo -e "[${yellow}IPv4 Address${plain}] ""N/A"
|
|
|
-[[ "$IPv4" && "$IPStackType" != "IPv6Stack" ]] && echo -e "[${yellow}IPv4 Subnet${plain}] ""$actualIp4Subnet" || echo -e "[${yellow}IPv4 Subnet${plain}] ""N/A"
|
|
|
-[[ "$IPv4" && "$IPStackType" != "IPv6Stack" ]] && echo -e "[${yellow}IPv4 Gateway${plain}] ""$GATE" || echo -e "[${yellow}IPv4 Gateway${plain}] ""N/A"
|
|
|
-[[ "$IPv4" && "$IPStackType" != "IPv6Stack" ]] && echo -e "[${yellow}IPv4 DNS${plain}] ""$ipDNS" || echo -e "[${yellow}IPv4 DNS${plain}] ""N/A"
|
|
|
-[[ "$IPStackType" != "IPv4Stack" ]] && echo -ne "\n[${yellow}IPv6 Method${plain}] $Network6Config\n" || echo -ne "\n[${yellow}IPv6 Method${plain}] N/A\n"
|
|
|
-[[ "$ip6Addr" && "$IPStackType" != "IPv4Stack" ]] && echo -e "[${yellow}IPv6 Address${plain}] ""$ip6Addr" || echo -e "[${yellow}IPv6 Address${plain}] ""N/A"
|
|
|
-[[ "$ip6Addr" && "$IPStackType" != "IPv4Stack" ]] && echo -e "[${yellow}IPv6 Subnet${plain}] ""$actualIp6Prefix" || echo -e "[${yellow}IPv6 Subnet${plain}] ""N/A"
|
|
|
-[[ "$ip6Addr" && "$IPStackType" != "IPv4Stack" ]] && echo -e "[${yellow}IPv6 Gateway${plain}] ""$ip6Gate" || echo -e "[${yellow}IPv6 Gateway${plain}] ""N/A"
|
|
|
-[[ "$ip6Addr" && "$IPStackType" != "IPv4Stack" ]] && echo -e "[${yellow}IPv6 DNS${plain}] ""$ip6DNS" || echo -e "[${yellow}IPv6 DNS${plain}] ""N/A"
|
|
|
-
|
|
|
-getUserTimeZone "/root/timezonelists" "https://api.ip.sb/geoip/" "http://ifconfig.co/json?ip=" "http://ip-api.com/json/" "https://ipapi.co/" "YjNhNjAxNjY5YTFiNDI2MmFmOGYxYjJjZDk3ZjNiN2YK" "MmUxMjBhYmM0Y2Q4NDM1ZDhhMmQ5YzQzYzk4ZTZiZTEK" "NjBiMThjZWJlMWU1NGQ5NDg2YWY0MTgyMWM0ZTZiZDgK"
|
|
|
-[[ -z "$TimeZone" ]] && TimeZone="Asia/Tokyo"
|
|
|
-echo -ne "\n${aoiBlue}# User Timezone${plain}\n\n"
|
|
|
-echo "$TimeZone"
|
|
|
-
|
|
|
-[[ -z "$tmpWORD" || "$linux_relese" == 'alpinelinux' || "$targetRelese" == 'Ubuntu' ]] && tmpWORD='LeitboGi0ro'
|
|
|
-myPASSWORD=$(openssl passwd -1 ''$tmpWORD'')
|
|
|
-[[ -z "$myPASSWORD" ]] && myPASSWORD='$1$OCy2O5bt$m2N6XMgFUwCn/2PPP114J/'
|
|
|
-echo -ne "\n${aoiBlue}# SSH or RDP Port, Username and Password${plain}\n\n"
|
|
|
-if [[ "$targetRelese" == 'Windows' && "$tmpURL" == "" || "$tmpURL" =~ "dl.lamp.sh" ]]; then
|
|
|
- echo "3389"
|
|
|
- echo "Administrator"
|
|
|
- echo "Teddysun.com"
|
|
|
-elif [[ -z "$targetRelese" && "$ddMode" == '1' ]]; then
|
|
|
- echo -e "N/A\nN/A\nN/A"
|
|
|
+if [[ "$linux_relese" == 'debian' ]]; then
|
|
|
+ sed -i '/user-setup\/allow-password-weak/d' /tmp/boot/preseed.cfg
|
|
|
+ sed -i '/user-setup\/encrypt-home/d' /tmp/boot/preseed.cfg
|
|
|
+ sed -i '/pkgsel\/update-policy/d' /tmp/boot/preseed.cfg
|
|
|
+ sed -i 's/umount\ \/media.*true\;\ //g' /tmp/boot/preseed.cfg
|
|
|
+ [[ -f '/tmp/firmware.cpio.gz' ]] && gzip -d < /tmp/firmware.cpio.gz | cpio --extract --verbose --make-directories --no-absolute-filenames >>/dev/null 2>&1
|
|
|
else
|
|
|
- echo "$sshPORT"
|
|
|
- echo "root"
|
|
|
- echo "$tmpWORD"
|
|
|
+ sed -i '/d-i\ grub-installer\/force-efi-extra-removable/d' /tmp/boot/preseed.cfg
|
|
|
fi
|
|
|
|
|
|
-setDisk=$(echo "$setDisk" | sed 's/[A-Z]/\l&/g')
|
|
|
-getDisk "$setDisk"
|
|
|
-echo -ne "\n${aoiBlue}# Installing Disks${plain}\n\n"
|
|
|
-[[ "$setDisk" == "all" || -n "$setRaid" ]] && echo "$AllDisks" || echo "$IncDisk"
|
|
|
-
|
|
|
-echo -ne "\n${aoiBlue}# Motherboard Firmware${plain}\n\n"
|
|
|
-[[ "$EfiSupport" == "enabled" ]] && echo "UEFI" || echo "BIOS"
|
|
|
-
|
|
|
-
|
|
|
-ArchName=`uname -m`
|
|
|
-[[ -z "$ArchName" ]] && ArchName=$(echo `hostnamectl status | grep "Architecture" | cut -d':' -f 2`)
|
|
|
-case $ArchName in arm64) VER="arm64";; aarch64) VER="aarch64";; x86|i386|i686) VER="i386";; x86_64) VER="x86_64";; x86-64) VER="x86-64";; amd64) VER="amd64";; *) VER="";; esac
|
|
|
-
|
|
|
-if [[ "$linux_relese" == 'debian' ]] || [[ "$linux_relese" == 'ubuntu' ]] || [[ "$linux_relese" == 'kali' ]]; then
|
|
|
-
|
|
|
-
|
|
|
- if [[ "$VER" == "x86_64" ]] || [[ "$VER" == "x86-64" ]]; then
|
|
|
- VER="amd64"
|
|
|
- elif [[ "$VER" == "aarch64" ]]; then
|
|
|
- VER="arm64"
|
|
|
- fi
|
|
|
-elif [[ "$linux_relese" == 'alpinelinux' ]] || [[ "$linux_relese" == 'centos' ]] || [[ "$linux_relese" == 'rockylinux' ]] || [[ "$linux_relese" == 'almalinux' ]] || [[ "$linux_relese" == 'fedora' ]]; then
|
|
|
- if [[ "$VER" == "amd64" ]] || [[ "$VER" == "x86-64" ]]; then
|
|
|
- VER="x86_64"
|
|
|
- elif [[ "$VER" == "arm64" ]]; then
|
|
|
- VER="aarch64"
|
|
|
- fi
|
|
|
-fi
|
|
|
-
|
|
|
-
|
|
|
-tmpVER="$(echo "$tmpVER" |sed -r 's/(.*)/\L\1/')"
|
|
|
-if [[ -n "$tmpVER" ]]; then
|
|
|
- case "$tmpVER" in
|
|
|
- i386|i686|x86|32)
|
|
|
- VER="i386"
|
|
|
- ;;
|
|
|
- amd64|x86_64|x64|64)
|
|
|
- [[ "$linux_relese" == 'alpinelinux' ]] || [[ "$linux_relese" == 'centos' ]] || [[ "$linux_relese" == 'rockylinux' ]] || [[ "$linux_relese" == 'almalinux' ]] || [[ "$linux_relese" == 'fedora' ]] && VER='x86_64' || VER='amd64'
|
|
|
- ;;
|
|
|
- aarch64|arm64|arm)
|
|
|
- [[ "$linux_relese" == 'alpinelinux' ]] || [[ "$linux_relese" == 'centos' ]] || [[ "$linux_relese" == 'rockylinux' ]] || [[ "$linux_relese" == 'almalinux' ]] || [[ "$linux_relese" == 'fedora' ]] && VER='aarch64' || VER='arm64'
|
|
|
- ;;
|
|
|
- *)
|
|
|
- VER=''
|
|
|
- ;;
|
|
|
- esac
|
|
|
-fi
|
|
|
-
|
|
|
-[[ ! -n "$VER" ]] && {
|
|
|
- echo -ne "\n[${red}Error${plain}] Unknown architecture.\n"
|
|
|
- bash $0 error
|
|
|
- exit 1
|
|
|
-}
|
|
|
-
|
|
|
-[[ -z "$tmpDIST" ]] && {
|
|
|
- [ "$Relese" == 'Debian' ] && tmpDIST='12'
|
|
|
- [ "$Relese" == 'Kali' ] && tmpDIST='rolling'
|
|
|
- [ "$Relese" == 'AlpineLinux' ] && tmpDIST='edge'
|
|
|
- [ "$Relese" == 'CentOS' ] && tmpDIST='9'
|
|
|
- [ "$Relese" == 'RockyLinux' ] && tmpDIST='9'
|
|
|
- [ "$Relese" == 'AlmaLinux' ] && tmpDIST='9'
|
|
|
- [ "$Relese" == 'Fedora' ] && tmpDIST='38'
|
|
|
-}
|
|
|
-[[ -z "$finalDIST" ]] && {
|
|
|
- [ "$targetRelese" == 'Ubuntu' ] && finalDIST='22.04'
|
|
|
- [ "$targetRelese" == 'Windows' ] && finalDIST='server 2022'
|
|
|
+[[ "$ddMode" == '1' ]] && {
|
|
|
+WinNoDHCP(){
|
|
|
+ echo -ne "for\0040\0057f\0040\0042tokens\00753\0052\0042\0040\0045\0045i\0040in\0040\0050\0047netsh\0040interface\0040show\0040interface\0040\0136\0174more\0040\00533\0040\0136\0174findstr\0040\0057I\0040\0057R\0040\0042鏈湴\0056\0052\0040浠ュお\0056\0052\0040Local\0056\0052\0040Ethernet\0042\0047\0051\0040do\0040\0050set\0040EthName\0075\0045\0045j\0051\r\nnetsh\0040\0055c\0040interface\0040ip\0040set\0040address\0040name\0075\0042\0045EthName\0045\0042\0040source\0075static\0040address\0075$IPv4\0040mask\0075$MASK\0040gateway\0075$GATE\r\nnetsh\0040\0055c\0040interface\0040ip\0040add\0040dnsservers\0040name\0075\0042\0045EthName\0045\0042\0040address\00758\00568\00568\00568\0040index\00751\0040validate\0075no\r\n\r\n" >>'/tmp/boot/net.tmp';
|
|
|
}
|
|
|
-
|
|
|
-if [[ -n "$tmpDIST" ]]; then
|
|
|
- if [[ "$Relese" == 'Debian' ]]; then
|
|
|
- SpikCheckDIST='0'
|
|
|
- DIST="$(echo "$tmpDIST" |sed -r 's/(.*)/\L\1/')"
|
|
|
- DebianDistNum="${DIST}"
|
|
|
- echo "$DIST" |grep -q '[0-9]'
|
|
|
- [[ $? -eq '0' ]] && {
|
|
|
- isDigital="$(echo "$DIST" |grep -o '[\.0-9]\{1,\}' |sed -n '1h;1!H;$g;s/\n//g;$p' |cut -d'.' -f1)";
|
|
|
- [[ -n $isDigital ]] && {
|
|
|
- [[ "$isDigital" == '7' ]] && DIST='wheezy'
|
|
|
- [[ "$isDigital" == '8' ]] && DIST='jessie'
|
|
|
- [[ "$isDigital" == '9' ]] && DIST='stretch'
|
|
|
- [[ "$isDigital" == '10' ]] && DIST='buster'
|
|
|
- [[ "$isDigital" == '11' ]] && DIST='bullseye'
|
|
|
- [[ "$isDigital" == '12' ]] && DIST='bookworm'
|
|
|
- [[ "$isDigital" == '13' ]] && DIST='trixie'
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
- }
|
|
|
- }
|
|
|
- LinuxMirror=$(selectMirror "$Relese" "$DIST" "$VER" "$tmpMirror")
|
|
|
- fi
|
|
|
- if [[ "$Relese" == 'Kali' ]]; then
|
|
|
- SpikCheckDIST='0'
|
|
|
- DIST="$(echo "$tmpDIST" |sed -r 's/(.*)/\L\1/')"
|
|
|
- [[ ! "$DIST" =~ "kali-" ]] && DIST="kali-""$DIST"
|
|
|
-
|
|
|
- LinuxMirror=$(selectMirror "$Relese" "$DIST" "$VER" "$tmpMirror")
|
|
|
- fi
|
|
|
- if [[ "$Relese" == 'AlpineLinux' ]]; then
|
|
|
- SpikCheckDIST='0'
|
|
|
- DIST="$(echo "$tmpDIST" |sed -r 's/(.*)/\L\1/')"
|
|
|
-
|
|
|
- AlpineVer1=`echo "$DIST" | sed 's/[a-z][A-Z]*//g' | cut -d"." -f 1`
|
|
|
- AlpineVer2=`echo "$DIST" | sed 's/[a-z][A-Z]*//g' | cut -d"." -f 2`
|
|
|
- if [[ "$AlpineVer1" -lt "3" || "$AlpineVer2" -le "15" ]] && [[ "$DIST" != "edge" ]]; then
|
|
|
- echo -ne "\n[${red}Warning${plain}] $Relese $DIST is not supported!\n"
|
|
|
- exit 1
|
|
|
- fi
|
|
|
- [[ "$DIST" != "edge" && ! "$DIST" =~ "v" ]] && DIST="v""$DIST"
|
|
|
-
|
|
|
- LinuxMirror=$(selectMirror "$Relese" "$DIST" "$VER" "$tmpMirror")
|
|
|
- fi
|
|
|
- if [[ "$Relese" == 'CentOS' ]] || [[ "$Relese" == 'RockyLinux' ]] || [[ "$Relese" == 'AlmaLinux' ]] || [[ "$Relese" == 'Fedora' ]]; then
|
|
|
- SpikCheckDIST='1'
|
|
|
- DISTCheck="$(echo "$tmpDIST" |grep -o '[\.0-9]\{1,\}' |head -n1)"
|
|
|
- RedHatSeries=`echo "$tmpDIST" | cut -d"." -f 1 | cut -d"-" -f 1`
|
|
|
-
|
|
|
-
|
|
|
- if [[ "$linux_relese" == 'centos' ]]; then
|
|
|
- [[ "$RedHatSeries" =~ [0-9]{${#1}} ]] && {
|
|
|
- if [[ "$RedHatSeries" == "6" ]]; then
|
|
|
- DISTCheck="6.10"
|
|
|
- echo -ne "\n[${red}Warning${plain}] $Relese $DISTCheck is not supported!\n"
|
|
|
- exit 1
|
|
|
- elif [[ "$RedHatSeries" == "7" ]]; then
|
|
|
- DISTCheck="7.9.2009"
|
|
|
- elif [[ "$RedHatSeries" -ge "8" ]] && [[ ! "$RedHatSeries" =~ "-stream" ]]; then
|
|
|
- DISTCheck="$RedHatSeries""-stream"
|
|
|
- elif [[ "$RedHatSeries" -le "5" ]]; then
|
|
|
- echo -ne "\n[${red}Warning${plain}] $Relese $DISTCheck is not supported!\n"
|
|
|
- else
|
|
|
- echo -ne "\n[${red}Error${plain}] Invaild $DIST! version!\n"
|
|
|
- fi
|
|
|
- }
|
|
|
- LinuxMirror=$(selectMirror "$Relese" "$DISTCheck" "$VER" "$tmpMirror")
|
|
|
- DIST="$DISTCheck"
|
|
|
- fi
|
|
|
- if [[ "$linux_relese" == 'rockylinux' ]] || [[ "$linux_relese" == 'almalinux' ]] || [[ "$linux_relese" == 'fedora' ]]; then
|
|
|
- [[ "$RedHatSeries" =~ [0-9]{${#1}} ]] && {
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
- if [[ "$linux_relese" == 'rockylinux' || "$linux_relese" == 'almalinux' ]] && [[ "$RedHatSeries" -le "7" ]]; then
|
|
|
- echo -ne "\n[${red}Warning${plain}] $Relese $DISTCheck is not supported!\n"
|
|
|
- exit 1
|
|
|
-
|
|
|
-
|
|
|
- elif [[ "$linux_relese" == 'fedora' ]] && [[ "$RedHatSeries" -le "36" ]]; then
|
|
|
- echo -ne "\n[${red}Warning${plain}] $Relese $DISTCheck is not supported!\n"
|
|
|
- exit 1
|
|
|
- fi
|
|
|
- }
|
|
|
- LinuxMirror=$(selectMirror "$Relese" "$DISTCheck" "$VER" "$tmpMirror")
|
|
|
- DIST="$DISTCheck"
|
|
|
- fi
|
|
|
- [[ -z "$DIST" ]] && {
|
|
|
- echo -ne '\nThe dists version not found in this mirror, Please check it! \n\n'
|
|
|
- bash $0 error
|
|
|
- exit 1
|
|
|
- }
|
|
|
- if [[ "$linux_relese" == 'centos' ]] && [[ "$RedHatSeries" -le "7" ]]; then
|
|
|
- wget --no-check-certificate -qO- "$LinuxMirror/$DIST/os/$VER/.treeinfo" | grep -q 'general'
|
|
|
- [[ $? != '0' ]] && {
|
|
|
- echo -ne "\n[${red}Warning${plain}] $Relese $DISTCheck was not found in this mirror, Please change mirror try again!\n"
|
|
|
- exit 1
|
|
|
- }
|
|
|
- elif [[ "$linux_relese" == 'centos' && "$RedHatSeries" -ge "8" ]] || [[ "$linux_relese" == 'rockylinux' ]] || [[ "$linux_relese" == 'almalinux' ]]; then
|
|
|
- wget --no-check-certificate -qO- "$LinuxMirror/$DIST/BaseOS/$VER/os/media.repo" | grep -q 'mediaid'
|
|
|
- [[ $? != '0' ]] && {
|
|
|
- echo -ne "\n[${red}Warning${plain}] $Relese $DISTCheck was not found in this mirror, Please change mirror try again!\n"
|
|
|
- exit 1
|
|
|
- }
|
|
|
- elif [[ "$linux_relese" == 'fedora' ]]; then
|
|
|
- wget --no-check-certificate -qO- "$LinuxMirror/releases/$DIST/Server/$VER/os/media.repo" | grep -q 'mediaid'
|
|
|
- [[ $? != '0' ]] && {
|
|
|
- echo -ne "\n[${red}Warning${plain}] $Relese $DISTCheck was not found in this mirror, Please change mirror try again!\n"
|
|
|
- exit 1
|
|
|
- }
|
|
|
- fi
|
|
|
- fi
|
|
|
-fi
|
|
|
-
|
|
|
-[[ -z "$LinuxMirror" ]] && {
|
|
|
- echo -ne "\n[${red}Error${plain}] Invaild mirror! \n"
|
|
|
- [ "$Relese" == 'Debian' ] && echo -ne "${yellow}Please check mirror lists:${plain} https://www.debian.org/mirror/list\n\n"
|
|
|
- [ "$Relese" == 'Ubuntu' ] && echo -ne "${yellow}Please check mirror lists:${plain} https://launchpad.net/ubuntu/+archivemirrors\n\n"
|
|
|
- [ "$Relese" == 'Kali' ] && echo -ne "${yellow}Please check mirror lists:${plain} https://http.kali.org/README.mirrorlist\n\n"
|
|
|
- [ "$Relese" == 'AlpineLinux' ] && echo -ne "${yellow}Please check mirror lists:${plain} https://mirrors.alpinelinux.org/\n\n"
|
|
|
- [ "$Relese" == 'CentOS' ] && echo -ne "${yellow}Please check mirror lists:${plain} https://www.centos.org/download/mirrors/\n\n"
|
|
|
- [ "$Relese" == 'RockyLinux' ] && echo -ne "${yellow}Please check mirror lists:${plain} https://mirrors.rockylinux.org/mirrormanager/mirrors\n\n"
|
|
|
- [ "$Relese" == 'AlmaLinux' ] && echo -ne "${yellow}Please check mirror lists:${plain} https://mirrors.almalinux.org/\n\n"
|
|
|
- [ "$Relese" == 'Fedora' ] && echo -ne "${yellow}Please check mirror lists:${plain} https://mirrors.fedoraproject.org/\n\n"
|
|
|
-
|
|
|
- exit 1
|
|
|
+WinRDP(){
|
|
|
+ echo -ne "netsh\0040firewall\0040set\0040portopening\0040protocol\0075ALL\0040port\0075$WinRemote\0040name\0075RDP\0040mode\0075ENABLE\0040scope\0075ALL\0040profile\0075ALL\r\nnetsh\0040firewall\0040set\0040portopening\0040protocol\0075ALL\0040port\0075$WinRemote\0040name\0075RDP\0040mode\0075ENABLE\0040scope\0075ALL\0040profile\0075CURRENT\r\nreg\0040add\0040\0042HKLM\0134SYSTEM\0134CurrentControlSet\0134Control\0134Network\0134NewNetworkWindowOff\0042\0040\0057f\r\nreg\0040add\0040\0042HKLM\0134SYSTEM\0134CurrentControlSet\0134Control\0134Terminal\0040Server\0042\0040\0057v\0040fDenyTSConnections\0040\0057t\0040reg\0137dword\0040\0057d\00400\0040\0057f\r\nreg\0040add\0040\0042HKLM\0134SYSTEM\0134CurrentControlSet\0134Control\0134Terminal\0040Server\0134Wds\0134rdpwd\0134Tds\0134tcp\0042\0040\0057v\0040PortNumber\0040\0057t\0040reg\0137dword\0040\0057d\0040$WinRemote\0040\0057f\r\nreg\0040add\0040\0042HKLM\0134SYSTEM\0134CurrentControlSet\0134Control\0134Terminal\0040Server\0134WinStations\0134RDP\0055Tcp\0042\0040\0057v\0040PortNumber\0040\0057t\0040reg\0137dword\0040\0057d\0040$WinRemote\0040\0057f\r\nreg\0040add\0040\0042HKLM\0134SYSTEM\0134CurrentControlSet\0134Control\0134Terminal\0040Server\0134WinStations\0134RDP\0055Tcp\0042\0040\0057v\0040UserAuthentication\0040\0057t\0040reg\0137dword\0040\0057d\00400\0040\0057f\r\nFOR\0040\0057F\0040\0042tokens\00752\0040delims\0075\0072\0042\0040\0045\0045i\0040in\0040\0050\0047SC\0040QUERYEX\0040TermService\0040\0136\0174FINDSTR\0040\0057I\0040\0042PID\0042\0047\0051\0040do\0040TASKKILL\0040\0057F\0040\0057PID\0040\0045\0045i\r\nFOR\0040\0057F\0040\0042tokens\00752\0040delims\0075\0072\0042\0040\0045\0045i\0040in\0040\0050\0047SC\0040QUERYEX\0040UmRdpService\0040\0136\0174FINDSTR\0040\0057I\0040\0042PID\0042\0047\0051\0040do\0040TASKKILL\0040\0057F\0040\0057PID\0040\0045\0045i\r\nSC\0040START\0040TermService\r\n\r\n" >>'/tmp/boot/net.tmp';
|
|
|
}
|
|
|
-
|
|
|
-[[ "$setNetbootXyz" == "1" ]] && SpikCheckDIST="1"
|
|
|
-if [[ "$SpikCheckDIST" == '0' ]]; then
|
|
|
- echo -ne "\n${aoiBlue}# Check DIST${plain}\n"
|
|
|
- DistsList="$(wget --no-check-certificate -qO- "$LinuxMirror/dists/" |grep -o 'href=.*/"' |cut -d'"' -f2 |sed '/-\|old\|Debian\|experimental\|stable\|test\|sid\|devel/d' |grep '^[^/]' |sed -n '1h;1!H;$g;s/\n//g;s/\//\;/g;$p')"
|
|
|
- [[ "$linux_relese" == 'kali' ]] && DistsList="$(wget --no-check-certificate -qO- "$LinuxMirror/dists/" | grep -o 'href=.*/"' | cut -d'"' -f2 | grep '^[^/]' | sed -n '1h;1!H;$g;s/\n//g;s/\//\;/g;$p')"
|
|
|
- [[ "$linux_relese" == 'alpinelinux' ]] && DistsList="$(wget --no-check-certificate -qO- "$LinuxMirror/" | grep -o 'href=.*/"' | cut -d'"' -f2 | grep '^[^/]' | sed -n '1h;1!H;$g;s/\n//g;s/\//\;/g;$p')"
|
|
|
- for CheckDEB in `echo "$DistsList" |sed 's/;/\n/g'`
|
|
|
- do
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
- [[ "$CheckDEB" =~ "$DIST" ]] && FindDists='1' && break;
|
|
|
- done
|
|
|
- [[ "$FindDists" == '0' ]] && {
|
|
|
- echo -ne '\n[${red}Error${plain}] The dists version not found, Please check it! \n\n'
|
|
|
- exit 1
|
|
|
- }
|
|
|
- echo -e "\nSuccess"
|
|
|
-fi
|
|
|
-
|
|
|
-if [[ "$ddMode" == '1' ]]; then
|
|
|
- if [[ "$targetRelese" == 'Ubuntu' ]]; then
|
|
|
- ubuntuDIST="$(echo "$finalDIST" |sed -r 's/(.*)/\L\1/')"
|
|
|
- UbuntuDistNum=`echo "$ubuntuDIST" | cut -d'.' -f1`
|
|
|
- echo "$ubuntuDIST" |grep -q '[0-9]'
|
|
|
- [[ $? -eq '0' ]] && {
|
|
|
- ubuntuDigital="$(echo "$ubuntuDIST" |grep -o '[\.0-9]\{1,\}' |sed -n '1h;1!H;$g;s/\n//g;$p')"
|
|
|
- ubuntuDigital1=`echo "$ubuntuDigital" | cut -d'.' -f1`
|
|
|
- ubuntuDigital2=`echo "$ubuntuDigital" | cut -d'.' -f2`
|
|
|
- if [[ "$ubuntuDigital1" -le "19" || "$ubuntuDigital1" -ge "23" || $((${ubuntuDigital1} % 2)) = 1 ]] || [[ "$ubuntuDigital2" != "04" ]]; then
|
|
|
- echo -ne "\n[${red}Error${plain}] The dists version not found, Please check it! \n'"
|
|
|
- exit 1
|
|
|
- fi
|
|
|
- [[ -n $ubuntuDigital ]] && {
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
- [[ "$ubuntuDigital" == '20.04' ]] && finalDIST='focal'
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
- [[ "$ubuntuDigital" == '22.04' ]] && finalDIST='jammy'
|
|
|
-
|
|
|
- }
|
|
|
- }
|
|
|
- if [[ "$VER" == "x86_64" ]] || [[ "$VER" == "x86-64" ]]; then
|
|
|
- ubuntuVER="amd64"
|
|
|
- elif [[ "$VER" == "aarch64" ]]; then
|
|
|
- ubuntuVER="arm64"
|
|
|
- fi
|
|
|
- if [[ "$tmpURL" == "" ]]; then
|
|
|
- tmpURL="https://cloud-images.a.disk.re/Ubuntu/"
|
|
|
- fi
|
|
|
- echo "$tmpURL" | grep -q '^http://\|^ftp://\|^https://'
|
|
|
- [[ $? -ne '0' ]] && echo -ne "\n[${red}Error${plain}] Please input a vaild URL, only support http://, ftp:// and https:// ! \n" && exit 1
|
|
|
- tmpURLCheck=$(echo $(curl -s -I -X GET $tmpURL) | grep -wi "http/[0-9]*" | awk '{print $2}')
|
|
|
- [[ -z "$tmpURLCheck" || ! "$tmpURLCheck" =~ ^[0-9]+$ ]] && {
|
|
|
- echo -ne "\n[${red}Error${plain}] The mirror of DD images is temporarily unavailable!\n"
|
|
|
- exit 1
|
|
|
- }
|
|
|
- DDURL="$tmpURL$finalDIST-server-cloudimg-$ubuntuVER.raw"
|
|
|
- ReleaseName="$targetRelese $finalDIST $ubuntuVER"
|
|
|
- elif [[ "$targetRelese" == 'Windows' ]]; then
|
|
|
- if [[ -z "$tmpURL" ]]; then
|
|
|
- tmpURL="https://dl.lamp.sh/vhd"
|
|
|
- [[ `echo "$finalDIST" | grep -i "server"` ]] && tmpFinalDIST=`echo $finalDIST | awk -F ' |-|_' '{print $2}'`
|
|
|
- [[ `echo "$finalDIST" | grep -i "pro"` || `echo "$finalDIST" | grep -i "ltsc"` ]] && tmpFinalDIST=`echo $finalDIST | awk -F ' |-|_' '{print $1}'`
|
|
|
- [[ "$finalDIST" =~ ^[0-9]+$ ]] && tmpFinalDIST="$finalDIST"
|
|
|
- if [[ "$tmpFinalDIST" -ge "2012" && "$tmpFinalDIST" -le "2019" ]]; then
|
|
|
- tmpTargetLang="$targetLang"
|
|
|
- else
|
|
|
- [[ "$targetLang" == 'cn' ]] && tmpTargetLang="zh-""$targetLang"
|
|
|
- [[ "$targetLang" == 'en' ]] && tmpTargetLang="$targetLang""-us"
|
|
|
- [[ "$targetLang" == 'ja' ]] && tmpTargetLang="ja-""$targetLang"
|
|
|
- fi
|
|
|
- if [[ "$tmpFinalDIST" == "2012" ]]; then
|
|
|
- tmpURL="$tmpURL/"${tmpTargetLang}"_win"${tmpFinalDIST}"r2.xz"
|
|
|
- showFinalDIST="Server $tmpFinalDIST R2"
|
|
|
- elif [[ "$tmpFinalDIST" -ge "2016" && "$tmpFinalDIST" -le "2022" ]]; then
|
|
|
- tmpURL="$tmpURL/"${tmpTargetLang}"_win"${tmpFinalDIST}".xz"
|
|
|
- showFinalDIST="Server $tmpFinalDIST"
|
|
|
- elif [[ "$tmpFinalDIST" -ge "10" && "$tmpFinalDIST" -le "11" ]]; then
|
|
|
- [[ "$tmpFinalDIST" == "10" ]] && { tmpURL="$tmpURL/"${tmpTargetLang}"_windows"${tmpFinalDIST}"_ltsc.xz"; showFinalDIST="$tmpFinalDIST Enterprise LTSC"; }
|
|
|
- [[ "$tmpFinalDIST" == "11" ]] && { tmpURL="$tmpURL/"${tmpTargetLang}"_windows"${tmpFinalDIST}"_22h2.xz"; showFinalDIST="$tmpFinalDIST Pro for Workstations 22H2"; }
|
|
|
- fi
|
|
|
- if [[ "$EfiSupport" == "enabled" ]]; then
|
|
|
- [[ "$tmpFinalDIST" == "10" ]] && tmpURL=`echo $tmpURL | sed 's/windows/win/g'`
|
|
|
- tmpURL=`echo $tmpURL | sed 's/...$/_uefi.xz/g'`
|
|
|
- fi
|
|
|
- ReleaseName="$targetRelese $showFinalDIST"
|
|
|
- else
|
|
|
- showFinalDIST=""
|
|
|
- ReleaseName="$targetRelese"
|
|
|
- fi
|
|
|
- verifyUrlValidationOfDdImages "$tmpURL"
|
|
|
- elif [[ -z "$targetRelese" && "$tmpURL" != "" ]]; then
|
|
|
- verifyUrlValidationOfDdImages "$tmpURL"
|
|
|
- ReleaseName="Self-Modified OS"
|
|
|
- else
|
|
|
- echo -ne "\n[${red}Warning${plain}] Please input a vaild image URL!\n"
|
|
|
- exit 1
|
|
|
- fi
|
|
|
-fi
|
|
|
-
|
|
|
-if [ -z "$interfaceSelect" ]; then
|
|
|
- if [[ "$linux_relese" == 'debian' ]] || [[ "$linux_relese" == 'ubuntu' ]] || [[ "$linux_relese" == 'kali' ]]; then
|
|
|
- interfaceSelect="auto"
|
|
|
- elif [[ "$linux_relese" == 'centos' ]] || [[ "$linux_relese" == 'rockylinux' ]] || [[ "$linux_relese" == 'almalinux' ]] || [[ "$linux_relese" == 'fedora' ]]; then
|
|
|
- interfaceSelect="link"
|
|
|
- fi
|
|
|
-else
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
- interface4=`echo "$interfaceSelect" | cut -d' ' -f 1`
|
|
|
- interface6=`echo "$interfaceSelect" | cut -d' ' -f 2`
|
|
|
- interface="$interface4"
|
|
|
- [[ -z "$interface6" ]] && {
|
|
|
- interface=`echo "$interfaceSelect" | sed 's/[[:space:]]//g'`
|
|
|
- interface6="$interface"
|
|
|
- }
|
|
|
-fi
|
|
|
-
|
|
|
-[[ "$setInterfaceName" == "1" ]] && {
|
|
|
- interface="eth0"
|
|
|
- interface4="eth0"
|
|
|
- interface6="eth0"
|
|
|
- [[ -n "$interface4" && -n "$interface6" && "$interface4" != "$interface6" ]] && {
|
|
|
- interface4="eth0"
|
|
|
- interface6="eth1"
|
|
|
- }
|
|
|
+ echo -ne "\0100ECHO\0040OFF\r\n\r\ncd\0056\0076\0045WINDIR\0045\0134GetAdmin\r\nif\0040exist\0040\0045WINDIR\0045\0134GetAdmin\0040\0050del\0040\0057f\0040\0057q\0040\0042\0045WINDIR\0045\0134GetAdmin\0042\0051\0040else\0040\0050\r\necho\0040CreateObject\0136\0050\0042Shell\0056Application\0042\0136\0051\0056ShellExecute\0040\0042\0045\0176s0\0042\0054\0040\0042\0045\0052\0042\0054\0040\0042\0042\0054\0040\0042runas\0042\0054\00401\0040\0076\0076\0040\0042\0045temp\0045\0134Admin\0056vbs\0042\r\n\0042\0045temp\0045\0134Admin\0056vbs\0042\r\ndel\0040\0057f\0040\0057q\0040\0042\0045temp\0045\0134Admin\0056vbs\0042\r\nexit\0040\0057b\00402\0051\r\n\r\n" >'/tmp/boot/net.tmp';
|
|
|
+ [[ "$setNet" == '1' ]] && WinNoDHCP;
|
|
|
+ [[ "$setNet" == '0' ]] && [[ "$AutoNet" == '0' ]] && WinNoDHCP;
|
|
|
+ [[ "$setRDP" == '1' ]] && [[ -n "$WinRemote" ]] && WinRDP
|
|
|
+ echo -ne "ECHO\0040SELECT\0040VOLUME\0075\0045\0045SystemDrive\0045\0045\0040\0076\0040\0042\0045SystemDrive\0045\0134diskpart\0056extend\0042\r\nECHO\0040EXTEND\0040\0076\0076\0040\0042\0045SystemDrive\0045\0134diskpart\0056extend\0042\r\nSTART\0040/WAIT\0040DISKPART\0040\0057S\0040\0042\0045SystemDrive\0045\0134diskpart\0056extend\0042\r\nDEL\0040\0057f\0040\0057q\0040\0042\0045SystemDrive\0045\0134diskpart\0056extend\0042\r\n\r\n" >>'/tmp/boot/net.tmp';
|
|
|
+ echo -ne "cd\0040\0057d\0040\0042\0045ProgramData\0045\0057Microsoft\0057Windows\0057Start\0040Menu\0057Programs\0057Startup\0042\r\ndel\0040\0057f\0040\0057q\0040net\0056bat\r\n\r\n\r\n" >>'/tmp/boot/net.tmp';
|
|
|
+ iconv -f 'UTF-8' -t 'GBK' '/tmp/boot/net.tmp' -o '/tmp/boot/net.bat'
|
|
|
+ rm -rf '/tmp/boot/net.tmp'
|
|
|
}
|
|
|
|
|
|
-echo -ne "\n${aoiBlue}# Installation Starting${plain}\n"
|
|
|
-
|
|
|
-[[ "$ddMode" == '1' ]] && echo -ne "${blue}Auto Mode${plain} Insatll [${yellow}$ReleaseName${plain}]\n$DDURL\n"
|
|
|
-
|
|
|
-if [[ "$linux_relese" == 'centos' ]]; then
|
|
|
- if [[ "$DIST" != "$UNVER" ]]; then
|
|
|
- awk 'BEGIN{print '${UNVER}'-'${DIST}'}' |grep -q '^-'
|
|
|
- if [ $? != '0' ]; then
|
|
|
- UNKNOWHW='1'
|
|
|
- echo -ne "\nThe version lower than ${red}$UNVER${plain} may not support in auto mode!\n"
|
|
|
- fi
|
|
|
- fi
|
|
|
-fi
|
|
|
-[[ "$setNetbootXyz" == "0" ]] && echo -ne "\n[${yellow}$Relese${plain}] [${yellow}$DIST${plain}] [${yellow}$VER${plain}] Downloading...\n" || echo -ne "\n[${yellow}netboot.xyz${plain}] Downloading...\n"
|
|
|
-
|
|
|
-
|
|
|
-[[ "$setNetbootXyz" == "0" ]] && {
|
|
|
- checkMem "$linux_relese" "$RedHatSeries" "$targetRelese"
|
|
|
- Add_OPTION="$Add_OPTION $lowmemLevel"
|
|
|
+[[ "$ddMode" == '0' ]] && {
|
|
|
+ sed -i '/anna-install/d' /tmp/boot/preseed.cfg
|
|
|
+ sed -i 's/wget.*\/sbin\/reboot\;\ //g' /tmp/boot/preseed.cfg
|
|
|
}
|
|
|
|
|
|
-if [[ "$setNetbootXyz" == "1" ]]; then
|
|
|
- [[ "$VER" == "x86_64" || "$VER" == "amd64" ]] && apt install grub-imageboot -y
|
|
|
- if [[ "$EfiSupport" == "enabled" ]] || [[ "$VER" == "aarch64" || "$VER" == "arm64" ]]; then
|
|
|
- echo -ne "\n[${red}Error${plain}] Netbootxyz doesn't support $VER architecture!\n"
|
|
|
- bash $0 error
|
|
|
- exit 1
|
|
|
- fi
|
|
|
-
|
|
|
-
|
|
|
- if [[ "$IsCN" == "cn" ]]; then
|
|
|
- NetbootXyzUrl="https://gitee.com/mb9e8j2/Tools/raw/master/Linux_reinstall/RedHat/NetbootXyz/netboot.xyz.iso"
|
|
|
- NetbootXyzGrub="https://gitee.com/mb9e8j2/Tools/raw/master/Linux_reinstall/RedHat/NetbootXyz/60_grub-imageboot"
|
|
|
- else
|
|
|
- NetbootXyzUrl="https://boot.netboot.xyz/ipxe/netboot.xyz.iso"
|
|
|
- NetbootXyzGrub="https://raw.githubusercontent.com/formorer/grub-imageboot/master/bin/60_grub-imageboot"
|
|
|
- fi
|
|
|
- [[ ! -d "/boot/images/" ]] && mkdir /boot/images/
|
|
|
- rm -rf /boot/images/netboot.xyz.iso
|
|
|
- echo -ne "[${yellow}Mirror${plain}] $NetbootXyzUrl\n"
|
|
|
- wget --no-check-certificate -qO '/boot/images/netboot.xyz.iso' "$NetbootXyzUrl"
|
|
|
- [[ ! -f "/etc/grub.d/60_grub-imageboot" ]] && wget --no-check-certificate -qO '/etc/grub.d/60_grub-imageboot' "$NetbootXyzGrub"
|
|
|
- chmod 755 /etc/grub.d/60_grub-imageboot
|
|
|
- [[ ! -z "$GRUBTYPE" && "$GRUBTYPE" == "isGrub2" ]] && {
|
|
|
- rm -rf /boot/memdisk
|
|
|
- cp /usr/share/syslinux/memdisk /boot/memdisk
|
|
|
- ln -s /usr/share/grub/grub-mkconfig_lib /usr/lib/grub/grub-mkconfig_lib
|
|
|
- }
|
|
|
-elif [[ "$linux_relese" == 'debian' ]] || [[ "$linux_relese" == 'ubuntu' ]] || [[ "$linux_relese" == 'kali' ]]; then
|
|
|
- [ "$DIST" == "focal" ] && legacy="legacy-" || legacy=""
|
|
|
- InitrdUrl="${LinuxMirror}/dists/${DIST}/main/installer-${VER}/current/${legacy}images/netboot/${linux_relese}-installer/${VER}/initrd.gz"
|
|
|
- VmLinuzUrl="${LinuxMirror}/dists/${DIST}${inUpdate}/main/installer-${VER}/current/${legacy}images/netboot/${linux_relese}-installer/${VER}/linux"
|
|
|
- [[ "$linux_relese" == 'kali' ]] && {
|
|
|
- InitrdUrl="${LinuxMirror}/dists/${DIST}/main/installer-${VER}/current/images/netboot/debian-installer/${VER}/initrd.gz"
|
|
|
- VmLinuzUrl="${LinuxMirror}/dists/${DIST}/main/installer-${VER}/current/images/netboot/debian-installer/${VER}/linux"
|
|
|
- }
|
|
|
- echo -ne "[${yellow}Mirror${plain}] $InitrdUrl\n\t $VmLinuzUrl\n"
|
|
|
- wget --no-check-certificate -qO '/tmp/initrd.img' "$InitrdUrl"
|
|
|
- [[ $? -ne '0' ]] && echo -ne "\n[${red}Error${plain}] Download 'initrd.img' for ${yellow}$linux_relese${plain} failed! \n" && exit 1
|
|
|
- wget --no-check-certificate -qO '/tmp/vmlinuz' "$VmLinuzUrl"
|
|
|
- [[ $? -ne '0' ]] && echo -ne "\n[${red}Error${plain}] Download 'vmlinuz' for ${yellow}$linux_relese${plain} failed! \n" && exit 1
|
|
|
- MirrorHost="$(echo "$LinuxMirror" |awk -F'://|/' '{print $2}')"
|
|
|
- MirrorFolder="$(echo "$LinuxMirror" |awk -F''${MirrorHost}'' '{print $2}')"
|
|
|
- [ -n "$MirrorFolder" ] || MirrorFolder="/"
|
|
|
-elif [[ "$linux_relese" == 'alpinelinux' ]]; then
|
|
|
- InitrdUrl="${LinuxMirror}/${DIST}/releases/${VER}/netboot/initramfs-lts"
|
|
|
- VmLinuzUrl="${LinuxMirror}/${DIST}/releases/${VER}/netboot/vmlinuz-lts"
|
|
|
- ModLoopUrl="${LinuxMirror}/${DIST}/releases/${VER}/netboot/modloop-lts"
|
|
|
- echo -ne "[${yellow}Mirror${plain}] $InitrdUrl\n\t $VmLinuzUrl\n"
|
|
|
- wget --no-check-certificate -qO '/tmp/initrd.img' "$InitrdUrl"
|
|
|
- [[ $? -ne '0' ]] && echo -ne "\n[${red}Error${plain}] Download 'initramfs-lts' for ${yellow}$linux_relese${plain} failed! \n" && exit 1
|
|
|
- wget --no-check-certificate -qO '/tmp/vmlinuz' "$VmLinuzUrl"
|
|
|
- [[ $? -ne '0' ]] && echo -ne "\n[${red}Error${plain}] Download 'vmlinuz-lts' for ${yellow}$linux_relese${plain} failed! \n" && exit 1
|
|
|
-elif [[ "$linux_relese" == 'centos' ]] && [[ "$RedHatSeries" -le "7" ]]; then
|
|
|
- InitrdUrl="${LinuxMirror}/${DIST}/os/${VER}/images/pxeboot/initrd.img"
|
|
|
- VmLinuzUrl="${LinuxMirror}/${DIST}/os/${VER}/images/pxeboot/vmlinuz"
|
|
|
- echo -ne "[${yellow}Mirror${plain}] $InitrdUrl\n\t $VmLinuzUrl\n"
|
|
|
- wget --no-check-certificate -qO '/tmp/initrd.img' "$InitrdUrl"
|
|
|
- [[ $? -ne '0' ]] && echo -ne "\n[${red}Error${plain}] Download 'initrd.img' for ${yellow}$linux_relese${plain} failed! \n" && exit 1
|
|
|
- wget --no-check-certificate -qO '/tmp/vmlinuz' "$VmLinuzUrl"
|
|
|
- [[ $? -ne '0' ]] && echo -ne "\n[${red}Error${plain}] Download 'vmlinuz' for ${yellow}$linux_relese${plain} failed! \n" && exit 1
|
|
|
-elif [[ "$linux_relese" == 'centos' && "$RedHatSeries" -ge "8" ]] || [[ "$linux_relese" == 'rockylinux' ]] || [[ "$linux_relese" == 'almalinux' ]]; then
|
|
|
- InitrdUrl="${LinuxMirror}/${DIST}/BaseOS/${VER}/os/images/pxeboot/initrd.img"
|
|
|
- VmLinuzUrl="${LinuxMirror}/${DIST}/BaseOS/${VER}/os/images/pxeboot/vmlinuz"
|
|
|
- echo -ne "[${yellow}Mirror${plain}] $InitrdUrl\n\t $VmLinuzUrl\n"
|
|
|
- wget --no-check-certificate -qO '/tmp/initrd.img' "$InitrdUrl"
|
|
|
- [[ $? -ne '0' ]] && echo -ne "\n[${red}Error${plain}] Download 'initrd.img' for ${yellow}$linux_relese${plain} failed! \n" && exit 1
|
|
|
- wget --no-check-certificate -qO '/tmp/vmlinuz' "$VmLinuzUrl"
|
|
|
- [[ $? -ne '0' ]] && echo -ne "\n[${red}Error${plain}] Download 'vmlinuz' for ${yellow}$linux_relese${plain} failed! \n" && exit 1
|
|
|
-elif [[ "$linux_relese" == 'fedora' ]]; then
|
|
|
- InitrdUrl="${LinuxMirror}/releases/${DIST}/Server/${VER}/os/images/pxeboot/initrd.img"
|
|
|
- VmLinuzUrl="${LinuxMirror}/releases/${DIST}/Server/${VER}/os/images/pxeboot/vmlinuz"
|
|
|
- echo -ne "[${yellow}Mirror${plain}] $InitrdUrl\n\t $VmLinuzUrl\n"
|
|
|
- wget --no-check-certificate -qO '/tmp/initrd.img' "$InitrdUrl"
|
|
|
- [[ $? -ne '0' ]] && echo -ne "\n[${red}Error${plain}] Download 'initrd.img' for ${yellow}$linux_relese${plain} failed! \n" && exit 1
|
|
|
- wget --no-check-certificate -qO '/tmp/vmlinuz' "$VmLinuzUrl"
|
|
|
- [[ $? -ne '0' ]] && echo -ne "\n[${red}Error${plain}] Download 'vmlinuz' for ${yellow}$linux_relese${plain} failed! \n" && exit 1
|
|
|
-else
|
|
|
- bash $0 error
|
|
|
- exit 1
|
|
|
-fi
|
|
|
-
|
|
|
-if [[ "$IncFirmware" == '1' ]]; then
|
|
|
- if [[ "$linux_relese" == 'debian' ]]; then
|
|
|
- if [[ "$IsCN" == "cn" ]]; then
|
|
|
- wget --no-check-certificate -qO '/tmp/firmware.cpio.gz' "https://mirrors.ustc.edu.cn/debian-cdimage/unofficial/non-free/firmware/${DIST}/current/firmware.cpio.gz"
|
|
|
- [[ $? -ne '0' ]] && echo -ne "\n[${red}Error${plain}] Download firmware for ${red}$linux_relese${plain} failed! \n" && exit 1
|
|
|
- else
|
|
|
- wget --no-check-certificate -qO '/tmp/firmware.cpio.gz' "http://cdimage.debian.org/cdimage/unofficial/non-free/firmware/${DIST}/current/firmware.cpio.gz"
|
|
|
- [[ $? -ne '0' ]] && echo -ne "\n[${red}Error${plain}] Download firmware for ${red}$linux_relese${plain} failed! \n" && exit 1
|
|
|
- fi
|
|
|
- if [[ "$ddMode" == '1' ]]; then
|
|
|
- vKernel_udeb=$(wget --no-check-certificate -qO- "http://$LinuxMirror/dists/$DIST/main/installer-$VER/current/images/udeb.list" | grep '^acpi-modules' | head -n1 | grep -o '[0-9]\{1,2\}.[0-9]\{1,2\}.[0-9]\{1,2\}-[0-9]\{1,2\}' | head -n1)
|
|
|
- [[ -z "vKernel_udeb" ]] && vKernel_udeb="6.1.0-11"
|
|
|
- fi
|
|
|
- elif [[ "$linux_relese" == 'kali' ]]; then
|
|
|
- if [[ "$IsCN" == "cn" ]]; then
|
|
|
- wget --no-check-certificate -qO /root/kaliFirmwareCheck 'https://mirrors.tuna.tsinghua.edu.cn/kali/pool/non-free/f/firmware-nonfree/?C=S&O=D'
|
|
|
- kaliFirmwareName=$(grep "href=\"firmware-nonfree" /root/kaliFirmwareCheck | head -n 1 | awk -F'\">' '/tar.xz/{print $3}' | cut -d'<' -f1 | cut -d'/' -f2)
|
|
|
- wget --no-check-certificate -qO '/tmp/kali_firmware.tar.xz' "https://mirrors.tuna.tsinghua.edu.cn/kali/pool/non-free/f/firmware-nonfree/$kaliFirmwareName"
|
|
|
- [[ $? -ne '0' ]] && echo -ne "\n[${red}Error${plain}] Download firmware for ${red}$linux_relese${plain} failed! \n" && exit 1
|
|
|
- rm -rf /root/kaliFirmwareCheck
|
|
|
- else
|
|
|
- wget --no-check-certificate -qO /root/kaliFirmwareCheck 'https://mirrors.ocf.berkeley.edu/kali/pool/non-free/f/firmware-nonfree/?C=S&O=D'
|
|
|
- kaliFirmwareName=$(grep "href=\"firmware-nonfree" /root/kaliFirmwareCheck | head -n 1 | awk -F'\">' '/tar.xz/{print $3}' | cut -d'<' -f1 | cut -d'/' -f2)
|
|
|
- wget --no-check-certificate -qO '/tmp/kali_firmware.tar.xz' "https://mirrors.ocf.berkeley.edu/kali/pool/non-free/f/firmware-nonfree/$kaliFirmwareName"
|
|
|
- [[ $? -ne '0' ]] && echo -ne "\n[${red}Error${plain}] Download firmware for ${red}$linux_relese${plain} failed! \n" && exit 1
|
|
|
- rm -rf /root/kaliFirmwareCheck
|
|
|
- fi
|
|
|
- decompressedKaliFirmwareDir=$(echo $kaliFirmwareName | cut -d'.' -f 1 | sed 's/_/-/g')
|
|
|
- fi
|
|
|
-fi
|
|
|
-
|
|
|
-[[ -d /tmp/boot ]] && rm -rf /tmp/boot
|
|
|
-mkdir -p /tmp/boot
|
|
|
-cd /tmp/boot
|
|
|
-
|
|
|
-if [[ "$linux_relese" == 'debian' ]] || [[ "$linux_relese" == 'ubuntu' ]] || [[ "$linux_relese" == 'kali' ]] || [[ "$linux_relese" == 'alpinelinux' ]]; then
|
|
|
- COMPTYPE="gzip"
|
|
|
-elif [[ "$linux_relese" == 'centos' ]] || [[ "$linux_relese" == 'rockylinux' ]] || [[ "$linux_relese" == 'almalinux' ]] || [[ "$linux_relese" == 'fedora' ]]; then
|
|
|
- COMPTYPE="$(file ../initrd.img |grep -o ':.*compressed data' |cut -d' ' -f2 |sed -r 's/(.*)/\L\1/' |head -n1)"
|
|
|
- [[ -z "$COMPTYPE" ]] && echo "Detect compressed type fail." && exit 1
|
|
|
-fi
|
|
|
-CompDected='0'
|
|
|
-for COMP in `echo -en 'gzip\nlzma\nxz'`
|
|
|
- do
|
|
|
- if [[ "$COMPTYPE" == "$COMP" ]]; then
|
|
|
- CompDected='1'
|
|
|
- if [[ "$COMPTYPE" == 'gzip' ]]; then
|
|
|
- NewIMG="initrd.img.gz"
|
|
|
- else
|
|
|
- NewIMG="initrd.img.$COMPTYPE"
|
|
|
- fi
|
|
|
- mv -f "/tmp/initrd.img" "/tmp/$NewIMG"
|
|
|
- break;
|
|
|
- fi
|
|
|
- done
|
|
|
-[[ "$CompDected" != '1' ]] && echo "Detect compressed type not support." && exit 1
|
|
|
-[[ "$COMPTYPE" == 'lzma' ]] && UNCOMP='xz --format=lzma --decompress'
|
|
|
-[[ "$COMPTYPE" == 'xz' ]] && UNCOMP='xz --decompress'
|
|
|
-[[ "$COMPTYPE" == 'gzip' ]] && UNCOMP='gzip -d'
|
|
|
-$UNCOMP < /tmp/$NewIMG | cpio --extract --make-directories --preserve-modification-time >>/dev/null 2>&1
|
|
|
-
|
|
|
-if [[ "$linux_relese" == 'debian' ]] || [[ "$linux_relese" == 'kali' ]] || [[ "$linux_relese" == 'ubuntu' ]]; then
|
|
|
- DebianPreseedProcess
|
|
|
- if [[ "$loaderMode" != "0" ]] && [[ "$setNet" == '0' ]]; then
|
|
|
- sed -i '/netcfg\/disable_autoconfig/d' /tmp/boot/preseed.cfg
|
|
|
- sed -i '/netcfg\/dhcp_options/d' /tmp/boot/preseed.cfg
|
|
|
- sed -i '/netcfg\/get_.*/d' /tmp/boot/preseed.cfg
|
|
|
- sed -i '/netcfg\/confirm_static/d' /tmp/boot/preseed.cfg
|
|
|
- fi
|
|
|
-
|
|
|
- if [[ "$disksNum" -le "1" || "$setDisk" != "all" || -n "$setRaid" ]]; then
|
|
|
- sed -i 's/lvremove --select all -ff -y;//g' /tmp/boot/preseed.cfg
|
|
|
- sed -i 's/vgremove --select all -ff -y;//g' /tmp/boot/preseed.cfg
|
|
|
- sed -i 's/pvremove \/dev\/\* -ff -y;//g' /tmp/boot/preseed.cfg
|
|
|
- elif [[ "$disksNum" -gt "1" && "$setDisk" == "all" ]]; then
|
|
|
-
|
|
|
- [[ -z "$virtWhat" ]] || sed -i 's/pvremove \/dev\/\* -ff -y;//g' /tmp/boot/preseed.cfg
|
|
|
- fi
|
|
|
- if [[ "$disksNum" -gt "1" ]] && [[ -n "$setRaid" ]]; then
|
|
|
- sed -i 's/d-i partman\/early_command.*//g' /tmp/boot/preseed.cfg
|
|
|
- sed -ri "/d-i grub-installer\/bootdev.*/c\d-i grub-installer\/bootdev string $AllDisks" /tmp/boot/preseed.cfg
|
|
|
- fi
|
|
|
-
|
|
|
- [[ "$DebianDistNum" -le "8" || -n "$setRaid" ]] && sed -i '/d-i\ partman\/default_filesystem string xfs/d' /tmp/boot/preseed.cfg
|
|
|
- if [[ "$linux_relese" == 'debian' ]] || [[ "$linux_relese" == 'kali' ]]; then
|
|
|
- sed -i '/user-setup\/allow-password-weak/d' /tmp/boot/preseed.cfg
|
|
|
- sed -i '/user-setup\/encrypt-home/d' /tmp/boot/preseed.cfg
|
|
|
- sed -i '/pkgsel\/update-policy/d' /tmp/boot/preseed.cfg
|
|
|
- sed -i 's/umount\ \/media.*true\;\ //g' /tmp/boot/preseed.cfg
|
|
|
- [[ -f '/tmp/firmware.cpio.gz' ]] && gzip -d < /tmp/firmware.cpio.gz | cpio --extract --verbose --make-directories --no-absolute-filenames >>/dev/null 2>&1
|
|
|
-
|
|
|
-
|
|
|
- [[ -f '/tmp/kali_firmware.tar.xz' ]] && {
|
|
|
- tar -Jxvf '/tmp/kali_firmware.tar.xz' -C /tmp/
|
|
|
- mv /tmp/$decompressedKaliFirmwareDir/* '/tmp/boot/lib/firmware/'
|
|
|
- }
|
|
|
- fi
|
|
|
-
|
|
|
- [[ "$TotalMem1" -ge "2558072" || "$TotalMem2" -ge "2558072" ]] && sed -i '/d-i\ lowmem\/low boolean true/d' /tmp/boot/preseed.cfg
|
|
|
-
|
|
|
- if [[ "$linux_relese" == 'ubuntu' ]]; then
|
|
|
- sed -i '/d-i\ partman\/default_filesystem string xfs/d' /tmp/boot/preseed.cfg
|
|
|
- sed -i '/d-i\ grub-installer\/force-efi-extra-removable/d' /tmp/boot/preseed.cfg
|
|
|
- sed -i '/d-i\ lowmem\/low boolean true/d' /tmp/boot/preseed.cfg
|
|
|
- fi
|
|
|
- if [[ "$partitionTable" == "gpt" ]]; then
|
|
|
- sed -i 's/default_filesystem string ext4/default_filesystem string xfs/g' /tmp/boot/preseed.cfg
|
|
|
- fi
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
- if [[ "$linux_relese" == 'kali' ]]; then
|
|
|
- sed -i 's/first multiselect minimal/first multiselect standard/g' /tmp/boot/preseed.cfg
|
|
|
- sed -i 's/upgrade select none/upgrade select full-upgrade/g' /tmp/boot/preseed.cfg
|
|
|
- sed -i 's/include string openssh-server/include string kali-linux-core openssh-server/g' /tmp/boot/preseed.cfg
|
|
|
- sed -i 's/d-i grub-installer\/with_other_os boolean true//g' /tmp/boot/preseed.cfg
|
|
|
- fi
|
|
|
-
|
|
|
- if [[ "$linux_relese" != 'kali' ]]; then
|
|
|
- if [[ "$tmpIpMask" -ge "16" || "$IPStackType" == "IPv6Stack" || "$BiStackPreferIpv6Status" == "1" || "$BurnIrregularIpv4Status" == "1" ]] && [[ "$linux_relese" == 'debian' && "$DebianDistNum" -gt "9" ]]; then
|
|
|
- sed -i '/d-i\ apt-setup\/services-select multiselect/d' /tmp/boot/preseed.cfg
|
|
|
- sed -i '/d-i\ apt-setup\/enable-source-repositories boolean false/d' /tmp/boot/preseed.cfg
|
|
|
- fi
|
|
|
- fi
|
|
|
-
|
|
|
- if [[ "$Network4Config" == "isStatic" ]] || [[ "$Network6Config" == "isStatic" ]]; then
|
|
|
- sed -i 's/ntp boolean true/ntp boolean false/g' /tmp/boot/preseed.cfg
|
|
|
- sed -i '/d-i\ clock-setup\/ntp-server string ntp.nict.jp/d' /tmp/boot/preseed.cfg
|
|
|
- fi
|
|
|
-
|
|
|
- [[ "$setInterfaceName" == "0" ]] && sed -i 's/net.ifnames=0 biosdevname=0//g' /tmp/boot/preseed.cfg
|
|
|
-
|
|
|
- [[ "$setIPv6" == "1" ]] && sed -i 's/ipv6.disable=1//g' /tmp/boot/preseed.cfg
|
|
|
-
|
|
|
- [[ "$ddMode" == '1' ]] && {
|
|
|
- WinNoDHCP(){
|
|
|
- echo -ne "for\0040\0057f\0040\0042tokens\00753\0052\0042\0040\0045\0045i\0040in\0040\0050\0047netsh\0040interface\0040show\0040interface\0040\0136\0174more\0040\00533\0040\0136\0174findstr\0040\0057I\0040\0057R\0040\0042本地\0056\0052\0040以太\0056\0052\0040Local\0056\0052\0040Ethernet\0042\0047\0051\0040do\0040\0050set\0040EthName\0075\0045\0045j\0051\r\nnetsh\0040\0055c\0040interface\0040ip\0040set\0040address\0040name\0075\0042\0045EthName\0045\0042\0040source\0075static\0040address\0075$IPv4\0040mask\0075$MASK\0040gateway\0075$GATE\r\nnetsh\0040\0055c\0040interface\0040ip\0040add\0040dnsservers\0040name\0075\0042\0045EthName\0045\0042\0040address\00758\00568\00568\00568\0040index\00751\0040validate\0075no\r\n\r\n" >>'/tmp/boot/net.tmp';
|
|
|
- }
|
|
|
- WinRDP(){
|
|
|
- echo -ne "netsh\0040firewall\0040set\0040portopening\0040protocol\0075ALL\0040port\0075$WinRemote\0040name\0075RDP\0040mode\0075ENABLE\0040scope\0075ALL\0040profile\0075ALL\r\nnetsh\0040firewall\0040set\0040portopening\0040protocol\0075ALL\0040port\0075$WinRemote\0040name\0075RDP\0040mode\0075ENABLE\0040scope\0075ALL\0040profile\0075CURRENT\r\nreg\0040add\0040\0042HKLM\0134SYSTEM\0134CurrentControlSet\0134Control\0134Network\0134NewNetworkWindowOff\0042\0040\0057f\r\nreg\0040add\0040\0042HKLM\0134SYSTEM\0134CurrentControlSet\0134Control\0134Terminal\0040Server\0042\0040\0057v\0040fDenyTSConnections\0040\0057t\0040reg\0137dword\0040\0057d\00400\0040\0057f\r\nreg\0040add\0040\0042HKLM\0134SYSTEM\0134CurrentControlSet\0134Control\0134Terminal\0040Server\0134Wds\0134rdpwd\0134Tds\0134tcp\0042\0040\0057v\0040PortNumber\0040\0057t\0040reg\0137dword\0040\0057d\0040$WinRemote\0040\0057f\r\nreg\0040add\0040\0042HKLM\0134SYSTEM\0134CurrentControlSet\0134Control\0134Terminal\0040Server\0134WinStations\0134RDP\0055Tcp\0042\0040\0057v\0040PortNumber\0040\0057t\0040reg\0137dword\0040\0057d\0040$WinRemote\0040\0057f\r\nreg\0040add\0040\0042HKLM\0134SYSTEM\0134CurrentControlSet\0134Control\0134Terminal\0040Server\0134WinStations\0134RDP\0055Tcp\0042\0040\0057v\0040UserAuthentication\0040\0057t\0040reg\0137dword\0040\0057d\00400\0040\0057f\r\nFOR\0040\0057F\0040\0042tokens\00752\0040delims\0075\0072\0042\0040\0045\0045i\0040in\0040\0050\0047SC\0040QUERYEX\0040TermService\0040\0136\0174FINDSTR\0040\0057I\0040\0042PID\0042\0047\0051\0040do\0040TASKKILL\0040\0057F\0040\0057PID\0040\0045\0045i\r\nFOR\0040\0057F\0040\0042tokens\00752\0040delims\0075\0072\0042\0040\0045\0045i\0040in\0040\0050\0047SC\0040QUERYEX\0040UmRdpService\0040\0136\0174FINDSTR\0040\0057I\0040\0042PID\0042\0047\0051\0040do\0040TASKKILL\0040\0057F\0040\0057PID\0040\0045\0045i\r\nSC\0040START\0040TermService\r\n\r\n" >>'/tmp/boot/net.tmp';
|
|
|
- }
|
|
|
- echo -ne "\0100ECHO\0040OFF\r\n\r\ncd\0056\0076\0045WINDIR\0045\0134GetAdmin\r\nif\0040exist\0040\0045WINDIR\0045\0134GetAdmin\0040\0050del\0040\0057f\0040\0057q\0040\0042\0045WINDIR\0045\0134GetAdmin\0042\0051\0040else\0040\0050\r\necho\0040CreateObject\0136\0050\0042Shell\0056Application\0042\0136\0051\0056ShellExecute\0040\0042\0045\0176s0\0042\0054\0040\0042\0045\0052\0042\0054\0040\0042\0042\0054\0040\0042runas\0042\0054\00401\0040\0076\0076\0040\0042\0045temp\0045\0134Admin\0056vbs\0042\r\n\0042\0045temp\0045\0134Admin\0056vbs\0042\r\ndel\0040\0057f\0040\0057q\0040\0042\0045temp\0045\0134Admin\0056vbs\0042\r\nexit\0040\0057b\00402\0051\r\n\r\n" >'/tmp/boot/net.tmp';
|
|
|
- [[ "$setNet" == '1' ]] && WinNoDHCP;
|
|
|
- [[ "$setNet" == '0' ]] && [[ "$AutoNet" == '0' ]] && WinNoDHCP;
|
|
|
- [[ "$setRDP" == '1' ]] && [[ -n "$WinRemote" ]] && WinRDP
|
|
|
- echo -ne "ECHO\0040SELECT\0040VOLUME\0075\0045\0045SystemDrive\0045\0045\0040\0076\0040\0042\0045SystemDrive\0045\0134diskpart\0056extend\0042\r\nECHO\0040EXTEND\0040\0076\0076\0040\0042\0045SystemDrive\0045\0134diskpart\0056extend\0042\r\nSTART\0040/WAIT\0040DISKPART\0040\0057S\0040\0042\0045SystemDrive\0045\0134diskpart\0056extend\0042\r\nDEL\0040\0057f\0040\0057q\0040\0042\0045SystemDrive\0045\0134diskpart\0056extend\0042\r\n\r\n" >>'/tmp/boot/net.tmp';
|
|
|
- echo -ne "cd\0040\0057d\0040\0042\0045ProgramData\0045\0057Microsoft\0057Windows\0057Start\0040Menu\0057Programs\0057Startup\0042\r\ndel\0040\0057f\0040\0057q\0040net\0056bat\r\n\r\n\r\n" >>'/tmp/boot/net.tmp';
|
|
|
- iconv -f 'UTF-8' -t 'GBK' '/tmp/boot/net.tmp' -o '/tmp/boot/net.bat'
|
|
|
- rm -rf '/tmp/boot/net.tmp'
|
|
|
- }
|
|
|
- [[ "$ddMode" == '0' ]] && {
|
|
|
- sed -i '/anna-install/d' /tmp/boot/preseed.cfg
|
|
|
- sed -i 's/wget.*\/sbin\/reboot\;\ //g' /tmp/boot/preseed.cfg
|
|
|
- }
|
|
|
-
|
|
|
-
|
|
|
- [[ "$BurnIrregularIpv4Status" == "1" ]] && {
|
|
|
- sed -i '/early_command string anna-install/d' /tmp/boot/preseed.cfg
|
|
|
- }
|
|
|
-elif [[ "$linux_relese" == 'alpinelinux' ]]; then
|
|
|
-
|
|
|
- [[ "$IPStackType" == "IPv6Stack" ]] && {
|
|
|
- echo -ne "\n[${red}Error${plain}] Does't support $IPStackType!\n"
|
|
|
- exit 1
|
|
|
- }
|
|
|
-
|
|
|
- HostName=$(hostname)
|
|
|
- [[ "$HostName" == "" || "$HostName" == "localhost" ]] && {
|
|
|
- [[ -n "$targetRelese" ]] && HostName="$targetRelese" || HostName="AlpineLinux"
|
|
|
- }
|
|
|
-
|
|
|
- echo "ipv6" >> /tmp/boot/etc/modules
|
|
|
- if [[ "$setAutoConfig" == "1" ]]; then
|
|
|
- AlpineInitLineNum=$(grep -E -n '^exec (/bin/busybox )?switch_root' /tmp/boot/init | cut -d: -f1)
|
|
|
- AlpineInitLineNum=$((AlpineInitLineNum - 1))
|
|
|
- if [[ "$IsCN" == "cn" ]]; then
|
|
|
- alpineInstallOrDdAdditionalFiles "https://gitee.com/mb9e8j2/Tools/raw/master/Linux_reinstall/Alpine/alpineInit.sh" "https://gitee.com/mb9e8j2/Tools/raw/master/Linux_reinstall/Alpine/network/resolv_cn.conf" "https://gitee.com/mb9e8j2/Tools/raw/master/Linux_reinstall/Alpine/motd.sh" "mirrors.ustc.edu.cn" "mirrors.tuna.tsinghua.edu.cn" "https://gitee.com/mb9e8j2/Tools/raw/master/Linux_reinstall/Ubuntu/ubuntuInit.sh" "https://gitee.com/mb9e8j2/Tools/raw/master/Linux_reinstall/Windows/windowsInit.sh" "https://gitee.com/mb9e8j2/Tools/raw/master/Linux_reinstall/Windows/SetupComplete.bat"
|
|
|
- else
|
|
|
- alpineInstallOrDdAdditionalFiles "https://raw.githubusercontent.com/leitbogioro/Tools/master/Linux_reinstall/Alpine/alpineInit.sh" "https://raw.githubusercontent.com/leitbogioro/Tools/master/Linux_reinstall/Alpine/network/resolv.conf" "https://raw.githubusercontent.com/leitbogioro/Tools/master/Linux_reinstall/Alpine/motd.sh" "archive.ubuntu.com" "ports.ubuntu.com" "https://raw.githubusercontent.com/leitbogioro/Tools/master/Linux_reinstall/Ubuntu/ubuntuInit.sh" "https://raw.githubusercontent.com/leitbogioro/Tools/master/Linux_reinstall/Windows/windowsInit.sh" "https://raw.githubusercontent.com/leitbogioro/Tools/master/Linux_reinstall/Windows/SetupComplete.bat"
|
|
|
- fi
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
- if [[ "$IPStackType" == "IPv4Stack" ]]; then
|
|
|
- if [[ "$Network4Config" == "isDHCP" ]]; then
|
|
|
- if [[ "$IsCN" == "cn" ]]; then
|
|
|
- AlpineNetworkConf="https://gitee.com/mb9e8j2/Tools/raw/master/Linux_reinstall/Alpine/network/dhcp_interfaces"
|
|
|
- [[ "$targetRelese" == 'Ubuntu' ]] && cloudInitUrl="https://gitee.com/mb9e8j2/Tools/raw/master/Linux_reinstall/Ubuntu/CloudInit/dhcp_interfaces.cfg"
|
|
|
- else
|
|
|
- AlpineNetworkConf="https://raw.githubusercontent.com/leitbogioro/Tools/master/Linux_reinstall/Alpine/network/dhcp_interfaces"
|
|
|
- [[ "$targetRelese" == 'Ubuntu' ]] && cloudInitUrl="https://raw.githubusercontent.com/leitbogioro/Tools/master/Linux_reinstall/Ubuntu/CloudInit/dhcp_interfaces.cfg"
|
|
|
- fi
|
|
|
- elif [[ "$Network4Config" == "isStatic" ]]; then
|
|
|
- if [[ "$IsCN" == "cn" ]]; then
|
|
|
- AlpineNetworkConf="https://gitee.com/mb9e8j2/Tools/raw/master/Linux_reinstall/Alpine/network/ipv4_static_interfaces"
|
|
|
- [[ "$targetRelese" == 'Ubuntu' ]] && cloudInitUrl="https://gitee.com/mb9e8j2/Tools/raw/master/Linux_reinstall/Ubuntu/CloudInit/ipv4_static_interfaces.cfg"
|
|
|
- else
|
|
|
- AlpineNetworkConf="https://raw.githubusercontent.com/leitbogioro/Tools/master/Linux_reinstall/Alpine/network/ipv4_static_interfaces"
|
|
|
- [[ "$targetRelese" == 'Ubuntu' ]] && cloudInitUrl="https://raw.githubusercontent.com/leitbogioro/Tools/master/Linux_reinstall/Ubuntu/CloudInit/ipv4_static_interfaces.cfg"
|
|
|
- fi
|
|
|
- fi
|
|
|
- elif [[ "$IPStackType" == "BiStack" ]]; then
|
|
|
-
|
|
|
- if [[ "$Network4Config" == "isDHCP" ]]; then
|
|
|
- [[ "$IsCN" == "cn" ]] && AlpineNetworkConf="https://gitee.com/mb9e8j2/Tools/raw/master/Linux_reinstall/Alpine/network/ipv6_static_interfaces" || AlpineNetworkConf="https://raw.githubusercontent.com/leitbogioro/Tools/master/Linux_reinstall/Alpine/network/ipv6_static_interfaces"
|
|
|
- elif [[ "$Network4Config" == "isStatic" ]]; then
|
|
|
- [[ "$IsCN" == "cn" ]] && AlpineNetworkConf="https://gitee.com/mb9e8j2/Tools/raw/master/Linux_reinstall/Alpine/network/ipv4_ipv6_static_interfaces" || AlpineNetworkConf="https://raw.githubusercontent.com/leitbogioro/Tools/master/Linux_reinstall/Alpine/network/ipv4_ipv6_static_interfaces"
|
|
|
- fi
|
|
|
- [[ "$targetRelese" == 'Ubuntu' ]] && {
|
|
|
- if [[ "$Network4Config" == "isDHCP" ]] && [[ "$Network6Config" == "isDHCP" ]]; then
|
|
|
- [[ "$IsCN" == "cn" ]] && cloudInitUrl="https://gitee.com/mb9e8j2/Tools/raw/master/Linux_reinstall/Ubuntu/CloudInit/dhcp_interfaces.cfg" || cloudInitUrl="https://raw.githubusercontent.com/leitbogioro/Tools/master/Linux_reinstall/Ubuntu/CloudInit/dhcp_interfaces.cfg"
|
|
|
- elif [[ "$Network4Config" == "isDHCP" ]] && [[ "$Network6Config" == "isStatic" ]]; then
|
|
|
- [[ "$IsCN" == "cn" ]] && cloudInitUrl="https://gitee.com/mb9e8j2/Tools/raw/master/Linux_reinstall/Ubuntu/CloudInit/ipv4_dhcp_ipv6_static_interfaces.cfg" || cloudInitUrl="https://raw.githubusercontent.com/leitbogioro/Tools/master/Linux_reinstall/Ubuntu/CloudInit/ipv4_dhcp_ipv6_static_interfaces.cfg"
|
|
|
- elif [[ "$Network4Config" == "isStatic" ]] && [[ "$Network6Config" == "isDHCP" ]]; then
|
|
|
- [[ "$IsCN" == "cn" ]] && cloudInitUrl="https://gitee.com/mb9e8j2/Tools/raw/master/Linux_reinstall/Ubuntu/CloudInit/ipv4_static_ipv6_dhcp_interfaces.cfg" || cloudInitUrl="https://raw.githubusercontent.com/leitbogioro/Tools/master/Linux_reinstall/Ubuntu/CloudInit/ipv4_static_ipv6_dhcp_interfaces.cfg"
|
|
|
- elif [[ "$Network4Config" == "isStatic" ]] && [[ "$Network6Config" == "isStatic" ]]; then
|
|
|
- [[ "$IsCN" == "cn" ]] && cloudInitUrl="https://gitee.com/mb9e8j2/Tools/raw/master/Linux_reinstall/Ubuntu/CloudInit/ipv4_static_ipv6_static_interfaces.cfg" || cloudInitUrl="https://raw.githubusercontent.com/leitbogioro/Tools/master/Linux_reinstall/Ubuntu/CloudInit/ipv4_static_ipv6_static_interfaces.cfg"
|
|
|
- fi
|
|
|
- }
|
|
|
- fi
|
|
|
-
|
|
|
- cat <<EOF | sed -i "${AlpineInitLineNum}r /dev/stdin" /tmp/boot/init
|
|
|
-
|
|
|
-wget --no-check-certificate -O \$sysroot/etc/network/tmp_interfaces ${AlpineNetworkConf}
|
|
|
-
|
|
|
-
|
|
|
-rm -rf \$sysroot/etc/resolv.conf
|
|
|
-wget --no-check-certificate -O \$sysroot/etc/resolv.conf ${AlpineDnsFile}
|
|
|
-chmod a+x \$sysroot/etc/resolv.conf
|
|
|
-
|
|
|
-
|
|
|
-rm -rf \$sysroot/etc/motd
|
|
|
-wget --no-check-certificate -O \$sysroot/etc/profile.d/motd.sh ${AlpineMotd}
|
|
|
-chmod a+x \$sysroot/etc/profile.d/motd.sh
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-echo "IncDisk "${IncDisk} >> \$sysroot/root/alpine.config
|
|
|
-
|
|
|
-
|
|
|
-echo "LinuxMirror "${LinuxMirror} >> \$sysroot/root/alpine.config
|
|
|
-
|
|
|
-
|
|
|
-echo "alpineVer "${DIST} >> \$sysroot/root/alpine.config
|
|
|
-
|
|
|
-
|
|
|
-echo "targetLinuxMirror "${targetLinuxMirror} >> \$sysroot/root/alpine.config
|
|
|
-
|
|
|
-
|
|
|
-echo "windowsStaticConfigCmd "${windowsStaticConfigCmd} >> \$sysroot/root/alpine.config
|
|
|
-
|
|
|
-
|
|
|
-echo "Network4Config "${Network4Config} >> \$sysroot/root/alpine.config
|
|
|
-
|
|
|
-
|
|
|
-echo "DEC_CMD "${DEC_CMD} >> \$sysroot/root/alpine.config
|
|
|
-
|
|
|
-
|
|
|
-echo "TimeZone "${TimeZone} >> \$sysroot/root/alpine.config
|
|
|
-
|
|
|
-
|
|
|
-echo 'tmpWORD '$tmpWORD'' >> \$sysroot/root/alpine.config
|
|
|
-
|
|
|
-
|
|
|
-echo "sshPORT "${sshPORT} >> \$sysroot/root/alpine.config
|
|
|
-
|
|
|
-
|
|
|
-echo "IPv4 "${IPv4} >> \$sysroot/root/alpine.config
|
|
|
-echo "MASK "${MASK} >> \$sysroot/root/alpine.config
|
|
|
-echo "ipPrefix "${ipPrefix} >> \$sysroot/root/alpine.config
|
|
|
-echo "actualIp4Prefix "${actualIp4Prefix} >> \$sysroot/root/alpine.config
|
|
|
-echo "actualIp4Subnet "${actualIp4Subnet} >> \$sysroot/root/alpine.config
|
|
|
-echo "GATE "${GATE} >> \$sysroot/root/alpine.config
|
|
|
-echo "ipDNS1 "${ipDNS1} >> \$sysroot/root/alpine.config
|
|
|
-echo "ipDNS2 "${ipDNS2} >> \$sysroot/root/alpine.config
|
|
|
-
|
|
|
-
|
|
|
-echo "ip6Addr "${ip6Addr} >> \$sysroot/root/alpine.config
|
|
|
-echo "ip6Mask "${ip6Mask} >> \$sysroot/root/alpine.config
|
|
|
-echo "actualIp6Prefix "${actualIp6Prefix} >> \$sysroot/root/alpine.config
|
|
|
-echo "ip6Gate "${ip6Gate} >> \$sysroot/root/alpine.config
|
|
|
-echo "ip6DNS1 "${ip6DNS1} >> \$sysroot/root/alpine.config
|
|
|
-echo "ip6DNS2 "${ip6DNS2} >> \$sysroot/root/alpine.config
|
|
|
-
|
|
|
-
|
|
|
-echo "setIPv6 "${setIPv6} >> \$sysroot/root/alpine.config
|
|
|
-
|
|
|
-
|
|
|
-echo "HostName "${HostName} >> \$sysroot/root/alpine.config
|
|
|
-
|
|
|
-
|
|
|
-echo "DDURL "${DDURL} >> \$sysroot/root/alpine.config
|
|
|
-
|
|
|
-
|
|
|
-echo "cloudInitUrl "${cloudInitUrl} >> \$sysroot/root/alpine.config
|
|
|
-
|
|
|
-
|
|
|
-wget --no-check-certificate -O \$sysroot/etc/local.d/${AlpineInitFileName} ${AlpineInitFile}
|
|
|
-
|
|
|
-
|
|
|
-chmod a+x \$sysroot/etc/local.d/${AlpineInitFileName}
|
|
|
-ln -s /etc/init.d/local \$sysroot/etc/runlevels/default/
|
|
|
-EOF
|
|
|
- fi
|
|
|
-elif [[ "$linux_relese" == 'centos' ]] || [[ "$linux_relese" == 'rockylinux' ]] || [[ "$linux_relese" == 'almalinux' ]] || [[ "$linux_relese" == 'fedora' ]]; then
|
|
|
- RedHatUrl=""
|
|
|
- RepoBase=""
|
|
|
- RepoAppStream=""
|
|
|
- [[ "$IsCN" == "cn" ]] && RepoEpel="repo --name=epel --baseurl=http://mirrors.ustc.edu.cn/epel/${RedHatSeries}/Everything/${VER}/" || RepoEpel="repo --name=epel --mirrorlist=https://mirrors.fedoraproject.org/mirrorlist?repo=epel-${RedHatSeries}&arch=${VER}"
|
|
|
- AuthMethod="authselect --useshadow --passalgo sha512"
|
|
|
- SetTimeZone="timezone --utc ${TimeZone}"
|
|
|
- [[ "$IsCN" == "cn" ]] && FirewallRule="https://gitee.com/mb9e8j2/Tools/raw/master/Linux_reinstall/RedHat/RHEL9Public.xml" || FirewallRule="https://raw.githubusercontent.com/leitbogioro/Tools/master/Linux_reinstall/RedHat/RHEL9Public.xml"
|
|
|
- if [[ "$linux_relese" == 'centos' ]] || [[ "$linux_relese" == 'rockylinux' ]] || [[ "$linux_relese" == 'almalinux' ]]; then
|
|
|
- if [[ "$RedHatSeries" -ge "8" ]]; then
|
|
|
- RedHatUrl="${LinuxMirror}/${DIST}/BaseOS/${VER}/os/"
|
|
|
- RepoBase="repo --name=base --baseurl=${LinuxMirror}/${DIST}/BaseOS/${VER}/os/"
|
|
|
- RepoAppStream="repo --name=appstream --baseurl=${LinuxMirror}/${DIST}/AppStream/${VER}/os/"
|
|
|
- elif [[ "$linux_relese" == 'centos' ]] && [[ "$RedHatSeries" -le "7" ]]; then
|
|
|
- RedHatUrl="${LinuxMirror}/${DIST}/os/${VER}/"
|
|
|
- AuthMethod="auth --useshadow --passalgo=sha512"
|
|
|
- SetTimeZone="timezone --isUtc ${TimeZone}"
|
|
|
- RepoBase="repo --name=base --baseurl=${LinuxMirror}/${DIST}/os/${VER}/"
|
|
|
- RepoAppStream="repo --name=updates --baseurl=${LinuxMirror}/${DIST}/updates/${VER}/"
|
|
|
- [[ "$IsCN" == "cn" ]] && FirewallRule="https://gitee.com/mb9e8j2/Tools/raw/master/Linux_reinstall/RedHat/RHEL7Public.xml" || FirewallRule="https://raw.githubusercontent.com/leitbogioro/Tools/master/Linux_reinstall/RedHat/RHEL7Public.xml"
|
|
|
- fi
|
|
|
- elif [[ "$linux_relese" == 'fedora' ]]; then
|
|
|
- RedHatUrl="${LinuxMirror}/releases/${DIST}/Server/${VER}/os/"
|
|
|
- RepoBase="repo --name=base --baseurl=${LinuxMirror}/releases/${DIST}/Server/${VER}/os/"
|
|
|
- [[ "$IsCN" == "cn" ]] && RepoAppStream="repo --name=updates --baseurl=http://mirrors.bfsu.edu.cn/fedora/updates/${DIST}/Everything/${VER}/" || RepoAppStream="repo --name=updates --mirrorlist=https://mirrors.fedoraproject.org/mirrorlist?repo=updates-released-f${DIST}&arch=${VER}"
|
|
|
- [[ "$IsCN" == "cn" ]] && RepoEpel="repo --name=epel --baseurl=http://mirrors.163.com/fedora/releases/${DIST}/Everything/${VER}/os/" || RepoEpel="repo --name=epel --mirrorlist=https://mirrors.fedoraproject.org/mirrorlist?repo=fedora-${DIST}&arch=${VER}"
|
|
|
- fi
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
- writeMultipleIpv6Addresses "$i6AddrNum" "" '/etc/NetworkManager/system-connections/'$interface'.nmconnection'
|
|
|
- if [[ "$IPStackType" == "IPv4Stack" ]]; then
|
|
|
- if [[ "$Network4Config" == "isDHCP" ]]; then
|
|
|
- NetConfigManually="network --device=$interface --bootproto=dhcp --ipv6=auto --nameserver=$ipDNS,$ip6DNS --hostname=$(hostname) --onboot=on"
|
|
|
- elif [[ "$Network4Config" == "isStatic" ]]; then
|
|
|
- NetConfigManually="network --device=$interface --bootproto=static --ip=$IPv4 --netmask=$actualIp4Subnet --gateway=$GATE --ipv6=auto --nameserver=$ipDNS,$ip6DNS --hostname=$(hostname) --onboot=on"
|
|
|
- fi
|
|
|
- elif [[ "$IPStackType" == "BiStack" ]]; then
|
|
|
- if [[ "$Network4Config" == "isDHCP" ]] && [[ "$Network6Config" == "isDHCP" ]]; then
|
|
|
- NetConfigManually="network --device=$interface --bootproto=dhcp --ipv6=auto --nameserver=$ipDNS,$ip6DNS --hostname=$(hostname) --onboot=on"
|
|
|
- elif [[ "$Network4Config" == "isDHCP" ]] && [[ "$Network6Config" == "isStatic" ]]; then
|
|
|
- NetConfigManually="network --device=$interface --bootproto=dhcp --ipv6=$ip6Addr/$actualIp6Prefix --ipv6gateway=$ip6Gate --nameserver=$ipDNS,$ip6DNS --hostname=$(hostname) --onboot=on"
|
|
|
- elif [[ "$Network4Config" == "isStatic" ]] && [[ "$Network6Config" == "isDHCP" ]]; then
|
|
|
- NetConfigManually="network --device=$interface --bootproto=static --ip=$IPv4 --netmask=$actualIp4Subnet --gateway=$GATE --ipv6=auto --nameserver=$ipDNS,$ip6DNS --hostname=$(hostname) --onboot=on"
|
|
|
- elif [[ "$Network4Config" == "isStatic" ]] && [[ "$Network6Config" == "isStatic" ]]; then
|
|
|
- NetConfigManually="network --device=$interface --bootproto=static --ip=$IPv4 --netmask=$actualIp4Subnet --gateway=$GATE --ipv6=$ip6Addr/$actualIp6Prefix --ipv6gateway=$ip6Gate --nameserver=$ipDNS,$ip6DNS --hostname=$(hostname) --onboot=on"
|
|
|
- fi
|
|
|
-
|
|
|
- [[ "$i6AddrNum" -ge "2" ]] && NetConfigManually="network --device=$interface --bootproto=static --ip=$IPv4 --netmask=$actualIp4Subnet --gateway=$GATE --nameserver=$ipDNS --hostname=$(hostname) --onboot=on"
|
|
|
- elif [[ "$IPStackType" == "IPv6Stack" ]]; then
|
|
|
- if [[ "$Network6Config" == "isDHCP" ]]; then
|
|
|
- NetConfigManually="network --device=$interface --bootproto=dhcp --ipv6=auto --nameserver=$ip6DNS --hostname=$(hostname) --onboot=on --activate --noipv4"
|
|
|
- elif [[ "$Network6Config" == "isStatic" ]]; then
|
|
|
- NetConfigManually="network --device=$interface --bootproto=dhcp --ipv6=$ip6Addr/$actualIp6Prefix --ipv6gateway=$ip6Gate --nameserver=$ip6DNS --hostname=$(hostname) --onboot=on --activate --noipv4"
|
|
|
- fi
|
|
|
- fi
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
- ksIncDisk=`echo $IncDisk | cut -d'/' -f 3`
|
|
|
- ksAllDisks=`echo $AllDisks | sed 's/\/dev\///g' | sed 's/ /,/g'`
|
|
|
- [[ "$disksNum" -le "1" || "$setDisk" != "all" ]] && {
|
|
|
- clearPart="clearpart --drives=${ksIncDisk} --all --initlabel"
|
|
|
- [[ "$EfiSupport" == "enabled" ]] && FormatDisk=`echo -e "part / --fstype="xfs" --ondisk="$ksIncDisk" --grow --size="0"\npart swap --ondisk="$ksIncDisk" --size="1024"\npart /boot --fstype="xfs" --ondisk="$ksIncDisk" --size="512"\npart /boot/efi --fstype="efi" --ondisk="$ksIncDisk" --size="1024""` || FormatDisk=`echo -e "part / --fstype="xfs" --ondisk="$ksIncDisk" --grow --size="0"\npart swap --ondisk="$ksIncDisk" --size="1024"\npart /boot --fstype="xfs" --ondisk="$ksIncDisk" --size="1024"\npart biosboot --fstype=biosboot --ondisk="$ksIncDisk" --size=1"`
|
|
|
- }
|
|
|
- [[ "$setDisk" == "all" || -n "$setRaid" ]] && {
|
|
|
- clearPart="clearpart --all --initlabel"
|
|
|
- FormatDisk="autopart"
|
|
|
- }
|
|
|
- setRaidRecipe "$setRaid" "$disksNum" "$AllDisks" "$linux_relese"
|
|
|
-if [[ "$setAutoConfig" == "1" ]]; then
|
|
|
- cat >/tmp/boot/ks.cfg<<EOF
|
|
|
-
|
|
|
-
|
|
|
+elif [[ "$linux_relese" == 'centos' ]]; then
|
|
|
+cat >/tmp/boot/ks.cfg<<EOF
|
|
|
+
|
|
|
firewall --enabled --ssh
|
|
|
-
|
|
|
-
|
|
|
-url --url="${RedHatUrl}"
|
|
|
-${RepoBase}
|
|
|
-${RepoAppStream}
|
|
|
-${RepoEpel}
|
|
|
-
|
|
|
-
|
|
|
+install
|
|
|
+url --url="$LinuxMirror/$DIST/os/$VER/"
|
|
|
rootpw --iscrypted $myPASSWORD
|
|
|
-
|
|
|
-
|
|
|
-${AuthMethod}
|
|
|
-
|
|
|
-
|
|
|
+auth --useshadow --passalgo=sha512
|
|
|
firstboot --disable
|
|
|
-
|
|
|
-
|
|
|
lang en_US
|
|
|
-
|
|
|
-
|
|
|
keyboard us
|
|
|
-
|
|
|
-
|
|
|
selinux --disabled
|
|
|
-
|
|
|
-
|
|
|
+logging --level=info
|
|
|
+reboot
|
|
|
text
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
+unsupported_hardware
|
|
|
+vnc
|
|
|
skipx
|
|
|
-
|
|
|
-
|
|
|
-${SetTimeZone}
|
|
|
-
|
|
|
-
|
|
|
-${NetConfigManually}
|
|
|
-
|
|
|
-
|
|
|
-bootloader --location=mbr --boot-drive=${ksIncDisk} --append="rhgb quiet crashkernel=auto net.ifnames=0 biosdevname=0 ipv6.disable=1"
|
|
|
-
|
|
|
-
|
|
|
+timezone --isUtc Asia/Hong_Kong
|
|
|
+
|
|
|
+network --bootproto=static --ip=$IPv4 --netmask=$MASK --gateway=$GATE --nameserver=$ipDNS --onboot=on
|
|
|
+bootloader --location=mbr --append="rhgb quiet crashkernel=auto"
|
|
|
zerombr
|
|
|
-${clearPart}
|
|
|
-
|
|
|
-
|
|
|
-${FormatDisk}
|
|
|
-
|
|
|
-
|
|
|
-reboot
|
|
|
-
|
|
|
-%packages --ignoremissing
|
|
|
-@^minimal-environment
|
|
|
-bind-utils
|
|
|
-curl
|
|
|
-epel-release
|
|
|
-fail2ban
|
|
|
-file
|
|
|
-lrzsz
|
|
|
-net-tools
|
|
|
-traceroute
|
|
|
-vim
|
|
|
-wget
|
|
|
-xz
|
|
|
+clearpart --all --initlabel
|
|
|
+autopart
|
|
|
|
|
|
+%packages
|
|
|
+@base
|
|
|
%end
|
|
|
|
|
|
-
|
|
|
-services --enabled=fail2ban,firewalld
|
|
|
-
|
|
|
-
|
|
|
%post --interpreter=/bin/bash
|
|
|
-
|
|
|
-
|
|
|
-sed -ri "/^#?SELINUX=permissive/c\SELINUX=disabled" /etc/selinux/config
|
|
|
-sed -ri "/^#?SELINUX=enforcing/c\SELINUX=disabled" /etc/selinux/config
|
|
|
-
|
|
|
-
|
|
|
-sed -ri "/^#?PermitRootLogin.*/c\PermitRootLogin yes" /etc/ssh/sshd_config
|
|
|
-sed -ri "/^#?PasswordAuthentication.*/c\PasswordAuthentication yes" /etc/ssh/sshd_config
|
|
|
-
|
|
|
-
|
|
|
-sed -ri "/^#?Port.*/c\Port ${sshPORT}" /etc/ssh/sshd_config
|
|
|
-rm -rf /etc/firewalld/zones/public.xml
|
|
|
-wget --no-check-certificate -qO /etc/firewalld/zones/public.xml '$FirewallRule'
|
|
|
-sed -ri 's/port=""/port="${sshPORT}"/g' /etc/firewalld/zones/public.xml
|
|
|
-firewall-cmd --reload
|
|
|
-
|
|
|
-
|
|
|
-touch /etc/fail2ban/jail.d/local.conf
|
|
|
-echo -ne "[DEFAULT]\nbanaction = firewallcmd-ipset\nbackend = systemd\n\n[sshd]\nenabled = true" > /etc/fail2ban/jail.d/local.conf
|
|
|
-
|
|
|
-
|
|
|
-touch /var/log/fail2ban.log
|
|
|
-sed -i -E 's/^(logtarget =).*/\1 \/var\/log\/fail2ban.log/' /etc/fail2ban/fail2ban.conf
|
|
|
-systemctl enable fail2ban
|
|
|
-
|
|
|
-
|
|
|
-${deleteOriginalIpv6Coning}
|
|
|
-${addIpv6AddrsForRedhat}
|
|
|
-${setIpv6ConfigMethodForRedhat}
|
|
|
-
|
|
|
-
|
|
|
rm -rf /root/anaconda-ks.cfg
|
|
|
rm -rf /root/install.*log
|
|
|
-rm -rf /root/original-ks.cfg
|
|
|
-
|
|
|
%end
|
|
|
|
|
|
EOF
|
|
|
-fi
|
|
|
-
|
|
|
- [[ "$setInterfaceName" == "0" ]] && sed -i 's/ net.ifnames=0 biosdevname=0//g' /tmp/boot/ks.cfg
|
|
|
-
|
|
|
- [[ "$setIPv6" == "1" ]] && sed -i 's/ipv6.disable=1//g' /tmp/boot/ks.cfg
|
|
|
-
|
|
|
- [[ "$UNKNOWHW" == '1' ]] && sed -i 's/^unsupported_hardware/#unsupported_hardware/g' /tmp/boot/ks.cfg
|
|
|
- [[ "$(echo "$DIST" |grep -o '^[0-9]\{1\}')" == '5' ]] && sed -i '0,/^%end/s//#%end/' /tmp/boot/ks.cfg
|
|
|
-fi
|
|
|
|
|
|
-
|
|
|
-rm -rf /boot/initrd.img
|
|
|
-rm -rf /boot/vmlinuz
|
|
|
-find . | cpio -o -H newc | gzip -1 > /tmp/initrd.img
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-if [[ ! -z "$GRUBTYPE" && "$GRUBTYPE" == "isGrub1" ]]; then
|
|
|
- if [[ "$setNetbootXyz" == "0" ]]; then
|
|
|
- READGRUB='/tmp/grub.read'
|
|
|
- [[ -f $READGRUB ]] && rm -rf $READGRUB
|
|
|
- touch $READGRUB
|
|
|
-
|
|
|
- cp $GRUBDIR/$GRUBFILE "$GRUBDIR/$GRUBFILE_$(date "+%Y%m%d%H%M").bak"
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
- cat $GRUBDIR/$GRUBFILE | sed -n '1h;1!H;$g;s/\n/%%%%%%%/g;$p' | grep -aom 1 'menuentry\ [^{].*{.[^}].*}%%%%%%%' | sed 's/%%%%%%%/\n/g' | grep -v '^#' | sed '/^[[:space:]]*$/d' >$READGRUB
|
|
|
- LoadNum="$(cat $READGRUB | grep -c 'menuentry ')"
|
|
|
- if [[ "$LoadNum" -eq '1' ]]; then
|
|
|
- cat $READGRUB | sed '/^$/d' >/tmp/grub.new;
|
|
|
- elif [[ "$LoadNum" -gt '1' ]]; then
|
|
|
- CFG0="$(awk '/menuentry /{print NR}' $READGRUB | head -n 1)";
|
|
|
- CFG2="$(awk '/menuentry /{print NR}' $READGRUB | head -n 2 | tail -n 1)";
|
|
|
- CFG1="";
|
|
|
- for tmpCFG in `awk '/}/{print NR}' $READGRUB`; do
|
|
|
- [ "$tmpCFG" -gt "$CFG0" -a "$tmpCFG" -lt "$CFG2" ] && CFG1="$tmpCFG";
|
|
|
- done
|
|
|
- [[ -z "$CFG1" ]] && {
|
|
|
- echo -ne "\n[${red}Error${plain}] Read $GRUBFILE.\n";
|
|
|
- exit 1;
|
|
|
- }
|
|
|
- sed -n "$CFG0,$CFG1"p $READGRUB >/tmp/grub.new;
|
|
|
- [[ -f /tmp/grub.new ]] && [[ "$(grep -c '{' /tmp/grub.new)" -eq "$(grep -c '}' /tmp/grub.new)" ]] || {
|
|
|
- echo -ne "\n[${red}Error${plain}] Not configure $GRUBFILE.\n";
|
|
|
- exit 1;
|
|
|
- }
|
|
|
- fi
|
|
|
- [ ! -f /tmp/grub.new ] && echo -ne "\n[${red}Error${plain}] $GRUBFILE. " && exit 1;
|
|
|
- sed -i "/menuentry.*/c\menuentry\ \'Install OS \[$Relese\ $DIST\ $VER\]\'\ --class debian\ --class\ gnu-linux\ --class\ gnu\ --class\ os\ \{" /tmp/grub.new
|
|
|
- sed -i "/echo.*Loading/d" /tmp/grub.new;
|
|
|
- INSERTGRUB="$(awk '/menuentry /{print NR}' $GRUBDIR/$GRUBFILE|head -n 1)"
|
|
|
-
|
|
|
- [[ -n "$(grep 'linux.*/\|kernel.*/' /tmp/grub.new |awk '{print $2}' |tail -n 1 |grep '^/boot/')" ]] && Type='InBoot' || Type='NoBoot';
|
|
|
-
|
|
|
- LinuxKernel="$(grep 'linux.*/\|kernel.*/' /tmp/grub.new |awk '{print $1}' |head -n 1)";
|
|
|
- [[ -z "$LinuxKernel" ]] && echo -ne "\n${red}Error${plain} read grub config!\n" && exit 1;
|
|
|
- LinuxIMG="$(grep 'initrd.*/' /tmp/grub.new |awk '{print $1}' |tail -n 1)";
|
|
|
- [ -z "$LinuxIMG" ] && sed -i "/$LinuxKernel.*\//a\\\tinitrd\ \/" /tmp/grub.new && LinuxIMG='initrd';
|
|
|
-
|
|
|
-
|
|
|
- [[ "$setInterfaceName" == "1" ]] && Add_OPTION="$Add_OPTION net.ifnames=0 biosdevname=0" || Add_OPTION="$Add_OPTION"
|
|
|
- [[ "$setIPv6" == "0" ]] && Add_OPTION="$Add_OPTION ipv6.disable=1" || Add_OPTION="$Add_OPTION"
|
|
|
-
|
|
|
- if [[ "$linux_relese" == 'debian' ]] || [[ "$linux_relese" == 'ubuntu' ]] || [[ "$linux_relese" == 'kali' ]]; then
|
|
|
-
|
|
|
-
|
|
|
- BOOT_OPTION="auto=true $Add_OPTION hostname=$(hostname) domain=$linux_relese quiet"
|
|
|
- elif [[ "$linux_relese" == 'alpinelinux' ]]; then
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
- [[ "$Network4Config" == "isStatic" ]] && Add_OPTION="ip=$IPv4::$GATE:$MASK::$interface::$ipDNS:" || Add_OPTION="ip=dhcp"
|
|
|
- BOOT_OPTION="alpine_repo=$LinuxMirror/$DIST/main modloop=$ModLoopUrl $Add_OPTION"
|
|
|
-
|
|
|
-
|
|
|
- elif [[ "$linux_relese" == 'centos' ]] || [[ "$linux_relese" == 'rockylinux' ]] || [[ "$linux_relese" == 'almalinux' ]] || [[ "$linux_relese" == 'fedora' ]]; then
|
|
|
- ipv6ForRedhatGrub
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
- BOOT_OPTION="inst.ks=file://ks.cfg $Add_OPTION inst.nomemcheck quiet $ipv6StaticConfForKsGrub"
|
|
|
- fi
|
|
|
- [[ "$setAutoConfig" == "0" ]] && sed -i 's/inst.ks=file:\/\/ks.cfg//' $GRUBDIR/$GRUBFILE
|
|
|
-
|
|
|
- [ -n "$setConsole" ] && BOOT_OPTION="$BOOT_OPTION --- console=$setConsole"
|
|
|
-
|
|
|
- [[ "$Type" == 'InBoot' ]] && {
|
|
|
- sed -i "/$LinuxKernel.*\//c\\\t$LinuxKernel\\t\/boot\/vmlinuz $BOOT_OPTION" /tmp/grub.new;
|
|
|
- sed -i "/$LinuxIMG.*\//c\\\t$LinuxIMG\\t\/boot\/initrd.img" /tmp/grub.new;
|
|
|
- }
|
|
|
- [[ "$Type" == 'NoBoot' ]] && {
|
|
|
- sed -i "/$LinuxKernel.*\//c\\\t$LinuxKernel\\t\/vmlinuz $BOOT_OPTION" /tmp/grub.new;
|
|
|
- sed -i "/$LinuxIMG.*\//c\\\t$LinuxIMG\\t\/initrd.img" /tmp/grub.new;
|
|
|
- }
|
|
|
|
|
|
- sed -i '$a\\n' /tmp/grub.new;
|
|
|
-
|
|
|
- sed -i ''${INSERTGRUB}'i\\n' $GRUBDIR/$GRUBFILE;
|
|
|
- sed -i ''${INSERTGRUB}'r /tmp/grub.new' $GRUBDIR/$GRUBFILE;
|
|
|
- [[ -f $GRUBDIR/grubenv ]] && sed -i 's/saved_entry/#saved_entry/g' $GRUBDIR/grubenv;
|
|
|
-
|
|
|
- elif [[ "$setNetbootXyz" == "1" ]]; then
|
|
|
- grub-mkconfig -o $GRUBDIR/$GRUBFILE >>/dev/null 2>&1
|
|
|
- grub-set-default "Bootable ISO Image: netboot.xyz" >>/dev/null 2>&1
|
|
|
- grub-reboot "Bootable ISO Image: netboot.xyz" >>/dev/null 2>&1
|
|
|
- fi
|
|
|
-elif [[ ! -z "$GRUBTYPE" && "$GRUBTYPE" == "isGrub2" ]]; then
|
|
|
- if [[ "$setNetbootXyz" == "0" ]]; then
|
|
|
-
|
|
|
-
|
|
|
- if [[ -f /boot/grub2/grubenv ]] && [[ -d /boot/loader/entries ]] && [[ "$(ls /boot/loader/entries | wc -w)" != "" ]]; then
|
|
|
- LoaderPath=$(cat /boot/grub2/grubenv | grep 'saved_entry=' | awk -F '=' '{print $2}')
|
|
|
- LpLength=`echo ${#LoaderPath}`
|
|
|
- LpFile="/boot/loader/entries/$LoaderPath.conf"
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
- if [[ "$LpLength" -le "1" ]] || [[ ! -f "$LpFile" ]]; then
|
|
|
- LpFile=`ls -Sl /boot/loader/entries/ | grep -wv "*rescue*" | awk -F' ' '{print $NF}' | sed -n '2p'`
|
|
|
- [[ "$(cat /boot/loader/entries/$LpFile | grep '^linux /boot/')" ]] && BootDIR='/boot' || BootDIR=''
|
|
|
- else
|
|
|
- [[ "$(cat $LpFile | grep '^linux /boot/')" ]] && BootDIR='/boot' || BootDIR=''
|
|
|
- fi
|
|
|
- else
|
|
|
- [[ -n "$(grep 'linux.*/\|kernel.*/' $GRUBDIR/$GRUBFILE | awk '{print $2}' | tail -n 1 | grep '^/boot/')" ]] && BootDIR='/boot' || BootDIR=''
|
|
|
- fi
|
|
|
-
|
|
|
- if [[ "$VER" == "x86_64" || "$VER" == "amd64" ]]; then
|
|
|
- [[ "$EfiSupport" == "enabled" ]] && BootHex="efi" || BootHex="16"
|
|
|
-
|
|
|
- elif [[ "$VER" == "aarch64" || "$VER" == "arm64" ]]; then
|
|
|
- BootHex=""
|
|
|
- fi
|
|
|
-
|
|
|
- CFG0="$(awk '/insmod part_/{print NR}' $GRUBDIR/$GRUBFILE|head -n 1)"
|
|
|
- CFG2tmp="$(awk '/--fs-uuid --set=root/{print NR}' $GRUBDIR/$GRUBFILE|head -n 2|tail -n 1)"
|
|
|
- CFG2=`expr $CFG2tmp + 1`
|
|
|
- CFG1=""
|
|
|
- for tmpCFG in `awk '/fi/{print NR}' $GRUBDIR/$GRUBFILE`; do
|
|
|
- [ "$tmpCFG" -ge "$CFG0" -a "$tmpCFG" -le "$CFG2" ] && CFG1="$tmpCFG"
|
|
|
- done
|
|
|
- if [[ -z "$CFG1" ]]; then
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
- SetRootCfg="$(awk '/--fs-uuid --set=root/{print NR}' $GRUBDIR/$GRUBFILE | head -n 2 | tail -n 1)"
|
|
|
- [[ "$SetRootCfg" == "" ]] && SetRootCfg="$(awk '/set root='\''hd[0-9]/{print NR}' /boot/grub2/grub.cfg | head -n 2 | tail -n 1)"
|
|
|
-
|
|
|
- InsmodPartArray=()
|
|
|
-
|
|
|
- IpaSpace=()
|
|
|
-
|
|
|
-
|
|
|
- for tmpCFG in `awk '/insmod part_/{print NR}' $GRUBDIR/$GRUBFILE`; do
|
|
|
- InsmodPartArray+=("$tmpCFG" "$InsmodPartArray")
|
|
|
-
|
|
|
- [[ `expr $SetRootCfg - $tmpCFG` -gt "0" ]] && IpaSpace+=(`expr "$SetRootCfg" - "$tmpCFG"` "$IpaSpace")
|
|
|
- done
|
|
|
-
|
|
|
- minArray=${IpaSpace[0]}
|
|
|
-
|
|
|
- for ((i=1;i<=`grep -io "insmod part_*" $GRUBDIR/$GRUBFILE | wc -l`;i++)); do
|
|
|
-
|
|
|
- for j in ${IpaSpace[@]}; do
|
|
|
-
|
|
|
-
|
|
|
- [[ $minArray -gt $j ]] && minArray=$j
|
|
|
- done
|
|
|
- done
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
- CFG0=`expr $SetRootCfg - $minArray`
|
|
|
- CFG1="$SetRootCfg"
|
|
|
- fi
|
|
|
- [[ -z "$CFG0" || -z "$CFG1" ]] && {
|
|
|
- echo -ne "\n[${red}Error${plain}] Read $GRUBFILE.\n"
|
|
|
- exit 1
|
|
|
- }
|
|
|
- sed -n "$CFG0,$CFG1"p $GRUBDIR/$GRUBFILE >/tmp/grub.new
|
|
|
- sed -i -e 's/^/ /' /tmp/grub.new
|
|
|
- [[ -f /tmp/grub.new ]] && [[ "$(grep -c '{' /tmp/grub.new)" -eq "$(grep -c '}' /tmp/grub.new)" ]] || {
|
|
|
- echo -ne "\n[${red}Error${plain}] Not configure $GRUBFILE. \n"
|
|
|
- exit 1
|
|
|
- }
|
|
|
- [ ! -f /tmp/grub.new ] && echo -ne "\n[${red}Error${plain}] $GRUBFILE.\n" && exit 1
|
|
|
-
|
|
|
- [[ "$setInterfaceName" == "1" ]] && Add_OPTION="net.ifnames=0 biosdevname=0" || Add_OPTION=""
|
|
|
- [[ "$setIPv6" == "0" ]] && Add_OPTION="$Add_OPTION ipv6.disable=1" || Add_OPTION="$Add_OPTION"
|
|
|
-
|
|
|
- if [[ "$linux_relese" == 'ubuntu' || "$linux_relese" == 'debian' || "$linux_relese" == 'kali' ]]; then
|
|
|
- BOOT_OPTION="auto=true $Add_OPTION hostname=$(hostname) domain=$linux_relese quiet"
|
|
|
- elif [[ "$linux_relese" == 'alpinelinux' ]]; then
|
|
|
- [[ "$Network4Config" == "isStatic" ]] && Add_OPTION="ip=$IPv4::$GATE:$MASK::$interface::$ipDNS:" || Add_OPTION="ip=dhcp"
|
|
|
- BOOT_OPTION="alpine_repo=$LinuxMirror/$DIST/main modloop=$ModLoopUrl $Add_OPTION"
|
|
|
- elif [[ "$linux_relese" == 'centos' ]] || [[ "$linux_relese" == 'rockylinux' ]] || [[ "$linux_relese" == 'almalinux' ]] || [[ "$linux_relese" == 'fedora' ]]; then
|
|
|
- ipv6ForRedhatGrub
|
|
|
- BOOT_OPTION="inst.ks=file://ks.cfg $Add_OPTION inst.nomemcheck quiet $ipv6StaticConfForKsGrub"
|
|
|
- fi
|
|
|
- [[ "$setAutoConfig" == "0" ]] && sed -i 's/inst.ks=file:\/\/ks.cfg//' $GRUBDIR/$GRUBFILE
|
|
|
- cat >> /etc/grub.d/40_custom <<EOF
|
|
|
-menuentry 'Install $Relese $DIST $VER' --class $linux_relese --class gnu-linux --class gnu --class os {
|
|
|
- load_video
|
|
|
- set gfxpayload=text
|
|
|
- insmod gzio
|
|
|
-$(cat /tmp/grub.new)
|
|
|
- linux$BootHex $BootDIR/vmlinuz $BOOT_OPTION
|
|
|
- initrd$BootHex $BootDIR/initrd.img
|
|
|
-}
|
|
|
-EOF
|
|
|
-
|
|
|
- sed -ri 's/GRUB_DEFAULT=0/GRUB_DEFAULT=saved/g' /etc/default/grub
|
|
|
-
|
|
|
- grub2-mkconfig -o $GRUBDIR/$GRUBFILE >>/dev/null 2>&1
|
|
|
- grub2-set-default "Install $Relese $DIST $VER" >>/dev/null 2>&1
|
|
|
- grub2-reboot "Install $Relese $DIST $VER" >>/dev/null 2>&1
|
|
|
-
|
|
|
- elif [[ "$setNetbootXyz" == "1" ]]; then
|
|
|
- grub2-mkconfig -o $GRUBDIR/$GRUBFILE >>/dev/null 2>&1
|
|
|
- grub2-set-default "Bootable ISO Image: netboot.xyz" >>/dev/null 2>&1
|
|
|
- grub2-reboot "Bootable ISO Image: netboot.xyz" >>/dev/null 2>&1
|
|
|
- fi
|
|
|
+[[ "$UNKNOWHW" == '1' ]] && sed -i 's/^unsupported_hardware/#unsupported_hardware/g' /tmp/boot/ks.cfg
|
|
|
+[[ "$(echo "$DIST" |grep -o '^[0-9]\{1\}')" == '5' ]] && sed -i '0,/^%end/s//#%end/' /tmp/boot/ks.cfg
|
|
|
fi
|
|
|
-
|
|
|
+
|
|
|
+find . | cpio -H newc --create --verbose | gzip -9 > /tmp/initrd.img;
|
|
|
+cp -f /tmp/initrd.img /boot/initrd.img || sudo cp -f /tmp/initrd.img /boot/initrd.img
|
|
|
+cp -f /tmp/vmlinuz /boot/vmlinuz || sudo cp -f /tmp/vmlinuz /boot/vmlinuz
|
|
|
+
|
|
|
+chown root:root $GRUBDIR/$GRUBFILE
|
|
|
+chmod 444 $GRUBDIR/$GRUBFILE
|
|
|
|
|
|
if [[ "$loaderMode" == "0" ]]; then
|
|
|
-
|
|
|
- cp -f /tmp/initrd.img /boot/initrd.img || sudo cp -f /tmp/initrd.img /boot/initrd.img
|
|
|
- cp -f /tmp/vmlinuz /boot/vmlinuz || sudo cp -f /tmp/vmlinuz /boot/vmlinuz
|
|
|
- chown root:root $GRUBDIR/$GRUBFILE
|
|
|
- chmod 444 $GRUBDIR/$GRUBFILE
|
|
|
+ sleep 3 && reboot || sudo reboot >/dev/null 2>&1
|
|
|
else
|
|
|
rm -rf "$HOME/loader"
|
|
|
mkdir -p "$HOME/loader"
|
|
|
- cp -rf "/tmp/initrd.img" "$HOME/loader/initrd.img"
|
|
|
- cp -rf "/tmp/vmlinuz" "$HOME/loader/vmlinuz"
|
|
|
- [[ -f "/tmp/initrd.img" ]] && rm -rf "/tmp/initrd.img"
|
|
|
- [[ -f "/tmp/vmlinuz" ]] && rm -rf "/tmp/vmlinuz"
|
|
|
+ cp -rf "/boot/initrd.img" "$HOME/loader/initrd.img"
|
|
|
+ cp -rf "/boot/vmlinuz" "$HOME/loader/vmlinuz"
|
|
|
+ [[ -f "/boot/initrd.img" ]] && rm -rf "/boot/initrd.img"
|
|
|
+ [[ -f "/boot/vmlinuz" ]] && rm -rf "/boot/vmlinuz"
|
|
|
echo && ls -AR1 "$HOME/loader"
|
|
|
fi
|
|
|
|
|
|
-echo -ne "\n[${green}Finish${plain}] Input '${yellow}reboot${plain}' to continue the subsequential installation.\n"
|
|
|
-exit 1
|