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