summary refs log tree commit diff
path: root/host/rootfs/etc/s6-rc/ext-rc-init/up
blob: f6d0e772ae3b94966c0dc6d13b203e44c4e21ac6 (plain) (blame)
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
# SPDX-License-Identifier: EUPL-1.2+
# SPDX-FileCopyrightText: 2021-2023 Alyssa Ross <hi@alyssa.is>
# SPDX-FileCopyrightText: 2022 Unikie

if { mkdir -p /run/s6-rc.ext.src }
cd /run/s6-rc.ext.src

if {
  elglob -0 dirs /ext/svc/data/*/
  forx -po0 -E dir { $dirs }
  backtick -E name { basename -- $dir }

  if { mkdir vm-${name} vm-${name}/data vm-${name}/dependencies.d vm-${name}/env }
  if { ln -s $dir vm-${name}/data/config }
  if { redirfd -w 1 vm-${name}/type echo longrun }
  if { redirfd -w 1 vm-${name}/notification-fd echo 3 }
  if { redirfd -w 1 vm-${name}/run printf "#!/bin/execlineb -P\n/bin/start-vm" }
  if { chmod +x vm-${name}/run }

  if {
    elglob -0 paths ${dir}/shared-dirs/*
    forx -po0 -E path { $paths }
    backtick -E fsname { basename -- $path }
    if { cp -R /etc/template/fs fs-${name}-${fsname} }
    if { mkdir fs-${name}-${fsname}/data fs-${name}-${fsname}/env }
    if { cp -P ${path}/dir fs-${name}-${fsname}/data/shared-dir }
    touch vm-${name}/dependencies.d/fs-${name}-${fsname}
  }

  if {
    if -t { test -e ${dir}/wayland }
    if { cp -R -- /etc/template/gpu gpu-${name} }
    if { mkdir -- gpu-${name}/env }
    touch -- vm-${name}/dependencies.d/gpu-${name}
  }

  elglob -0 paths /ext/svc/data/${name}/providers/net/*
  forx -po0 -E path { $paths }
  backtick -E dep { basename -- $path }
  touch vm-${name}/dependencies.d/vm-${dep}
}

if { s6-rc-compile /run/s6-rc.ext.db /run/s6-rc.ext.src }
s6-rc-init -c /run/s6-rc.ext.db -l /run/s6-rc.ext -p ext- /run/service