Add weston dependency for units with display permission
[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 After=Network.target
50
51 IF_PERM(:public:display)
52 BindsTo=weston@display.service
53 After=weston@display.service
54 ENDIF
55
56 # Adds check to smack
57 ConditionSecurity=smack
58 %nl
59
60 # Automatic bound to required api
61 {{#required-binding}}
62 {{#value=extern}}
63 Requires=UNIT_NAME_BINDING_SERVICE({{name}})
64 After=UNIT_NAME_BINDING_SERVICE({{name}})
65 {{/value=extern}}
66 {{/required-binding}}
67
68 {{#required-api}}
69 {{#value=auto|ws}}
70 Requires=UNIT_NAME_API_SERVICE({{name}})
71 After=UNIT_NAME_API_SERVICE({{name}})
72 {{/value=auto|ws}}
73 {{/required-api}}
74
75 {{#provided-api}}
76 {{#value=ws|auto}}
77 Requires=UNIT_NAME_API_SOCKET({{name}})
78 After=UNIT_NAME_API_SOCKET({{name}})
79 {{/value=ws|auto}}
80 {{/provided-api}}
81
82 %nl
83
84 [Service]
85
86 EnvironmentFile=-@afm_confdir@/unit.env.d/*
87 EnvironmentFile=-@afm_confdir@/widget.env.d/{{:id}}/*
88 SmackProcessLabel=SMACKLABEL
89 SuccessExitStatus=0 SIGKILL
90 UMask=0077
91
92 IF_PERM(:partner:scope-platform)
93 #DynamicUser=true
94 User=daemon
95 Group=nobody
96 Slice=platform.slice
97 ELSE
98 User=%i
99 Slice=user-%i.slice
100 WorkingDirectory=-APP_WORK_DIR
101 ExecStartPre=/bin/mkdir -p APP_WORK_DIR
102 Environment=DBUS_SESSION_BUS_ADDRESS=unix:path=USER_RUN_DIR/bus
103 ENDIF
104 IF_PERM(:system:capability:keep-all)
105 CapabilityBoundingSet=~
106 AmbientCapabilities=~
107 ELSE
108 CapabilityBoundingSet=
109 ENDIF
110
111 ON_PERM(:platform:no-oom,   OOMScoreAdjust=-500)
112 ON_PERM(:partner:real-time, IOSchedulingClass=realtime)
113 ON_PERM(:public:display,    SupplementaryGroups=display)
114 ON_PERM(:public:audio,      SupplementaryGroups=audio)
115 ON_NOT_PERM(:public:syscall:clock, SystemCallFilter=~@clock)
116 %nl
117
118 Environment=AFM_ID=TARGET
119 Environment=AFM_APP_INSTALL_DIR={{:#metadata.install-dir}}
120 Environment=AFM_WORKDIR=APP_WORK_DIR
121 Environment=AFM_WSAPI_DIR=API_PATH_WS
122 Environment=PATH=/usr/sbin:/usr/bin:/sbin:/bin:{{:#metadata.install-dir}}/bin
123 Environment=LD_LIBRARY_PATH={{:#metadata.install-dir}}/lib
124 Environment=XDG_DATA_HOME=APP_WORK_DIR
125 Environment=XDG_CONFIG_HOME=APP_WORK_DIR
126 Environment=XDG_CACHE_HOME=APP_WORK_DIR
127 Environment=XDG_RUNTIME_DIR=RUN_DIR
128 ON_CONTENT(text/html, Environment=WAIT_FOR_HOST_SERVICE="1")
129
130 IF_AGL_DEVEL
131 ; Needed to enable debug
132 EnvironmentFile=-DEBUGGING_DIR/TARGET.env
133 ENDIF
134
135 SyslogIdentifier=afbd-TARGET
136 StandardInput=null
137 StandardOutput=journal
138 StandardError=journal
139
140 ;-------------------------------------------------------------------------------
141 ;----   text/html  application/vnd.agl.native  application/vnd.agl.service  ----
142 ;-------------------------------------------------------------------------------
143 {{#content.type=text/html|application/vnd.agl.native|application/vnd.agl.service}}
144 include(binder.inc)
145 {{/content.type=text/html|application/vnd.agl.native|application/vnd.agl.service}}
146
147 ;-------------------------------------------------------------------------------
148 ;----                 application/x-executable                              ----
149 ;-------------------------------------------------------------------------------
150 {{#content.type=application/x-executable}}
151 ExecStart={{:#metadata.install-dir}}/{{content.src}}
152 {{/content.type=application/x-executable}}
153
154 ;-------------------------------------------------------------------------------
155 ;----                 application/vnd.agl.resource                          ----
156 ;-------------------------------------------------------------------------------
157 {{#content.type=application/vnd.agl.resource}}
158 Type=oneshot
159 ExecStart=/bin/true
160 {{/content.type=application/vnd.agl.resource}}
161
162 IF_PERM(:system:run-by-default)
163 ;-------------------------------------------------------------------------------
164 ; auto start
165 ;-------------------------------------------------------------------------------
166 [Install]
167 IF_PERM(:partner:scope-platform)
168 WantedBy=multi-user.target
169 %systemd-unit wanted-by multi-user.target
170 ELSE
171 WantedBy=afm-user-session@.target
172 %systemd-unit wanted-by afm-user-session@.target
173 ENDIF
174 ENDIF
175
176 %end systemd-unit