-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathenterthevoid
More file actions
executable file
·223 lines (193 loc) · 6.65 KB
/
enterthevoid
File metadata and controls
executable file
·223 lines (193 loc) · 6.65 KB
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
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
#!/bin/bash
# enter the void - developed by acidvegas
set -xev
# Configuration
ARCH=x86_64 # x86_64 or x86_64-musl
CPU=intel # amd or intel
DRIVE=/dev/sdb # can be a single drive or an array if using raidz with zfs
HOSTNAME=blackhole
SWAP_SIZE=4 # In GB (set to 0 to disable)
ROOT_FS=btrfs # btrfs or ext4
TIMEZONE=America/New_York
USERNAME=fractal
WIFI_SSID= # Leave blank if you don't want to use wifi
WIFI_PASS=
WIFI_DEV=wlan0
if [ -d /sys/firmware/efi ]; then
BOOT_OPTION=UEFI
else
BOOT_OPTION=BIOS
fi
check_config() {
if [ ! $ARCH = "x86_64" ] && [ ! $ARCH = "x86_64-musl" ]; then
printf "invalid ARCH\n" && exit 1
elif [ ! $CPU = "amd" ] && [ ! $CPU = "intel" ]; then
printf "invalid CPU\n" && exit 1
elif [ ! -b $DRIVE ]; then
printf "invalid DRIVE\n" && exit 1
elif [ -z $HOSTNAME ]; then
printf "invalid HOSTNAME\n" && exit 1
elif ! [ "$SWAP_SIZE" -eq "$SWAP_SIZE" ] 2>/dev/null; then
printf "invalid SWAP_SIZE\n" && exit 1
elif [ ! $ROOT_FS = "btrfs" ] && [ ! $ROOT_FS = "ext4" ] && [ ! $ROOT_FS = "zfs" ]; then
printf "invalid ROOT_FS\n" && exit 1
elif [ ! -f /usr/share/zoneinfo/$TIMEZONE ]; then
printf "invalid TIMEZONE\n" && exit 1
elif [ -z $USERNAME ]; then
printf "invalid USERNAME\n" && exit 1
elif [ ! -z $WIFI_SSID ]; then
if [ -z $(ip addr | grep '^[0-9]:' | awk '{print $2}' | tr -d ':' | grep $WIFI_DEV) ]; then
printf "invalid WIFI_DEV\n" && exit 1
fi
fi
}
setup_network() {
if [ ! -z "$WIFI_SSID" ]; then
if rfkill list wifi | grep -q 'Soft blocked: yes\|Hard blocked: yes'; then
printf "Wifi is blocked, attempting to unblock... (make sure to handle this after reboot)\n"
rfkill unblock wifi
fi
wpa_passphrase "$WIFI_SSID" "$WIFI_PASS" | wpa_supplicant -i $WIFI_DEV -c /dev/stdin
fi
}
setup_partition() {
xbps-install -u xbps
xbps-install -Su
xbps-install parted
wipefs -a $DRIVE
if [ $BOOT_OPTION = "UEFI" ]; then
parted $DRIVE --script mklabel gpt
parted $DRIVE --script mkpart primary fat32 1MiB 513MiB
parted $DRIVE --script set 1 esp on
parted $DRIVE --script mkpart primary $ROOT_FS 513MiB 100%
partprobe $DRIVE
mkfs.vfat ${DRIVE}1
if [ $ROOT_FS = "btrfs" ]; then
mkfs.btrfs -f ${DRIVE}2
mount ${DRIVE}2 /mnt
btrfs subvolume create /mnt/@
btrfs subvolume create /mnt/@home
btrfs subvolume create /mnt/@snapshots
umount /mnt
mount -o subvol=@ ${DRIVE}2 /mnt
mkdir -p /mnt/{home,snapshots}
mount -o subvol=@home ${DRIVE}2 /mnt/home
mount -o subvol=@snapshots ${DRIVE}2 /mnt/snapshots
elif [ $ROOT_FS = "ext4" ]; then
mkfs.ext4 ${DRIVE}2
mount ${DRIVE}2 /mnt
fi
mkdir -p /mnt/boot/efi
mount ${DRIVE}1 /mnt/boot/efi
elif [ $BOOT_OPTION = "BIOS" ]; then
parted $DRIVE --script mklabel msdos
parted $DRIVE --script mkpart primary $ROOT_FS 1MiB 100%
parted $DRIVE --script set 1 boot on
partprobe $DRIVE
if [ $ROOT_FS = "btrfs" ]; then
mkfs.btrfs -f ${DRIVE}1
mount ${DRIVE}1 /mnt
btrfs subvolume create /mnt/@
btrfs subvolume create /mnt/@home
btrfs subvolume create /mnt/@snapshots
umount /mnt
mount -o subvol=@ ${DRIVE}1 /mnt
mkdir -p /mnt/{home,snapshots}
mount -o subvol=@home ${DRIVE}1 /mnt/home
mount -o subvol=@snapshots ${DRIVE}1 /mnt/snapshots
elif [ $ROOT_FS = "ext4" ]; then
mkfs.ext4 ${DRIVE}1
mount ${DRIVE}1 /mnt
fi
fi
}
setup_install() {
REPO=https://repo-default.voidlinux.org/current
if [ $ARCH = 'x86-64-musl' ]; then
REPO=$REPO/musl
fi
mkdir -p /mnt/var/db/xbps/keys
cp /var/db/xbps/keys/* /mnt/var/db/xbps/keys/
XBPS_ARCH=$ARCH xbps-install -S -r /mnt -R "$REPO" base-system linux
printf "entering chroot...remember to run setup_chroot() inside the chroot!\n"
xchroot /mnt /bin/bash
}
setup_chroot() {
passwd
xbps-install -u xbps
xbps-install -Su
if [ $CPU = "intel" ]; then
xbps-install void-repo-nonfree
xbps-install -Su
xbps-install intel-ucode
ln -sf /etc/sv/intel-ucode /etc/runit/runsvdir/default/
elif [ $CPU = "amd" ]; then
xbps-install linux-firmware-amd
fi
useradd -m -s /bin/bash $USERNAME && passwd $USERNAME && gpasswd -a $USERNAME wheel
ln -sf /usr/share/zoneinfo/$TIMEZONE /etc/localtime
ln -sf /etc/sv/dhcpcd /etc/runit/runsvdir/default/
hwclock --systohc
printf "$HOSTNAME\n" > /etc/hostname
printf "HOSTNAME=\"$HOSTNAME\"\nHARDWARECLOCK=\"UTC\"\nTIMEZONE=\"$TIMEZONE\"\nKEYMAP=us\n" > /etc/rc.conf
if [ $ARCH = 'x86_64' ]; then
printf "en_US.UTF-8 UTF-8\n" > /etc/default/libc-locales
printf "LANG=en_US.UTF-8\n" > /etc/locale.conf
xbps-reconfigure -f glibc-locales
fi
if [ $BOOT_OPTION = "UEFI" ]; then
if [ $ROOT_FS = "btrfs" ]; then
printf "UUID=$(blkid -s UUID -o value ${DRIVE}2) / $ROOT_FS defaults,noatime,subvol=@ 0 1\n"
printf "UUID=$(blkid -s UUID -o value ${DRIVE}2) /home $ROOT_FS defaults,subvol=@home 0 1\n"
printf "UUID=$(blkid -s UUID -o value ${DRIVE}2) /snapshots $ROOT_FS defaults,subvol=@snapshots 0 1\n"
elif [ $ROOT_FS = "ext4" ]; then
printf "UUID=$(blkid -s UUID -o value ${DRIVE}2) / $ROOT_FS defaults,noatime 0 1\n"
fi
printf "UUID=$(blkid -s UUID -o value ${DRIVE}1) /boot/efi vfat defaults,noatime 0 1\n"
elif [ $BOOT_OPTION = "BIOS" ]; then
if [ $ROOT_FS = "btrfs" ]; then
printf "UUID=$(blkid -s UUID -o value ${DRIVE}1) / btrfs defaults,noatime,subvol=@ 0 1\n"
printf "UUID=$(blkid -s UUID -o value ${DRIVE}1) /home btrfs defaults,subvol=@home 0 1\n"
printf "UUID=$(blkid -s UUID -o value ${DRIVE}1) /snapshots btrfs defaults,subvol=@snapshots 0 1\n"
elif [ $ROOT_FS = "ext4" ]; then
printf "UUID=$(blkid -s UUID -o value ${DRIVE}1) / $ROOT_FS defaults,noatime 0 1\n"
fi
fi > /etc/fstab
printf "tmpfs /tmp tmpfs defaults,nosuid,nodev 0 0\n" >> /etc/fstab
if [ $SWAP_SIZE -gt 0 ]; then
touch /swapfile
if [ $ROOT_FS = "btrfs" ]; then
chattr +C /swapfile
fi
dd if=/dev/zero of=/swapfile bs=1M count=${SWAP_SIZE}k status=progress
chmod 0600 /swapfile
mkswap /swapfile
swapon /swapfile
printf "/swapfile none swap sw 0 0\n" >> /etc/fstab
fi
if [ $BOOT_OPTION = "UEFI" ]; then
xbps-install gummiboot
gummiboot install
nano /boot/loader/void-options.conf
xbps-reconfigure -f linux$(unamer -r)
# Optional, copy the EFI /boot/efi/EFI/boot/bootx64.efi to for tricking compatability
elif [ $BOOT_OPTION = "BIOS" ]; then
xbps-install grub
grub-install /dev/$DRIVE
fi
xbps-reconfigure -fa
exit
}
if [ "$#" -ne 1 ]; then
printf "usage: $0 [install|partition|chroot|final]\n"
exit 1
fi
check_config
case "$1" in
network) setup_network ;;
partition) setup_partition ;;
install) setup_install ;;
chroot) setup_chroot ;;
final) umount -R /mnt; reboot ;;
*) printf "usage: $0 [install|partition|chroot|final]\n"; exit 1 ;;
esac