56a90750345c392b17f57485036c4a3aa8b8da8d
[src/app-framework-main.git] / conf / unit / 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 %systemd-unit system
86 %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}}@
87 [Unit]
88 Description={{description}}
89 X-AFM-description={{description}}
90 X-AFM-name={{name.content}}
91 X-AFM-shortname={{name.short}}
92 X-AFM-id={{idaver}}{{^#target=main}}@{{:#target}}{{/#target=main}}
93 X-AFM-version={{:version}}
94 X-AFM-author={{author.content}}
95 X-AFM-author-email={{author.email}}
96 X-AFM-width={{width}}
97 X-AFM-height={{height}}
98 {{#icon}}
99 X-AFM-icon={{:#metadata.install-dir}}/{{:src}}
100 {{/icon}}
101 X-AFM--ID={{:id}}
102 X-AFM--target-name={{:#target}}
103 X-AFM--content={{content.src}}
104 X-AFM--type={{content.type}}
105 X-AFM--wgtdir={{:#metadata.install-dir}}
106 X-AFM--workdir=/home/%i/app-data/{{:id}}
107 %nl
108 Requires=afm-user-session@%i.target
109 Requires=afm-user-setup@%i.service
110 After=afm-user-setup@%i.service
111 # Adds check to smack
112 ConditionSecurity=smack
113 %nl
114 # Automatic bound to required api
115 {{#required-api}}
116 {{#value=auto|ws}}
117 BindsTo=afm-api-ws-{{name}}@%i.socket
118 After=afm-api-ws-{{name}}@%i.socket
119 {{/value=auto|ws}}
120 {{/required-api}}
121 %nl
122 [Service]
123 EnvironmentFile=-@afm_confdir@/unit.env.d/*
124 SmackProcessLabel=User::App::{{:id}}
125 SuccessExitStatus=0 SIGKILL
126 User=%i
127 Slice=user-%i.slice
128 #CapabilityBoundingSet=
129 #AmbientCapabilities=
130 {{#required-permission.urn:AGL:permission::platform:no-oom}}OOMScoreAdjust=-500{{/required-permission.urn:AGL:permission::platform:no-oom}}
131 {{#required-permission.urn:AGL:permission::partner:real-time}}IOSchedulingClass=realtime{{/required-permission.urn:AGL:permission::partner:real-time}}
132 {{#required-permission.urn:AGL:permission::public:display}}SupplementaryGroups=display{{/required-permission.urn:AGL:permission::public:display}}
133 {{^required-permission.urn:AGL:permission::public:syscall:clock}}SystemCallFilter=~@clock{{/required-permission.urn:AGL:permission::public:syscall:clock}}
134 %nl
135 WorkingDirectory=-/home/%i/app-data/{{:id}}
136 ExecStartPre=/bin/mkdir -p /home/%i/app-data/{{:id}}
137 Environment=AFM_APP_INSTALL_DIR={{:#metadata.install-dir}}
138 Environment=PATH=/usr/sbin:/usr/bin:/sbin:/bin:{{:#metadata.install-dir}}
139 Environment=XDG_DATA_HOME=/home/%i/app-data/{{:id}}
140 Environment=XDG_CONFIG_HOME=/home/%i/app-data/{{:id}}
141 Environment=XDG_CACHE_HOME=/home/%i/app-data/{{:id}}
142 Environment=XDG_RUNTIME_DIR=/run/user/%i
143 Environment=DBUS_SESSION_BUS_ADDRESS=unix:path=/run/user/%i/bus
144 Environment=LD_LIBRARY_PATH=$ORIGIN/lib
145 SyslogIdentifier=afbd-{{idaver}}{{^#target=main}}@{{:#target}}{{/#target=main}}
146 StandardInput=null
147 StandardOutput=journal
148 StandardError=journal
149 ;---------------------------------------------------------------------------------
150 ;----   text/html  application/vnd.agl.native  application/vnd.agl.service    ----
151 ;---------------------------------------------------------------------------------
152 {{#content.type=text/html|application/vnd.agl.native|application/vnd.agl.service}}
153 {{^content.type=application/vnd.agl.service}}
154 X-AFM--http-port={{:#metadata.http-port}}
155 {{/content.type=application/vnd.agl.service}}
156 Type=notify
157 ExecStart=/usr/bin/afb-daemon \
158         --name afbd-{{idaver}}{{^#target=main}}@{{:#target}}{{/#target=main}} \
159         --rootdir={{:#metadata.install-dir}} \
160         --workdir=/home/%i/app-data/{{id}} \
161         {{#content.type=application/vnd.agl.service}} \
162                 --no-httpd \
163         {{/content.type=application/vnd.agl.service}}{{^content.type=application/vnd.agl.service}} \
164                 --port={{:#metadata.http-port}} \
165                 --random-token \
166                 --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}} \
167         {{/content.type=application/vnd.agl.service}} \
168         {{#required-permission.urn:AGL:permission::public:applications:read}}--alias=/icons:{{:#metadata.icons-dir}}{{/required-permission.urn:AGL:permission::public:applications:read}} \
169         {{#required-api}} \
170                 {{#value=auto|ws}}--ws-client=unix:/run/user/%i/apis/ws/{{name}}{{/value=auto|ws}} \
171                 {{#value=dbus}}--dbus-client={{name}}{{/value=dbus}} \
172                 {{#value=link}}--binding=/run/user/%i/apis/lib/{{name}}{{/value=link}} \
173                 {{#value=cloud}}--cloud-client={{name}}{{/value=cloud}} \
174                 {{#value=local}}--binding={{:#metadata.install-dir}}/{{name}}{{/value=local}} \
175         {{/required-api}} \
176         {{#provided-api}} \
177                 {{#value=auto|ws}}--ws-server=sd:{{name}}{{/value=auto|ws}} \
178                 {{#value=dbus}}--dbus-server={{name}}{{/value=dbus}} \
179         {{/provided-api}} \
180         {{#content.type=text/html}}--exec /usr/bin/web-runtime http://localhost:@p/{{content.src}}?token=@t{{/content.type=text/html}} \
181         {{#content.type=application/vnd.agl.native}}--exec {{:#metadata.install-dir}}/{{content.src}} @p @t{{/content.type=application/vnd.agl.native}}
182 {{/content.type=text/html|application/vnd.agl.native|application/vnd.agl.service}}
183 ;---------------------------------------------------------------------------------
184 ;----                 application/x-executable                                ----
185 ;---------------------------------------------------------------------------------
186 {{#content.type=application/x-executable}}
187 ExecStart={{:#metadata.install-dir}}/{{content.src}}
188 {{/content.type=application/x-executable}}
189 {{#required-permission.urn:AGL:permission::system:run-by-default}}
190 ;---------------------------------------------------------------------------------
191 ; auto start
192 ;---------------------------------------------------------------------------------
193 [Install]
194 WantedBy=afm-user-session@.target
195 %systemd-unit wanted-by afm-user-session@.target
196 {{/required-permission.urn:AGL:permission::system:run-by-default}}
197 %end systemd-unit
198 ;---------------------------------------------------------------------------------
199 ;----        P R O V I D E D   A P I S                                        ----
200 ;---------------------------------------------------------------------------------
201 {{#provided-api}}
202 {{#value=ws|auto}}
203 %begin systemd-unit
204 # auto generated by wgtpkg-unit for {{:id}} version {{:version}} target {{:#target}} of {{:idaver}}
205 %systemd-unit system
206 %systemd-unit socket afm-api-ws-{{name}}@
207 [Unit]
208 Description=Provides api {{name}} for user %i
209 Requires=afm-user-setup@%i.service
210 After=afm-user-setup@%i.service
211 [Socket]
212 SmackLabel=*
213 ListenStream=/run/user/%i/apis/ws/{{name}}
214 FileDescriptorName={{name}}
215 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
216 %nl
217 [Install]
218 WantedBy=afm-user-session@.target
219 %systemd-unit wanted-by afm-user-session@.target
220 %end systemd-unit
221 {{/value=ws|auto}}
222 {{/provided-api}}
223 {{/targets}}
224 ;---------------------------------------------------------------------------------
225 ; End of file afm-unit.conf mode RELEASE
226 ;---------------------------------------------------------------------------------