Permalink
Browse files

dpkg-query support

  • Loading branch information...
serghey-rodin committed Oct 7, 2013
1 parent 82a7469 commit 4c4433916ca1f2b7ad2d54e90659c8faa1009212
Showing with 43 additions and 15 deletions.
  1. +43 −15 bin/v-list-sys-vesta-updates
@@ -29,16 +29,24 @@ tmp_file=$(mktemp)
# Check latest version
wget -q -T 1 -t 1 http://c.vestacp.com/latest.txt -O $tmp_file
# Define rpm query format
rpm_format="VERSION='%{VERSION}'"
rpm_format="$rpm_format RELEASE='%{RELEASE}'"
rpm_format="$rpm_format ARCH='%{ARCH}'"
rpm_format="$rpm_format UTIME='%{INSTALLTIME}'\n"
# Check vesta version
eval $(rpm --queryformat="$rpm_format" -q vesta)
DATE=$(date -d @$UTIME +%F)
TIME=$(date -d @$UTIME +%T)
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
@@ -49,9 +57,19 @@ str="NAME='vesta' VERSION='$VERSION' RELEASE='$RELEASE' ARCH='$ARCH'"
str="$str UPDATED='$UPDATED' DESCR='core package' TIME='$TIME' DATE='$DATE'"
# Check vesta-php version
eval $(rpm --queryformat="$rpm_format" -q vesta-php)
DATE=$(date -d @$UTIME +%F)
TIME=$(date -d @$UTIME +%T)
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
@@ -63,9 +81,19 @@ str="$str UPDATED='$UPDATED' DESCR='php interpreter' TIME='$TIME'"
str="$str DATE='$DATE'"
# Check vesta-nginx version
eval $(rpm --queryformat="$rpm_format" -q vesta-nginx)
DATE=$(date -d @$UTIME +%F)
TIME=$(date -d @$UTIME +%T)
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

0 comments on commit 4c44339

Please sign in to comment.