zulip/scripts/lib/setup-apt-repo

45 lines
1.7 KiB
Bash
Executable File

#!/bin/bash
set -x
SOURCES_FILE=/etc/apt/sources.list.d/zulip.list
STAMP_FILE=/etc/apt/sources.list.d/zulip.list.apt-update-in-progress
zulip_source_hash=$(sha1sum "$SOURCES_FILE")
apt-get install -y lsb-release apt-transport-https
SCRIPTS_PATH="$(dirname "$(dirname "$0")")"
release=$(lsb_release -sc)
if [ "$release" = "trusty" ] || [ "$release" = "xenial" ] || [ "$release" = "bionic" ]; then
apt-key add "$SCRIPTS_PATH"/setup/pgroonga-ppa.asc
apt-key add "$SCRIPTS_PATH"/setup/zulip-ppa.asc
cat >/etc/apt/sources.list.d/zulip.list <<EOF
deb http://ppa.launchpad.net/groonga/ppa/ubuntu $release main
deb http://ppa.launchpad.net/tabbott/zulip/ubuntu $release main
deb-src http://ppa.launchpad.net/groonga/ppa/ubuntu $release main
deb-src http://ppa.launchpad.net/tabbott/zulip/ubuntu $release main
EOF
elif [ "$release" = "stretch" ]; then
apt-get install -y debian-archive-keyring
apt-key add "$SCRIPTS_PATH"/setup/packagecloud.asc
apt-key add "$SCRIPTS_PATH"/setup/pgroonga-debian.asc
cat >/etc/apt/sources.list.d/zulip.list <<EOF
deb https://packagecloud.io/zulip/server/debian/ stretch main
deb https://packages.groonga.org/debian/ stretch main
deb-src https://packages.groonga.org/debian/ stretch main
EOF
else
echo "Unsupported release $release."
exit 1
fi
if [ "$zulip_source_hash" = "$(sha1sum "$SOURCES_FILE")" ] && ! [ -e "$STAMP_FILE" ]; then
echo "zulip.list file did not change; skipping apt-get update"
else
# We create this stamp file to ensure `apt-get update` will be run
# the next time this script is invoked, and each time after, until
# `apt-get update` finishes successfully.
touch "$STAMP_FILE"
apt-get update && rm -f "$STAMP_FILE"
fi