|
| 1 | +# METABEGIN |
| 2 | +# X-Env-Layer-Name: rpi-connect |
| 3 | +# X-Env-Layer-Category: service |
| 4 | +# X-Env-Layer-Desc: Raspberry Pi Connect client with screen-sharing support and |
| 5 | +# remote shell access |
| 6 | +# X-Env-Layer-Version: 1.0.0 |
| 7 | +# X-Env-Layer-Requires: systemd-min,rpi-user-credentials |
| 8 | +# X-Env-Layer-Provides: rpi-connect-client |
| 9 | +# |
| 10 | +# X-Env-VarRequires: IGconf_device_user1 |
| 11 | +# X-Env-VarRequires-Valid: string |
| 12 | +# |
| 13 | +# X-Env-VarPrefix: connect |
| 14 | +# |
| 15 | +# X-Env-Var-authkey: |
| 16 | +# X-Env-Var-authkey-Desc: Auth key generated via Raspberry Pi Connect account |
| 17 | +# Settings. This can hold a path to the key file or the key itself. |
| 18 | +# X-Env-Var-authkey-Required: n |
| 19 | +# X-Env-Var-authkey-Valid: string |
| 20 | +# X-Env-Var-authkey-Set: n |
| 21 | +# |
| 22 | +# X-Env-Var-on: y |
| 23 | +# X-Env-Var-on-Desc: Enable Raspberry Pi Connect on system startup |
| 24 | +# X-Env-Var-on-Required: n |
| 25 | +# X-Env-Var-on-Valid: bool |
| 26 | +# X-Env-Var-on-Set: y |
| 27 | +# METAEND |
| 28 | +--- |
| 29 | +mmdebstrap: |
| 30 | + packages: |
| 31 | + - rpi-connect |
| 32 | + - wayvnc |
| 33 | + customize-hooks: |
| 34 | + - |- |
| 35 | + set -eu |
| 36 | + uchroot "$1" 'mkdir -m 0700 -p ${HOME}/.config/com.raspberrypi.connect' |
| 37 | +
|
| 38 | + # Write the authkey from file or as string |
| 39 | + if [ -n "${IGconf_connect_authkey-}" ] ; then |
| 40 | + if [ -f "$IGconf_connect_authkey" ]; then |
| 41 | + uchroot "$1" 'umask 077; cat > "$HOME/.config/com.raspberrypi.connect/auth.key"' \ |
| 42 | + < "$IGconf_connect_authkey" |
| 43 | + else |
| 44 | + printf '%s' "$IGconf_connect_authkey" | \ |
| 45 | + uchroot "$1" 'umask 077; cat > "$HOME/.config/com.raspberrypi.connect/auth.key"' |
| 46 | + fi |
| 47 | + echo "Raspberry Pi Connect Auth key installed" |
| 48 | + fi |
| 49 | +
|
| 50 | + # Enable units |
| 51 | + uchroot "$1" 'set -e |
| 52 | + base="$HOME/.config/systemd/user" |
| 53 | + mkdir -p "$base/default.target.wants" "$base/rpi-connect.service.wants" |
| 54 | + ln -sf /usr/lib/systemd/user/rpi-connect.service "$base/default.target.wants/rpi-connect.service" |
| 55 | + ln -sf /usr/lib/systemd/user/rpi-connect-signin.path "$base/rpi-connect.service.wants/rpi-connect-signin.path" |
| 56 | + ln -sf /usr/lib/systemd/user/rpi-connect-wayvnc.service "$base/rpi-connect.service.wants/rpi-connect-wayvnc.service"' |
| 57 | +
|
| 58 | + # Write linger marker to trigger auto start via logind |
| 59 | + install -d -m 0755 "$1/var/lib/systemd/linger" |
| 60 | + if [ "$IGconf_connect_on" = "y" ]; then |
| 61 | + install -m 0644 /dev/null "$1/var/lib/systemd/linger/$IGconf_device_user1" |
| 62 | + echo "Raspberry Pi Connect enabled for system startup" |
| 63 | + fi |
0 commit comments