summaryrefslogtreecommitdiffstats
path: root/hosts/print1/postinst
blob: f9fafd825865362aaac141a4ada7608fa5e3fa98 (plain)
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
#!/bin/sh

# Purge systemd.
in_target apt-get -q -y purge libpam-systemd systemd || return 1
in_target apt-get -q -y --purge autoremove || return 1

# Remove packages from APT cache.
in_target apt-get clean || return 1

# Fix booting and install GRUB.
mv "${target}/etc/default/grub" "${target}/etc/default/grub.dist"
sed \
	-e '^s/\(GRUB_CMDLINE_LINUX=".*\)"$/\1nomodeset"/'
	"${target}/etc/default/grub.dist" 1>"${target}/etc/default/grub"
in_target update-grub
in_target grub-install "${dev}"

# Update initramfs.
in_target update-initramfs -u

# Configure network interfaces.
mv "${target}/etc/network/interfaces" "${target}/etc/network/interfaces.dist"
cat 1>"${target}/etc/network/interfaces" 0<<-EOF
	auto lo
	iface lo inet loopback

	auto enp1s0
	iface enp1s0 inet dhcp
	EOF

# Configure NFS.
mv "${target}/etc/exports" "${target}/etc/exports.dist"
cat 1>"${target}/etc/exports" 0<<-EOF
	EOF

# Harden SSH server.
mv "${target}/etc/ssh/sshd_config" "${target}/etc/ssh/sshd_config.dist"
sed \
	-e 's/^PermitRootLogin .*$/PermitRootLogin no/' \
	-e 's/^#PasswordAuthentication .*$/#PasswordAuthentication no/' \
	"${target}/etc/ssh/sshd_config.dist" 1>"${target}/etc/ssh/sshd_config"

return 0