aboutsummarylogtreecommitdiffstats
path: root/tailscale_install
blob: b18585f984409c0d964a6effcf372d75ec9db9f9 (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
#!/usr/bin/env ash

build() {
	if ! pacman -Qi tailscale >/dev/null 2>&1; then
		error "Package tailscale not installed"
		return 1
	fi

	local setupdir="/etc/initcpio/tailscale"
	for fn in tailscaled.state default.env; do
		if ! [[ -r "${setupdir}/${fn}" && -s "${setupdir}/${fn}" ]]; then
			error "Missing configuration file at ${setupdir}/${fn}. Have you run setup-initcpio-tailscale yet?"
			return 1
		fi
	done
	add_file ${setupdir}/default.env /etc/default/tailscaled
	add_file ${setupdir}/tailscaled.state /var/lib/tailscale/tailscaled.state

	# tailscale requirements
	add_module tun
	add_full_dir /usr/lib/xtables
	add_all_modules netfilter
	map add_binary iptables ip6tables tailscale tailscaled

	add_run_script
}

help() {
	cat <<-__EOF_HELP__
	This hook enables tailscale service within busybox initramfs.

	It copies all required files and binaries to initramfs and runs
	tailscale daemon in the background. Remember to place it before 
	any other hook that blocks for input like the 'encrypt' hook.

	Configuration is copied into the initramfs from:
	
		* /etc/initcpio/tailscale/tailscaled.state to /var/lib/tailscale/tailscaled.state
		* /etc/initcpio/tailscale/default.env to /etc/default/tailscaled

	Run setup-initcpio-tailscale to initialize /etc/initcpio/tailscale/ configuration files.

	This hook must come after the network is setup and before other hooks that blocks the
	init chain. Place it before 'encrypt' if you plan to unlock a rootfs remotely.
	
	__EOF_HELP__
}

# vim: noexpandtab