-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathchroot.sh
executable file
·117 lines (97 loc) · 2.89 KB
/
chroot.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
#!/bin/bash
set -uo pipefail
trap 's=$?; echo "$0: Error on line "$LINENO": $BASH_COMMAND"; exit $s' ERR
IFS=$'\n\t'
# Load config
. /root/config.sh
ln -sf "/usr/share/zoneinfo/$TIMEZONE_LOCATION" /etc/localtime
# Uncomment en_US.UTF-8 from /etc/locale.gen
sed -i 's/\#en\_US\.UTF\-8\ UTF\-8/en\_US\.UTF\-8\ UTF\-8/g' /etc/locale.gen
{
echo "LANG=en_US.UTF-8"
echo "LC_CTYPE=en_US.UTF-8"
echo "LC_MESSAGES=en_US.UTF-8"
echo "LC_ALL=en_US.UTF-8"
echo "LANGUAGE=\"en_US.UTF-8\""
} >> /etc/locale.conf
locale-gen
echo "$HOSTNAME" > /etc/hostname
{
echo "127.0.0.1 localhost.localdomain localhost"
echo "::1 localhost.localdomain localhost"
echo "127.0.0.1 $HOSTNAME.localdomain $HOSTNAME"
} >> /etc/hosts
pacman-key --init
pacman-key --populate archlinuxarm
# Pacman customizations
sed -i 's/\#Color/Color/g' /etc/pacman.conf
sed -i 's/\#TotalDownload/TotalDownload/g' /etc/pacman.conf
sed -i 's/\#VerbosePkgLists/VerbosePkgLists/g' /etc/pacman.conf
sed -i '/VerbosePkgLists/a ILoveCandy' /etc/pacman.conf
# Default user is alarm
sed -i "s/alarm/$USERNAME/g" /etc/passwd /etc/group /etc/shadow
mv /home/alarm "/home/$USERNAME"
echo -e "$PASSWORD\n$PASSWORD" | passwd "$USERNAME"
# Enable RPi Camera
sed -i 's/gpu_mem=.*/gpu_mem=128/' /boot/config.txt
grep 'start_file=start_x.elf' /boot/config.txt >/dev/null || echo 'start_file=start_x.elf' >> /boot/config.txt
grep 'fixup_file=fixup_x.dat' /boot/config.txt >/dev/null || echo 'fixup_file=fixup_x.dat' >> /boot/config.txt
# Connect to WiFi
ln -sf /usr/lib/systemd/system/[email protected] /etc/systemd/system/multi-user.target.wants/[email protected]
ln -sf /usr/lib/systemd/system/[email protected] /etc/systemd/system/multi-user.target.wants/[email protected]
cat <<EOF >"/etc/netctl/wlan0-SSID"
Description='Baked in profile'
Interface=wlan0
Connection=wireless
Security=wpa
ESSID="$SSID"
IP=dhcp
Key="$WIFI_PASSWORD"
EOF
# Install necessary packages
pacman -Syu --needed --noconfirm \
archlinux-keyring \
bash-completion \
crda \
dhcpcd \
dialog \
dnsutils \
exfat-utils \
git \
ifplugd \
iw \
networkmanager \
openssh \
sudo \
wpa_supplicant \
# Clear pacman cache
pacman -Sc --noconfirm
pacman -Syu --needed --noconfirm \
aria2 \
docker \
docker-compose \
htop \
neovim \
stow \
tmux \
tree \
wireguard-tools \
wireguard-dkms \
zsh
# Clear pacman cache
pacman -Sc --noconfirm
# Enable passwordless sudo for wheel group
echo '%wheel ALL=(ALL) ALL' >> /etc/sudoers.d/wheel
usermod -a -G wheel $USERNAME
# Enable SSH
mkdir -p ~/.ssh
mkdir -p /home/$USERNAME/.ssh
curl -L https://github.com/codingcoffee.keys >> ~/.ssh/authorized_keys
curl -L https://github.com/codingcoffee.keys >> /home/$USERNAME/.ssh/authorized_keys
systemctl enable sshd
# TODO Enable Docker and grant cc docker access
systemctl enable docker
usermod -a -G docker $USERNAME
# Cleanup
rm /root/config.sh
rm /root/chroot.sh