Updated VPS installer to drop DHCP and generate routes during install
This commit is contained in:
parent
86626f254d
commit
8e3fdce02a
2
setup
2
setup
|
@ -65,7 +65,7 @@ setup_root() {
|
|||
printf "AuthenticationMethods publickey\nBanner /etc/issue\nClientAliveInterval 0\nDisableForwarding yes\nPermitRootLogin no\nPort CHANGEME\nPrintLastLog no\n" > /etc/ssh/sshd_config
|
||||
elif [ $REMOTE_ACCESS = "dropbear" ]; then
|
||||
xbps-install -y dropbear
|
||||
printf '#!/bin/sh\nexec 2>&1\n[ -r conf ] && . ./conf\nexec dropbear -p CHANGE:ME -w -s -R -F}\n' > /etc/sv/dropbear/run
|
||||
printf '#!/bin/sh\nexec 2>&1\n[ -r conf ] && . ./conf\nexec dropbear -p CHANGE:ME -w -s -R -F\n' > /etc/sv/dropbear/run
|
||||
ln -sf /etc/sv/dropbear /var/service/
|
||||
fi
|
||||
|
||||
|
|
51
vps
51
vps
|
@ -3,11 +3,13 @@
|
|||
|
||||
set -xev
|
||||
|
||||
# Configuration
|
||||
ARCH=x86_64-musl # x86_64 or x86_64-musl
|
||||
DRIVE=/dev/vda
|
||||
HOSTNAME=blackhole
|
||||
TIMEZONE="America/New_York"
|
||||
SSH_PORT=22 # Change me
|
||||
SWAP_SIZE=4 # In GB (set to 0 to disable)
|
||||
TIMEZONE="America/New_York"
|
||||
USERNAME=acidvegas
|
||||
|
||||
setup_root() {
|
||||
|
@ -23,24 +25,55 @@ setup_root() {
|
|||
cp /var/db/xbps/keys/* /mnt/var/db/xbps/keys/
|
||||
REPO=https://repo-default.voidlinux.org/current
|
||||
[ $ARCH = 'x86_64-musl' ] && REPO=$REPO/musl
|
||||
XBPS_ARCH=$ARCH xbps-install -S -r /mnt -R "$REPO" base-system linux nano wget
|
||||
XBPS_ARCH=$ARCH xbps-install -S -r /mnt -R "$REPO" base-system linux
|
||||
cp vps /mnt/root/
|
||||
xchroot /mnt /bin/bash
|
||||
}
|
||||
|
||||
setup_chroot() {
|
||||
passwd
|
||||
|
||||
xbps-install -u xbps
|
||||
xbps-install -Su
|
||||
xbps-remove base-system openssh
|
||||
xbps-install curl dropbear git nano net-tools termux socklog-void wget
|
||||
|
||||
IP_ADDR=$(ip addr show eth0 | grep 'inet ' | awk '{print $2}' | cut -d'/' -f1)
|
||||
GATEWAY=$(ip route show default | awk '/default/ {print $3}')
|
||||
printf "ip link set eth0 up\nip addr add ${IP_ADDR}/24 dev eth0\nip route add default via $GATEWAY" > /etc/rc.local
|
||||
printf "nameserver 208.67.222.222\nnameserver 208.67.220.220\nnameserver 2620:119:35::35\nnameserver 2620:119:53::53\n" > /etc/resolv.conf
|
||||
|
||||
>/var/log/lastlog && chattr +i /var/log/lastlog
|
||||
|
||||
printf '#!/bin/sh\nexec 2>&1\n[ -r conf ] && . ./conf\nexec dropbear -p $SSH_PORT -R -m -w -t -T 1 -R\n' > /etc/sv/dropbear/run
|
||||
printf "\nexport HISTFILE=/dev/null\nexport LESSHISTFILE=/dev/null\nexport PYTHONHISTFILE=/dev/null\n" >> /etc/profile
|
||||
printf "set boldtext\nset minibar\nset nohelp\nset nowrap\nset quickblank\nset tabsize 4\nunbind ^J main\nset selectedcolor black,red\ninclude \"/usr/share/nano/*.nanorc\"\n" > /etc/nanorc
|
||||
echo "hsts=0" >> /etc/wgetrc
|
||||
#printf "Defaults lecture = always\nDefaults lecture_file = /etc/sudoers.d/sudoers.lecture\nroot ALL=(ALL) ALL\n%%wheel ALL=(ALL) ALL\n" > /etc/sudoers
|
||||
#printf "\n\033[1m \033[32m\"Bee\" careful \033[34m__\n \033[32mwith sudo! \033[34m// \ \n \\\\\\_/ \033[33m//\n \033[35m''-.._.-''-.._.. \033[33m-(||)(')\n '''\033[0m\n" > /etc/sudoers.d/sudoers.lecture
|
||||
|
||||
echo "proc /proc proc defaults,hidepid=2 0 0" >> /etc/fstab
|
||||
mount -o remount /proc
|
||||
|
||||
ln -sfv /etc/sv/socklog-unix /var/service
|
||||
ln -sfv /etc/sv/nanoklogd /var/service
|
||||
ln -sfv /etc/sv/dropbear /var/service/
|
||||
ln -sfv /usr/share/zoneinfo/$TIMEZONE /etc/localtime
|
||||
|
||||
hwclock --systohc
|
||||
|
||||
useradd -m -s /bin/bash $USERNAME && passwd $USERNAME
|
||||
ln -sf /usr/share/zoneinfo/$TIMEZONE /etc/localtime && hwclock --systohc
|
||||
ln -sf /etc/sv/dhcpcd /etc/runit/runsvdir/default/
|
||||
cp vps /home/$USERNAME/ && chown $USERNAME:$USERNAME /home/$USERNAME/vps
|
||||
|
||||
if [ ! $ARCH = 'x86_64-musl' ]; then
|
||||
echo "en_US.UTF-8 UTF-8" > /etc/default/libc-locales
|
||||
echo "LANG=en_US.UTF-8" > /etc/locale.conf
|
||||
xbps-reconfigure -f glibc-locales
|
||||
fi
|
||||
echo "$HOSTNAME" > /etc/hostname
|
||||
|
||||
echo "UUID=$(blkid -s UUID -o value ${DRIVE}1) / ext4 rw,errors=remount-ro,noatime 0 1" > /etc/fstab
|
||||
|
||||
touch /swapfile
|
||||
dd if=/dev/zero of=/swapfile bs=1M count=$SWAP_SIZE status=progress
|
||||
chmod 0600 /swapfile
|
||||
|
@ -49,7 +82,15 @@ setup_chroot() {
|
|||
xbps-install -Sy grub
|
||||
grub-install $DRIVE
|
||||
grub-mkconfig -o /boot/grub/grub.cfg
|
||||
echo "exit and run umount /mnt && reboot"
|
||||
|
||||
xbps-reconfigure -fa
|
||||
}
|
||||
|
||||
setup_user() {
|
||||
mkdir -p $HOME/.ssh
|
||||
printf "ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIBgw6zK6LghGq/6fdMGFKfH9fr+qCOASlD+Xi7Zoe7Ps acidvegas@blackhole" > $HOME/.ssh/authorized_keys
|
||||
chmod 700 $HOME/.ssh && chown -R $USER $HOME/.ssh
|
||||
chmod 400 $HOME/.ssh/authorized_keys && chattr +i $HOME/.ssh/authorized_keys && chattr +i $HOME/.ssh
|
||||
}
|
||||
|
||||
[ $1 = "root" ] && setup_root
|
||||
|
|
Loading…
Reference in New Issue