Skip to content

Instantly share code, notes, and snippets.

@ubnt-intrepid
Last active July 29, 2016 21:06
Show Gist options
  • Select an option

  • Save ubnt-intrepid/8f854cf7bba3794b2d0b52aab61dd9c8 to your computer and use it in GitHub Desktop.

Select an option

Save ubnt-intrepid/8f854cf7bba3794b2d0b52aab61dd9c8 to your computer and use it in GitHub Desktop.
#!/bin/sh
# vim: ft=sh ts=2 sw=2 et :
set -ex
# set hostname
echo arch-localhost > /etc/hostname
# set locale settings
ln -sf /usr/share/zoneinfo/Asia/Tokyo /etc/localtime
sed -i.bak -e 's/#\(en_US.UTF-8.*\)/\1/' /etc/locale.gen
rm /etc/locale.gen.bak
locale-gen
# settings of account
useradd -m -G wheel -s /bin/zsh archie
echo -e 'archie\narchie\n' | passwd
echo -e 'archie\narchie\n' | passwd archie
mkdir -p /etc/sudoers.d
cat > /etc/sudoers.d/archie << EOF
archie ALL=(ALL) NOPASSWD: ALL
Defaults env_keep += "SSH_AUTH_SOCK"
EOF
chmod 0440 /etc/sudoers.d/archie
echo "UseDNS no" >> /etc/sshd_config
echo 'sshd: ALL' > /etc/hosts.allow
echo 'ALL: ALL' > /etc/hosts.deny
# shared folder settings
#modprobe -a vboxguest vboxsf
#cat > /etc/modules-load.d/virtualbox.conf << EOF
#vboxguest
#vboxsf
#EOF
#gpasswd -a vagrant vboxsf
#systemctl enable vboxservice
# enable network settings
device_name=$(ip addr | grep "^[0-9]" | awk '{print $2}' | sed -e 's/://' | grep -v '^lo$' | head -n 1)
systemctl enable sshd.service
systemctl enable "dhcpcd@${device_name}.service"
# install bootloader
bootctl --path=/boot install
cat << EOF > /boot/loader/loader.conf
default arch
timeout 1
editor 0
EOF
cat << EOF > /boot/loader/entries/arch.conf
title Arch Linux
linux /vmlinuz-linux
initrd /initramfs-linux.img
options root=PARTUUID=$(blkid -s PARTUUID -o value /dev/sda2) rw
EOF
#!/bin/sh
# vim: ft=sh ts=2 sw=2 et :
set -ex
# Create partitions
sgdisk \
-n 1::+128m \
-n 2 \
/dev/sda
mkfs.ext4 /dev/sda2
mkfs.vfat -F32 /dev/sda1
# mount partitions
mount /dev/sda2 /mnt
mkdir -p /mnt/boot
mount /dev/sda1 /mnt/boot
# change mirrorlist
sed -e '1iServer = http://ftp.jaist.ac.jp/pub/Linux/ArchLinux/$repo/os/$arch' -i /etc/pacman.d/mirrorlist
sed -e '1iServer = http://ftp.tsukuba.wide.ad.jp/Linux/archlinux/$repo/os/$arch' -i /etc/pacman.d/mirrorlist
# copy base system and kernel images {{{
pacstrap /mnt base base-devel zsh git vim openssh
# }}}
# generate /etc/fstab from mouned conditions
genfstab -U -p /mnt >> /mnt/etc/fstab
# enter target environment and run setup scripts
cp ./setup-chroot.sh /mnt
chmod +x /mnt/setup-chroot.sh
arch-chroot /mnt /setup-chroot.sh
rm /mnt/setup-chroot.sh
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment