Skip to content

Instantly share code, notes, and snippets.

@ckujau
Last active April 17, 2025 14:08
Show Gist options
  • Save ckujau/b3291d2a25a5d250747a256b49c182a5 to your computer and use it in GitHub Desktop.
Save ckujau/b3291d2a25a5d250747a256b49c182a5 to your computer and use it in GitHub Desktop.
Workaround for #1630
#!/usr/bin/env bash
#
# (c)2018 Christian Kujau <[email protected]>
# Get a fresh copy from https://signal.org/
#
# A (far too complicated) script to get the Ubuntu package of
# Signal on a non-Debian based Desktop, due to:
#
# > Packages for rpm-based linux distributions like Fedora #1630
# > https://github.com/signalapp/Signal-Desktop/issues/1630
#
# PGP Key:
# https://pgp.key-server.io/pks/lookup?op=get&search=0xD980A17457F6FB06
#
set -e
BASEURL=https://updates.signal.org/desktop/apt
DIST=dists/xenial
DEST=/opt/Signal
umask 0022
# unset me!
# DEBUG=echo
# Kill it with fire
_die() {
echo "$@"
exit 1
}
# Sanity checks
command -v fzf > /dev/null || _die "### ERROR: fzf not found!"
command -v ar > /dev/null || _die "### ERROR: ar not found!"
TEMP=$(mktemp -d)
trap 'rm -r ${TEMP}' EXIT INT TERM HUP
cd "$TEMP" || _die "Could not change to directory $TEMP"
echo "### URL: ${BASEURL}"
# Download & verify InRelease
if [ ! -f InRelease ]; then
if curl -sLO "${BASEURL}/${DIST}/InRelease"; then
echo "### Download ${DIST}/InRelease OK."
else
_die "### Download ${DIST}/InRelease FAILED."
fi
fi
# Refresh keys once a month
if [ -f "${HOME}/.config/Signal/gpg.refresh" ]; then
DIFF="$(( $(date +%s) - $(stat -c %Y "${HOME}/.config/Signal/gpg.refresh") ))"
if [ ${DIFF} -gt 2592000 ]; then
gpg --keyserver keys.openpgp.org --refresh-keys DBA36B5181D0C816F630E889D980A17457F6FB06
gpg --tofu-policy good DBA36B5181D0C816F630E889D980A17457F6FB06
touch "${HOME}/.config/Signal/gpg.refresh"
fi
else
mkdir -p "${HOME}/.config/Signal"
touch "${HOME}/.config/Signal/gpg.refresh"
fi
# Trust on first use
if gpg --trust-model tofu --verify InRelease; then
echo "### ${DIST}/InRelease signature verified."
SHA256=$(grep -A5 ^SHA256 InRelease | awk '/main\/binary-amd64\/Packages.xz/ {print $1}')
else
_die "### ${DIST}/InRelease signature FAILED."
fi
# Download & verify Packages.xz
if curl -sLO "${BASEURL}/${DIST}/main/binary-amd64/Packages.xz"; then
echo "### Download ${DIST}/main/binary-amd64/Packages.xz OK."
else
_die "### Download Packages.xz FAILED."
fi
if sha256sum Packages.xz | grep -q "${SHA256}"; then
echo "### Packages.xz checksum verified."
else
_die "### Packages.xz checksum FAILED."
fi
sudo mkdir -p ${DEST}
if [ ! -f ${DEST}/.version.txt ]; then
echo "### Signal does not appear to be installed yet."
echo "0" | sudo tee ${DEST}/.version.txt
fi
CURRENT=$(cat ${DEST}/.version.txt)
echo "### Available versions:"
VERSION=$(xz -dc Packages.xz | grep -E '^Version' | sort -k2 -V | tail | fzf --no-clear --height=50% --prompt "${CURRENT}> ")
FILENAME=$(xz -dc Packages.xz | grep -E -A10 "^${VERSION}$" | awk '/^Filename/ {print $2}')
SHA256=$(xz -dc Packages.xz | grep -E -A10 "^${VERSION}$" | awk '/^SHA256/ {print $2}')
echo
echo "### Downloading ${FILENAME}..."
if ${DEBUG} curl -LO "${BASEURL}/${FILENAME}"; then
echo "### ${FILENAME} downloaded."
else
_die "Failed to download package"
fi
if sha256sum signal-desktop*amd64.deb | grep --color "${SHA256}"; then
echo "### ${FILENAME} checksum verified."
else
_die "### ${FILENAME} checksum FAILED."
fi
# Extract the data part of the Debian package
if ${DEBUG} ar x signal-desktop*amd64.deb data.tar.xz; then
echo "### data.tar.xz extraction OK."
else
_die "### data.tar.xz extraction FAILED."
fi
# Install
if [ -d ${DEST}.old ]; then
echo "### Removing ${DEST}.old"
${DEBUG} sudo rm -r ${DEST}.old
fi
echo "### Move ${DEST} to ${DEST}.old"
${DEBUG} sudo mv -v ${DEST} ${DEST}.old
echo "### Extracting data.tar.xz to /opt"
${DEBUG} sudo tar -C / -xJf data.tar.xz ./opt
echo "### Extracting icons to /usr/share/icons"
${DEBUG} sudo tar -C / --transform="s|usr|$HOME/.local|" -xJf data.tar.xz ./usr/share/icons/
echo "### Change ownership to root:root"
${DEBUG} sudo chown -R root:root ${DEST}*
echo "### Create /usr/local/bin/signal-desktop symlink"
${DEBUG} sudo ln -svf ${DEST}/signal-desktop /usr/local/bin/signal-desktop
echo "Currently installed: ${VERSION}" | ${DEBUG} sudo tee ${DEST}/.version.txt
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment