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