This repository has been archived by the owner on Oct 3, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 284
/
add_repositories
94 lines (87 loc) · 3.03 KB
/
add_repositories
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
#!/bin/bash
# Add Apt Repo
#
# ${1} = "Name"
# ${2} = https://key.example.com/signing-key-pub.gpg
# ${3} = "deb https://repo.example.com/linux apt/repo"
# ${4} = list-name (derived from package-name)
# ${5} = return_function
function add_apt_repo() {
echo_message header "Starting 'add_apt_repo' function"
# Check if already added
if ! grep -q "${3}" /etc/apt/sources.list /etc/apt/sources.list.d/*; then
# draw window
if (whiptail \
--title "Add package Repository" \
--yesno "The ${1} package repository is not present on your system. \n\nWould you like to add it to continue? " 10 64) then
# Add repository signing key
echo_message info "Adding '${4}' package repository signing key to keyring..."
wget -qO - "${2}" | superuser_do apt-key --keyring ${4}.gpg add -
# Add repository
echo_message info "Adding '${4}' apt repository to 'sources.list.d'..."
echo ${3} | superuser_do tee /etc/apt/sources.list.d/${4}.list
# Update repository information
echo_message info "Refreshing repository information..."
superuser_do "apt update -y -qq"
# Done
echo_message success "Repository added."
# whiptail --title "Finished" --msgbox "The '${1}' package repository has been added." 8 56
else
# Cancelled
echo_message info "Addition of '${4}' package repository cancelled."
$5
fi
else
echo_message info "${1} repository already added."
fi
}
# Add Flatpak Repo
#
# ${1} = remote
# ${2} = https://remote.example.com/
function add_flatpak_repo() {
echo_message header "Starting 'add_flatpak_repo' function"
# Check if already added
flatpak remotes | grep ${1} &> /dev/null
# If repo is added
if [ $? = 0 ]; then
echo_message info "Repository already added."
# whiptail --msgbox "The ${1} Flatpak repository is already added." 8 56
else
# Add repository
echo_message info "Adding flatpak repository..."
flatpak remote-add --if-not-exists ${1} ${2}
echo_message success "Repository added."
# whiptail --title "Finished" --msgbox "The '${1}' Flatpak repository has been added." 8 56
fi
}
# Add Launchpad PPA
#
# ${1} = Name
# ${2} = launchpad-user/ppa-name
function add_launchpad_ppa() {
echo_message header "Starting 'add_launchpad_ppa' function"
# Check if PPA already added
if ! grep -q "^deb .*${2}" /etc/apt/sources.list /etc/apt/sources.list.d/*; then
# draw window
if (whiptail \
--title "Add PPA Repository" \
--yesno "The ${1} PPA repository (${2}) is not present on your system. \n\nWould you like to add it to continue? " 10 64) then
# Add repository
echo_message info "Adding ${1} PPA repository..."
superuser_do "add-apt-repository -y ppa:${2}"
# Update repository information
echo_message info "Refreshing repository information..."
superuser_do "apt update -y -qq"
# Done
echo_message success "Repository added."
# whiptail --title "Finished" --msgbox "The '${1}' PPA repository has been added." 8 56
else
# Cancelled
echo_message info "Addition of ${1} PPA repository cancelled."
$3
fi
else
echo_message info "${1} PPA repository already added."
fi
}