forked from Zaechus/artix-installer
-
Notifications
You must be signed in to change notification settings - Fork 0
/
install.sh
executable file
·124 lines (106 loc) · 3.53 KB
/
install.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
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
#!/bin/sh -e
#
# A simple installer for Artix Linux
#
# Copyright (c) 2022 Maxwell Anderson
#
# This file is part of artix-installer.
#
# artix-installer is free software: you can redistribute it and/or modify it
# under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# artix-installer is distributed in the hope that it will be useful, but
# WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
# General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with artix-installer. If not, see <https://www.gnu.org/licenses/>.
confirm_password () {
local pass1="a"
local pass2="b"
until [[ $pass1 == $pass2 && $pass2 ]]; do
printf "$1: " >&2 && read -rs pass1
printf "\n" >&2
printf "confirm $1: " >&2 && read -rs pass2
printf "\n" >&2
done
echo $pass2
}
# Load keymap
sudo loadkeys us
# Check boot mode
[[ ! -d /sys/firmware/efi ]] && printf "Not booted in UEFI mode. Aborting..." && exit 1
# Choose my_init
until [[ $my_init == "openrc" || $my_init == "dinit" ]]; do
printf "Init system (openrc/dinit): " && read my_init
[[ ! $my_init ]] && my_init="openrc"
done
# Choose disk
while :
do
sudo fdisk -l
printf "\nDisk to install to (e.g. /dev/sda): " && read my_disk
[[ -b $my_disk ]] && break
done
part1="$my_disk"1
part2="$my_disk"2
part3="$my_disk"3
if [[ $my_disk == *"nvme"* ]]; then
part1="$my_disk"p1
part2="$my_disk"p2
part3="$my_disk"p3
fi
# Swap size
until [[ $swap_size =~ ^[0-9]+$ && (($swap_size -gt 0)) && (($swap_size -lt 97)) ]]; do
printf "Size of swap partition in GiB (4): " && read swap_size
[[ ! $swap_size ]] && swap_size=4
done
# Choose filesystem
until [[ $my_fs == "btrfs" || $my_fs == "ext4" ]]; do
printf "Filesystem (btrfs/ext4): " && read my_fs
[[ ! $my_fs ]] && my_fs="btrfs"
done
root_part=$part3
[[ $my_fs == "ext4" ]] && root_part=$part2
# Encrypt or not
printf "Encrypt? (y/N): " && read encrypted
[[ ! $encrypted ]] && encrypted="n"
my_root="/dev/mapper/root"
my_swap="/dev/mapper/swap"
if [[ $encrypted == "y" ]]; then
cryptpass=$(confirm_password "encryption password")
else
my_root=$part3
my_swap=$part2
[[ $my_fs == "ext4" ]] && my_root=$part2
fi
[[ $my_fs == "ext4" ]] && my_swap="/dev/MyVolGrp/swap"
# Timezone
until [[ -f /usr/share/zoneinfo/$region_city ]]; do
printf "Region/City (e.g. 'America/Denver'): " && read region_city
[[ ! $region_city ]] && region_city="America/Denver"
done
# Host
while :
do
printf "Hostname: " && read my_hostname
[[ $my_hostname ]] && break
done
# Users
root_password=$(confirm_password "root password")
installvars () {
echo my_init=$my_init my_disk=$my_disk part1=$part1 part2=$part2 part3=$part3 \
swap_size=$swap_size my_fs=$my_fs root_part=$root_part encrypted=$encrypted my_root=$my_root my_swap=$my_swap \
region_city=$region_city my_hostname=$my_hostname \
cryptpass=$cryptpass root_password=$root_password
}
printf "\nDone with configuration. Installing...\n\n"
# Install
sudo $(installvars) sh src/installer.sh
# Chroot
sudo cp src/iamchroot.sh /mnt/root/ && \
sudo $(installvars) artix-chroot /mnt /bin/bash -c 'sh /root/iamchroot.sh; rm /root/iamchroot.sh; exit' && \
printf '\n`sudo artix-chroot /mnt /bin/bash` back into the system to make any final changes.\n\nYou may now poweroff.\n'