Start user units at the system level
[src/app-framework-main.git] / conf / afm-unit-debug.conf.in
1 ;---------------------------------------------------------------------------------
2 ; File:
3 ;
4 ;    afm-unit.conf
5 ;
6 ; Role:
7 ;
8 ;    Configure how installation of widget produces unit files for systemd
9 ;
10 ; Processing and format:
11 ;
12 ;    1. File load
13 ;
14 ;           Lines beginning with ; are firstly removed
15 ;
16 ;    2. File instantiation
17 ;
18 ;           Mustache (extended) substitutions are applied using JSON
19 ;           data deduced from config.xml file of the widget.
20 ;
21 ;    3. Extraction of units
22 ;
23 ;           Extract produced units, pack it (remove empty lines and directives)
24 ;
25 ; Directives:
26 ;
27 ;    Any directive occupy one whole line starting with %
28 ;
29 ;     - %nl
30 ;
31 ;             produce an empty line at the end
32 ;
33 ;     - %begin systemd-unit
34 ;     - %end systemd-unit
35 ;
36 ;             delimit the produced unit
37 ;
38 ;     - %systemd-unit user
39 ;     - %systemd-unit system
40 ;
41 ;             tells the kind of unit (user/system)
42 ;
43 ;     - %systemd-unit service NAME
44 ;     - %systemd-unit socket NAME
45 ;
46 ;             gives the name and type of the unit
47 ;
48 ;     - %systemd-unit wanted-by NAME
49 ;
50 ;             tells to install a link to unit in the wants of NAME
51 ;
52 ; Setting variables:
53 ;
54 ;    AFM uses the feature of systemd that completely ignores options prefixed
55 ;    with X-
56 ;
57 ;    Consequently, options starting with X-AFM- are recorded as public data
58 ;    about the application and options starting starting with X-AFM-- are
59 ;    recorded as private data.
60 ;
61 ;    Examples:
62 ;
63 ;        X-AFM-description={{description}}
64 ;
65 ;              Records the description of the unit in the field "description"
66 ;              of both the public and private object describing the unit.
67 ;
68 ;        X-AFM--wgtdir={{:#metadata.install-dir}}
69 ;
70 ;              Records the installation directory path in the field "wgtdir"
71 ;              of the private object only.
72 ;
73 ;---------------------------------------------------------------------------------
74 {{#targets}}
75
76 ;---------------------------------------------------------------------------------
77 ;----        P R O V I D E D   U N I T S                                      ----
78 ;---------------------------------------------------------------------------------
79 %begin systemd-unit
80
81 # auto generated by wgtpkg-unit for {{:id}} version {{:version}} target {{:#target}} of {{:idaver}}
82 %nl
83
84 [Unit]
85 Description={{description}}
86 X-AFM-description={{description}}
87 X-AFM-name={{name.content}}
88 X-AFM-shortname={{name.short}}
89 #***************
90 # use X-AFM-id={{:id}}--{{:ver}}--{{:#target}}
91 # instead of:
92 X-AFM-id={{idaver}}{{^#target=main}}@{{:#target}}{{/#target=main}}
93 # when home screen will use real ids
94 #**************
95 X-AFM-version={{:version}}
96 X-AFM-author={{author.content}}
97 X-AFM-author-email={{author.email}}
98 X-AFM-width={{width}}
99 X-AFM-height={{height}}
100 {{#icon}}
101 X-AFM-icon={{:#metadata.install-dir}}/{{:src}}
102 {{/icon}}
103 X-AFM--ID={{:id}}
104 X-AFM--target-name={{:#target}}
105 X-AFM--content={{content.src}}
106 X-AFM--type={{content.type}}
107 X-AFM--wgtdir={{:#metadata.install-dir}}
108 X-AFM--workdir={{&#metadata.app-data-dir}}/{{:id}}
109 %nl
110
111 Wants=sockets.target
112
113 # Adds check to smack
114 ConditionSecurity=smack
115 %nl
116
117 # Automatic bound to required api
118 {{#required-api}}
119 {{#value=auto|ws}}
120 BindsTo=afm-api-ws-{{name}}@%i.socket
121 After=afm-api-ws-{{name}}@%i.socket
122 {{/value=auto|ws}}
123 {{/required-api}}
124 %nl
125
126 [Service]
127 EnvironmentFile=-@afm_confdir@/unit.env.d/*
128 SmackProcessLabel=User::App::{{:id}}
129 SuccessExitStatus=0 SIGKILL
130
131 PAMName=su
132 User=%i
133
134 {{#required-permission}}
135   {{#urn:AGL:permission::platform:no-oom}}      OOMScoreAdjust=-500             {{/urn:AGL:permission::platform:no-oom}}
136   {{#urn:AGL:permission::partner:real-time}}    IOSchedulingClass=realtime      {{/urn:AGL:permission::partner:real-time}}
137 #  {{^urn:AGL:permission::partner:real-time}}    RestrictRealtime=on             {{/urn:AGL:permission::partner:real-time}}
138   {{#urn:AGL:permission::public:display}}       SupplementaryGroups=display     {{/urn:AGL:permission::public:display}}
139   {{^urn:AGL:permission::public:syscall:clock}} SystemCallFilter=~@clock        {{/urn:AGL:permission::public:syscall:clock}}
140 {{/required-permission}}
141 %nl
142
143 WorkingDirectory=-{{&#metadata.app-data-dir}}/{{:id}}
144 ExecStartPre=/bin/mkdir -p {{&#metadata.app-data-dir}}/{{:id}}
145 Environment=AFM_APP_INSTALL_DIR={{:#metadata.install-dir}}
146 Environment=PATH=/usr/sbin:/usr/bin:/sbin:/bin:{{:#metadata.install-dir}}
147
148 ; Needed to enable debug
149 Environment=AFM_ID={{idaver}}{{^#target=main}}@{{:#target}}{{/#target=main}}
150 EnvironmentFile=-/var/run/afm-debug/{{idaver}}{{^#target=main}}@{{:#target}}{{/#target=main}}.env
151
152 %systemd-unit system
153 {{#required-permission.urn:AGL:permission::public:hidden}}\
154 %systemd-unit service afm-service-{{:id}}--{{:ver}}--{{:#target}}@
155 {{/required-permission.urn:AGL:permission::public:hidden}}\
156 {{^required-permission.urn:AGL:permission::public:hidden}}\
157 %systemd-unit service afm-appli-{{:id}}--{{:ver}}--{{:#target}}@
158 {{/required-permission.urn:AGL:permission::public:hidden}}\
159
160 Environment=LD_LIBRARY_PATH=$ORIGIN/lib
161
162 SyslogIdentifier=afbd-{{idaver}}{{^#target=main}}@{{:#target}}{{/#target=main}}
163 StandardInput=null
164 StandardOutput=journal
165 StandardError=journal
166
167 ;---------------------------------------------------------------------------------
168 ;----   text/html  application/vnd.agl.native  application/vnd.agl.service    ----
169 ;---------------------------------------------------------------------------------
170 {{#content.type=text/html|application/vnd.agl.native|application/vnd.agl.service}}
171
172 X-AFM--http-port={{:#metadata.http-port}}
173
174 ExecStart=/usr/bin/afb-daemon \
175         --name afbd-{{idaver}}{{^#target=main}}@{{:#target}}{{/#target=main}} \
176         --rootdir={{:#metadata.install-dir}} \
177         --workdir={{&#metadata.app-data-dir}}/{{id}} \
178         --port={{:#metadata.http-port}} \
179         --token=HELLO \
180         --verbose \
181         --monitoring \
182         {{^content.type=application/vnd.agl.service}} \
183                 {{#required-permission.urn:AGL:permission::public:no-htdocs}}\
184                         --roothttp=. \
185                 {{/required-permission.urn:AGL:permission::public:no-htdocs}}\
186                 {{^required-permission.urn:AGL:permission::public:no-htdocs}}\
187                         --roothttp=htdocs \
188                 {{/required-permission.urn:AGL:permission::public:no-htdocs}}\
189         {{/content.type=application/vnd.agl.service}} \
190         {{#content.type=application/vnd.agl.service}} \
191                 --roothttp=. \
192         {{/content.type=application/vnd.agl.service}} \
193         {{#required-permission.urn:AGL:permission::public:applications:read}}\
194                 --alias=/icons:{{:#metadata.icons-dir}} \
195         {{/required-permission.urn:AGL:permission::public:applications:read}}\
196         {{#required-api}}\
197                 {{#value=auto}}\
198                         --ws-client=unix:%t/apis/ws/{{name}} \
199                 {{/value=auto}}\
200                 {{#value=ws}}\
201                         --ws-client=unix:%t/apis/ws/{{name}} \
202                 {{/value=ws}}\
203                 {{#value=dbus}}\
204                         --dbus-client={{name}} \
205                 {{/value=dbus}}\
206                 {{#value=link}}\
207                         --binding=%t/apis/lib/{{name}} \
208                 {{/value=link}}\
209                 {{#value=cloud}}\
210                         --cloud-client={{name}} \
211                 {{/value=cloud}}\
212                 {{#value=local}}\
213                         --binding={{:#metadata.install-dir}}/{{name}} \
214                 {{/value=local}}\
215         {{/required-api}}\
216         {{#provided-api}}\
217                 {{#value=auto}}\
218                         {{^required-permission.urn:AGL:permission::partner:service:no-ws}}\
219                                 --ws-server=sd:{{name}} \
220                         {{/required-permission.urn:AGL:permission::partner:service:no-ws}}\
221                         {{^required-permission.urn:AGL:permission::partner:service:no-dbus}}\
222                                 --dbus-server={{name}} \
223                         {{/required-permission.urn:AGL:permission::partner:service:no-dbus}}\
224                 {{/value=auto}}\
225                 {{#value=ws}}\
226                         --ws-server=sd:{{name}} \
227                 {{/value=ws}}\
228                 {{#value=dbus}}\
229                         --dbus-server={{name}} \
230                 {{/value=dbus}}\
231         {{/provided-api}}\
232         {{#content.type=text/html}}\
233                 --exec /usr/bin/web-runtime http://localhost:@p/{{content.src}}?token=@t
234         {{/content.type=text/html}}\
235         {{#content.type=application/vnd.agl.native}}\
236                 --exec {{:#metadata.install-dir}}/{{content.src}} @p @t
237         {{/content.type=application/vnd.agl.native}}
238
239 {{/content.type=text/html|application/vnd.agl.native|application/vnd.agl.service}}
240
241
242 ;---------------------------------------------------------------------------------
243 ;----                 application/x-executable                                ----
244 ;---------------------------------------------------------------------------------
245 {{#content.type=application/x-executable}}
246
247 ExecStart={{:#metadata.install-dir}}/{{content.src}}
248
249 {{/content.type=application/x-executable}}
250
251 ;---------------------------------------------------------------------------------
252 ; auto start
253 ;---------------------------------------------------------------------------------
254 {{#required-permission.urn:AGL:permission::system:run-by-default}}
255 %nl
256 [Install]
257 WantedBy=default.target
258 %systemd-unit wanted-by default.target
259 {{/required-permission.urn:AGL:permission::system:run-by-default}}
260
261 %end systemd-unit
262
263
264 ;---------------------------------------------------------------------------------
265 ;----        P R O V I D E D   A P I S                                        ----
266 ;---------------------------------------------------------------------------------
267
268 {{#provided-api}}
269 {{#value=ws|auto}}
270
271 %begin systemd-unit
272
273 # auto generated by wgtpkg-unit for {{:id}} version {{:version}} target {{:#target}} of {{:idaver}}
274 #
275 %systemd-unit system
276 %systemd-unit socket afm-api-ws-{{name}}@
277
278 [Socket]
279 SmackLabel=*
280 ListenStream=%t/apis/ws/{{name}}
281 FileDescriptorName={{name}}
282
283 {{#required-permission.urn:AGL:permission::public:hidden}}\
284 Service=afm-service-{{:id}}--{{:ver}}--{{:#target}}@%i.service
285 {{/required-permission.urn:AGL:permission::public:hidden}}\
286 {{^required-permission.urn:AGL:permission::public:hidden}}\
287 Service=afm-appli-{{:id}}--{{:ver}}--{{:#target}}@%i.service
288 {{/required-permission.urn:AGL:permission::public:hidden}}\
289
290 ;---------------------------------------------------------------------------------
291 %nl
292 [Install]
293 WantedBy=sockets.target
294 %systemd-unit wanted-by sockets.target
295 ;---------------------------------------------------------------------------------
296
297 %end systemd-unit
298
299 {{/value=ws|auto}}
300 {{/provided-api}}
301
302 {{/targets}}
303