-
Notifications
You must be signed in to change notification settings - Fork 2
/
arch.sh
185 lines (127 loc) · 3.11 KB
/
arch.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
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
#!/bin/bash
#
# Travis Person ([email protected])
#
# Arch Linux Installation
USER="travis"
HOSTNAME="black"
DOMAIN="travis.fyi"
HOME="/home/$USER"
DOT_TAR="https://api.github.com/repos/travisperson/.dot/tarball"
# PACMAN_CACHE is expected to be an already formated partition that is
# ready to be written too. If from a previous installation it can contain
# pacman packages that will be used during installation.
PACMAN_CACHE="/dev/sdb1"
# WARNING! The primary device will be destroyed and all data losted
PRIMARY_DEVICE="/dev/sda"
#
#
# Time
#
timedatectl set-ntp true
#
# Disk partition
#
# TODO: Detect and partition pacman cache?
PD_MAX_SECTORS=$(blockdev --getsz "$PRIMARY_DEVICE")
# SATA Drives LBA starts @ 2048
# 6144 = 4096 (Sector Start) + 2048 (First LBA)
sfdisk "$PRIMARY_DEVICE" <<EOF
label: gpt
label-id: B0F48A5F-CB93-4C3F-8992-222217998248
device: $PRIMARY_DEVICE
unit: sectors
first-lba: 2048
last-lba: $((PD_MAX_SECTORS - 2048))
${PRIMARY_DEVICE}1 : start= 2048, size= 2048, type=21686148-6449-6E6F-744E-656564454649, uuid=E88EB8CC-ADB4-6040-B3DA-1754D18368BA
${PRIMARY_DEVICE}2 : start= 4096, size= $((PD_MAX_SECTORS - 6144)), type=0FC63DAF-8483-4772-8E79-3D69D8477DE4, uuid=D02DD14B-A49F-F845-80E3-29EC929C7A95
EOF
sync
# Format the second parittion as ext4
mkfs.ext4 -F "${PRIMARY_DEVICE}2"
#
# Initial disk setup
#
# Mount primary
mount "${PRIMARY_DEVICE}2" /mnt
# Setup pacman cache
mkdir -p /mnt/var/cache/pacman/pkg
mount "$PACMAN_CACHE" /mnt/var/cache/pacman/pkg
#
# Initial Install
#
pacstrap /mnt base base-devel i3 xorg xorg-apps xorg-drivers
#
# Generate fstab
#
genfstab -U /mnt >> /mnt/etc/fstab
#
# Post chroot setup script
#
cat > /mnt/root/setup.sh <<EOFSUB
#
# Timezone / locale
#
ln -sf /usr/share/zoneinfo/America/Los_Angeles /etc/localtime
hwclock --systohc
sed -i -e "/#en_US.UTF-8 UTF-8/c\en_US.UTF-8 UTF-8" -e "/#en_US ISO-8859-1/c\en_US ISO-8859-1" /etc/locale.gen
locale-gen
cat > /etc/locale.conf <<EOF
LANG=en_US.UTF-8
EOF
#
# Enable passwordless sudo for easy setup
#
sed -i -e "/# %wheel ALL=(ALL) NOPASSWD: ALL/c\%wheel ALL=(ALL) NOPASSWD: ALL" /etc/sudoers
#
# Hostname / host file setup
#
cat > /etc/hostname <<EOF
$HOSTNAME.$DOMAIN
EOF
cat > /etc/hosts <<EOF
127.0.0.1 localhost.localdomain localhost
::1 localhost.localdomain localhost
127.0.1.1 $HOSTNAME.$DOMAIN $HOSTNAME
EOF
#
# Setup Grub
#
pacman -Sy --noconfirm grub
grub-install --target=i386-pc "$PRIMARY_DEVICE"
grub-mkconfig -o /boot/grub/grub.cfg
#
# User setup
#
useradd -m $USER -d $HOME -G wheel
passwd -d $USER
mkdir $HOME/.dot
curl -L $DOT_TAR | tar xz -C $HOME/.dot --strip=1
chown -R $USER:$USER $HOME
#
# Yaourt
#
cat >> /etc/pacman.conf <<EOF
[archlinuxfr]
SigLevel = Never
Server = https://repo.archlinux.fr/\\\$arch
EOF
#
# Post login setup
#
cat >> $HOME/.bash_profile <<EOF
[[ -f ~/.setup ]] && sh ~/.setup
EOF
ln -s $HOME/.dot/setup.sh $HOME/.setup
exit
EOFSUB
#
# chroot install
#
arch-chroot /mnt /bin/bash -c "/bin/bash /root/setup.sh"
#
# Cleanup mounted dirs
#
umount /mnt/var/cache/pacman/pkg
umount /mnt
reboot