124 lines
3.1 KiB
Bash
124 lines
3.1 KiB
Bash
|
#!/usr/bin/env bash
|
||
|
|
||
|
### https://wiki.archlinux.org/title/Archiso
|
||
|
|
||
|
set -eou pipefail
|
||
|
set -x
|
||
|
|
||
|
# Test if archiso is installed
|
||
|
if ! pacman -Qs archiso > /dev/null; then
|
||
|
echo "Error: archiso is not installed."
|
||
|
|
||
|
read -p "Do youwant to install archiso? [Y]es or [N]o. \n" -n 1 -r
|
||
|
if [[ $REPLY =~ ^[Yy]$ ]]; then
|
||
|
sudo pacman -Sy archiso
|
||
|
else
|
||
|
echo "Exiting."
|
||
|
exit 0
|
||
|
fi
|
||
|
fi
|
||
|
|
||
|
# Write log
|
||
|
logdir="/home/$USER/.archiso/logs"
|
||
|
mkdir -p "${logdir}"
|
||
|
logfile="${logdir}/$(date +%Y-%m-%d_%H:%M).log"
|
||
|
exec >> >(tee -i "${logfile}")
|
||
|
exec 2>&1
|
||
|
|
||
|
# Ask password for ISO user
|
||
|
pw_hash=$(openssl passwd -6)
|
||
|
|
||
|
# Profile to use
|
||
|
profile="releng"
|
||
|
#profile="baseline"
|
||
|
|
||
|
# releng is used to create the official monthly installation ISO.
|
||
|
# It can be used as a starting point for creating a customized ISO image.
|
||
|
|
||
|
# baseline is a minimal configuration, that includes only the bare minimum
|
||
|
# packages required to boot the live environment from the medium.
|
||
|
|
||
|
# Define directories
|
||
|
dir="/home/$USER/.archiso"
|
||
|
prof_dir="${dir}/${profile}"
|
||
|
pkgs_file="${prof_dir}/packages.x86_64"
|
||
|
#workdir="${dir}/.tmp"
|
||
|
workdir="/tmp/archiso"
|
||
|
root_etc="${prof_dir}/airootfs/etc"
|
||
|
|
||
|
# Delete old profile
|
||
|
sudo rm -rf ${prof_dir}
|
||
|
sudo rm -rf ${dir}/output/*
|
||
|
sudo rm -rf ${dir}/.tmp/*
|
||
|
|
||
|
# Copy new profile template
|
||
|
# https://wiki.archlinux.org/title/Archiso#Prepare_a_custom_profile
|
||
|
cp -r "/usr/share/archiso/configs/${profile}" "${dir}"
|
||
|
|
||
|
# Define packages to install
|
||
|
# https://wiki.archlinux.org/title/Archiso#Selecting_packages
|
||
|
touch "${pkgs_file}"
|
||
|
|
||
|
declare -a pkgs=(
|
||
|
firefox
|
||
|
konsole
|
||
|
plasma-desktop
|
||
|
sddm
|
||
|
sddm-kcm
|
||
|
)
|
||
|
|
||
|
for pkg in "${pkgs[@]}"; do
|
||
|
echo "${pkg}" >> "${pkgs_file}"
|
||
|
done
|
||
|
|
||
|
# Activate sddm.service
|
||
|
# https://wiki.archlinux.org/title/Archiso#Login_manager
|
||
|
ln -s /usr/lib/systemd/system/sddm.service \
|
||
|
"${root_etc}/systemd/system/display-manager.service"
|
||
|
|
||
|
# Autologin config
|
||
|
# https://wiki.archlinux.org/title/Archiso#Changing_automatic_login
|
||
|
mkdir "${root_etc}/sddm.conf.d"
|
||
|
cat << EOF > "${root_etc}/sddm.conf.d/autologin.conf"
|
||
|
[Autologin]
|
||
|
Relogin=false
|
||
|
Session=plasmax11
|
||
|
User=$USER
|
||
|
|
||
|
[Theme]
|
||
|
Current=breeze
|
||
|
CursorTheme=Breeze_Light
|
||
|
EOF
|
||
|
|
||
|
# Create user
|
||
|
# https://wiki.archlinux.org/title/Archiso#Users_and_passwords
|
||
|
root_etc="${prof_dir}/airootfs/etc"
|
||
|
|
||
|
echo root:x:0:0:root:/root:/usr/bin/zsh > "${root_etc}/passwd"
|
||
|
echo "${USER}":x:1000:1000::/home/"${USER}":/usr/bin/zsh >> "${root_etc}/passwd"
|
||
|
|
||
|
echo "${USER}:${pw_hash}:14871::::::" >> "${root_etc}/shadow"
|
||
|
|
||
|
echo root:x:0:root > "${root_etc}/group"
|
||
|
echo adm:x:4:"${USER}" >> "${root_etc}/group"
|
||
|
echo wheel:x:10:"${USER}" >> "${root_etc}/group"
|
||
|
echo uucp:x:14:"${USER}" >> "${root_etc}/group"
|
||
|
echo "${USER}":x:1000: >> "${root_etc}/group"
|
||
|
|
||
|
echo root:!*::root > "${root_etc}/gshadow"
|
||
|
echo "${USER}":!*:: >> "${root_etc}/gshadow"
|
||
|
|
||
|
sed -i '27s/.*/ ["\/etc\/gshadow"]="0:0:0400"/' "$HOME/.archiso/releng/profiledef.sh"
|
||
|
echo ")" >> "$HOME/.archiso/releng/profiledef.sh"
|
||
|
|
||
|
echo "%wheel ALL=(ALL) ALL" > "${root_etc}/sudoers"
|
||
|
|
||
|
# Create image
|
||
|
mkdir -p "${workdir}"
|
||
|
nice -n 19 ionice -c 3 sudo mkarchiso -w "${workdir}" -o "${dir}/output" "${prof_dir}"
|
||
|
|
||
|
exit 0
|
||
|
|
||
|
# To-Dos
|
||
|
# - NetworkManager?
|
||
|
# - SDDM Loginscreen?
|