#!/bin/bash
|
|
|
|
if [ ! -f "/install/device" ]; then
|
|
mkdir -p /install
|
|
echo "Now you will specify the partitions you have created"
|
|
echo "Please enter the suffix for each partition. For Ex:"
|
|
echo "1 if boot partition is /dev/sda1 or p1 if boot is on /dev/nvme0n1p1 and the disk is /dev/nvme0n1"
|
|
echo -n "Please enter boot partition suffix: "
|
|
read boot_p
|
|
boot=$device$boot_p
|
|
echo -n "Please enter root partition suffix: "
|
|
read root_p
|
|
root=$device$root_p
|
|
echo -n "Please enter swap partition suffix: "
|
|
read swap_p
|
|
swap=$device$swap_p
|
|
echo -n "Did you create a home partition as well?(y/N): "
|
|
read home_s
|
|
if [ "$home_s" = "y" ]; then
|
|
echo -n "Please enter home partition suffix: "
|
|
read home_p
|
|
home=$device$home_p
|
|
echo -en "$boot\n$root\n$swap\n$home" > /install/device
|
|
else
|
|
echo -en "$boot\n$root\n$swap" > /install/device
|
|
fi
|
|
fi
|
|
|
|
boot=$(head -n 1 /install/device | tail -n 1)
|
|
root=$(head -n 2 /install/device | tail -n 1)
|
|
swap=$(head -n 3 /install/device | tail -n 1)
|
|
if [ ! "$(wc -l /install/device)" = "3" ]; then
|
|
home=$(head -n 4 /install/device | tail -n 1)
|
|
fi
|
|
|
|
ln -sf /usr/share/zoneinfo/Europe/Istanbul /etc/localtime
|
|
hwclock --systohc
|
|
echo -e "en_US.UTF-8 UTF-8\ntr_TR.UTF-8 UTF-8" > /etc/locale.gen
|
|
locale-gen
|
|
echo "LANG=en_US.UTF-8" > /etc/locale.conf
|
|
if [ ! -f "/tmp/.blackarch" ]; then
|
|
curl https://blackarch.org/strap.sh > /tmp/strap.sh
|
|
chmod +x /tmp/strap.sh
|
|
/tmp/strap.sh
|
|
touch /tmp/.blackarch
|
|
fi
|
|
echo "Please enter hostname: "
|
|
read hostname
|
|
echo $hostname > /etc/hostname
|
|
|
|
echo "Please enter name for regular user:"
|
|
read username
|
|
|
|
useradd -m $username
|
|
usermod -aG wheel yigit
|
|
|
|
systemctl enable fstrim.timer
|
|
|
|
echo -e "127.0.0.1 localhost\n::1 localhost\n127.0.0.1 $hostname.localdomain $hostname" > /etc/hosts
|
|
|
|
cat << EOF > /etc/initcpio/hooks/openswap
|
|
run_hook ()
|
|
{
|
|
x=0;
|
|
while [ ! -b /dev/mapper/root ] && [ \$x -le 10 ]; do
|
|
x=$((x+1))
|
|
sleep .2
|
|
done
|
|
mkdir crypto_key_device
|
|
mount /dev/mapper/root crypto_key_device
|
|
cryptsetup open --key-file crypto_key_device/root/.keys/swap-keyfile $swap swap
|
|
umount crypto_key_device
|
|
}
|
|
EOF
|
|
|
|
cat << EOF > /etc/initcpio/install/openswap
|
|
build ()
|
|
{
|
|
add_runscript
|
|
}
|
|
help ()
|
|
{
|
|
cat<<HELPEOF
|
|
This opens the swap encrypted partition $swap in /dev/mapper/swap
|
|
HELPEOF
|
|
}
|
|
EOF
|
|
|
|
if [ ! "$home" = "" ]; then
|
|
cat << EOF > /etc/initcpio/hooks/openhome
|
|
run_hook ()
|
|
{
|
|
x=0;
|
|
while [ ! -b /dev/mapper/root ] && [ \$x -le 10 ]; do
|
|
x=$((x+1))
|
|
sleep .2
|
|
done
|
|
mkdir crypto_key_device
|
|
mount /dev/mapper/root crypto_key_device
|
|
cryptsetup open --key-file crypto_key_device/root/.keys/home-keyfile $home home
|
|
umount crypto_key_device
|
|
}
|
|
EOF
|
|
cat << EOF > /etc/initcpio/install/openhome
|
|
build ()
|
|
{
|
|
add_runscript
|
|
}
|
|
help ()
|
|
{
|
|
cat<<HELPEOF
|
|
This opens the swap encrypted partition $home in /dev/mapper/home
|
|
HELPEOF
|
|
}
|
|
EOF
|
|
cat << EOF > /etc/mkinitcpio.conf
|
|
MODULES=(vfat i915)
|
|
BINARIES=()
|
|
FILES=()
|
|
HOOKS=(base udev plymouth autodetect keyboard keymap consolefont modconf block plymouth-encrypt openswap openhome resume filesystems fsck)
|
|
EOF
|
|
else
|
|
cat << EOF > /etc/mkinitcpio.conf
|
|
MODULES=(vfat i915)
|
|
BINARIES=()
|
|
FILES=()
|
|
HOOKS=(base udev plymouth autodetect keyboard keymap consolefont modconf block plymouth-encrypt openswap resume filesystems fsck)
|
|
EOF
|
|
fi
|
|
|
|
pacman --noconfirm -R vim
|
|
|
|
line=1
|
|
|
|
blkid | while IFS= read -r i; do
|
|
echo "$line: $i"
|
|
((line=line+1))
|
|
done
|
|
|
|
echo "Please select the device you will save the LUKS key to:"
|
|
read keydev
|
|
|
|
uuid=$(blkid | sed -n 's/.*UUID=\"\([^\"]*\)\".*/\1/p' | sed -n "$keydev"p)
|
|
cat << EOF > /boot/refind_linux.conf
|
|
"Boot with encryption" "root=/dev/mapper/root resume=/dev/mapper/swap cryptdevice=UUID=$(blkid -s UUID -o value $root):root:allow-discards cryptkey=UUID=$uuid:vfat:key.yeet rw loglevel=3 quiet splash"
|
|
EOF
|
|
|
|
mkdir -p /etc/sudoers.d
|
|
echo "$username $hostname =NOPASSWD: /usr/bin/systemctl poweroff,/usr/bin/systemctl halt,/usr/bin/systemctl reboot,/usr/bin/systemctl hibernate" >> /etc/sudoers.d/wheel
|
|
echo "Defaults env_reset,pwfeedback" >> /etc/sudoers.d/wheel
|
|
echo "%wheel ALL=(ALL) NOPASSWD: ALL" >> /etc/sudoers.d/nopwd
|
|
|
|
echo "Set password for user $username: "
|
|
passwd $username
|
|
|
|
sudo -u $username bash -c "git clone https://aur.archlinux.org/yay.git /tmp/yay"
|
|
sudo -u $username bash -c "(cd /tmp/yay; makepkg --noconfirm -si)"
|
|
sudo -u $username bash -c "yay --noconfirm -S plymouth"
|
|
|
|
refind-install
|
|
|
|
|
|
sudo -u $username bash -c "git clone --recurse-submodules https://github.com/theFr1nge/dotfiles.git ~/.dotfiles"
|
|
sudo -u $username bash -c "(cd ~/.dotfiles; ./install.sh)"
|
|
|
|
git clone https://github.com/adi1090x/plymouth-themes.git /tmp/pthemes
|
|
|
|
cat << EOF > /etc/plymouth/plymouthd.conf
|
|
[Daemon]
|
|
Theme=sphere
|
|
ShowDelay=0
|
|
DeviceTimeout=8
|
|
EOF
|
|
cp -r /tmp/pthemes/pack_4/sphere /usr/share/plymouth/themes
|
|
|
|
echo -e "/boot/EFI/refind\n2\n2" | sudo bash -c "$(curl -fsSL https://raw.githubusercontent.com/bobafetthotmail/refind-theme-regular/master/install.sh)"
|
|
|
|
systemctl enable NetworkManager
|
|
systemctl enable ly
|
|
systemctl enable cronie
|
|
|
|
mkinitcpio -P
|
|
|
|
vim /etc/fstab
|
|
pacman -R nano # uninstall nano, eww
|
|
|
|
rm -rf /etc/sudoers.d/nopwd
|
|
echo "%wheel ALL=(ALL) ALL" >> /etc/sudoers.d/wheel
|
|
|
|
rm -rf /bin/sh
|
|
ln -sf /bin/dash /bin/sh
|
|
|
|
echo "SETUP COMPLETE"
|
|
bash
|
|
rm -rf /install
|