-
Notifications
You must be signed in to change notification settings - Fork 24
/
Copy pathconfigure-repos.sh
executable file
·300 lines (215 loc) · 6.34 KB
/
configure-repos.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
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
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
#!/bin/bash
#-------------------------------------------------------------------------------
# Author: Michael DeGuzis
# Script Ver: 1.3.3
# Description: Configures LibreGeek repositories
#
# Usage: ./configure-repos.sh
# Opts: See "--help"
# ------------------------------------------------------------------------------
ARG1="$1"
# Set default arg if none is set
if [[ "${ARG1}" == "" ]]; then
ARG1="--default"
fi
function_repair_setup()
{
echo -e "\n==> Repairing repository configurations\n"
sleep 2s
BETA_LIST="/etc/apt/sources.list/steamos-tools-beta.list"
BETA_PREFS="/etc/apt/preferences.d/steamos-tools-beta"
# See if we have a beta repository, so it is retained
if [[ "${BETA_LIST}" != "" || "${BETA_PREFS}" != "" ]]; then
# If either file is present, assume beta was added or is now broken
BETA_REPO="true"
fi
# Clear out packages
pkgs="steamos-tools-repo libregeek-archive-keyring steamos-tools-beta-repo"
for pkg in $pkgs
do
if dpkg -l $pkg &> /dev/null; then
sudo apt-get purge -y $pkg
fi
done
files="jessie jessie-backports steamos-tools steamos-tools-beta"
for file in ${files};
do
sudo rm -rf /etc/apt/sources.list.d/${file}*
sudo rm -rf /etc/apt/preferences.d/${file}*
done
# Comment out any non SteamOS source lines that are not already commented out
# Backup file for safety
# Original file: https://gist.github.com/ProfessorKaos64/085ad37c7d23b9a1141c4d6268416205
# Updated 20161117
sudo sed -i.bak '/steamos/! s/^/#/' "/etc/apt/sources.list"
echo -e "\nNotice: /etc/apt/sources.list backup saved as /etc/apt/sources.list.bak"
# /etc/apt/preferences usually does not exist, but back it up if it does
# This should not exist on a default installation
if [[ -d "/etc/apt/preferences" ]]; then
sudo mv "/etc/apt/preferences" "/etc/apt/preferences.bak"
echo -e "Notice: /etc/apt/preferences backup saved as /etc/apt/preferences.bak\n"
fi
}
function_repo_setup()
{
if [[ "${INSTALL}" = "true" ]]; then
# Add main configuration set
echo -e "\n==> Adding keyrings and repository configurations\n"
sleep 2s
wget http://packages.libregeek.org/libregeek-archive-keyring.deb -nc
wget http://packages.libregeek.org/steamos-tools-repo.deb -nc
sudo dpkg -i libregeek-archive-keyring.deb
sudo dpkg -i steamos-tools-repo.deb
sudo apt-get install -y debian-archive-keyring
# If beta repo is requested
if [[ "${BETA_REPO}" = "true" ]]; then
echo -e "\n==> Adding additional beta repository\n"
sleep 2s
wget http://packages.libregeek.org/steamos-tools-beta-repo.deb -nc
sudo dpkg -i steamos-tools-beta-repo.deb
fi
elif [[ "${INSTALL}" = "false" ]]; then
if [[ "${BETA_REPO}" = "true" ]]; then
# only remove beta repo setup
echo -e "\n==> Removing SteamOS-TOols beta repository setup.\n"
sleep 2s
sudo apt-get purge -y steamos-tools-beta-repo
# Catch any leftovers...
sudo rm -f /etc/apt/sources.list.d/steamos-tools-beta.list
sudo rm -f /etc/apt/sources.list.d/steamos-tools.list
else
echo -e "\n==> Removing all repository setups and keyrings.\n"
sleep 2s
sudo apt-get purge -y steamos-tools-beta-repo steamos-tools-repo libregeek-archive-keyring
# Catch any leftovers...
sudo rm -f /etc/apt/sources.list.d/steamos-tools-beta.list
sudo rm -f /etc/apt/sources.list.d/steamos-tools.list
fi
fi
}
function_debian_only()
{
if [[ "${INSTALL}" = "true" ]]; then
echo -e "\n==> Adding Debian repository\n"
sleep 2s
wget http://packages.libregeek.org/debian-repo.deb -nc
sudo dpkg -i debian-repo.deb
elif [[ "${INSTALL}" = "false" ]]; then
echo -e "\n==> Removing Debian repository setup.\n"
sleep 2s
sudo apt-get purge -y debian-repo
fi
}
function_debian_backports_only()
{
if [[ "${INSTALL}" = "true" ]]; then
echo -e "\n==> Adding Debian backports repository\n"
sleep 2s
wget http://packages.libregeek.org/debian-backports-repo.deb -nc
sudo dpkg -i debian-backports-repo.deb
elif [[ "${INSTALL}" = "false" ]]; then
echo -e "\n==> Removing Debian backports repository setup.\n"
sleep 2s
sudo apt-get purge -y debian-backports-repo
fi
}
function_cleanup()
{
echo -e "\n==> Updating system\n"
sleep 2s
sudo apt-get update -y
# check for expired keys and request again to attempt to resolve
steamos_tools_expired=$(LANG=C apt-key list | grep 34C589A7 | grep "expired")
if [[ ${steamos_tools_expired} != "" ]]; then
echo "SteamOS-Tools expiration check: [FAILED]"
echo "SteamOS-Tools GPG key looks expired, attempting to renew..."
sudo apt-key adv --keyserver pool.sks-keyservers.net --recv-keys 34C589A7
else
echo "SteamOS-Tools expiration check: [OK]"
fi
echo -e "\n==> Cleaning up\n"
rm -f libregeek-archive-keyring.deb
rm -f steamos-tools-beta-repo.deb
rm -f steamos-tools-repo.deb
rm -f debian-repo.deb
}
function_help()
{
clear
cat<<- EOF
==================================================================
Available options
==================================================================
--default Normal installation
--debian-only Add only Debian sources
--debian-backports Enable Debian backports repo
--repair Repair and install setup
--enable-testing Add testing repository
--remove Remove all repository setups
--remove-testing Remove just beta repository setup
EOF
}
main()
{
# Process options or exit if an incorrect option is called
case "${ARG1}" in
-h|--help)
# Just show help
function_help
exit
;;
--default)
# Process just default setup
INSTALL="true"
function_repo_setup
function_cleanup
;;
--debian-only)
# Process just debian setup
INSTALL="true"
function_debian_only
function_cleanup
;;
--debian-backports)
# Process just debian backports setup
INSTALL="true"
function_debian_backports_only
function_cleanup
;;
--repair)
# reapair setup and process normally
INSTALL="true"
function_repair_setup
function_repo_setup
function_cleanup
;;
--enable-testing)
# Default + testings
INSTALL="true"
BETA_REPO="true"
function_repo_setup
function_cleanup
;;
--remove)
# process removal
INSTALL="false"
function_repo_setup
function_cleanup
;;
--remove-testing)
# process remove for beta setup
INSTALL="false"
BETA_REPO="true"
function_repo_setup
function_cleanup
;;
*)
# invalid option, exit
echo -e "Invalid option! Exiting..."
sleep 2s
exit
;;
esac
}
# Start script
main