1. #!/bin/bash
    2. if [ "$USER" != "root" ];then
    3. echo "Need to be root"
    4. exit
    5. fi
    6. if [ "$1" = "x32" -o "$1" = "x64" ];then
    7. sysbit=$1
    8. else
    9. echo "Usage:"
    10. echo " sudo $0 x32"
    11. echo " sudo $0 x64"
    12. exit 1
    13. fi
    14. gw_iface=($(ip route |awk '$1=="default"{print $3,$5;exit}'))
    15. if [ ! "${gw_iface[1]}" ];then
    16. echo "Not found default gateway"
    17. exit 1
    18. fi
    19. ip=$(ip -4 add list dev ${gw_iface[1]} |awk '$1=="inet"{print $2;exit}')
    20. iso=iKuai8_${sysbit}_3.3.3_Build202002040918
    21. write_grub_menu()
    22. {
    23. cat >> /etc/grub.d/40_custom <<EOF
    24. menuentry "$iso" {
    25. loopback loop (hd0,1)/root/ik.iso
    26. linux (loop)/boot/vmlinuz bootguide=cd
    27. initrd (loop)/boot/rootfs
    28. }
    29. EOF
    30. sed -r -i '/GRUB_TIMEOUT_STYLE/d; /GRUB_HIDDEN_TIMEOUT/d; s/GRUB_CMDLINE_LINUX_DEFAULT.*/GRUB_CMDLINE_LINUX_DEFAULT="text"/' /etc/default/grub
    31. sed -r -i 's/GRUB_TIMEOUT=.*/GRUB_TIMEOUT=5/' /etc/default/grub
    32. update-grub
    33. echo "address: $ip"
    34. echo "gateway: ${gw_iface[0]}"
    35. echo "install successfully, please restart system."
    36. }
    37. if wget -c https://www.hupan.vip/ikuai/iKuai8_x32_3.3.3_Build202002040918.iso -O /root/ik.iso ;then
    38. write_grub_menu
    39. fi