Skip to content

Instantly share code, notes, and snippets.

@nickvanw
Last active August 29, 2015 14:00
Show Gist options
  • Save nickvanw/11238938 to your computer and use it in GitHub Desktop.
Save nickvanw/11238938 to your computer and use it in GitHub Desktop.
Dotdeb Install Script
#!/bin/bash
OFFICIAL_DOTDEB="http://packages.dotdeb.org"
APT_FOLDER="/etc/apt/sources.list.d/"
DOTDEB_FILE="dotdeb.list"
# Make sure we're running this as root!
if [[ $UID -ne 0 ]]; then
echo "$0 must be run as root"
exit 1
fi
# Check if we've done this!
if [ -f "$APT_FOLDER$DOTDEB_FILE" ]; then
echo "DotDeb already installed!"
exit 1
fi
install_official() {
install_key
VER=`lsb_release -s -c`
touch $APT_FOLDER$DOTDEB_FILE
echo "deb $OFFICIAL_DOTDEB $VER all" >> $APT_FOLDER$DOTDEB_FILE
echo "deb-src $OFFICIAL_DOTDEB $VER all" >> $APT_FOLDER$DOTDEB_FILE
echo "Doing final apt-get update."
apt-get update >> /dev/null
echo "You are now ready to use Dotdeb on this server."
}
install_user() {
install_key
VER=`lsb_release -s -c`
echo -n "What is the URL of the dotdeb mirror you want to use?"
read line
touch $APT_FOLDER$DOTDEB_FILE
echo "deb $line $VER all" >> $APT_FOLDER$DOTDEB_FILE
echo "deb-src $line $VER all" >> $APT_FOLDER$DOTDEB_FILE
echo "Doing final apt-get update."
apt-get update >> /dev/null
echo "You are now ready to use Dotdeb on this server."
}
install_key() {
echo "Getting Dotdeb gpg key"
wget -q http://www.dotdeb.org/dotdeb.gpg
apt-key add dotdeb.gpg
rm dotdeb.gpg
}
install_lsb() {
echo "Installing lsb-release so we can get your system version"
apt-get install lsb-release -y >> /dev/null
}
install_lsb
echo "Would you like to use the official repo?"
select yn in "Yes" "No"; do
echo $yn
case $yn in
"Yes" ) install_official; break;;
"No" ) install_user; break;;
esac
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment