-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathupdate_c2c.sh
153 lines (127 loc) · 4.7 KB
/
update_c2c.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
#!/bin/bash -x
function LogRight {
# Checking if the user has run the script with "sudo" or not
if [[ $EUID -ne 0 ]] ; then
clear
echo ""
echo "c2c upgrade tool must be run as root or with sudo. Now I will just exit..." 1>&2
echo ""
sleep 2
exit 1
fi
}
function setup {
# check to install the needed dependencies
#install deborphan
apt install deborphan
}
greeting() {
echo "_______________________________________________________"
echo " "
echo " C2C UPGRADE TOOL UBUNTU 20.04 "
echo " ~~~~~~~~~~~~~~~~~~~~~ "
echo " "
echo " Welcome to all-in-one System Update and maintenance "
echo " assistant app. "
echo " "
echo " "
echo " This simple script will automatically "
echo " refresh your packagelist, download and "
echo " install updates (if there are any), remove any old "
echo " kernels, obsolete packages and configuration files "
echo " to free up disk space, without any need of user "
echo " interference "
echo " "
echo " VERSION 1.0 "
echo "_______________________________________________________"
echo
echo " C2C UGRADE TOOL will start in 5 seconds... "
sleep 6
}
function DISABLE_PUPPET {
# this function will check ifpuppet agent disabled in the system or not
FILE=/opt/puppetlabs/puppet/cache/state/agent_disabled.lock
if [ -f "$FILE" ]; then
echo "puppet agent has already disabled"
else
puppet agent --disable "puppet will be disabled because the system is upgrading to new release"
echo "Puppet has been diabled successfully!! "
fi
}
function SWITCH_TO_LTS {
#this function will check if the prompt is set as lts if not it will switch it to lts.
TEST=cat | grep "Prompt=lts" /etc/update-manager/release-upgrades
if [ "$TEST" = "0" ]; then
echo "prompt is already set in lts"
else
echo "Switching to the 'lts' release channel (if 'never' or 'normal')"
sed -i -E 's/Prompt=(never|normal)/Prompt=lts/g' "/etc/update-manager/release-upgrades"
fi
}
function DISABLE_PPAs {
#this function will add the # character in lines that begin with deb.
for i in docker-ce.list slack-desktop.list user.list
do
sed -i -E 's/^/#/' /etc/apt/sources.list.d/$i
echo "files has been modified successfully"
done
}
function UPDATE_C2C {
echo
echo
echo "#########################"
echo " Started"
echo "#########################"
echo
## Updates package lists
apt update;
echo
echo "###############################"
echo "Finished updating package lists"
echo "###############################"
sleep 1
## Updates packages and libraries
apt full-upgrade;
echo
echo "###############################################"
echo "Finished updating packages and system libraries"
echo "###############################################"
sleep 1
echo
## Removes unneeded packages
apt --purge autoremove;
echo
echo "###################################"
echo "Finished removing unneeded packages"
echo "###################################"
sleep 1
echo
## Removes unused config files
deborphan -n --find-config | xargs apt --purge autoremove;
echo
echo "#####################################"
echo "Finished removing unused config files"
echo "#####################################"
sleep 1
echo
## Removes package files that can no longer be downloaded and everything except
# the lock file in /var/cache/apt/archives, including directories.
apt autoclean; apt clean;
echo
echo "######################################"
echo " Cleaned downloaded temporary packages"
echo "######################################"
echo
echo
echo "######################################"
echo " You need to reboot the machine manually in order to upgrade to ubuntu version 20.04"
echo "######################################"
echo
}
LogRight
setup
greeting
DISABLE_PUPPET
SWITCH_TO_LTS
DISABLE_PPAs
UPDATE_C2C