From 4c4433916ca1f2b7ad2d54e90659c8faa1009212 Mon Sep 17 00:00:00 2001 From: Serghey Rodin Date: Mon, 7 Oct 2013 12:11:31 +0300 Subject: [PATCH] dpkg-query support --- bin/v-list-sys-vesta-updates | 58 ++++++++++++++++++++++++++---------- 1 file changed, 43 insertions(+), 15 deletions(-) diff --git a/bin/v-list-sys-vesta-updates b/bin/v-list-sys-vesta-updates index a904aa2dc9..12db31ac08 100755 --- a/bin/v-list-sys-vesta-updates +++ b/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