#!/bin/bash # # ---------------------------------------------------------------------- # # Description: Automates adding an Ubuntu PPA to a Debian installation # # Author: Maccus # # Initial version: 111222-01 # # Update: 111224-01 # - Added menu to select distribution codename # # Requires: apt-get # # This script has been written and tested on # Ubuntu Linux 10.04 and Debian Testing (Wheezy) # # ---------------------------------------------------------------------- # # Usage: Place the script in "/usr/local/bin", do a # "chmod +x /usr/local/bin/system-ppa2debian" as root, # and run "system-ppa2debian ppa:ppa_user/ppa_name" from the command line. # # ---------------------------------------------------------------------- # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation; either version 2 of the License, or # (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License along # with this program; if not, write to the Free Software Foundation, # Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. # # ---------------------------------------------------------------------- # # Uncomment for debugging # # set -x # Start script echo -e "\n\033[1;33mSTATUS\033[0m: Script \"$(basename $0)\" is gestart...\n" # Check to see if we are root. if [ "${UID}" != "0" ]; then echo -e "You must be root !!\n" sleep 2 exit 1 fi if [ $# -eq 1 ]; then NM="$(uname -a && date)" NAME="$(echo ${NM} | md5sum | cut -f1 -d " ")" PPA="$(echo "$1" | cut -d ":" -f2 -s)" PPAFORMAT="$(echo ${PPA} | tr "/" "-")" PPADESC="$(echo ${PPA} | sed 's|.*\/||;s|\-| |g;s/\<./\U&/g')" echo "Choose Ubuntu distribution codename:" select CNAME in lucid maverick natty oneiric precise; do CODENAME="${CNAME:=maverick}" && break done if [ -z "${PPA}" ]; then echo "PPA name not found!" echo "Utility to add PPA repositories to your Debian machine" echo "USAGE: $0 ppa:ppa_user/ppa_name" else echo "Adding ${PPADESC} PPA..." echo "deb http://ppa.launchpad.net/${PPA}/ubuntu ${CODENAME} main #${PPADESC} PPA" >> /etc/apt/sources.list.d/${PPAFORMAT}-${CODENAME}.list apt-get update >> /dev/null 2> /tmp/${NAME}_apt_add_key.txt KEY="$(cat /tmp/${NAME}_apt_add_key.txt | cut -d":" -f6 | cut -d" " -f3)" apt-key adv --keyserver keyserver.ubuntu.com --recv-keys ${KEY} rm -rf /tmp/${NAME}_apt_add_key.txt fi else echo "Utility to add PPA repositories to your Debian machine" echo "USAGE: $0 ppa:user/ppa_name" fi