summaryrefslogtreecommitdiff
path: root/installer/guix-password
blob: a39c5664608261d50d102e65b930b5515524be2e (plain)
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
#!/run/current-system/profile/bin/bash

USER_PASSWORD=""
ROOT_PASSWORD=""

source ./guix-env
source ./guix-log

get_root_password() {
    read -s -p "Root password: " PASSWORD
    printf "\n"
    read -s -p "Confirm password: " PASSWORD_CONFIRM
    printf "\n"
    if [ "$PASSWORD" == "$PASSWORD_CONFIRM" ]; then
        ROOT_PASSWORD=$PASSWORD
        return
    else
        ERROR "Passwords do not match"
        get_root_password
    fi
}

get_user_password() {
    read -s -p "User password: " PASSWORD
    printf "\n"
    read -s -p "Confirm password: " PASSWORD_CONFIRM
    printf "\n"
    if [ "$PASSWORD" == "$PASSWORD_CONFIRM" ]; then
        USER_PASSWORD=$PASSWORD
        return
    else
        ERROR "Passwords do not match"
        get_user_password
    fi
}

EVENT "Setup /etc/shadow for root and user"

get_root_password
get_user_password

cat << EOF | chroot /mnt
passwd
$ROOT_PASSWORD
$ROOT_PASSWORD
passwd freya
$USER_PASSWORD
$USER_PASSWORD
EOF

EVENT "Successfully set passwords"