-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathsnap-setup.sh
More file actions
executable file
·37 lines (33 loc) · 1.38 KB
/
snap-setup.sh
File metadata and controls
executable file
·37 lines (33 loc) · 1.38 KB
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
#!/bin/bash
set -e
snap wait system seed.loaded
# Install all snaps (latest version from store)
for pkg in hello-world jq yq micro btop tree httpie certbot lolcat go; do
case "$pkg" in
micro|certbot|go) snap install "$pkg" --classic || true ;;
*) snap install "$pkg" || true ;;
esac
done
# Disable the automatic refresh timer so snaps stay at whatever revision we
# install. Using "snap refresh --hold" would also hide them from
# "snap refresh --list", so we stop the timer instead.
systemctl stop snapd.refresh.timer 2>/dev/null || true
systemctl disable snapd.refresh.timer 2>/dev/null || true
# Downgrade non-classic snaps to their previous store revision so that
# "snap refresh --list" always reports available updates for testing.
for pkg in hello-world jq yq btop tree httpie lolcat; do
REV=$(snap list "$pkg" 2>/dev/null | awk -v p="$pkg" '$1==p {print $3}')
if [ -n "$REV" ] && [ "$REV" -gt 1 ]; then
OLD=$((REV - 1))
snap remove "$pkg" 2>/dev/null || true
if snap download --basename="$pkg" --revision="$OLD" --target-directory=/tmp "$pkg" 2>/dev/null; then
snap ack "/tmp/$pkg.assert" 2>/dev/null || true
snap install "/tmp/$pkg.snap" 2>/dev/null || true
rm -f "/tmp/$pkg.snap" "/tmp/$pkg.assert"
else
# Previous revision unavailable — reinstall latest
snap install "$pkg" || true
fi
fi
done
touch /var/snap/.snaps-installed