main
1#!/bin/sh
2# Common setup for all Alpine appliances
3# (sourced into the combined setup script, runs in chroot)
4
5# --- Runlevels ---
6# sysinit
7rc-update add devfs sysinit
8rc-update add dmesg sysinit
9rc-update add mdev sysinit
10rc-update add hwdrivers sysinit
11
12# boot
13rc-update add hwclock boot
14rc-update add modules boot
15rc-update add sysctl boot
16rc-update add hostname boot
17rc-update add bootmisc boot
18rc-update add syslog boot
19rc-update add networking boot
20rc-update add seedrng boot
21
22# shutdown
23rc-update add mount-ro shutdown
24rc-update add killprocs shutdown
25
26# default
27rc-update add crond default
28rc-update add chronyd default
29rc-update add sshd default
30rc-update add node-exporter default
31rc-update add persist-keys default
32rc-update add secrets default
33
34# WireGuard: create symlink for wg0 interface
35ln -sf /etc/init.d/wg-quick /etc/init.d/wg-quick.wg0
36# Add to boot but allow failure (no private key in QEMU, no route to endpoint)
37rc-update add wg-quick.wg0 default
38
39# --- Users ---
40adduser -D -s /bin/ash -h /home/vincent vincent
41adduser vincent wheel
42# Unlock account (adduser -D leaves it locked, which blocks SSH pubkey login)
43passwd -u vincent
44# Fix ownership of .ssh (copied from skeleton before user was created)
45chown -R vincent:vincent /home/vincent
46
47# --- Root password disabled, SSH only ---
48# Set a known password for console access (SSH is key-only)
49echo 'root:alpine' | chpasswd
50
51# --- Generate SSH host keys for testing ---
52# These get overridden at boot by /etc/init.d/persist-keys if /persist exists.
53# Generating them here ensures sshd works in QEMU without a persist partition.
54ssh-keygen -A
55
56# --- Serial console for QEMU/debug ---
57# Add getty on ttyAMA0 (RPi UART / QEMU serial)
58echo 'ttyAMA0::respawn:/sbin/getty -L ttyAMA0 115200 vt100' >> /etc/inittab