-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathinstall.sh
125 lines (103 loc) · 2.57 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
125
#!/bin/bash
# This script installs a non-UEFI, ext4, runit system with partitions for /, /boot, and /home.
if [ "$(id -u)" != 0 ]; then
echo "Must be run as root."
exit 1
fi
# Check UEFI or not
ls /sys/firmware/efi/efivars
if [ $? -eq 0 ]; then
echo UEFI
exit 1
fi
echo
# Check internet
ping -c 3 artixlinux.org
[ $? -eq 0 ] || exit 1
echo
set -x
# Install prereqs
alias pacman='pacman --noconfirm'
pacman -Sy
pacman -S fzf
alias fzf='fzf --layout=reverse'
alias lsblk='lsblk -o NAME,FSTYPE,SIZE,TYPE,MOUNTPOINTS,LABEL,UUID'
echo
# Set up partitions
set +x
drive="$(lsblk --nodeps | tail -n +2 | fzf --prompt="Select a drive to partition: " | awk '{print $1}')"
[ "$drive" == "" ] && exit 1
clear
echo "************************************************************************"
echo "Set up your partitions on drive: /dev/$drive"
echo
echo "Hints:"
echo " p: list partitions"
echo " d: delete partition"
echo " n: create new partition"
echo " w: write changes"
echo " q: quit without writing"
echo
echo "Guidelines:"
echo " 1. delete all partitions"
echo " 2. create /boot partition (default first sector; +1G size)"
echo " 3. create / partition (default first sector; +50G size)"
echo " 4. create /home partition (default first sector; default last sector)"
echo " 5. write partitions"
echo "************************************************************************"
fdisk /dev/"$drive"
echo
# Create filesystems
get_part() {
prompt="$1"
part="$(lsblk --list | grep "^$drive[0-9]\+.*" | fzf --prompt="$prompt" | awk '{print $1}')"
echo "$part"
}
while true; do
part=$( get_part "Select a partition to format to ext4 (esc to stop): " )
[ "$part" != "" ] || break
set -x
mkfs.ext4 /dev/"$part"
set +x
sleep 0.5
clear
done
echo
# Mount partitions
mount_part() {
dir="$1"
while true; do
part=$( get_part "Select the $dir partition to mount: " )
[ "$part" != "" ] || continue
set -x
mkdir -p /mnt"$dir"
mount /dev/"$part" /mnt"$dir"
set +x
clear
break
done
}
mount_part "/"
mount_part "/boot"
mount_part "/home"
echo
lsblk
echo
# Install base operating system
read -p "Continue to bootstrap operating system to /dev/$drive [y/n]? " -n 1 -r
echo
[[ $REPLY =~ ^[Yy]$ ]] || exit 0
set -x
basestrap /mnt base base-devel runit elogind-runit pacman-contrib
# Basic initial system setup
cp system-config/fstab-clean /mnt/etc/fstab
fstabgen -U /mnt >> /mnt/etc/fstab
cp ./initialize.sh /mnt/
artix-chroot /mnt sudo sh ./initialize.sh "$drive"
# Cleanup
rm -f /mnt/initialize.sh
# Done!
set +x
echo
read -p "Installation done! Press any key to shut down. " -n 1 -r
shutdown -h now