-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathrun-snapd-srv
executable file
·52 lines (42 loc) · 1.06 KB
/
run-snapd-srv
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
#!/bin/sh
set -eu
if [ "$(id -u)" != "0" ]; then
echo "error: must run as root"
exit 1
fi
srv="${1:-/tmp/srv}"
if [ ! -x "$srv" ]; then
echo "error: no $srv"
exit 1
fi
if systemctl is-active --quiet snapd.service snapd.socket; then
echo "error: snapd (or its socket) still active"
exit 1
fi
if [ "${2:-}" ]; then
export SNAPPY_FORCE_CPI_URL="$2"
fi
if [ ! -d /usr/lib/snapd ]; then
mkdir -v /usr/lib/snapd
fi
d=/usr/lib/snapd/snapd
if [ "$srv" != "$d" ]; then
if [ ! -e "$d" ]; then
trap exit INT
trap 'rm -v "$d"' EXIT
elif [ ! -e "${d}.real" ]; then
mv -v "$d" "${d}.real"
trap exit INT
trap 'mv -v "${d}.real" "$d"; exit' EXIT
fi
cp -v "$srv" "$d"
fi
export SNAP_REEXEC=0
export SNAPD_DEBUG="${SNAPD_DEBUG:-1}"
export SNAPD_DEBUG_HTTP="${SNAPD_DEBUG_HTTP:-7}"
export SNAPPY_SQUASHFS_UNPACK_FOR_TESTS="${SNAPPY_SQUASHFS_UNPACK_FOR_TESTS:-0}"
export SNAPPY_TESTING="${SNAPPY_TESTING:-1}"
export SNAP_CONFINE_DEBUG="${SNAP_CONFINE_DEBUG:-1}"
while "$d"; do
sleep 1 || break
done