#!/bin/bash # This script is called after the cryfs .deb package is installed. # It sets up the package source so the user gets automatic updates for cryfs. # DEVELOPER WARNING: There is a lot of redundancy between this file and the install.sh script in the cryfs-web repository. Please port modifications to there! set -e DEBIAN_REPO_URL="http://apt.cryfs.org/debian" UBUNTU_REPO_URL="http://apt.cryfs.org/ubuntu" DISTRIBUTION=`lsb_release -s -i` DISTRIBUTION_VERSION=`lsb_release -s -c` containsElement () { local e for e in "${@:2}"; do [[ "$e" == "$1" ]] && return 0; done return 1 } get_repo_url () { if [[ "$DISTRIBUTION" == "Debian" ]] || [[ "$DISTRIBUTION" == "Devuan" ]]; then echo $DEBIAN_REPO_URL elif [[ "$DISTRIBUTION" == "Ubuntu" ]]; then echo $UBUNTU_REPO_URL else echo Not adding package source because $DISTRIBUTION is not supported. Please keep CryFS manually up to date. 1>&2 exit 0 fi } get_apt_config () { apt-config dump|grep "$1 "|sed -e "s/^$1\ \"\([^\"]*\)\"\;/\1/g" } sources_list_dir () { root=$(get_apt_config "Dir") etc=$(get_apt_config "Dir::Etc") sourceparts=$(get_apt_config "Dir::Etc::sourceparts") echo "$root/$etc/$sourceparts" } add_repository () { dir=$(sources_list_dir) repo_url=$(get_repo_url) echo "deb $repo_url $DISTRIBUTION_VERSION main" > $dir/cryfs.list } install_key () { # Key from http://www.cryfs.org/apt.key apt-key add - > /dev/null <&2 exit 1 ;; esac set +e exit 0