#!/bin/sh # script to add apt.postgresql.org to sources.list # from command line CODENAME="$1" # lsb_release is the best interface, but not always available if [ -z "$CODENAME" ]; then CODENAME=$(lsb_release -cs 2>/dev/null) fi # parse os-release (unreliable, does not work on Ubuntu) if [ -z "$CODENAME" -a -f /etc/os-release ]; then . /etc/os-release # Debian: VERSION="7.0 (wheezy)" # Ubuntu: VERSION="13.04, Raring Ringtail" CODENAME=$(echo $VERSION | sed -ne 's/.*(\(.*\)).*/\1/') fi # guess from sources.list if [ -z "$CODENAME" ]; then CODENAME=$(grep '^deb ' /etc/apt/sources.list | head -n1 | awk '{ print $3 }') fi # complain if no result yet if [ -z "$CODENAME" ]; then cat < /etc/apt/sources.list.d/pgdg.list <