Created
March 6, 2021 19:05
-
-
Save pipelinedave/70c54ed5e2c1ece2b9749c9867f7389b to your computer and use it in GitHub Desktop.
This file contains hidden or 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/bash | |
HOST=myhostname | |
USERNAME=myusername | |
HOME_DIR="/home/${USERNAME}" | |
SWAP_SIZE=4G | |
echo DISK="$1", HOST="$HOST", USERNAME="$USERNAME", HOME_DIR="$HOME_DIR" | |
# grub as a bootloader | |
grub-install --target=i386-pc --recheck "$1" | |
# This makes the grub timeout 0, it's faster than 5 :) | |
sudo sed -i 's/GRUB_TIMEOUT=5/GRUB_TIMEOUT=0/g' /etc/default/grub | |
grub-mkconfig -o /boot/grub/grub.cfg | |
# run these following essential service by default | |
systemctl enable sshd.service | |
systemctl enable dhcpcd.service | |
systemctl enable ntpd.service | |
echo "$HOST" > /etc/hostname | |
# inject vimrc config to default user dir if you like vim | |
echo -e 'runtime! archlinux.vim\nsyntax on' > /etc/skel/.vimrc | |
# adding your normal user with additional wheel group so can sudo | |
useradd -m -G wheel -s /bin/bash "$USERNAME" | |
# adding public key both to root and user for ssh key access | |
mkdir -m 700 "$HOME_DIR/.ssh" | |
mkdir -m 700 /root/.ssh | |
cp /authorized_keys "/$HOME_DIR/.ssh" | |
cp /authorized_keys /root/.ssh | |
chown -R "$USERNAME:$USERNAME" "$HOME_DIR/.ssh" | |
# adjust your timezone here | |
ln -f -s /usr/share/zoneinfo/Australia/Melbourne /etc/localtime | |
hwclock --systohc | |
# adjust your name servers here if you don't want to use google | |
echo 'name_servers="8.8.8.8 8.8.4.4"' >> /etc/resolvconf.conf | |
echo en_US.UTF-8 UTF-8 > /etc/locale.gen | |
echo LANG=en_US.UTF-8 > /etc/locale.conf | |
locale-gen | |
# because we are using ssh keys, make sudo not ask for passwords | |
echo 'root ALL=(ALL) ALL' > /etc/sudoers | |
echo '%wheel ALL=(ALL) NOPASSWD: ALL' >> /etc/sudoers | |
# I like to use vim :) | |
echo -e 'EDITOR=vim' > /etc/environment | |
# creating the swap file, if you have enough RAM, you can skip this step | |
fallocate -l "$SWAP_SIZE" /swapfile | |
chmod 600 /swapfile | |
mkswap /swapfile | |
echo /swapfile none swap defaults 0 0 >> /etc/fstab | |
# auto-complete these essential commands | |
echo complete -cf sudo >> /etc/bash.bashrc | |
echo complete -cf man >> /etc/bash.bashrc |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment