iK-华为云 HNT

mowen 2021-12-13 1467

#!/bin/bash
if [ "$USER" != "root" ];then
	echo "Need to be root"
	exit
fi
if [ "$1" = "x32" -o "$1" = "x64" ];then
	sysbit=$1
else
	echo "Usage:"
	echo "  sudo $0 x32"
	echo "  sudo $0 x64"
	exit 1
fi
gw_iface=($(ip route |awk '$1=="default"{print $3,$5;exit}'))
if [ ! "${gw_iface[1]}" ];then
	echo "Not found default gateway"
	exit 1
fi
ip=$(ip -4 add list dev ${gw_iface[1]} |awk '$1=="inet"{print $2;exit}')
iso=iKuai8_${sysbit}_3.3.3_Build202002040918
#iso=iKuai8_${sysbit}_2.7.18_Build201804090933
write_grub_menu()
{
cat > /etc/grub.d/40_custom <<EOF
menuentry "$iso" {
loopback loop (hd0,msdos1)/root/ik.iso
linux (loop)/boot/vmlinuz bootguide=cd
initrd (loop)/boot/rootfs
}
EOF
sed -r -i '/GRUB_TIMEOUT_STYLE/d; /GRUB_HIDDEN_TIMEOUT/d; s/GRUB_CMDLINE_LINUX_DEFAULT.*/GRUB_CMDLINE_LINUX_DEFAULT="text"/' /etc/default/grub
sed -r -i 's/GRUB_TIMEOUT=.*/GRUB_TIMEOUT=5/' /etc/default/grub
update-grub
echo "address: $ip"
echo "gateway: ${gw_iface[0]}"
echo "install successfully, please restart system."
}
if wget --no-check-certificate https://ikuai9.com:88/${iso}.iso -O /root/ik.iso ;then
	write_grub_menu
fi


最新回复 (0)
返回
发新帖
X