- #!sh
-
- rm -f $0
-
- # Check if user is root
- if [ $(id -u) != "0" ]; then
- echo "Error: You must be root to run this script"
- exit
- fi
-
- clear
- echo "+————————————————————————+"
- echo "| ALpine |"
- echo "+————————————————————————+"
- echo "| A tool to auto-compile & install Alpine |"
- echo "+————————————————————————+"
- echo "| Welcome to https://github.com/52Fancy |"
- echo "+————————————————————————+"
-
- echo -n "请选择安装版本(默认latest-stable):"
- read branch
- if [ -z $branch ]
- then
- branch=latest-stable
- fi
-
- apt install -y wget
-
- flavor=virt
- mirror=http://mirrors.ustc.edu.cn/alpine
- arch=x86_64
- console=tty0
- echo yes | ssh-keygen -t ed25519 -N ” -f KEY
- ssh_key=`wget -qO- –method PUT –body-file=KEY.pub https://transfer.sh/key.pub`
-
- wget –no-check-certificate ${mirror}/${branch}/releases/${arch}/netboot/vmlinuz-${flavor} -O /boot/vmlinuz-${flavor}
- wget –no-check-certificate ${mirror}/${branch}/releases/${arch}/netboot/initramfs-${flavor} -O /boot/initramfs-${flavor}
-
- cat > /etc/grub.d/40_custom << EOF
- #!/bin/sh
- exec tail -n +3 $0
- # This file provides an easy way to add custom menu entries. Simply type the
- # menu entries you want to add after this comment. Be careful not to change
- # the ‘exec tail’ line above.
- menuentry ‘Alpine’ {
- linux /boot/vmlinuz-${flavor} alpine_repo="${mirror}/${branch}/main" modloop="${mirror}/${branch}/releases/${arch}/netboot/modloop-${flavor}" modules="loop,squashfs" initrd="initramfs-${flavor}" console="${console}" ssh_key="${ssh_key}"
- initrd /boot/initramfs-${flavor}
- }
- EOF
-
- sed -i "s/GRUB_DEFAULT.*/GRUB_DEFAULT=saved/g" /etc/default/grub && update-grub && grub-reboot Alpine
- cat KEY
- echo "请自行下载或者保存私钥,然后重启服务器继续安装"
- echo `wget -qO- –method PUT –body-file=KEY https://transfer.sh/key`
复制代码
|