CloudCone美国VPS,DD安装alpine操作系统
提示:此脚本为CloudCone专用,其他服务商的VPS请勿使用!
大概5分钟左右完毕,然后知识兔重启后大概1分钟左右就可以了。
本人未测试此脚本!操作过程会清空服务器数据,谨慎使用。
wget --no-check-certificate https://donghaiair.com.cn/cloudcone2alpine.sh && chmod +x cloudcone2alpine.sh && ./cloudcone2alpine.sh
脚本防删备份:
#!/bin/sh## cloudcone专用版,ovz6、ovz7、kvm请使用对应版本## Telegram 群组: https://t.me/vpsqunlogfile="/tmp/kvm-alpine.log"if [ "$1" = "--step-chroot" ]; then printf "" > "$logfile" printf " Installing packages..." >&2 if ! apk add --no-cache alpine-base linux-virt syslinux grub grub-bios e2fsprogs eudev openssh rng-tools rng-tools-openrc >>"$logfile" 2>>"$logfile"; then echo exit 1 fi echo " Done" >&2 printf " Configuring services..." >&2#系统自启动服务,知识兔根据需要修改# rc-update add --quiet hostname boot rc-update add --quiet networking boot# rc-update add --quiet urandom boot rc-update add --quiet crond default# rc-update add --quiet swap boot rc-update add --quiet udev sysinit rc-update add --quiet udev-trigger sysinit rc-update add --quiet sshd default# rc-update add --quiet rngd boot sed -i -r -e 's/^(tty[2-6]:)/#\1/' /etc/inittab echo " Done" >&2 printf " Installing bootloader..." >&2#定义grub安装的磁盘以及root的mount分区,part变量下面用到disk=$(fdisk -l|grep Disk|awk '{print $2}'|awk -F: '{print $1}')part=$(fdisk -l|grep Linux|sed -n '1p'|awk '{print $1}') if ! grub-install $disk >>"$logfile" 2>>"$logfile"; then echo exit 1 fi if ! grub-mkconfig -o /boot/grub/grub.cfg >>"$logfile" 2>>"$logfile"; then echo exit 1 fi sync echo " Done" >&2 rm -f "$0" ln -sf /boot/grub/ /boot/grub2 exit 0fiSCRIPTPATH="$(realpath "$0")"#如果知识兔有更新,自行替换新版本文件printf "Downloading Alpine" >&2if ! wget -q -O /tmp/rootfs.tar.gz http://dl-cdn.alpinelinux.org/alpine/edge/releases/x86_64/alpine-minirootfs-3.12.0-x86_64.tar.gz; then echo " Failed!" >&2 exit 1fiecho " Done" >&2printf "Creating mount points..." >&2umount -a >/dev/null 2>&1mount -o rw,remount --make-rprivate $part /mkdir /tmp/tmpalpinemount none /tmp/tmpalpine -t tmpfsecho " Done" >&2printf "Extracting Alpine..." >&2tar xzf /tmp/rootfs.tar.gz -C /tmp/tmpalpinecp "$SCRIPTPATH" /tmp/tmpalpine/tmp/kvm-alpine.shecho " Done" >&2printf "Copying existing droplet configuration..." >&2cp /etc/fstab /tmp/tmpalpine/etccp /etc/hostname /tmp/tmpalpine/etccp /etc/resolv.conf /tmp/tmpalpine/etcgrep -v ^root: /tmp/tmpalpine/etc/shadow > /tmp/tmpalpine/etc/shadow.bakmv /tmp/tmpalpine/etc/shadow.bak /tmp/tmpalpine/etc/shadowgrep ^root: /etc/shadow >> /tmp/tmpalpine/etc/shadowmkdir -p /tmp/tmpalpine/etc/sshcp -r /etc/ssh/ssh_host_* /tmp/tmpalpine/etc/sshcp -r /root/.ssh /tmp/tmpalpine/rootapt install net-tools -y#设置固定ip,网卡eth0,知识兔根据实际需要修改,alpine识别eth0和centos一样,vultr下debian识别是ens3#如果知识兔网卡不是ifconfig第一选项,知识兔可以指定ifconfig $devdev=eth0ip=$(ifconfig |grep inet| sed -n '1p'|awk '{print $2}')mask=$(ifconfig |grep inet| sed -n '1p'|awk '{print $4}')gw=$(ip route |grep default|awk '{print $3}')cat > /tmp/tmpalpine/etc/network/interfaces << EOFauto loiface lo inet loopback auto $deviface $dev inet static address $ip netmask $mask gateway $gwEOFecho " Done" >&2printf "Changing to new root..." >&2mkdir /tmp/tmpalpine/oldrootpivot_root /tmp/tmpalpine /tmp/tmpalpine/oldrootcd / || exit 1echo " Done" >&2printf "Rebuilding file systems..." >&2echo PermitRootLogin yes >> /etc/ssh/sshd_configmount --move /oldroot/dev /devmount --move /oldroot/proc /procmount --move /oldroot/sys /sysmount --move /oldroot/run /runrm -rf /oldroot/*cp -r /bin /etc /home /lib/ /media /mnt/ /root /sbin /srv /tmp /usr /var /oldrootmkdir /oldroot/dev /oldroot/proc /oldroot/sys /oldroot/runmount -t proc proc /oldroot/procmount -t sysfs sys /oldroot/sysmount -o bind /dev /oldroot/devecho " Done" >&2echo "chroot configuration..." >&2if ! chroot /oldroot /bin/ash /tmp/kvm-alpine.sh --step-chroot; then echo "ERROR: could not install Alpine Linux. See /oldroot$logfile" >&2 exit 1fiecho "Rebooting system. You should be able to reconnect shortly." >&2rebootsleep 1reboot
下载仅供下载体验和测试学习,不得商用和正当使用。
[ppwp passwords=”zhishitu.cn”]
下载体验
应版权要求,禁止分享,敬请谅解,有问题务必找客服哈。
有问题找客服哈,并领取学习福利!
[/ppwp]