Last active
May 11, 2022 13:02
-
-
Save nobodyzxc/5e9bb4d6134dfa5e9a98709ae9b945b3 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
################# | |
# configs # | |
################# | |
HDLOC=/dev/sda | |
UEFISIZE=250M | |
ROOTSIZE=32G | |
SWAPSIZE=16G | |
ROOTPASS=root | |
USERNAME=zxc | |
USERPASS=user | |
NEWHOSTNAME=kabaneri | |
rm -rf /etc/pacman.d/gnupg | |
pacman-key --init | |
pacman-key --populate archlinux | |
pacman-key --refresh-keys | |
read -p "${USERNAME}@${NEWHOSTNAME} on $HDLOC | |
`lsblk` | |
swap size: $SWAPSIZE | |
root directory size: $ROOTSIZE | |
boot partition size: $UEFISIZE | |
enter to contine, ^C to stop:" | |
set -e | |
# keep track of the last executed command | |
trap 'last_command=$current_command; current_command=$BASH_COMMAND' DEBUG | |
# echo an error message before exiting | |
trap 'echo "\"${last_command}\" command end with exit code $?."' EXIT | |
(echo "g"; sleep 1; \ | |
echo "n"; \ | |
echo "1"; \ | |
echo ""; \ | |
echo "+$UEFISIZE"; sleep 1; \ | |
echo "n"; \ | |
echo "2"; \ | |
echo ""; \ | |
echo "+$ROOTSIZE"; sleep 1; \ | |
echo "n"; \ | |
echo "3"; \ | |
echo ""; \ | |
echo "+$SWAPSIZE"; sleep 1; \ | |
echo "n"; \ | |
echo "4"; \ | |
echo ""; \ | |
echo ""; sleep 1; \ | |
echo "t"; \ | |
echo "1"; \ | |
echo "1"; sleep 1; \ | |
echo "t"; \ | |
echo "2"; \ | |
echo "20"; sleep 1; \ | |
echo "t"; \ | |
echo "3"; \ | |
echo "19"; sleep 1; \ | |
echo "t"; \ | |
echo "4"; \ | |
echo "20"; sleep 5; \ | |
echo "w"; sleep 1;) | fdisk $HDLOC | |
# format | |
mkfs.vfat ${HDLOC}1 | |
mkfs.ext4 ${HDLOC}2 | |
mkfs.ext4 ${HDLOC}4 | |
mkswap ${HDLOC}3 | |
swapon ${HDLOC}3 | |
# mount | |
mount ${HDLOC}2 /mnt | |
mkdir /mnt/boot | |
mount ${HDLOC}1 /mnt/boot | |
mkdir /mnt/home | |
mount ${HDLOC}4 /mnt/home | |
cat /etc/pacman.conf \ | |
| sed '/\[core\]/ a Server = http://archlinux.cs.nctu.edu.tw/$repo/os/$arch' \ | |
| sed '/\[extra\]/ a Server = http://archlinux.cs.nctu.edu.tw/$repo/os/$arch' \ | |
| sed '/\[community\]/ a Server = http://archlinux.cs.nctu.edu.tw/$repo/os/$arch' > pacman.conf | |
cp pacman.conf /etc/pacman.conf | |
# install base | |
pacstrap /mnt base base-devel linux linux-firmware | |
# make system configs | |
genfstab -U /mnt >> /mnt/etc/fstab | |
arch-chroot /mnt ln -s -f /usr/share/zoneinfo/Asia/Taipei /etc/localtime | |
arch-chroot /mnt hwclock --systohc | |
sed -i "s/#en_US.UTF-8 UTF-8/en_US.UTF-8 UTF-8/" /mnt/etc/locale.gen | |
sed -i "s/#zh_TW.UTF-8 UTF-8/zh_TW.UTF-8 UTF-8/" /mnt/etc/locale.gen | |
arch-chroot /mnt locale-gen | |
echo "LANG=en_US.UTF-8" > /mnt/etc/locale.conf | |
echo "$NEWHOSTNAME" > /mnt/etc/hostname | |
cp pacman.conf /mnt/etc/pacman.conf | |
cat << EOF > /mnt/etc/hosts | |
127.0.0.1 localhost | |
::1 localhost | |
127.0.1.1 $NEWHOSTNAME.localdomain $NEWHOSTNAME | |
EOF | |
echo "nameserver 8.8.8.8" >> /mnt/etc/resolv.conf | |
# user settings | |
arch-chroot /mnt pacman -Syy --noconfirm --needed sudo && \ | |
sed -i 's/^#\s*\(%wheel\s\+ALL=(ALL)\s\+ALL\)/\1/' /mnt/etc/sudoers | |
arch-chroot /mnt useradd -m -u 1001 $USERNAME | |
arch-chroot /mnt usermod $USERNAME -G wheel | |
arch-chroot /mnt bash -c "echo root:$ROOTPASS | chpasswd" | |
arch-chroot /mnt bash -c "echo ${USERNAME}:${USERPASS} | chpasswd" | |
# make img and install grub & network pkgs | |
arch-chroot /mnt mkinitcpio -p linux && \ | |
arch-chroot /mnt pacman -S --noconfirm --needed grub os-prober efibootmgr && \ | |
arch-chroot /mnt grub-install --target=x86_64-efi --efi-directory=/boot --bootloader-id=grub && \ | |
arch-chroot /mnt grub-mkconfig -o /boot/grub/grub.cfg # warnning here | |
arch-chroot /mnt pacman -S --noconfirm --needed net-tools wireless_tools dhclient wpa_supplicant dhcpcd openssh | |
arch-chroot /mnt systemctl enable dhcpcd.service | |
# basic installation done | |
################# | |
# official pkgs # | |
################# | |
DM=lightdm | |
GUI_PKGS="xorg xorg-server" | |
GUI_PKGS="$GUI_PKGS deepin deepin-extra" | |
GUI_PKGS="$GUI_PKGS i3-gaps i3lock i3status" | |
DM_PKGS="$DM lightdm-webkit2-greeter lightdm-webkit-theme-litarvan" | |
UTILITY_PKGS="gvim tmux ibus ibus-chewing" | |
# summary of official pkgs | |
PACMAN_PKGS="$GUI_PKGS $UTILITY_PKGS" | |
# install pkgs | |
arch-chroot /mnt sudo pacman -S --noconfirm --needed $PACMAN_PKGS | |
# extra action after official pkgs installation | |
sed -i 's/^#greeter-session=example-gtk-gnome/greeter-session=lightdm-webkit2-greeter/' /mnt/etc/lightdm/lightdm.conf | |
arch-chroot /mnt systemctl enable ${DM}.service | |
################# | |
# AUR pkgs # | |
################# | |
FONT_PKGS="ttf-dejavu ttf-droid ttf-freefont ttf-hack ttf-liberation \ | |
adobe-source-code-pro-fonts cantarell-fonts gsfonts powerline-fonts \ | |
ttf-freefont noto-fonts noto-fonts-emoji ttf-roboto ttf-roboto-mono \ | |
noto-fonts-cjk ttf-tw ttf-twcns-fonts ttf-arphic-ukai ttf-times-new-roman ttf-ms-fonts" | |
EXTRA_PKGS="google-chrome" | |
# summary of AUR pkgs | |
YAY_PKGS="$FONT_PKGS $EXTRA_PKGS" | |
# yay installation need git and go | |
arch-chroot /mnt pacman -S --noconfirm --needed git go | |
# install yay | |
arch-chroot /mnt sudo -H -u $USERNAME bash -c "cd && git clone https://aur.archlinux.org/yay.git && cd yay && makepkg -si" | |
# install pkgs | |
arch-chroot /mnt sudo -H -u $USERNAME bash -c "yay -S --sudoloop $YAY_PKGS" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment