97 lines
2.7 KiB
Bash
Executable File
97 lines
2.7 KiB
Bash
Executable File
#!/bin/sh
|
|
set -e
|
|
|
|
skip_unusable_snapd() {
|
|
if [ -e "/run/snapd.socket" ]; then
|
|
# Snapd is present, run the upgrade
|
|
return 1
|
|
fi
|
|
|
|
return 0
|
|
}
|
|
|
|
case "$1" in
|
|
install|upgrade)
|
|
. /usr/share/debconf/confmodule
|
|
|
|
echo "=> Installing the firefox snap"
|
|
|
|
# Warn about downtime
|
|
if [ -e "/usr/lib/firefox/firefox" ]; then
|
|
db_input high firefox/snap-upgrade-warning || true
|
|
db_go
|
|
fi
|
|
|
|
# Check store connectivity
|
|
echo "==> Checking connectivity with the snap store"
|
|
COUNT=0
|
|
SKIP=false
|
|
while :; do
|
|
if skip_unusable_snapd; then
|
|
echo "===> System doesn't have a working snapd, skipping"
|
|
SKIP=true
|
|
break
|
|
fi
|
|
|
|
snap info firefox >/dev/null 2>&1 && break
|
|
|
|
db_fset firefox/snap-no-connectivity seen false
|
|
if ! db_input critical firefox/snap-no-connectivity; then
|
|
db_go
|
|
|
|
if [ "${COUNT}" = "0" ]; then
|
|
echo "===> Unable to contact the store, trying every minute for the next 30 minutes"
|
|
elif [ "${COUNT}" = "10" ]; then
|
|
echo "===> Still unable to contact the store, trying for another 20 minutes"
|
|
elif [ "${COUNT}" = "20" ]; then
|
|
echo "===> Still unable to contact the store, trying for another 10 minutes"
|
|
elif [ "${COUNT}" = "30" ]; then
|
|
echo "===> Still unable to contact the store, aborting"
|
|
exit 1
|
|
fi
|
|
|
|
sleep 1m
|
|
else
|
|
db_go
|
|
db_get firefox/snap-no-connectivity
|
|
if [ "${RET}" = "Abort" ]; then
|
|
echo "===> Aborting at user request"
|
|
exit 1
|
|
elif [ "${RET}" = "Skip" ]; then
|
|
echo "===> Skipping at user request"
|
|
SKIP=true
|
|
break
|
|
fi
|
|
|
|
if [ "${COUNT}" = "0" ]; then
|
|
echo "===> Unable to contact the store"
|
|
fi
|
|
fi
|
|
|
|
COUNT=$((COUNT+1))
|
|
done
|
|
|
|
if ! ${SKIP}; then
|
|
# Install the snap
|
|
echo "==> Installing the firefox snap"
|
|
snap install firefox
|
|
echo "=> Snap installation complete"
|
|
fi
|
|
;;
|
|
|
|
abort-upgrade|abort-remove|abort-deconfigure)
|
|
;;
|
|
|
|
*)
|
|
echo "postinst called with unknown argument \`$1'" >&2
|
|
exit 1
|
|
;;
|
|
esac
|
|
|
|
# Automatically added by dh_installdeb/13.6ubuntu1
|
|
dpkg-maintscript-helper rm_conffile /etc/firefox/syspref.js -- "$@"
|
|
# End automatically added section
|
|
|
|
|
|
exit 0
|