mirror of
https://github.com/arthur-pbty/arch-custom-iso.git
synced 2026-08-01 20:28:05 +02:00
add auto login
This commit is contained in:
+31
-47
@@ -88,16 +88,14 @@ print_grid_menu() {
|
|||||||
done
|
done
|
||||||
}
|
}
|
||||||
|
|
||||||
ask_confirm() { read -rp "$1 (y/n): " ans; [[ "$ans" =~ ^[yY]$ ]]; }
|
|
||||||
|
|
||||||
# Fonction pour échapper les caractères spéciaux JSON (Remplace jq)
|
# Fonction pour échapper les caractères spéciaux JSON (Remplace jq)
|
||||||
json_escape() {
|
json_escape() {
|
||||||
local s="$1"
|
local s="$1"
|
||||||
s="${s//\\/\\\\}" # Antislash
|
s="${s//\\/\\\\}"
|
||||||
s="${s//\"/\\\"}" # Guillemets
|
s="${s//\"/\\\"}"
|
||||||
s="${s//$'\n'/\\n}" # Retour à la ligne
|
s="${s//$'\n'/\\n}"
|
||||||
s="${s//$'\r'/\\r}" # Retour chariot
|
s="${s//$'\r'/\\r}"
|
||||||
s="${s//$'\t'/\\t}" # Tabulation
|
s="${s//$'\t'/\\t}"
|
||||||
printf '%s' "$s"
|
printf '%s' "$s"
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -131,7 +129,6 @@ install_base_system() {
|
|||||||
pacman -Sy --noconfirm
|
pacman -Sy --noconfirm
|
||||||
|
|
||||||
local disk
|
local disk
|
||||||
# On lit le disque directement avec bash au lieu de jq
|
|
||||||
disk=$(grep -o '"device": *"[^"]*"' user_configuration.json | head -1 | cut -d'"' -f4)
|
disk=$(grep -o '"device": *"[^"]*"' user_configuration.json | head -1 | cut -d'"' -f4)
|
||||||
cleanup_install_disk "$disk"
|
cleanup_install_disk "$disk"
|
||||||
|
|
||||||
@@ -157,7 +154,7 @@ run_configurator() {
|
|||||||
|
|
||||||
while true; do
|
while true; do
|
||||||
clear
|
clear
|
||||||
echo "=== SELECT KEYBOARD LAYOUT ===" # TITRE
|
echo "=== SELECT KEYBOARD LAYOUT ==="
|
||||||
print_grid_menu $(( PAGE - 1 ))
|
print_grid_menu $(( PAGE - 1 ))
|
||||||
echo -e "\n[n] Next | [p] Prev | [q] Quit"
|
echo -e "\n[n] Next | [p] Prev | [q] Quit"
|
||||||
read -rp "Entrée (n/p ou nombre) : " input
|
read -rp "Entrée (n/p ou nombre) : " input
|
||||||
@@ -200,7 +197,7 @@ run_configurator() {
|
|||||||
|
|
||||||
while true; do
|
while true; do
|
||||||
clear
|
clear
|
||||||
echo "=== SELECT TIMEZONE ===" # TITRE
|
echo "=== SELECT TIMEZONE ==="
|
||||||
print_grid_menu $(( PAGE - 1 ))
|
print_grid_menu $(( PAGE - 1 ))
|
||||||
echo -e "\n[n] Next | [p] Prev | [q] Quit"
|
echo -e "\n[n] Next | [p] Prev | [q] Quit"
|
||||||
read -rp "Entrée (n/p ou nombre) : " input
|
read -rp "Entrée (n/p ou nombre) : " input
|
||||||
@@ -246,7 +243,7 @@ run_configurator() {
|
|||||||
|
|
||||||
while true; do
|
while true; do
|
||||||
clear
|
clear
|
||||||
echo "=== SELECT INSTALLATION DISK ===" # TITRE
|
echo "=== SELECT INSTALLATION DISK ==="
|
||||||
print_grid_menu $(( PAGE - 1 ))
|
print_grid_menu $(( PAGE - 1 ))
|
||||||
echo -e "\n[n] Next | [p] Prev | [q] Quit"
|
echo -e "\n[n] Next | [p] Prev | [q] Quit"
|
||||||
read -rp "Entrée (n/p ou nombre) : " input
|
read -rp "Entrée (n/p ou nombre) : " input
|
||||||
@@ -263,13 +260,10 @@ run_configurator() {
|
|||||||
done
|
done
|
||||||
disk=$(echo "${DISKS[$((PAGE - 1))]}" | awk '{print $1}')
|
disk=$(echo "${DISKS[$((PAGE - 1))]}" | awk '{print $1}')
|
||||||
|
|
||||||
# --- 5. ENCRYPTION ---
|
# --- 5. ENCRYPTION (FORCE ACTIVÉ) ---
|
||||||
clear; local encrypt_installation="false"
|
local encrypt_installation="true"
|
||||||
ask_confirm "Encrypt disk?" && encrypt_installation="true"
|
|
||||||
|
|
||||||
# --- JSON GENERATION (100% BASH PUR, PLUS DE JQ) ---
|
# --- JSON GENERATION (100% BASH PUR) ---
|
||||||
|
|
||||||
# On échappe les variables et on les entoure de guillemets
|
|
||||||
local pw_esc="\"$(json_escape "$password")\""
|
local pw_esc="\"$(json_escape "$password")\""
|
||||||
local hash_esc="\"$(json_escape "$password_hash")\""
|
local hash_esc="\"$(json_escape "$password_hash")\""
|
||||||
local user_esc="\"$(json_escape "$username")\""
|
local user_esc="\"$(json_escape "$username")\""
|
||||||
@@ -278,12 +272,7 @@ run_configurator() {
|
|||||||
local kb_esc="\"$(json_escape "$keyboard")\""
|
local kb_esc="\"$(json_escape "$keyboard")\""
|
||||||
local disk_esc="\"$(json_escape "$disk")\""
|
local disk_esc="\"$(json_escape "$disk")\""
|
||||||
|
|
||||||
# Fichier identifiants
|
credentials_encryption_line=" \"encryption_password\": $pw_esc,"
|
||||||
if [[ $encrypt_installation == "true" ]]; then
|
|
||||||
credentials_encryption_line=" \"encryption_password\": $pw_esc,"
|
|
||||||
else
|
|
||||||
credentials_encryption_line=""
|
|
||||||
fi
|
|
||||||
|
|
||||||
cat <<_EOF_ >user_credentials.json
|
cat <<_EOF_ >user_credentials.json
|
||||||
{
|
{
|
||||||
@@ -300,7 +289,6 @@ run_configurator() {
|
|||||||
}
|
}
|
||||||
_EOF_
|
_EOF_
|
||||||
|
|
||||||
# Calculs partitions
|
|
||||||
local disk_size; disk_size=$(lsblk -bdno SIZE "$disk" 2>/dev/null) || true
|
local disk_size; disk_size=$(lsblk -bdno SIZE "$disk" 2>/dev/null) || true
|
||||||
local mib=$((1024*1024))
|
local mib=$((1024*1024))
|
||||||
local gib=$((mib*1024))
|
local gib=$((mib*1024))
|
||||||
@@ -309,9 +297,7 @@ _EOF_
|
|||||||
local main_start=$((boot_size + mib))
|
local main_start=$((boot_size + mib))
|
||||||
local main_size=$((disk_size_in_mib - main_start - mib))
|
local main_size=$((disk_size_in_mib - main_start - mib))
|
||||||
|
|
||||||
# Fichier configuration principal
|
disk_encryption_config=$(cat <<_EOF_
|
||||||
if [[ $encrypt_installation == true ]]; then
|
|
||||||
disk_encryption_config=$(cat <<_EOF_
|
|
||||||
,
|
,
|
||||||
"disk_encryption": {
|
"disk_encryption": {
|
||||||
"encryption_type": "luks",
|
"encryption_type": "luks",
|
||||||
@@ -322,9 +308,6 @@ _EOF_
|
|||||||
}
|
}
|
||||||
_EOF_
|
_EOF_
|
||||||
)
|
)
|
||||||
else
|
|
||||||
disk_encryption_config=""
|
|
||||||
fi
|
|
||||||
|
|
||||||
cat <<_EOF_ >user_configuration.json
|
cat <<_EOF_ >user_configuration.json
|
||||||
{
|
{
|
||||||
@@ -442,31 +425,32 @@ if [[ $(tty) == "/dev/tty1" ]]; then
|
|||||||
"ghostty"
|
"ghostty"
|
||||||
"hyprland"
|
"hyprland"
|
||||||
"xdg-desktop-portal-hyprland"
|
"xdg-desktop-portal-hyprland"
|
||||||
"git" # Assure-toi que git est bien là pour cloner yay
|
"git"
|
||||||
|
"kitty" # A ENLEVER APRES !
|
||||||
)
|
)
|
||||||
|
|
||||||
arch-chroot /mnt pacman -S --noconfirm "${EXTRA_PACKAGES[@]}"
|
arch-chroot /mnt pacman -S --noconfirm "${EXTRA_PACKAGES[@]}"
|
||||||
|
|
||||||
# --- 2. CONFIGURATION DE L'AUR (YAY) ---
|
# --- 2. CONFIGURATION TTY AUTO-LOGIN ---
|
||||||
clear
|
echo "Configuring TTY auto-login for $username..."
|
||||||
echo "Installing YAY (AUR helper) as user $username..."
|
|
||||||
|
|
||||||
# On crée le dossier de cache de compilation pour l'utilisateur
|
mkdir -p /mnt/etc/systemd/system/getty@tty1.service.d
|
||||||
mkdir -p /mnt/home/$username/.cache
|
cat > /mnt/etc/systemd/system/getty@tty1.service.d/override.conf << EOF
|
||||||
chown -R 1000:1000 /mnt/home/$username/.cache
|
[Service]
|
||||||
|
ExecStart=
|
||||||
|
ExecStart=-/sbin/agetty --autologin $username --noclear %I \$TERM
|
||||||
|
EOF
|
||||||
|
|
||||||
# On télécharge et on compile YAY *en tant qu'utilisateur* (très important)
|
# --- 3. LANCEMENT AUTOMATIQUE DE HYPRLAND ---
|
||||||
arch-chroot /mnt su - "$username" -c 'cd /tmp && git clone https://aur.archlinux.org/yay.git && cd yay && makepkg -si --noconfirm'
|
echo "Configuring auto-start Hyprland..."
|
||||||
|
|
||||||
# --- 3. INSTALLATION DE BRAVE VIA YAY ---
|
cat > "/mnt/home/$username/.bash_profile" << 'EOF'
|
||||||
clear
|
if [ -z "${DISPLAY}" ] && [ "$(tty)" = "/dev/tty1" ]; then
|
||||||
echo "Installing Brave via AUR..."
|
exec Hyprland
|
||||||
|
fi
|
||||||
# On utilise yay en tant qu'utilisateur pour installer brave-bin
|
EOF
|
||||||
arch-chroot /mnt su - "$username" -c 'yay -S --noconfirm brave-bin'
|
|
||||||
|
|
||||||
echo "Custom packages installed successfully!"
|
|
||||||
|
|
||||||
|
chown 1000:1000 "/mnt/home/$username/.bash_profile"
|
||||||
# --- REBOOT AUTOMATIQUE ---
|
# --- REBOOT AUTOMATIQUE ---
|
||||||
echo "Installation finished! Rebooting in 3 seconds..."
|
echo "Installation finished! Rebooting in 3 seconds..."
|
||||||
sleep 3
|
sleep 3
|
||||||
|
|||||||
Reference in New Issue
Block a user