Last active
August 29, 2015 14:14
-
-
Save Duncaen/0cb1d3818c9483a3e2a8 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/sh | |
TARGETDIR=/mnt/target | |
TARGET_FSTAB=$(mktemp -t vinstall-fstab-XXXXXXXX || exit 1) | |
KEYMAP=de-latin1 | |
LOCALE=de_DE.UTF-8 | |
TIMEZONE=Europe/Berlin | |
HOSTNAME=void | |
ROOTPASSWORD=voidlinux | |
# xbps-install -Suy | |
xbps-install -y gpt-fdisk | |
sgdisk --clear | |
sgdisk --new 1:+2M | |
sgdisk --new 2:+2M:+10G | |
sgdisk --new 3:+10G:+5G | |
sgdisk --randomize-guids | |
modprobe ext4 | |
mke2fs -F -t ext4 /dev/vda2 | |
mkswap /dev/vda3 | |
uuid=$(blkid -o value -s UUID "$dev") | |
echo "UUID=$uuid none swap sw 0 0" >> $TARGET_FSTAB | |
mount -t ext4 /dev/vda2 $TARGETDIR | |
swapon /dev/vda3 | |
uuid=$(blkid -o value -s UUID "$dev") | |
echo "UUID=$uuid $mntpt $fstype defaults 0 fspassno=1" >>$TARGET_FSTAB | |
mount --bind /sys $TARGETDIR/sys | |
mount --bind /proc $TARGETDIR/proc | |
mount --bind /dev $TARGETDIR/dev | |
mkdir -p $TARGETDIR/var/db/xbps/keys $TARGETDIR/usr/share/xbps | |
cp -a /usr/share/xbps/repo.d $TARGETDIR/usr/share/xbps/ | |
cp /var/db/xbps/keys/*.plist $TARGETDIR/var/db/xbps/keys | |
mkdir -p $TARGETDIR/boot/grub | |
xbps-install -r $TARGETDIR -Sy base-system grub | |
install -Dm644 $TARGET_FSTAB $TARGETDIR/etc/fstab | |
echo "tmpfs /tmp tmpfs defaults,nosuid,nodev 0 0" >> $TARGETDIR/etc/fstab | |
# setup keymap | |
sed -i -e "s|KEYMAP=.*|KEYMAP=$KEYMAP|g" $TARGETDIR/etc/rc.conf | |
# setup locale | |
sed -i -e "s|LANG=.*|LANG=$LOCALE|g" $TARGETDIR/etc/locale.conf | |
sed -e "/${LOCALE}/s/^\#//" -i $TARGETDIR/etc/default/libc-locales | |
chroot $TARGETDIR xbps-reconfigure -f glibc-locales | |
# setup timezone | |
ln -sf /usr/share/zoneinfo/${TIMEZONE} $TARGETDIR/etc/localtime | |
# set hostname | |
echo $HOSTNAME > $TARGETDIR/etc/hostname | |
# set root password | |
echo "root:${ROOTPASSWORD}" | chpasswd -R $TARGETDIR -c SHA512 | |
# Copy /etc/skel to root | |
cp $TARGETDIR/etc/skel/.[bix]* $TARGETDIR/root | |
# dhcpcd | |
ln -s /etc/sv/dhcpcd $TARGETDIR/etc/runit/runsvdir/default/dhcpcd | |
# ssh | |
ln -s /etc/sv/sshd $TARGETDIR/etc/runit/runsvdir/default/sshd | |
# install bootloader | |
chroot $TARGETDIR grub-install /dev/vda | |
chroot $TARGETDIR grub-mkconfig -o /boot/grub/grub.cfg | |
sync && sync && sync | |
# umount | |
umount $TARGETDIR/sys | |
umount $TARGETDIR/proc | |
umount $TARGETDIR/dev | |
swapoff /dev/vda3 | |
umount $TARGETDIR | |
# reboot | |
shutdown -r now |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment