-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathasl-repo-switch
executable file
·75 lines (61 loc) · 1.86 KB
/
asl-repo-switch
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
#!/usr/bin/bash
LISTFILE=/etc/apt/sources.list.d/allstarlink.list
if [ "$(whoami)" != "root" ]; then
echo "ERROR: must be run as root or using sudo" 1>&2
exit 1
fi
function set_level() {
echo -n "Setting level $1..."
case $1 in
main) COMPONENTS="main" ;;
beta) COMPONENTS="main beta" ;;
devel)
echo "WARNING: It is not recommended to use 'devel' unless instructed to by a developer!!"
COMPONENTS="main beta devel"
;;
*) usage ;;
esac
cat - > ${LISTFILE} <<EOF
# set by asl-repo-switch to ${1}
deb [signed-by=/etc/apt/keyrings/allstarlink.gpg] https://repo.allstarlink.org/public bookworm ${COMPONENTS}
EOF
echo " DONE"
}
function reset(){
cat - > ${LISTFILE} <<EOF
# Primary AllStarLink Repo for Production Packages
deb [signed-by=/etc/apt/keyrings/allstarlink.gpg] https://repo.allstarlink.org/public bookworm main
# Include Beta Component for Testing
#deb [signed-by=/etc/apt/keyrings/allstarlink.gpg] https://repo.allstarlink.org/public bookworm main beta
# Include Beta and Devel component for Development
# !! If you are not a developer and have not been told by a !!
# !! developer to uncomment this than DO NOT !!
#deb [signed-by=/etc/apt/keyrings/allstarlink.gpg] https://repo.allstarlink.org/public bookworm main beta devel
EOF
}
## Options
function usage() {
echo "Usage: $0 -l (main | beta | devel) --> Set level" 1>&2
echo "Usage: $0 -r --> Reset to stock" 1>&2
exit 1
}
while getopts "l:r" opt; do
case ${opt} in
l) LEVEL="${OPTARG}"; OP="level" ;;
r) RESET=y ; OP="reset" ;;
*) usage ;;
esac
done
shift $((OPTIND-1))
if [ -z "${LEVEL}" ] && [ -z "${RESET}" ]; then
usage
fi
if [ ! -z "${LEVEL}" ] && [ ! -z "${RESET}" ]; then
echo "ERROR: -l LEVEL and -r (reset) options conflict" 1>&2
fi
case ${OP} in
level) set_level ${LEVEL};;
reset) reset;;
esac
echo "Run 'apt update' to refresh the package repo cache."
exit 0