#!/bin/bash set -eux ## ## kal-scripts ## if ! status=$(dpkg-query -W -f='${db:Status-Abbrev}\n' 'apt-transport-https') || [ "$status" != "ii " ]; then ## Required to fetch our repository in https apt-get install -y apt-transport-https /dev/null); then return 3 fi if [[ "$out" = *" NO_PUBKEY "* ]]; then return 2 fi if [[ "$out" = *$'\n'"Err:1 "* ]]; then return 1 fi return 0 } check_working_source_file() { local source_file="$1" if ! [ -e "/etc/apt/sources.list.d/${source_file}" ]; then return 1 fi update_repos_from_source_file "${source_file}" 2>/dev/null && return 0 local errlvl="$?" if [[ "$errlvl" == 2 ]]; then return 2 fi return 127 ## Unmanaged error } errlvl=0 ## Will check and update package list if running correctly check_working_source_file "kalysto.org.list" || errlvl="$?" if [ "$errlvl" -gt 0 ]; then if [ "$errlvl" -le 1 ]; then ## no file in source list cat < /etc/apt/sources.list.d/kalysto.org.list ## vlab's shell libraries deb https://deb.kalysto.org no-dist kal-alpha kal-beta kal-main EOF fi if [ "$errlvl" -le 2 ]; then ## no pub key if ! type gpg >/dev/null; then apt-get install -y gnupg2 &2 echo " Despite having just added the GPG key." >&2 exit 1 fi fi if [ "$errlvl" == 127 ]; then echo "Error: Couldn't update repository information of kalysto deb repository..." >&2 echo " - check /etc/apt/source.list.d/kalysto.org.list content and" >&2 echo " - check \`\`apt-get update\`\` output for errors." >&2 exit 1 fi fi apt-get install -y kal-scripts