feat: automate every step after mounting disk
This commit is contained in:
parent
ce45d892ce
commit
5d848c7baf
64
base.sh
Normal file
64
base.sh
Normal file
@ -0,0 +1,64 @@
|
|||||||
|
#!/bin/bash -e
|
||||||
|
|
||||||
|
# System config
|
||||||
|
ln -sf "/usr/share/zoneinfo/$tz" /etc/localtime
|
||||||
|
hwclock --systohc
|
||||||
|
for l in "${locales[@]}"; do
|
||||||
|
sed -i "/^#\s*$l.UTF-8/s/^#\s*//" /etc/locale.gen
|
||||||
|
done
|
||||||
|
locale-gen
|
||||||
|
echo "LANG=$lang.UTF-8" > /etc/locale.conf
|
||||||
|
echo "$hostname" > /etc/hostname
|
||||||
|
|
||||||
|
# Drivers
|
||||||
|
case "$(lscpu | grep Vendor)" in
|
||||||
|
*AuthenticAMD*) cpu=amd ;;
|
||||||
|
*GenuineIntel*) cpu=intel ;;
|
||||||
|
esac
|
||||||
|
sed -i '/^HOOKS=(/s/filesystems/encrypt filesystems/' /etc/mkinitcpio.conf
|
||||||
|
|
||||||
|
# Services
|
||||||
|
pac "$cpu-ucode"
|
||||||
|
systemctl enable \
|
||||||
|
NetworkManager \
|
||||||
|
ip6tables \
|
||||||
|
iptables \
|
||||||
|
podman.socket \
|
||||||
|
reflector.timer \
|
||||||
|
systemd-resolved \
|
||||||
|
systemd-timesyncd
|
||||||
|
|
||||||
|
if ls -d /sys/class/power_supply/BAT*/ > /dev/null 2>&1; then
|
||||||
|
pac "${laptop_pkg[@]}"
|
||||||
|
systemctl enable tlp
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Users
|
||||||
|
echo "root:$root_passwd" | chpasswd
|
||||||
|
useradd -mG wheel,video "$username" -s "${default_shell-/bin/bash}"
|
||||||
|
echo "$username:$user_passwd" | chpasswd
|
||||||
|
su "$username" -c 'xdg-user-dirs-update' 2> /dev/null || true
|
||||||
|
|
||||||
|
sed -i '/^#\s*%wheel\s\+ALL=(ALL:ALL)\s\+ALL/s/^#\s*//' /etc/sudoers
|
||||||
|
|
||||||
|
# Bootloader
|
||||||
|
bootctl install
|
||||||
|
|
||||||
|
root="$(findmnt -nr -o source /)"
|
||||||
|
cryptdev="$(cryptsetup status "$root" | grep device | awk '{print $2}' || true)"
|
||||||
|
if [ -n "$cryptdev" ]; then
|
||||||
|
uuid="$(blkid | grep "$cryptdev" | awk '{print $2}')"
|
||||||
|
options="cryptdevice=$uuid:$(basename "$root") "
|
||||||
|
fi
|
||||||
|
|
||||||
|
options="${options}root=$root"
|
||||||
|
|
||||||
|
for f in /boot/loader/entries/*.conf; do
|
||||||
|
cat << EOF >> "$f"
|
||||||
|
initrd /$cpu-ucode.img
|
||||||
|
options $options rw
|
||||||
|
EOF
|
||||||
|
done
|
||||||
|
|
||||||
|
echo -e "${BOLD}${GREEN}DONE. You can install a desktop environment \
|
||||||
|
(see README.md). Then, you can Ctrl+D, umount -R /mnt/ and reboot${NORMAL}"
|
6
config
6
config
@ -1,6 +1,10 @@
|
|||||||
# User Variables
|
# User Variables
|
||||||
# Comment to disable
|
# Comment to disable
|
||||||
|
|
||||||
|
set -a
|
||||||
|
|
||||||
|
swapfile=auto # true|MB
|
||||||
|
|
||||||
username=ange
|
username=ange
|
||||||
user_passwd=ange
|
user_passwd=ange
|
||||||
root_passwd=root
|
root_passwd=root
|
||||||
@ -46,4 +50,6 @@ laptop_pkg=(
|
|||||||
tlp
|
tlp
|
||||||
)
|
)
|
||||||
|
|
||||||
|
set +a
|
||||||
|
|
||||||
# vim: ft=sh
|
# vim: ft=sh
|
||||||
|
@ -1,3 +1,8 @@
|
|||||||
|
# User Variables
|
||||||
|
# Comment to disable
|
||||||
|
|
||||||
|
set -a
|
||||||
|
|
||||||
pkg=(
|
pkg=(
|
||||||
alacritty
|
alacritty
|
||||||
dunst
|
dunst
|
||||||
@ -8,7 +13,7 @@ pkg=(
|
|||||||
keepassxc
|
keepassxc
|
||||||
materia-{gtk-theme,kde} papirus-icon-theme gtk-engine-murrine
|
materia-{gtk-theme,kde} papirus-icon-theme gtk-engine-murrine
|
||||||
mpv
|
mpv
|
||||||
noto-fonts{,-cjk,-emoji} ttf-{dejavu,liberation}
|
noto-fonts{,-cjk,-emoji} ttf-{dejavu,liberation} otf-font-awesome
|
||||||
pcmanfm
|
pcmanfm
|
||||||
pipewire{,-pulse,-jack} wireplumber pavucontrol playerctl
|
pipewire{,-pulse,-jack} wireplumber pavucontrol playerctl
|
||||||
polkit-gnome
|
polkit-gnome
|
||||||
@ -26,4 +31,6 @@ flatpakpkg=(
|
|||||||
org.mozilla.firefox
|
org.mozilla.firefox
|
||||||
)
|
)
|
||||||
|
|
||||||
|
set +a
|
||||||
|
|
||||||
# vim: ft=sh
|
# vim: ft=sh
|
||||||
|
@ -1,6 +1,8 @@
|
|||||||
# User Variables
|
# User Variables
|
||||||
# Comment to disable
|
# Comment to disable
|
||||||
|
|
||||||
|
set -a
|
||||||
|
|
||||||
pkg=(
|
pkg=(
|
||||||
autorandr
|
autorandr
|
||||||
i3lock xss-lock
|
i3lock xss-lock
|
||||||
@ -8,4 +10,6 @@ pkg=(
|
|||||||
xorg-{server,xinit,xrandr,xsetroot} xclip
|
xorg-{server,xinit,xrandr,xsetroot} xclip
|
||||||
)
|
)
|
||||||
|
|
||||||
|
set +a
|
||||||
|
|
||||||
# vim: ft=sh
|
# vim: ft=sh
|
||||||
|
@ -9,7 +9,7 @@ if [ "$EUID" != 0 ]; then
|
|||||||
fi
|
fi
|
||||||
|
|
||||||
pac "${pkg[@]}" flatpak
|
pac "${pkg[@]}" flatpak
|
||||||
flatpak install "${flatpakpkg[@]}"
|
flatpak install -y "${flatpakpkg[@]}"
|
||||||
|
|
||||||
case "$(lspci -k | grep -E '(VGA|3D)')" in
|
case "$(lspci -k | grep -E '(VGA|3D)')" in
|
||||||
*AMD*)
|
*AMD*)
|
||||||
|
84
install.sh
84
install.sh
@ -3,67 +3,29 @@ cd "$(dirname "$0")"
|
|||||||
. ./config
|
. ./config
|
||||||
. ./lib.sh
|
. ./lib.sh
|
||||||
|
|
||||||
# System config
|
(
|
||||||
cp -rfT rootfs/ /
|
case "$swapfile" in
|
||||||
pac "${pkg[@]}"
|
[0-9]*)
|
||||||
ln -sf "/usr/share/zoneinfo/$tz" /etc/localtime
|
size=$swapfile
|
||||||
hwclock --systohc
|
;;
|
||||||
for l in "${locales[@]}"; do
|
true)
|
||||||
sed -i "/^#\s*$l.UTF-8/s/^#\s*//" /etc/locale.gen
|
size="$(python -c "from math import ceil,log; print(2**ceil((log($swapfile)/log(2))))")"
|
||||||
done
|
;;
|
||||||
locale-gen
|
*)
|
||||||
echo "LANG=$lang.UTF-8" > /etc/locale.conf
|
exit
|
||||||
echo "$hostname" > /etc/hostname
|
;;
|
||||||
|
|
||||||
# Drivers
|
|
||||||
case "$(lscpu | grep Vendor)" in
|
|
||||||
*AuthenticAMD*) cpu=amd ;;
|
|
||||||
*GenuineIntel*) cpu=intel ;;
|
|
||||||
esac
|
esac
|
||||||
sed -i '/^HOOKS=(/s/filesystems/encrypt filesystems/' /etc/mkinitcpio.conf
|
|
||||||
|
|
||||||
# Packages
|
dd if=/dev/zero of=/mnt/swapfile bs=1M count="$swapfile" status=progress
|
||||||
pac "$cpu-ucode"
|
chmod 600 /mnt/swapfile
|
||||||
systemctl enable \
|
mkswap /mnt/swapfile
|
||||||
NetworkManager \
|
swapon /mnt/swapfile
|
||||||
ip6tables \
|
)
|
||||||
iptables \
|
|
||||||
podman.socket \
|
|
||||||
reflector.timer \
|
|
||||||
systemd-resolved \
|
|
||||||
systemd-timesyncd
|
|
||||||
|
|
||||||
if ls -d /sys/class/power_supply/BAT*/ > /dev/null 2>&1; then
|
cp -f rootfs/etc/pacman.conf /etc/pacman.conf
|
||||||
pac "${laptop_pkg[@]}"
|
systemctl restart reflector
|
||||||
systemctl enable tlp
|
pacman -Sy
|
||||||
fi
|
pacstrap -K /mnt/ "${pkg[@]}"
|
||||||
|
cp -rfT rootfs/ /mnt/
|
||||||
# Users
|
genfstab -U /mnt >> /mnt/etc/fstab
|
||||||
echo "root:$root_passwd" | chpasswd
|
cat base.sh | arch-chroot /mnt/ bash
|
||||||
useradd -mG wheel,video "$username" -s "${default_shell-/bin/bash}"
|
|
||||||
echo "$username:$user_passwd" | chpasswd
|
|
||||||
su "$username" -c 'xdg-user-dirs-update' 2> /dev/null || true
|
|
||||||
|
|
||||||
sed -i '/^#\s*%wheel\s\+ALL=(ALL:ALL)\s\+ALL/s/^#\s*//' /etc/sudoers
|
|
||||||
|
|
||||||
# Bootloader
|
|
||||||
bootctl install
|
|
||||||
|
|
||||||
root="$(findmnt -nr -o source /)"
|
|
||||||
cryptdev="$(cryptsetup status "$root" | grep device | awk '{print $2}' || true)"
|
|
||||||
if [ -n "$cryptdev" ]; then
|
|
||||||
uuid="$(blkid | grep "$cryptdev" | awk '{print $2}')"
|
|
||||||
options="cryptdevice=$uuid:$(basename "$root") "
|
|
||||||
fi
|
|
||||||
|
|
||||||
options="${options}root=$root"
|
|
||||||
|
|
||||||
for f in /boot/loader/entries/*.conf; do
|
|
||||||
cat << EOF >> "$f"
|
|
||||||
initrd /$cpu-ucode.img
|
|
||||||
options $options rw
|
|
||||||
EOF
|
|
||||||
done
|
|
||||||
|
|
||||||
echo -e "${BOLD}${GREEN}DONE. You can install a desktop environment \
|
|
||||||
(see README.md). Then, you can Ctrl+D, umount -R /mnt and reboot${NORMAL}"
|
|
||||||
|
Loading…
Reference in New Issue
Block a user