Created
November 24, 2024 21:12
-
-
Save ergolyam/d4a03f17ecfee2a130038cfef31e11f1 to your computer and use it in GitHub Desktop.
Script that adds a ppa repository on any deb based distribution
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/bin/bash | |
| NM=`uname -a && date` | |
| NAME=`echo $NM | md5sum | cut -f1 -d" "` | |
| if [ $# -eq 1 ]; then | |
| ppa_name=`echo "$1" | cut -d":" -f2 -s` | |
| if [ -z "$ppa_name" ]; then | |
| echo "PPA name not found" | |
| echo "Utility to add PPA repositories in your debian machine" | |
| echo "$0 ppa:user/ppa-name" | |
| else | |
| repo_line="deb http://ppa.launchpad.net/$ppa_name/ubuntu jammy main" | |
| if grep -Fxq "$repo_line" /etc/apt/sources.list; then | |
| echo "Repository $repo_line already exists in /etc/apt/sources.list, skipping." | |
| else | |
| echo "$repo_line" >> /etc/apt/sources.list | |
| apt-get update >> /dev/null 2> /tmp/${NAME}_apt_add_key.txt | |
| key=`grep -oP 'NO_PUBKEY \K\w+' /tmp/${NAME}_apt_add_key.txt` | |
| if [ ! -z "$key" ]; then | |
| echo "Adding the key: $key" | |
| apt-key adv --keyserver keyserver.ubuntu.com --recv-keys $key | |
| fi | |
| rm -rf /tmp/${NAME}_apt_add_key.txt | |
| fi | |
| fi | |
| else | |
| echo "Utility to add PPA repositories in your debian machine" | |
| echo "$0 ppa:user/ppa-name" | |
| fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment