dcc576b41a7a955273c44787f3f77005267e7ab6
[src/app-framework-main.git] / conf / unit / service.inc
1 dnl vim: set filetype=sysctl.conf.m4 syntax=sysctl.conf.m4:
2 ;-------------------------------------------------------------------------------
3 ;----         M A I N    P A R T    O F   T H E   S E R V I C E             ----
4 ;-------------------------------------------------------------------------------
5 %begin systemd-unit
6
7 # auto generated by wgtpkg-unit for {{:id}} version {{:version}} target {{:#target}} of {{:idaver}}
8 %nl
9
10 %systemd-unit system
11 IF_PERM(:partner:scope-platform)
12 %systemd-unit service UNIT_NAME_BASE
13 ELSE
14 %systemd-unit service UNIT_NAME_BASE@
15 ENDIF
16
17 [Unit]
18 Description={{description}}
19 X-AFM-description={{description}}
20 X-AFM-name={{name.content}}
21 X-AFM-shortname={{name.short}}
22 X-AFM-id=TARGET
23 X-AFM-version={{:version}}
24 X-AFM-author={{author.content}}
25 X-AFM-author-email={{author.email}}
26 X-AFM-width={{width}}
27 X-AFM-height={{height}}
28 {{#icon}}
29 X-AFM-icon={{:#metadata.install-dir}}/{{:src}}
30 {{/icon}}
31 X-AFM--ID=AFID
32 X-AFM--target-name={{:#target}}
33 X-AFM--content={{content.src}}
34 X-AFM--type={{content.type}}
35 X-AFM--wgtdir={{:#metadata.install-dir}}
36 X-AFM--workdir=APP_WORK_DIR
37 X-AFM--visibility=ON_PERM(`:public:hidden', `hidden', `visible')
38 %nl
39
40 IF_PERM(:partner:scope-platform)
41 X-AFM--scope=platform
42 After=afm-system-setup.service
43 ELSE
44 X-AFM--scope=user
45 Requires=afm-user-session@%i.target
46 After=user@%i.service
47 ENDIF
48
49 IF_PERM(:public:display)
50 BindsTo=weston@display.service
51 After=weston@display.service
52 ENDIF
53
54 IF_PERM(:public:bluetooth)
55 Wants=bluetooth.target
56 After=bluetooth.target
57 ENDIF
58
59 IF_PERM(:public:network)
60 Wants=network.target
61 After=network.target
62 ENDIF
63
64 # Adds check to smack
65 ConditionSecurity=smack
66 %nl
67
68 # Automatic bound to required api
69 {{#required-binding}}
70 {{#value=extern}}
71 Requires=UNIT_NAME_BINDING_SERVICE({{name}})
72 After=UNIT_NAME_BINDING_SERVICE({{name}})
73 {{/value=extern}}
74 {{/required-binding}}
75
76 {{#required-api}}
77 {{#value=auto|ws}}
78 Requires=UNIT_NAME_API_SERVICE({{name}})
79 After=UNIT_NAME_API_SERVICE({{name}})
80 {{/value=auto|ws}}
81 {{/required-api}}
82
83 {{#provided-api}}
84 {{#value=ws|auto}}
85 Requires=UNIT_NAME_API_SOCKET({{name}})
86 After=UNIT_NAME_API_SOCKET({{name}})
87 {{/value=ws|auto}}
88 {{/provided-api}}
89
90 %nl
91
92 [Service]
93
94 EnvironmentFile=-@afm_confdir@/unit.env.d/*
95 EnvironmentFile=-@afm_confdir@/widget.env.d/{{:id}}/*
96 SmackProcessLabel=SMACKLABEL
97 SuccessExitStatus=0 SIGKILL
98 UMask=0077
99
100 IF_PERM(:partner:scope-platform)
101 #DynamicUser=true
102 User=daemon
103 Group=nobody
104 Slice=platform.slice
105 ELSE
106 User=%i
107 Slice=user-%i.slice
108 WorkingDirectory=-APP_WORK_DIR
109 ExecStartPre=/bin/mkdir -p APP_WORK_DIR
110 Environment=DBUS_SESSION_BUS_ADDRESS=unix:path=USER_RUN_DIR/bus
111 ENDIF
112 IF_PERM(:system:capability:keep-all)
113 CapabilityBoundingSet=~
114 AmbientCapabilities=~
115 ELSE
116 CapabilityBoundingSet=
117 ENDIF
118
119 ON_PERM(:platform:no-oom,   OOMScoreAdjust=-500)
120 ON_PERM(:partner:real-time, IOSchedulingClass=realtime)
121 ON_PERM(:public:display,    SupplementaryGroups=display)
122 ON_PERM(:public:audio,      SupplementaryGroups=audio)
123 ON_NOT_PERM(:public:syscall:clock, SystemCallFilter=~@clock)
124 %nl
125
126 Environment=AFM_ID=TARGET
127 Environment=AFM_APP_INSTALL_DIR={{:#metadata.install-dir}}
128 Environment=AFM_WORKDIR=APP_WORK_DIR
129 Environment=AFM_WSAPI_DIR=API_PATH_WS
130 Environment=PATH=/usr/sbin:/usr/bin:/sbin:/bin:{{:#metadata.install-dir}}/bin
131 Environment=LD_LIBRARY_PATH={{:#metadata.install-dir}}/lib
132 Environment=XDG_DATA_HOME=APP_WORK_DIR
133 Environment=XDG_CONFIG_HOME=APP_WORK_DIR
134 Environment=XDG_CACHE_HOME=APP_WORK_DIR
135 Environment=XDG_RUNTIME_DIR=RUN_DIR
136 ON_CONTENT(text/html, Environment=WAIT_FOR_HOST_SERVICE="1")
137
138 IF_AGL_DEVEL
139 ; Needed to enable debug
140 EnvironmentFile=-DEBUGGING_DIR/TARGET.env
141 ENDIF
142
143 SyslogIdentifier=afbd-TARGET
144 StandardInput=null
145 StandardOutput=journal
146 StandardError=journal
147
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 include(binder.inc)
153 {{/content.type=text/html|application/vnd.agl.native|application/vnd.agl.service}}
154
155 ;-------------------------------------------------------------------------------
156 ;----                 application/x-executable                              ----
157 ;-------------------------------------------------------------------------------
158 {{#content.type=application/x-executable}}
159 ExecStart={{:#metadata.install-dir}}/{{content.src}}
160 {{/content.type=application/x-executable}}
161
162 ;-------------------------------------------------------------------------------
163 ;----                 application/vnd.agl.resource                          ----
164 ;-------------------------------------------------------------------------------
165 {{#content.type=application/vnd.agl.resource}}
166 Type=oneshot
167 ExecStart=/bin/true
168 {{/content.type=application/vnd.agl.resource}}
169
170 IF_PERM(:system:run-by-default)
171 ;-------------------------------------------------------------------------------
172 ; auto start
173 ;-------------------------------------------------------------------------------
174 [Install]
175 IF_PERM(:partner:scope-platform)
176 WantedBy=multi-user.target
177 %systemd-unit wanted-by multi-user.target
178 ELSE
179 WantedBy=afm-user-session@.target
180 %systemd-unit wanted-by afm-user-session@.target
181 ENDIF
182 ENDIF
183
184 %end systemd-unit