-
Notifications
You must be signed in to change notification settings - Fork 17
/
Copy pathinit
82 lines (72 loc) · 2.42 KB
/
init
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
#!/bin/bash
#################
# Launcher init #
#################
# shellcheck disable=SC2034
START=$(date +%s.%N)
# ensure_dir_exists calls `mkdir -p` if the given path is not a directory.
# This speeds up execution time by avoiding unnecessary calls to mkdir.
#
# Usage: ensure_dir_exists <path> [<mkdir-options>]...
#
function ensure_dir_exists() {
[ -d "$1" ] || mkdir -p "$@"
}
declare -A PIDS
function async_exec() {
"$@" &
PIDS[$!]=$*
}
function wait_for_async_execs() {
for pid in "${!PIDS[@]}"
do
wait "$pid" && continue || echo "ERROR: ${PIDS[$pid]} exited abnormally with status $?"
done
}
# shellcheck source=/dev/null
source "$SNAP_USER_DATA/.last_revision" 2>/dev/null || true
if [ "$SNAP_DESKTOP_LAST_REVISION" = "$SNAP_REVISION" ]; then
needs_update=false
else
needs_update=true
fi
# Set $REALHOME to the users real home directory
REALHOME=${SNAP_REAL_HOME}
# Set config folder to local path
export XDG_CONFIG_HOME="$SNAP_USER_DATA/.config"
ensure_dir_exists "$XDG_CONFIG_HOME"
chmod 700 "$XDG_CONFIG_HOME"
# If there is no user user-dirs, don't check for the checksum
if [[ -f "$SNAP_REAL_HOME/.config/user-dirs.dirs" ]]; then
# If the user has modified their user-dirs settings, force an update
if [[ -f "$XDG_CONFIG_HOME/user-dirs.dirs.md5sum" ]]; then
if [[ "$(md5sum < "$SNAP_REAL_HOME/.config/user-dirs.dirs")" != "$(cat "$XDG_CONFIG_HOME/user-dirs.dirs.md5sum")" ||
( -f "$XDG_CONFIG_HOME/user-dirs.locale.md5sum" &&
"$(md5sum < "$SNAP_REAL_HOME/.config/user-dirs.locale")" != "$(cat "$XDG_CONFIG_HOME/user-dirs.locale.md5sum")" ) ]]; then
needs_update=true
fi
else
# shellcheck disable=SC2034
needs_update=true
fi
fi
if [ "$SNAP_ARCH" = "amd64" ]; then
ARCH="x86_64-linux-gnu"
elif [ "$SNAP_ARCH" = "armhf" ]; then
ARCH="arm-linux-gnueabihf"
elif [ "$SNAP_ARCH" = "arm64" ]; then
ARCH="aarch64-linux-gnu"
elif [ "$SNAP_ARCH" = "ppc64el" ]; then
ARCH="powerpc64le-linux-gnu"
else
ARCH="$SNAP_ARCH-linux-gnu"
fi
export SNAP_LAUNCHER_ARCH_TRIPLET="$ARCH"
# Don't LD_PRELOAD bindtextdomain for classic snaps
if ! grep -qs "^\s*confinement:\s*classic\s*" "$SNAP/meta/snap.yaml"; then
if [ -f "$SNAP/lib/$ARCH/bindtextdomain.so" ]; then
export LD_PRELOAD="$LD_PRELOAD:$SNAP/\$LIB/bindtextdomain.so"
elif [ -f "$SNAP/gnome-platform/lib/$ARCH/bindtextdomain.so" ]; then
export LD_PRELOAD="$LD_PRELOAD:$SNAP/gnome-platform/\$LIB/bindtextdomain.so"
fi
fi