summaryrefslogtreecommitdiffstats
path: root/hosts/generic1
blob: acd40b07d59c210137ea59387a0328c4242d078a (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
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
#!/bin/sh

#	start,size,id,bootable
part_script='
	1024,+,83,*
	'

#	fs           mp       type    options              dump    pass
fstab='
	@DEV1@       /        ext4    errors=remount-ro    0       1
	'

mirror='http://httpredir.debian.org/debian'
suite='jessie'
arch='amd64'
extra_pkgs='
	grub-pc
	linux-image-amd64
	sysvinit-core
	'

hostname='generic1'

locale='en_US'
supported_locales='en_US.UTF-8 en_DK.UTF-8'

time_zone='UTC'

passwd_shadow='on'
root_passwd_crypted='$6$he1NJ78D$MX6RAaXqldtiHl5e5tHtBn06lol0py5Y6fvsQrJ0vY2olzQabWKlqQxCtROVYf6Ud/du4AqcGnj06YKYRtTDb0'
root_login=true
user_make=true
user_name='user'
user_full_name='User'
user_groups='adm cdrom floppy sudo audio dip video plugdev netdev'
user_passwd_crypted='$6$HW3iK00IksexUd$6cyoqzc/VL7cXryGM8hxl9SVYornqTK9x3DMJnU4WmQaAMJeJIXPXMZwjLATtlYS5tvtL//6ms23vtx6.MIY0/'

debconf_selections='
	keyboard-configuration keyboard-configuration/layout select English (US)
	keyboard-configuration keyboard-configuration/variant select English (US)
	'

postinst_pkgs='
	bash bash-completion
	screen sudo adduser
	bc
	nocache
	lsof
	info
	vcsh myrepos
	vim bvi less wdiff vbindiff
	git build-essential autoconf automake pkg-config m4 bison flex gdb
	subversion mercurial
	patch quilt
	flashrom
	dnsutils whois ftp
	gddrescue
	alsa-utils alsa-base
	openssh-server openssh-client rsync netcat-openbsd
	minicom htop ntp ncdu
	'

do_postinst()
{
	# Add "deb-src" line and backports.
	cat >"${target}/etc/apt/sources.list" <<-EOF
		deb http://httpredir.debian.org/debian jessie main
		deb-src http://httpredir.debian.org/debian jessie main
		EOF
	cat >"${target}/etc/apt/sources.list.d/jessie-backports.list" <<-EOF
		deb http://httpredir.debian.org/debian jessie-backports main
		deb-src http://httpredir.debian.org/debian jessie-backports main
		EOF
	in_target apt-get update || return 1

	# 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

	# Install GRUB.
	in_target update-grub
	in_target grub-install "${dev}"

	# Update initramfs.
	in_target update-initramfs -u

	# Configure network interfaces.
	cat >"${target}/etc/network/interfaces" <<-EOF
	# This file describes the network interfaces available on your system
	# and how to activate them. For more information, see interfaces(5).

	# The loopback network interface
	auto lo
	iface lo inet loopback

	# The primary network interface
	auto eth0
	allow-hotplug eth0
	iface eth0 inet dhcp
	EOF

	# Use temporary configuation SSH key.
	install -d -o 1000 -g 1000 -m 0700 "${target}/home/user/.ssh" || return 1
	cat >"${target}/home/user/.ssh/id_rsa" <<-EOF
		-----BEGIN RSA PRIVATE KEY-----
		MIICXAIBAAKBgQCzAF0zqeS2X0TuVOIxqMec3lMzZy/MHQswPP+BQkmc2D3YVb2x
		px1YAAweQnfZ27pGJkDztStOtMQJeaOsnAVdm2NSe+hEdaKAOxf9p6t+F930HM/w
		1wkm1ddlsnCaaCipzGVOM77Q/brEItWvuq8G0+/fgN1o4pZzl4Bub/4D4QIDAQAB
		AoGAS+wKnAAiXuv3m7LrIa75w2JVHcdVcZicB0DICnYoLNtXF+v+AlzkSE/009zT
		YtccoeZVxEiCbuajA3XRY0PlzgGHTbsGn1BWqI9cjdXTiotnjzOH8zr3JiMZMWwf
		hqwbtleP+yruNPHMxQ8dKVXv875NKJW+aArmQWtjeMOy/vECQQDdsvPJ4bUu8M7/
		MXqGtz8CJbrRp+ZMKUw0WuwSwTfHRs/Jp27mWf5+t/u+RN8WK/RRD8FHvz4azLhr
		sNUFiE69AkEAzrI/DFBFOM5mUECujs2UvCCeWZiAi9QoJ7kDrrAkcG+hMalpNUU3
		SUZ76stBUk3hZNpc82aq0a0o8ac0VrBd9QJAB3nbYrlrxLN2J4Dhot1XEJl5HUzO
		JU9XNITEZTWCzgODSkeNI9NxE5DcumPUKgk9aeZgHC1EyN6ScX87D76y+QJAL8DE
		ii69X1toDeBzs7BRTYlnrCFsiWGRiWPYMvKk6IkRv6x5DwKXvEkZdexRghdWHHvK
		f71Xd6u+yt2rXN/QRQJBALv6SwbokdXp5qKJV48QG452dSOT7FQEINnCsIeNUKP6
		9YyaZxqLia6pEbEKTSRdztXaMqRsrmOG8E084sFg8DQ=
		-----END RSA PRIVATE KEY-----
		EOF
	in_target chown user:user '/home/user/.ssh/id_rsa'
	in_target chmod 0600 '/home/user/.ssh/id_rsa'

	# Set up SSH known hosts.
	cat >"${target}/home/user/.ssh/known_hosts" <<-EOF
		|1|fypb7kn7NH0fqHGj9Xs/rdpO71s=|SCtg2BdMNB9zL5bAPYkJy1uiNSM= ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQCXcG5BuZi4947D9WqY1L6CzaH4Qjw7YA7Dja+09y0nZjLVDd1saZCPkTjo1PEHxVCvSHvc0VmRqIZ2wUGtuqIlgGPMphCPAtdHN63YcNXqIhjEygLsaSZgy1Qz33YQF+YSANbeZQ4vnqiYr3C1IA7Cw4km/0s1BvP3t9yJf/iYODZqjVqUhqB4hzXJcBZHrgnM4LmPD4NH81fCqpwfRviNQNFAqd/aT1YTvgdn46HTVz7dV8ahW6SLXBTJZvO9dLAAKOPPZwuluaRphBqjPLC83zsihQ884SAH+AKcpN1ne73UZUuA1Gyk3HW+a/ngbzm1nmoeC0Sm1nNlTvC4WrLD
		|1|z7it+otnWcn/98YKdeaBCXl+ug8=|NFRpdQZBMTAuWbUDAqXLptFR5Ao= ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQCXcG5BuZi4947D9WqY1L6CzaH4Qjw7YA7Dja+09y0nZjLVDd1saZCPkTjo1PEHxVCvSHvc0VmRqIZ2wUGtuqIlgGPMphCPAtdHN63YcNXqIhjEygLsaSZgy1Qz33YQF+YSANbeZQ4vnqiYr3C1IA7Cw4km/0s1BvP3t9yJf/iYODZqjVqUhqB4hzXJcBZHrgnM4LmPD4NH81fCqpwfRviNQNFAqd/aT1YTvgdn46HTVz7dV8ahW6SLXBTJZvO9dLAAKOPPZwuluaRphBqjPLC83zsihQ884SAH+AKcpN1ne73UZUuA1Gyk3HW+a/ngbzm1nmoeC0Sm1nNlTvC4WrLD
		EOF
	in_target chown user:user '/home/user/.ssh/known_hosts'
	in_target chmod 0600 '/home/user/.ssh/known_hosts'

	# Bootstrap vcsh and mr.
	rm -f "${target}/home/user/.profile" "${target}/home/user/.bashrc" \
		"${target}/home/user/.bash_logout"
	in_target sudo -u user vcsh clone \
		ssh://git@git.pehjota.net/dotfiles/mr.git mr || return 1
	in_target sudo -u user mr update || return 1

	# Generate target's SSH keypair.
	#rm -f "${target}/home/user/.ssh/id_rsa" \
	#	"${target}/home/user/.ssh/id_rsa.pub" || return 1
	#in_target ssh-keygen -b 4096 -C user@generic1 -t rsa \
	#	-f /home/user/.ssh/id_rsa </dev/null || return 1
	#cp "${target}/home/user/.ssh/id_rsa.pub" 'user@generic1.pub' || return 1

	return 0
}