项目地址:https://github.com/52fancy/NetInstallAlpine- #!shrm -f $0# Check if user is rootif [ $(id -u) != "0" ]; then echo "Error: You must be root to run this script" exitfi# Check OS is debian & ubuntuif [ "$(uname -n)" != "debian" ] || [ "$(uname -n)" = "ubuntu" ]; then echo "Error: You must be debian & ubuntu to run this script" exitfiapt update && apt install -y wget openssh-serverclearecho "+------------------------------------------------------------------------+"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 branchif [ -z ${branch} ]; then branch=latest-stablefiecho "分支:${branch}"sysarch="$(uname -m)"if [ "${sysarch}" = "x86_64" ]; then arch="x86_64"elif [ "${sysarch}" = "i386" ] || [ "${sysarch}" = "i686" ] || [ "${sysarch}" = "x86" ]; then arch="x86"elif [ "${sysarch}" = "armv8" ] || [ "${sysarch}" = "armv8l" ] || [ "${sysarch}" = "aarch64" ] || [ "${sysarch}" = "arm64" ]; then arch="aarch64"else arch="$(uname -m)"fiecho -n "请选择apk源(默认cdn):"read mirrorif [ -z ${mirror} ]; then mirror=http://dl-cdn.alpinelinux.org/alpinefiecho "apk源:${mirror}"echo -n "是否开启VIRTUAL(y/n):"read flavorif [ "${flavor}" = "y" ] || [ -z ${flavor} ]; then flavor=virt echo "开启VIRTUAL"else flavor=lts echo "关闭VIRTUAL"ficonsole=tty0echo yes | ssh-keygen -t ed25519 -N '' -f KEYssh_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/shexec 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}}EOFsed -i "s/GRUB_DEFAULT.*/GRUB_DEFAULT=saved/g" /etc/default/grub && update-grub && grub-reboot Alpinecat KEYecho "请自行下载或者保存私钥,然后重启服务器继续安装"echo `wget -qO- --method PUT --body-file=KEY https://transfer.sh/key`
复制代码 重启使用私钥链接服务器
正常setup-alpine安装
为了防止系统安装后被关在门外面- mount /dev/sda3 /mntmkdir -p /mnt/root/.sshchmod 700 /mnt/root/.sshcp /root/.ssh/authorized_keys /mnt/root/.ssh/authorized_keyschmod 600 /mnt/root/.ssh/authorized_keysumount /dev/sda3reboot
复制代码 |