-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathsetup-arch-pi.sh
64 lines (52 loc) · 1.56 KB
/
setup-arch-pi.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
#!/bin/sh
# by Ian Lansdowne
set -e
# Get Arch ARM (aarch64) Filesystem
wget -Nq http://os.archlinuxarm.org/os/ArchLinuxARM-rpi-aarch64-latest.tar.gz
[[ -z "$device" ]] && read -p 'Device to format: ' device
[[ -z "$hostname" ]] && read -p 'Enter a hostname: ' hostname
[[ -z "$user" ]] && read -p 'New User: ' user
[[ -z "$pw" ]] && read -sp 'Password: ' pw
wipefs -abf "$device"
sfdisk "$device" < partitions.sfdisk
mkfs.vfat -I "${device}1"
mkfs.ext4 -F "${device}2"
fatlabel "${device}1" boot
e2label "${device}2" root
mkdir -p root
mount "${device}2" root
mkdir -p root/boot
mount "${device}1" root/boot
tar -xpf ArchLinuxARM-rpi-aarch64-latest.tar.gz -C root
sync
sed -i 's/mmcblk0/mmcblk1/g' root/etc/fstab # required for aarch64
sed -i "/^#Color/ cColor" /etc/pacman.conf # colors!
sed -i "/^#ParallelDownloads/ cParallelDownloads=5" /etc/pacman.conf # faster package downloads
# Modify configuration files
# Automatically connect to a Wi-Fi network
cat << EOF > root/etc/netctl/automatic-wifi
Description='A simple WPA encrypted wireless connection'
Interface=wlan0
Connection=wireless
Security=wpa
IP=dhcp
ESSID='<ssid>'
Key='<password>'
EOF
echo "$hostname" > root/etc/hostname
# Run configuration script
arch-chroot root /bin/sh << EOF
pacman-key --init
pacman-key --populate archlinuxarm
pacman -Syu --noconfirm sudo fish
pacman -Sc --noconfirm
echo "%wheel ALL=(ALL:ALL) ALL" >> /etc/sudoers
visudo -c
useradd -m "$user" -s /bin/fish
echo "$user:$pw" | chpasswd
usermod -aG wheel "$user"
passwd -d root
userdel -r alarm
netctl enable automatic-wifi
EOF
umount -AR root