summaryrefslogtreecommitdiffstats
path: root/conf/afm-unit.conf
blob: 303ee2702dfd71de146d8d1728e64bfcce3489fe (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
165
166
167
168
169
170
171
172
173
174
;---------------------------------------------------------------------------------
; File:
;
;    afm-unit.conf
;
; Role:
;
;    Configure how installation of widget produces unit files for systemd
;
; Processing and format:
;
;    1. File load
;
;           Lines beginning with ; are firstly removed
;
;    2. File instanciation
;
;           Mustache (extended) substitutions are applied using JSON
;           data deduced from config.xml file of the widget.
;
;    3. Extraction of units
;
;           Extract produced units, pack it (remove empty lines and directives)
;
; Directives:
;
;    All directive occopy one whole line starting with %
;
;     - %nl
;
;             produce an empty line at the end
;
;     - %begin systemd-unit
;     - %end systemd-unit
;
;             delimit the produced unit
;
;     - %systemd-unit user
;     - %systemd-unit system
;
;             tells the kind of unit (user/system)
;
;     - %systemd-unit service NAME
;     - %systemd-unit socket NAME
;
;             gives the name and type of the unit
;
;---------------------------------------------------------------------------------
{{#targets}}
%begin systemd-unit

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

[unit]
Description={{description}}
X-AGL-Name={{name.content}}
X-AGL-Name-Short={{name.short}}
X-AGL-Id={{id}}
X-AGL-Idaver={{idaver}}
X-AGL-Target-Name={{:#target}}
X-AGL-Author={{author.content}}
X-AGL-Author-email={{author.email}}
X-AGL-HTTP-port={{:#metadata.http-port}}
%nl

# Adds check to smack
ConditionSecurity=smack
%nl

# Automatic bound to required api
{{#required-api}}
BindsTo=afm-api-{{name}}
After=afm-api-{{name}}
{{/required-api}}
%nl

[Service]
SmackProcessLabel=User::App::{{id}}

{{#required-permission}}
  {{#urn:AGL:permission::platform:no-oom}}      OOMScoreAdjust=-500             {{/urn:AGL:permission::platform:no-oom}}
  {{#urn:AGL:permission::partner:real-time}}    IOSchedulingClass=realtime      {{/urn:AGL:permission::partner:real-time}}
  {{^urn:AGL:permission::partner:real-time}}    RestrictRealtime=on             {{/urn:AGL:permission::partner:real-time}}
  {{#urn:AGL:permission::public:display}}       SupplementaryGroups=display     {{/urn:AGL:permission::public:display}}
  {{^urn:AGL:permission::public:syscall:clock}} SystemCallFilter=~@clock        {{/urn:AGL:permission::public:syscall:clock}}
  {{^urn:AGL:permission::public:internet}}      RestrictAddressFamilies=AF_UNIX {{/urn:AGL:permission::public:internet}}
{{/required-permission}}
%nl

WorkingDirectory={{&#metadata.app-data-dir}}
SuccessExitStatus=0 SIGKILL

;---------------------------------------------------------------------------------
{{#content.type=text/html}}

%systemd-unit user

%systemd-unit service afm-appli-{{idaver}}{{^#target=main}}@{{:#target}}{{/#target=main}}

ExecStart=/usr/bin/afb-daemon --port={{:#metadata.http-port}} --random-token \
	--rootdir={{:#metadata.install-dir}} \
	--workdir={{&#metadata.app-data-dir}} \
	--roothttp=htdocs \
	{{#required-permission.urn:AGL:permission::public:applications:read}}\
		--alias=/icons:{{:#metadata.icons-dir}} \
	{{/required-permission.urn:AGL:permission::public:applications:read}}\
	{{#required-api}}\
		{{#value=auto}}\
			--ws-client=unix:%t/apis/ws/{{name}} \
		{{/value=auto}}\
		{{#value=ws}}\
			--ws-client=unix:%t/apis/ws/{{name}} \
		{{/value=ws}}\
		{{#value=dbus}}\
			--dbus-client={{name}} \
		{{/value=dbus}}\
		{{#value=link}}\
			--binding=%t/apis/lib/{{name}} \
		{{/value=link}}\
		{{#value=cloud}}\
			--cloud-client={{name}} \
		{{/value=cloud}}\
	{{/required-api}}\
	--exec /usr/bin/web-runtime http://localhost:@p/{{content.src}}?token=@t

{{/content.type=text/html}}

;---------------------------------------------------------------------------------
{{#content.type=application/vnd.agl.service}}

%systemd-unit user
%systemd-unit service afm-api-{{:#target}}

ExecStart=/usr/bin/afb-daemon \
	--rootdir={{:#metadata.install-dir}} \
	--workdir={{&#metadata.install-dir}} \
	{{^required-permission.urn:AGL:permission::partner:service:no-ws}}\
		--ws-server=unix:%t/bindings/{{:#target}} \
	{{/required-permission.urn:AGL:permission::partner:service:no-ws}}\
	{{^required-permission.urn:AGL:permission::partner:service:no-dbus}}\
		--dbus-server={{:#target}} \
	{{/required-permission.urn:AGL:permission::partner:service:no-dbus}}\
	--no-httpd 

{{^required-permission.urn:AGL:permission::partner:service:no-ws}}

%end systemd-unit
%begin systemd-unit

# auto generated by wgtpkg-unit for {{id}} version {{version}} target {{:#target}}
#
%systemd-unit user
%systemd-unit socket afm-api-{{:#target}}


[socket]
SmackLabel=*
ListenStream=%t/bindings/{{:#target}}

{{/required-permission.urn:AGL:permission::partner:service:no-ws}}

{{/content.type=application/vnd.agl.service}}

;---------------------------------------------------------------------------------
{{#required-permission.urn:AGL:permission::system:run-by-default}}
[install]
WantedBy=default.target
{{/required-permission.urn:AGL:permission::system:run-by-default}}
;---------------------------------------------------------------------------------
%end systemd-unit
{{/targets}}