-
Notifications
You must be signed in to change notification settings - Fork 1k
/
v-list-sys-vesta-updates
executable file
·135 lines (116 loc) · 4.34 KB
/
v-list-sys-vesta-updates
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
#!/bin/bash
# info: list system updates
# options: [FORMAT]
#
# The function checks available updates for vesta packages.
#----------------------------------------------------------#
# Variable&Function #
#----------------------------------------------------------#
# Argument defenition
format=${1-shell}
# Includes
source $VESTA/func/main.sh
#----------------------------------------------------------#
# Action #
#----------------------------------------------------------#
# Remove upd_flag
rm -f $VESTA/web/.update
# Create tmp file
tmp_file=$(mktemp)
# Check latest version
wget -q -T 1 -t 1 http://c.vestacp.com/latest.txt -O $tmp_file
# Check vesta version
if [ -e "/etc/redhat-release" ]; then
rpm_format="VERSION='%{VERSION}'"
rpm_format="$rpm_format RELEASE='%{RELEASE}'"
rpm_format="$rpm_format ARCH='%{ARCH}'"
rpm_format="$rpm_format UTIME='%{INSTALLTIME}'\n"
eval $(rpm --queryformat="$rpm_format" -q vesta)
DATE=$(date -d @$UTIME +%F)
TIME=$(date -d @$UTIME +%T)
else
dpkg_data=$(dpkg-query -s vesta)
pkg_date=$(stat -c "%Y" /var/lib/dpkg/info/vesta.list)
ARCH=$(echo "$dpkg_data"|grep Architecture | cut -f 2 -d ' ')
VERSION=$(echo "$dpkg_data"|grep Version |cut -f 2 -d ' '|cut -f 1 -d \-)
RELEASE=$(echo "$dpkg_data"|grep Version |cut -f 2 -d ' '|cut -f 2 -d \-)
DATE=$(date -d @$pkg_date +"%F")
TIME=$(date -d @$pkg_date +"%T")
fi
latest=$(grep vesta $tmp_file)
UPDATED='yes'
if [ ! -z "$latest" ] && [ "$latest" != "vesta-$VERSION-$RELEASE" ]; then
UPDATED='no'
set_upd_flag='yes'
fi
str="NAME='vesta' VERSION='$VERSION' RELEASE='$RELEASE' ARCH='$ARCH'"
str="$str UPDATED='$UPDATED' DESCR='core package' TIME='$TIME' DATE='$DATE'"
# Check vesta-php version
if [ -e "/etc/redhat-release" ]; then
eval $(rpm --queryformat="$rpm_format" -q vesta-php)
DATE=$(date -d @$UTIME +%F)
TIME=$(date -d @$UTIME +%T)
else
dpkg_data=$(dpkg-query -s vesta-php)
pkg_date=$(stat -c "%Y" /var/lib/dpkg/info/vesta-php.list)
ARCH=$(echo "$dpkg_data"|grep Architecture | cut -f 2 -d ' ')
VERSION=$(echo "$dpkg_data"|grep Version |cut -f 2 -d ' '|cut -f 1 -d \-)
RELEASE=$(echo "$dpkg_data"|grep Version |cut -f 2 -d ' '|cut -f 2 -d \-)
DATE=$(date -d @$pkg_date +"%F")
TIME=$(date -d @$pkg_date +"%T")
fi
latest=$(grep php $tmp_file)
UPDATED='yes'
if [ ! -z "$latest" ] && [ "$latest" != "php-$VERSION-$RELEASE" ]; then
UPDATED='no'
set_upd_flag='yes'
fi
str="$str\nNAME='vesta-php' VERSION='$VERSION' RELEASE='$RELEASE' ARCH='$ARCH'"
str="$str UPDATED='$UPDATED' DESCR='php interpreter' TIME='$TIME'"
str="$str DATE='$DATE'"
# Check vesta-nginx version
if [ -e "/etc/redhat-release" ]; then
eval $(rpm --queryformat="$rpm_format" -q vesta-nginx)
DATE=$(date -d @$UTIME +%F)
TIME=$(date -d @$UTIME +%T)
else
dpkg_data=$(dpkg-query -s vesta-nginx)
pkg_date=$(stat -c "%Y" /var/lib/dpkg/info/vesta-nginx.list)
ARCH=$(echo "$dpkg_data"|grep Architecture | cut -f 2 -d ' ')
VERSION=$(echo "$dpkg_data"|grep Version |cut -f 2 -d ' '|cut -f 1 -d \-)
RELEASE=$(echo "$dpkg_data"|grep Version |cut -f 2 -d ' '|cut -f 2 -d \-)
DATE=$(date -d @$pkg_date +"%F")
TIME=$(date -d @$pkg_date +"%T")
fi
latest=$(grep nginx $tmp_file)
UPDATED='yes'
if [ ! -z "$latest" ] && [ "$latest" != "nginx-$VERSION-$RELEASE" ]; then
UPDATED='no'
set_upd_flag='yes'
fi
str="$str\nNAME='vesta-nginx' VERSION='$VERSION' RELEASE='$RELEASE'"
str="$str ARCH='$ARCH' UPDATED='$UPDATED' DESCR='internal web server'"
str="$str TIME='$TIME' DATE='$DATE'"
# Create flag if updates avaiable
if [ "$set_upd_flag" == 'yes' ]; then
touch $VESTA/web/.update
chmod a+r $VESTA/web/.update
fi
# Defining config
echo -e "$str" > $tmp_file
conf=$tmp_file
# Defining fileds to select
fields="\$NAME \$VERSION \$RELEASE \$ARCH \$UPDATED \$DESCR \$TIME \$DATE"
# Listing services
case $format in
json) json_list ;;
plain) nohead=1; shell_list ;;
shell) fields='$NAME $VERSION $RELEASE $ARCH $UPDATED $TIME $DATE'
shell_list | column -t ;;
*) check_args '1' '0' 'USER [FORMAT]'
esac
rm -f $tmp_file
#----------------------------------------------------------#
# Vesta #
#----------------------------------------------------------#
exit