-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathupdate
110 lines (95 loc) · 4.42 KB
/
update
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
#!/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 "Hello,Let's update this system."
echo "##############################################################################################################################################################"
echo " ______ ______ ______ __ __ _______ ______ _______ ______ _______ ________ ________ ______ ______ __ "
echo " / \ / \ / \ / | / |/ \ / \ / \ / \ / \ / | / |/ \ / \ / | "
echo " /$$$$$$ |/$$$$$$ |/$$$$$$ | $$ | $$ |$$$$$$$ |/$$$$$$ |$$$$$$$ |/$$$$$$ |$$$$$$$ |$$$$$$$$/ $$$$$$$$//$$$$$$ |/$$$$$$ |$$ | "
echo " $$ | $$/ $$____$$ |$$ | $$/ $$ | $$ |$$ |__$$ |$$ | _$$/ $$ |__$$ |$$ |__$$ |$$ | $$ |$$ |__ $$ | $$ | $$ |$$ | $$ |$$ | "
echo " $$ | / $$/ $$ | $$ | $$ |$$ $$/ $$ |/ |$$ $$< $$ $$ |$$ | $$ |$$ | $$ | $$ | $$ |$$ | $$ |$$ | "
echo " $$ | __ /$$$$$$/ $$ | __ $$ | $$ |$$$$$$$/ $$ |$$$$ |$$$$$$$ |$$$$$$$$ |$$ | $$ |$$$$$/ $$ | $$ | $$ |$$ | $$ |$$ | "
echo " $$ \__/ |$$ |_____ $$ \__/ | $$ \__$$ |$$ | $$ \__$$ |$$ | $$ |$$ | $$ |$$ |__$$ |$$ |_____ $$ | $$ \__$$ |$$ \__$$ |$$ |_____ "
echo " $$ $$/ $$ |$$ $$/ $$ $$/ $$ | $$ $$/ $$ | $$ |$$ | $$ |$$ $$/ $$ | $$ | $$ $$/ $$ $$/ $$ | "
echo " $$$$$$/ $$$$$$$$/ $$$$$$/ $$$$$$/ $$/ $$$$$$/ $$/ $$/ $$/ $$/ $$$$$$$/ $$$$$$$$/ $$/ $$$$$$/ $$$$$$/ $$$$$$$$/ "
echo "###############################################################################################################################################################"
echo
}
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 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
}
LogRight
setup
greeting
DISABLE_PUPPET
UPDATE_C2C