2020-01-26 11:59:13 +01:00
|
|
|
build {
|
|
|
|
sources = [
|
2020-09-29 23:02:32 +02:00
|
|
|
"source.hcloud.main",
|
|
|
|
"source.digitalocean.main",
|
|
|
|
"source.qemu.main"
|
2020-01-26 11:59:13 +01:00
|
|
|
]
|
|
|
|
|
|
|
|
provisioner "file" {
|
|
|
|
direction = "upload"
|
2020-02-06 20:06:08 +01:00
|
|
|
source = "./rootfs"
|
|
|
|
destination = "/tmp"
|
2020-01-26 11:59:13 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
provisioner "shell" {
|
|
|
|
environment_vars = [
|
2020-02-06 20:02:31 +01:00
|
|
|
"DPKG_FORCE=confold",
|
2020-01-26 11:59:13 +01:00
|
|
|
"DEBIAN_FRONTEND=noninteractive"
|
|
|
|
]
|
2020-02-06 20:02:31 +01:00
|
|
|
inline_shebang = "/bin/sh -eux"
|
2020-01-26 11:59:13 +01:00
|
|
|
inline = [
|
2020-02-06 20:02:31 +01:00
|
|
|
<<EOF
|
2020-09-29 23:03:29 +02:00
|
|
|
find /tmp/rootfs/ -type f -name .gitkeep -delete
|
2020-02-06 20:06:08 +01:00
|
|
|
find /tmp/rootfs/ -type d -exec chmod 755 '{}' ';' -exec chown root:root '{}' ';'
|
|
|
|
find /tmp/rootfs/ -type f -exec chmod 644 '{}' ';' -exec chown root:root '{}' ';'
|
|
|
|
find /tmp/rootfs/ -type f -regex '.+/\(bin\|cron\..+\)/.+' -exec chmod 755 '{}' ';'
|
2020-02-06 20:58:18 +01:00
|
|
|
find /tmp/rootfs/ -type f -regex '.+/\(etc/wireguard\)/.+' -exec chmod 600 '{}' ';'
|
2020-02-07 22:28:11 +01:00
|
|
|
find /tmp/rootfs/ -mindepth 1 -maxdepth 1 -exec cp -fla '{}' / ';'
|
2020-02-06 20:06:08 +01:00
|
|
|
rm -rf /tmp/rootfs/
|
2020-02-06 20:02:31 +01:00
|
|
|
EOF
|
|
|
|
,
|
2020-06-11 19:09:29 +02:00
|
|
|
<<EOF
|
|
|
|
systemctl daemon-reload
|
2020-06-11 19:39:21 +02:00
|
|
|
EOF
|
2020-06-11 19:09:29 +02:00
|
|
|
,
|
2020-02-06 20:22:40 +01:00
|
|
|
<<EOF
|
|
|
|
timedatectl set-timezone UTC
|
|
|
|
localectl set-locale LANG=en_US.UTF-8
|
|
|
|
EOF
|
|
|
|
,
|
2020-02-06 20:02:31 +01:00
|
|
|
<<EOF
|
|
|
|
apt-get update
|
2020-05-03 14:47:53 +02:00
|
|
|
apt-get dist-upgrade -y
|
2020-02-06 20:17:29 +01:00
|
|
|
EOF
|
|
|
|
,
|
|
|
|
<<EOF
|
2020-10-07 00:28:19 +02:00
|
|
|
apt-get install -y --no-install-recommends \
|
|
|
|
ca-certificates \
|
2020-02-06 20:17:29 +01:00
|
|
|
dns-root-data \
|
2020-10-07 00:28:19 +02:00
|
|
|
gcc \
|
2020-06-19 00:12:25 +02:00
|
|
|
git \
|
2020-02-06 20:17:29 +01:00
|
|
|
htop \
|
2020-10-07 00:28:19 +02:00
|
|
|
libc6-dev \
|
2020-06-19 00:12:25 +02:00
|
|
|
libsystemd-dev \
|
2020-10-07 00:28:19 +02:00
|
|
|
make \
|
2020-02-06 20:17:29 +01:00
|
|
|
nano \
|
2020-06-14 19:49:14 +02:00
|
|
|
nftables \
|
2020-02-06 20:17:29 +01:00
|
|
|
openresolv \
|
2020-06-19 00:12:25 +02:00
|
|
|
pkgconf \
|
2020-02-06 20:17:29 +01:00
|
|
|
qrencode \
|
2020-06-11 19:18:18 +02:00
|
|
|
rng-tools \
|
2020-02-06 20:17:29 +01:00
|
|
|
ssh-import-id \
|
|
|
|
unattended-upgrades \
|
2020-04-24 00:15:12 +02:00
|
|
|
unbound \
|
|
|
|
wireguard
|
2020-09-06 13:27:23 +02:00
|
|
|
EOF
|
|
|
|
,
|
|
|
|
<<EOF
|
|
|
|
apt-get purge -y \
|
2020-10-07 00:28:19 +02:00
|
|
|
accountsservice \
|
|
|
|
packagekit \
|
2020-09-06 13:27:23 +02:00
|
|
|
snapd
|
2020-05-28 22:40:53 +02:00
|
|
|
apt-get autoremove -y
|
2020-02-06 20:02:31 +01:00
|
|
|
EOF
|
|
|
|
,
|
2020-06-19 00:12:25 +02:00
|
|
|
<<EOF
|
|
|
|
mkdir /usr/local/src/udptunnel/ && cd /usr/local/src/udptunnel/
|
|
|
|
git clone 'https://github.com/hectorm/udptunnel.git' ./
|
|
|
|
git checkout '2e32c0db162c6bfb61031c90d23ad941bf65797f'
|
|
|
|
PREFIX=/usr/local ./udptunnel-installer.sh
|
|
|
|
udptunnel --help
|
|
|
|
EOF
|
|
|
|
,
|
2020-02-06 20:02:31 +01:00
|
|
|
<<EOF
|
|
|
|
systemctl disable --now systemd-resolved.service
|
|
|
|
unlink /etc/resolv.conf && printf 'nameserver 127.0.0.1\n' > /etc/resolv.conf
|
|
|
|
systemctl enable --now unbound.service unbound-resolvconf.service
|
|
|
|
EOF
|
|
|
|
,
|
|
|
|
<<EOF
|
2020-06-14 19:49:14 +02:00
|
|
|
systemctl enable --now nftables.service rng-tools.service ssh.service
|
2020-06-11 19:19:16 +02:00
|
|
|
systemctl enable --now apt-daily-upgrade.timer apt-daily.timer unattended-upgrades.service
|
2020-06-19 00:12:25 +02:00
|
|
|
systemctl enable udptunnel.service wg-quick@wg0.service
|
2020-02-06 20:02:31 +01:00
|
|
|
EOF
|
|
|
|
,
|
|
|
|
<<EOF
|
2020-06-14 19:49:14 +02:00
|
|
|
groupadd -r ssh-user
|
|
|
|
usermod -aG ssh-user root
|
2020-08-09 13:57:41 +02:00
|
|
|
usermod -p '*' root
|
2020-02-06 20:02:31 +01:00
|
|
|
EOF
|
|
|
|
,
|
|
|
|
<<EOF
|
|
|
|
rm -f /etc/ssh/ssh_host_*key*
|
2020-06-11 19:23:32 +02:00
|
|
|
rm -f /etc/wireguard/*-*key /etc/wireguard/*-iface
|
|
|
|
find /var/lib/apt/lists/ -mindepth 1 -delete
|
2020-06-14 19:49:14 +02:00
|
|
|
find / -type f -regex '.+\.\(dpkg\|ucf\)-\(old\|new\|dist\)' -ignore_readdir_race -delete ||:
|
2020-02-06 20:02:31 +01:00
|
|
|
EOF
|
2020-01-26 11:59:13 +01:00
|
|
|
]
|
|
|
|
}
|
|
|
|
}
|