feat: run scripts directly from iso

This commit is contained in:
AngeD 2023-11-09 12:32:30 +01:00
parent 5d848c7baf
commit 956f923f3f
5 changed files with 86 additions and 88 deletions

64
base.sh
View File

@ -1,64 +0,0 @@
#!/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}"

View File

@ -1,13 +1,12 @@
#!/bin/bash -e #!/bin/bash -ex
cd cd "$(dirname "$0")"
. ./config
. ./lib.sh
if [ -t 1 ]; then awk 'p; /pattern/{p=1}' "$0" | arch-chroot /mnt/ su "$username" -c bash -ex; exit
NORMAL='\e[0m'
BOLD='\e[1m'
GREEN='\e[32m'
fi
config="git --git-dir $HOME/.dotfiles --work-tree $HOME"
config=(git --git-dir "$HOME/.dotfiles" --work-tree "$HOME")
repo='https://git.maby.dev/ange/.dotfiles.git' repo='https://git.maby.dev/ange/.dotfiles.git'
if [ "$EUID" = 0 ]; then if [ "$EUID" = 0 ]; then
@ -17,8 +16,8 @@ fi
git clone --bare "$repo" "$HOME/.dotfiles" git clone --bare "$repo" "$HOME/.dotfiles"
$config checkout -f "${config[@]}" checkout -f
$config submodule update --init --recursive --remote "${config[@]}" submodule update --init --recursive --remote
$config config status.showUntrackedFiles no "${config[@]}" config status.showUntrackedFiles no
echo -e "${BOLD}${GREEN}DONE. You need to reboot to apply the changes.${NORMAL}" echo -e "${BOLD}${GREEN}DONE. You need to reboot to apply the changes.${NORMAL}"

View File

@ -3,10 +3,8 @@ cd "$(dirname "$0")"
. ./config . ./config
. ../../lib.sh . ../../lib.sh
if [ "$EUID" != 0 ]; then awk 'p; /pattern/{p=1}' "$(basename "$0")" | arch-chroot /mnt/ bash -ex; exit
echo 'This script needs root privileges.'
exit 1
fi
# drivers # drivers
case "$(lspci -k | grep -A3 -E '(VGA|3D)')" in case "$(lspci -k | grep -A3 -E '(VGA|3D)')" in
@ -28,5 +26,4 @@ git clone https://git.maby.dev/ange/suckless.git /tmp/suckless/
cd /tmp/suckless cd /tmp/suckless
./update.sh ./update.sh
echo -e "${BOLD}${GREEN}DONE. I recommend you run \`su ${username-\$username} \ echo -e "${BOLD}${GREEN}DONE. I recommend you to install dotfiles.sh to get a fully functioning config.${NORMAL}"
-c ./dotfiles\` to get a fully functioning config.${NORMAL}"

View File

@ -1,12 +1,10 @@
#!/bin/bash -e #!/bin/bash -ex
cd "$(dirname "$0")" cd "$(dirname "$0")"
. ./config . ./config
. ../lib.sh . ../lib.sh
if [ "$EUID" != 0 ]; then awk 'p; /pattern/{p=1}' "$(basename "$0")" | arch-chroot /mnt/ bash -ex; exit
echo 'This script needs root privileges.'
exit 1
fi
pac "${pkg[@]}" flatpak pac "${pkg[@]}" flatpak
flatpak install -y "${flatpakpkg[@]}" flatpak install -y "${flatpakpkg[@]}"

View File

@ -1,4 +1,4 @@
#!/bin/bash -e #!/bin/bash -ex
cd "$(dirname "$0")" cd "$(dirname "$0")"
. ./config . ./config
. ./lib.sh . ./lib.sh
@ -28,4 +28,72 @@ pacman -Sy
pacstrap -K /mnt/ "${pkg[@]}" pacstrap -K /mnt/ "${pkg[@]}"
cp -rfT rootfs/ /mnt/ cp -rfT rootfs/ /mnt/
genfstab -U /mnt >> /mnt/etc/fstab genfstab -U /mnt >> /mnt/etc/fstab
cat base.sh | arch-chroot /mnt/ bash
awk 'p; /pattern/{p=1}' "$0" | arch-chroot /mnt/ bash -ex; exit
# 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}"