;
; gives the name and type of the unit
;
+; - %systemd-unit wanted-by NAME
+;
+; tells to install a link to unit in the wants of NAME
+;
+; Setting variables:
+;
+; AFM uses the feature of systemd that completely ignores options prefixed
+; with X-
+;
+; Consequently, options starting with X-AFM- are recorded as public data
+; about the application and options starting starting with X-AFM-- are
+; recorded as private data.
+;
+; Examples:
+;
+; X-AFM-description={{description}}
+;
+; Records the descritpion of the unit in the field "description"
+; of both the public and private object describing the unit.
+;
+; X-AFM--wgtdir={{:#metadata.install-dir}}
+;
+; Records the installation directory path in the field "wgtdir"
+; of the private object only.
+;
;---------------------------------------------------------------------------------
{{#targets}}
%begin systemd-unit
# auto generated by wgtpkg-unit for {{id}} version {{version}} target {{:#target}}
%nl
-[unit]
+[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}}
+X-AFM-description={{description}}
+X-AFM-name={{name.content}}
+X-AFM-shortname={{name.short}}
+X-AFM-id={{idaver}}
+X-AFM-version={{version}}
+X-AFM-author={{author.content}}
+X-AFM-author-email={{author.email}}
+X-AFM-width={{width}}
+X-AFM-height={{height}}
+X-AFM--ID={{id}}
+X-AFM--target-name={{:#target}}
+X-AFM--content={{content.src}}
+X-AFM--type={{content.type}}
+X-AFM--wgtdir={{:#metadata.install-dir}}
+X-AFM--workdir={{&#metadata.app-data-dir}}/{{id}}
%nl
# Adds check to smack
[Service]
SmackProcessLabel=User::App::{{id}}
+SuccessExitStatus=0 SIGKILL
{{#required-permission}}
{{#urn:AGL:permission::platform:no-oom}} OOMScoreAdjust=-500 {{/urn:AGL:permission::platform:no-oom}}
{{/required-permission}}
%nl
-WorkingDirectory={{&#metadata.app-data-dir}}
-SuccessExitStatus=0 SIGKILL
+WorkingDirectory=-{{&#metadata.app-data-dir}}/{{id}}
+ExecStartPre=/bin/mkdir -p {{&#metadata.app-data-dir}}/{{id}}
+Environment=AFM_APP_INSTALL_DIR={{:#metadata.install-dir}}
+
;---------------------------------------------------------------------------------
{{#content.type=text/html}}
%systemd-unit service afm-appli-{{idaver}}{{^#target=main}}@{{:#target}}{{/#target=main}}
+X-AFM--http-port={{:#metadata.http-port}}
ExecStart=/usr/bin/afb-daemon --port={{:#metadata.http-port}} --random-token \
--rootdir={{:#metadata.install-dir}} \
--workdir={{&#metadata.app-data-dir}}/{{id}} \
{{/content.type=text/html}}
+;---------------------------------------------------------------------------------
+{{#content.type=application/x-executable}}
+
+%systemd-unit user
+%systemd-unit service afm-appli-{{idaver}}{{^#target=main}}@{{:#target}}{{/#target=main}}
+
+Environment=LD_LIBRARY_PATH=$ORIGIN/$LIB
+
+ExecStart={{:#metadata.install-dir}}/{{content.src}}
+
+{{/content.type=application/x-executable}}
+
;---------------------------------------------------------------------------------
{{#content.type=application/vnd.agl.service}}
%systemd-unit user
-%systemd-unit service afm-api-{{:#target}}
+%systemd-unit service afm-service-{{:#target}}
ExecStart=/usr/bin/afb-daemon \
--rootdir={{:#metadata.install-dir}} \
# auto generated by wgtpkg-unit for {{id}} version {{version}} target {{:#target}}
#
%systemd-unit user
-%systemd-unit socket afm-api-{{:#target}}
+%systemd-unit socket afm-service-{{:#target}}
-
-[socket]
+[Socket]
SmackLabel=*
ListenStream=%t/bindings/{{:#target}}
FileDescriptorName={{:#target}}
;---------------------------------------------------------------------------------
{{#required-permission.urn:AGL:permission::system:run-by-default}}
-[install]
+[Install]
WantedBy=default.target
+%systemd-unit wanted-by default.target
{{/required-permission.urn:AGL:permission::system:run-by-default}}
;---------------------------------------------------------------------------------
%end systemd-unit
{{/targets}}
-