This repository has been archived by the owner on Oct 6, 2022. It is now read-only.
-
-
Notifications
You must be signed in to change notification settings - Fork 42
/
rolling-rhino
executable file
·174 lines (152 loc) · 5.92 KB
/
rolling-rhino
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
#!/usr/bin/env bash
function usage () {
echo
echo "Usage"
echo " $0"
echo
}
function fancy_message() {
# $1 = type , $2 = message
# Message types
# 0 - info
# 1 - warning
# 2 - error
if [ -z "${1}" ] || [ -z "${2}" ]; then
return
fi
local RED="\e[31m"
local GREEN="\e[32m"
local YELLOW="\e[33m"
local RESET="\e[0m"
local MESSAGE_TYPE=""
local MESSAGE=""
MESSAGE_TYPE="${1}"
MESSAGE="${2}"
case ${MESSAGE_TYPE} in
0) echo -e " [${GREEN}+${RESET}] INFO: ${MESSAGE}";;
1) echo -e " [${YELLOW}*${RESET}] WARNING: ${MESSAGE}";;
2) echo -e " [${RED}!${RESET}] ERROR: ${MESSAGE}";;
*) echo -e " [?] UNKNOWN: ${MESSAGE}";;
esac
}
echo "Rolling Rhino 🦏"
# Check if the user running the script is root
if [ "$(id -u)" -ne 0 ]; then
fancy_message 2 "You need to be root."
exit 1
fi
# Take command line arguments
while [ $# -gt 0 ]; do
case "${1}" in
-h|--h|-help|--help)
usage
exit 0;;
*)
fancy_message 2 "\"${1}\" is not a supported parameter."
usage
exit 1;;
esac
done
if which lsb_release 1>/dev/null; then
fancy_message 0 "lsb_release detected."
else
fancy_message 2 "lsb_release not detected. Quitting."
exit 1
fi
if grep -q devel /etc/apt/sources.list; then
fancy_message 2 "Already tracking the devel series. Nothing to do."
exit 1
fi
OS_CODENAME=$(lsb_release --codename --short)
OS_ID=$(lsb_release --id --short)
if [ "${OS_ID}" == "Ubuntu" ]; then
fancy_message 0 "Ubuntu detected."
else
fancy_message 2 "${OS_ID} detected, which is not supported."
exit 1
fi
OS_DESCRIPTION=$(lsb_release --description --short)
if [[ "${OS_DESCRIPTION}" == *"development branch"* ]]; then
fancy_message 0 "${OS_DESCRIPTION} detected."
elif [[ "${OS_DESCRIPTION}" == *"LTS"* ]]; then
fancy_message 2 "${OS_DESCRIPTION} detected. Switching a LTS release to the devel series directly is not supported."
exit 1
else
fancy_message 2 "${OS_DESCRIPTION} detected. Switching an interim release to the devel series directly is not supported."
exit 1
fi
DESKTOP_FOUND=0
for META in kubuntu-desktop lubuntu-desktop ubuntu-desktop ubuntu-budgie-desktop ubuntukylin-desktop ubuntu-mate-desktop ubuntustudio-desktop xubuntu-desktop; do
INSTALLED=$(apt list --installed "${META}" 2>/dev/null | grep installed)
if [ -n "${INSTALLED}" ]; then
fancy_message 0 "Detected ${META}."
DESKTOP_FOUND=1
break
fi
done
if [ ${DESKTOP_FOUND} -eq 0 ]; then
fancy_message 2 "No installed desktop packages were detected. Quitting."
exit 1
fi
if [ -z "$(ls -A /etc/apt/sources.list.d/*.list 2>/dev/null)" ]; then
fancy_message 0 "No PPAs detected, this is good."
else
fancy_message 1 "PPAs detected, you're responsible for taking care of PPA migrations in the future."
fi
fancy_message 0 "All checks passed."
read -p "Are you sure you want to start tracking the devel series? [Y/N]" -n 1 -r
if [[ ${REPLY} =~ ^[Yy]$ ]]; then
cp /etc/apt/sources.list /etc/apt/sources.list.${OS_CODENAME}
cat << EOF > /etc/apt/sources.list
# See http://help.ubuntu.com/community/UpgradeNotes for how to upgrade to
# newer versions of the distribution.
deb http://archive.ubuntu.com/ubuntu devel main restricted
# deb-src http://archive.ubuntu.com/ubuntu devel main restricted
## Major bug fix updates produced after the final release of the
## distribution.
deb http://archive.ubuntu.com/ubuntu devel-updates main restricted
# deb-src http://archive.ubuntu.com/ubuntu devel-updates main restricted
## N.B. software from this repository is ENTIRELY UNSUPPORTED by the Ubuntu
## team. Also, please note that software in universe WILL NOT receive any
## review or updates from the Ubuntu security team.
deb http://archive.ubuntu.com/ubuntu devel universe
# deb-src http://archive.ubuntu.com/ubuntu devel universe
deb http://archive.ubuntu.com/ubuntu devel-updates universe
# deb-src http://archive.ubuntu.com/ubuntu devel-updates universe
## N.B. software from this repository is ENTIRELY UNSUPPORTED by the Ubuntu
## team, and may not be under a free licence. Please satisfy yourself as to
## your rights to use the software. Also, please note that software in
## multiverse WILL NOT receive any review or updates from the Ubuntu
## security team.
deb http://archive.ubuntu.com/ubuntu devel multiverse
# deb-src http://archive.ubuntu.com/ubuntu devel multiverse
deb http://archive.ubuntu.com/ubuntu devel-updates multiverse
# deb-src http://archive.ubuntu.com/ubuntu devel-updates multiverse
## N.B. software from this repository may not have been tested as
## extensively as that contained in the main release, although it includes
## newer versions of some applications which may provide useful features.
## Also, please note that software in backports WILL NOT receive any review
## or updates from the Ubuntu security team.
deb http://archive.ubuntu.com/ubuntu devel-backports main restricted universe multiverse
# deb-src http://archive.ubuntu.com/ubuntu devel-backports main restricted universe multiverse
## Uncomment the following two lines to add software from Canonical's
## 'partner' repository.
## This software is not part of Ubuntu, but is offered by Canonical and the
## respective vendors as a service to Ubuntu users.
# deb http://archive.canonical.com/ubuntu devel partner
# deb-src http://archive.canonical.com/ubuntu devel partner
deb http://security.ubuntu.com/ubuntu devel-security main restricted
# deb-src http://security.ubuntu.com/ubuntu devel-security main restricted
deb http://security.ubuntu.com/ubuntu devel-security universe
# deb-src http://security.ubuntu.com/ubuntu devel-security universe
deb http://security.ubuntu.com/ubuntu devel-security multiverse
# deb-src http://security.ubuntu.com/ubuntu devel-security multiverse
EOF
fancy_message 0 "Switching to devel series."
apt -y autoclean
apt -y clean
apt -y update
apt -y dist-upgrade
fancy_message 0 "Your Rolling Rhino is ready."
cat "$(dirname "$0")/logo.txt"
fi