forked from luisdavim/dotfiles
-
Notifications
You must be signed in to change notification settings - Fork 0
/
ppa-cleanup.sh
executable file
·34 lines (32 loc) · 1.05 KB
/
ppa-cleanup.sh
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
#!/usr/bin/env bash
# Remove broken repos
sudo rm -f /tmp/update.txt; tput setaf 6; echo "Initializing.. Please Wait"
sudo apt-get update >> /tmp/update.txt 2>&1; awk '( /E:|W:/ && /launchpad/ && /404/ ) { print substr($5,26) }' /tmp/update.txt > /tmp/awk.txt; awk -F '/' '{ print $1"/"$2 }' /tmp/awk.txt > /tmp/awk1.txt; sort -u /tmp/awk1.txt > /tmp/awk2.txt
tput sgr0
if [ -s /tmp/awk2.txt ]
then
tput setaf 1
printf "PPA's going to be removed\n%s\n" "$(cat /tmp/awk2.txt)"
tput sgr0
while read -r line; do echo "sudo add-apt-repository -r ppa:$line"; done < /tmp/awk2.txt > /tmp/out
bash /tmp/out
else
tput setaf 1
echo "No PPA's to be removed"
tput sgr0
fi
rm -f /tmp/update.txt
rm -f /tmp/awk*.txt
rm -rf /tmp/out
# Fix missing GPG keys
sudo apt-get update 2> /tmp/keymissing
if [ -f /tmp/keymissing ]
then
for key in $(grep "NO_PUBKEY" /tmp/keymissing |sed "s/.*NO_PUBKEY //")
do
echo -e "\nProcessing key: $key"
sudo apt-key adv --keyserver keyserver.ubuntu.com --recv-keys $key
sudo apt-get update
done
rm /tmp/keymissing
fi