@ -6,26 +6,87 @@ set -eux
## kal-scripts
## kal-scripts
##
##
if ! [ -e /etc/apt/sources.list.d/kalysto.org.list ] ; then
if ! status = $( dpkg-query -W -f= '${db:Status-Abbrev}\n' 'apt-transport-https' ) ||
[ " $status " != "ii " ] ; then
## Required to fetch our repository in https
## Required to fetch our repository in https
apt-get install -y apt-transport-https </dev/null
apt-get install -y apt-transport-https </dev/null
fi
update_repos_from_source_file( ) {
local source_file = " $1 "
## Update only repo's from this source file
if ! out = $( apt-get update \
-o Dir::Etc::sourcelist= " sources.list.d/ ${ source_file } " \
-o Dir::Etc::sourceparts= "-" \
-o APT::Get::List-Cleanup= "0" 2>/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 <<EOF > /etc/apt/sources.list.d/kalysto.org.list
cat <<EOF > /etc/apt/sources.list.d/kalysto.org.list
## vlab's shell libraries
## vlab's shell libraries
deb https://deb.kalysto.org no-dist kal-alpha kal-beta kal-main
deb https://deb.kalysto.org no-dist kal-alpha kal-beta kal-main
EOF
EOF
fi
if [ " $errlvl " -le 2 ] ; then ## no pub key
if ! type gpg >/dev/null; then
if ! type gpg >/dev/null; then
apt-get install -y gnupg2 </dev/null
apt-get install -y gnupg2 </dev/null
fi
fi
## Include the GPG key
## Include the GPG key
wget -O - https://deb.kalysto.org/conf/public-key.gpg | apt-key add -
wget -O - https://deb.kalysto.org/conf/public-key.gpg | apt-key add -
## Update only this repo:
## Update only this repo:
apt-get update -o Dir::Etc::sourcelist= "sources.list.d/kalysto.org.list" \
-o Dir::Etc::sourceparts= "-" -o APT::Get::List-Cleanup= "0"
if ! update_repos_from_source_file "kalysto.org.list" ; then
echo "Error: Couldn't update repository information of kalysto deb repository" >& 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
fi
apt-get install -y kal-scripts </dev/null
apt-get install -y kal-scripts </dev/null