summaryrefslogtreecommitdiffstats
path: root/conf/unit/service.inc
blob: bebf25a4090396c4b4463dbda8b0d432d27defe5 (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
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
dnl vim: set filetype=sysctl.conf.m4 syntax=sysctl.conf.m4:
;-------------------------------------------------------------------------------
;----         M A I N    P A R T    O F   T H E   S E R V I C E             ----
;-------------------------------------------------------------------------------
%begin systemd-unit

# auto generated by wgtpkg-unit for {{:id}} version {{:version}} target {{:#target}} of {{:idaver}}
%nl

%systemd-unit system
IF_PERM(:partner:scope-platform)
%systemd-unit service UNIT_NAME_BASE
ELSE
%systemd-unit service UNIT_NAME_BASE@
ENDIF

[Unit]
Description={{description}}
X-AFM-description={{description}}
X-AFM-name={{name.content}}
X-AFM-shortname={{name.short}}
X-AFM-id=TARGET
X-AFM-version={{:version}}
X-AFM-author={{author.content}}
X-AFM-author-email={{author.email}}
X-AFM-width={{width}}
X-AFM-height={{height}}
{{#icon}}
X-AFM-icon={{:#metadata.install-dir}}/{{:src}}
{{/icon}}
X-AFM--ID={{:id}}
X-AFM--target-name={{:#target}}
X-AFM--content={{content.src}}
X-AFM--type={{content.type}}
X-AFM--wgtdir={{:#metadata.install-dir}}
X-AFM--workdir=APP_WORK_DIR
X-AFM--visibility=ON_PERM(`:public:hidden', `hidden', `visible')
%nl

IF_PERM(:partner:scope-platform)
X-AFM--scope=platform
After=afm-system-setup.service
ELSE
X-AFM--scope=user
Requires=afm-user-session@%i.target
After=user@%i.service
ENDIF

After=Network.target

# Adds check to smack
ConditionSecurity=smack
%nl

# Automatic bound to required api
{{#required-binding}}
{{#value=extern}}
BindsTo=UNIT_NAME_BINDING_SERVICE({{name}})
After=UNIT_NAME_BINDING_SERVICE({{name}})
{{/value=extern}}
{{/required-binding}}

{{#required-api}}
{{#value=auto|ws}}
BindsTo=UNIT_NAME_API_SERVICE({{name}})
After=UNIT_NAME_API_SERVICE({{name}})
{{/value=auto|ws}}
{{/required-api}}

{{#provided-api}}
{{#value=ws|auto}}
Requires=UNIT_NAME_API_SOCKET({{name}})
After=UNIT_NAME_API_SOCKET({{name}})
{{/value=ws|auto}}
{{/provided-api}}

%nl

[Service]

EnvironmentFile=-@afm_confdir@/unit.env.d/*
EnvironmentFile=-@afm_confdir@/widget.env.d/{{:id}}/*
SmackProcessLabel=SMACKLABEL
SuccessExitStatus=0 SIGKILL
UMask=0077

IF_PERM(:partner:scope-platform)
#DynamicUser=true
User=daemon
Group=nobody
Slice=platform.slice
ELSE
User=%i
Slice=user-%i.slice
WorkingDirectory=-APP_WORK_DIR
ExecStartPre=/bin/mkdir -p APP_WORK_DIR
Environment=DBUS_SESSION_BUS_ADDRESS=unix:path=USER_RUN_DIR/bus
ENDIF
IF_PERM(:system:capability:keep-all)
CapabilityBoundingSet=~
AmbientCapabilities=~
ELSE
CapabilityBoundingSet=
ENDIF

ON_PERM(:platform:no-oom,   OOMScoreAdjust=-500)
ON_PERM(:partner:real-time, IOSchedulingClass=realtime)
ON_PERM(:public:display,    SupplementaryGroups=display)
ON_PERM(:public:audio,      SupplementaryGroups=audio)
ON_NOT_PERM(:public:syscall:clock, SystemCallFilter=~@clock)
%nl

Environment=AFM_ID=TARGET
Environment=AFM_APP_INSTALL_DIR={{:#metadata.install-dir}}
Environment=AFM_WORKDIR=APP_WORK_DIR
Environment=AFM_WSAPI_DIR=API_PATH_WS
Environment=PATH=/usr/sbin:/usr/bin:/sbin:/bin:{{:#metadata.install-dir}}/bin
Environment=LD_LIBRARY_PATH={{:#metadata.install-dir}}/lib
Environment=XDG_DATA_HOME=APP_WORK_DIR
Environment=XDG_CONFIG_HOME=APP_WORK_DIR
Environment=XDG_CACHE_HOME=APP_WORK_DIR
Environment=XDG_RUNTIME_DIR=RUN_DIR

IF_AGL_DEVEL
; Needed to enable debug
EnvironmentFile=-DEBUGGING_DIR/TARGET.env
ENDIF

SyslogIdentifier=afbd-TARGET
StandardInput=null
StandardOutput=journal
StandardError=journal

;-------------------------------------------------------------------------------
;----   text/html  application/vnd.agl.native  application/vnd.agl.service  ----
;-------------------------------------------------------------------------------
{{#content.type=text/html|application/vnd.agl.native|application/vnd.agl.service}}
include(binder.inc)
{{/content.type=text/html|application/vnd.agl.native|application/vnd.agl.service}}

;-------------------------------------------------------------------------------
;----                 application/x-executable                              ----
;-------------------------------------------------------------------------------
{{#content.type=application/x-executable}}
ExecStart={{:#metadata.install-dir}}/{{content.src}}
{{/content.type=application/x-executable}}

IF_PERM(:system:run-by-default)
;-------------------------------------------------------------------------------
; auto start
;-------------------------------------------------------------------------------
[Install]
IF_PERM(:partner:scope-platform)
WantedBy=multi-user.target
%systemd-unit wanted-by multi-user.target
ELSE
WantedBy=afm-user-session@.target
%systemd-unit wanted-by afm-user-session@.target
ENDIF
ENDIF

%end systemd-unit