Merge pull request #1464 from Lin-Buo-Ren/patch/snap/support-canonical-config-paths

snap: Support canonical config paths, fixes #1403
This commit is contained in:
Nicolas Hennion 2019-04-11 13:31:21 +02:00 committed by GitHub
commit 9b7e7f1ba7
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 44 additions and 1 deletions

View File

@ -0,0 +1,26 @@
#!/usr/bin/env bash
# This is the maintainence launcher for the snap, make necessary runtime
# environment changes to make the snap work here. You may also insert
# security confinement/deprecation/obsoletion notice of the snap here.
set \
-o errexit \
-o errtrace \
-o nounset \
-o pipefail
# Use user's real home directory for canonical configuration path access
HOME="$(
getent passwd "${USER}" \
| cut --delimiter=: --fields=6
)"
# Use snap's own folder for cache directory
declare XDG_CACHE_HOME
mkdir \
--parents \
"${SNAP_USER_DATA}"/.cache
XDG_CACHE_HOME="${SNAP_USER_DATA}"/.cache
export XDG_CACHE_HOME
# Finally run the next part of the command chain
exec "${@}"

View File

@ -12,7 +12,9 @@ confinement: strict
apps:
glances:
command: bin/glances
command: >
bin/glances-launch
$SNAP/bin/glances
plugs:
- network
- system-observe
@ -28,6 +30,16 @@ apps:
LANG: C.UTF-8
LC_ALL: C.UTF-8
plugs:
home-glances-config:
interface: personal-files
read:
- $HOME/.config/glances/glances.conf
etc-glances-config:
interface: system-files
read:
- /etc/glances/glances.conf
parts:
glances:
plugin: python
@ -51,3 +63,8 @@ parts:
source: https://github.com/docker/docker-py.git
source-tag: '3.7.0'
source-depth: 1
launchers:
source: snap/local/launchers
plugin: dump
organize:
'*': bin/