-
Notifications
You must be signed in to change notification settings - Fork 0
/
install_chroot.sh
94 lines (77 loc) · 2.73 KB
/
install_chroot.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
#!/bin/bash
uefi=$(cat /var_uefi); hd=$(cat /var_hd);
cat /comp > /etc/hostname && rm /comp
pacman --noconfirm -S dialog
pacman -S --noconfirm grub
if [ "$uefi" = 1 ]; then
pacman -S --noconfirm efibootmgr
grub-install --target=x86_64-efi \
--bootloader-id=GRUB \
--efi-directory=/boot/efi
else
grub-install "$hd"
fi
grub-mkconfig -o /boot/grub/grub.cfg
# Set hardware clock from system clock
hwclock --systohc
# Don't forget to change "Europe/Amsterdam" with your own timezone!
# To list the timezones: `timedatectl list-timezones`
ln -sf /usr/share/zoneinfo/Europe/Amsterdam /etc/localtime
# Replace en_US.UTF-8 by whatever locale you want.
# You can run `cat /etc/locale.gen` to see all the locales available
echo "en_US.UTF-8 UTF-8" >> /etc/locale.gen
locale-gen
echo "LANG=en_US.UTF-8" > /etc/locale.conf
# Set the keymap layout if you don't use an EN_US keyboard. Replace "fr-latin1" by the keyboard layout you want.
# loadkeys fr-latin1
# echo "KEYMAP=fr-latin1" >> /etc/vconsole.conf
# No argument: ask for a username.
# One argument: use the username passed as argument.
function config_user() {
if [ -z "$1" ]; then
dialog --no-cancel --inputbox "Please enter your username." \
10 60 2> name
else
echo "$1" > name
fi
dialog --no-cancel --passwordbox "Enter your password." \
10 60 2> pass1
dialog --no-cancel --passwordbox "Confirm your password." \
10 60 2> pass2
while [ "$(cat pass1)" != "$(cat pass2)" ]
do
dialog --no-cancel --passwordbox \
"Passwords do not match.\n\nEnter password again." \
10 60 2> pass1
dialog --no-cancel --passwordbox \
"Retype your password." \
10 60 2> pass2
done
name=$(cat name) && rm name
pass1=$(cat pass1) && rm pass1 pass2
# Create user if doesn't exist
if [[ ! "$(id -u "$name" 2> /dev/null)" ]]; then
dialog --infobox "Adding user $name..." 4 50
useradd -m -g wheel -s /bin/bash "$name"
fi
# Add password to user
echo "$name:$pass1" | chpasswd
}
dialog --title "root password" \
--msgbox "It's time to add a password for the root user" \
10 60
config_user root
dialog --title "Add User" \
--msgbox "Let's create another user." \
10 60
config_user
# Save your username for the next script.
echo "$name" > /tmp/user_name
# Ask to install all your apps / dotfiles.
# Don't forget to replace "Phantas0s" by the username of your Github account!
dialog --title "Continue installation" --yesno \
"Do you want to install all your apps and your dotfiles?" \
10 60 \
&& curl https://raw.githubusercontent.com/benjaminshawki\
/arch_installer/main/install_apps.sh > /tmp/install_apps.sh \
&& bash /tmp/install_apps.sh