@@ -23,6 +23,25 @@ source_conf "$HESTIA/conf/hestia.conf"
2323
2424fields=" \$ NAME \$ VERSION \$ ARCH \$ UPDATED \$ DESCR \$ TIME \$ DATE"
2525
26+ # Check details of installed .deb package function
27+ check_installed_deb () {
28+ dpkg_data=$( dpkg-query -s $1 )
29+ pkg_date=$( stat -c " %Y" /var/lib/dpkg/info/$1 .list)
30+ ARCH=$( echo " $dpkg_data " | grep Architecture | cut -f 2 -d ' ' )
31+ VERSION=$( echo " $dpkg_data " | grep ^Version | cut -f 2 -d ' ' )
32+ DATE=$( date -d @$pkg_date +" %F" )
33+ TIME=$( date -d @$pkg_date +" %T" )
34+ }
35+
36+ # Check details of installed .rpm package function
37+ check_installed_rpm () {
38+ rpm_data=$( rpm -qi $1 )
39+ ARCH=$( echo " $rpm_data " | grep Architecture | cut -f 2 -d ' ' )
40+ VERSION=$( echo " $rpm_data " | grep Version | cut -f 2 -d ' :' | xargs)
41+ DATE=$( echo " $rpm_data " | grep " Build Date" | awk ' {print $5 " " $6 " " $7}' )
42+ TIME=$( echo " $rpm_data " | grep " Build Date" | awk ' {print $8 " " $9 " " $10}' )
43+ }
44+
2645# JSON list function
2746json_list () {
2847 IFS=$' \n '
@@ -65,17 +84,22 @@ shell_list() {
6584# ----------------------------------------------------------#
6685
6786# Checking official latest version
68- hestia_v=$( apt-cache policy hestia | grep Candidate | cut -d ' :' -f 2 | xargs)
69- nginx_v=$( apt-cache policy hestia-nginx | grep Candidate | cut -d ' :' -f 2 | xargs)
70- php_v=$( apt-cache policy hestia-php | grep Candidate | cut -d ' :' -f 2 | xargs)
87+ if [ -f ' /etc/redhat-release' ]; then
88+ hestia_v=$( dnf list hestia | grep hestia | awk ' {print $2}' | cut -f 1 -d ' -' )
89+ nginx_v=$( dnf list hestia-nginx | grep hestia-nginx | awk ' {print $2}' | cut -f 1 -d ' -' )
90+ php_v=$( dnf list hestia-php | grep hestia-php | awk ' {print $2}' | cut -f 1 -d ' -' )
91+ else
92+ hestia_v=$( apt-cache policy hestia | grep Candidate | cut -d ' :' -f 2 | xargs)
93+ nginx_v=$( apt-cache policy hestia-nginx | grep Candidate | cut -d ' :' -f 2 | xargs)
94+ php_v=$( apt-cache policy hestia-php | grep Candidate | cut -d ' :' -f 2 | xargs)
95+ fi
7196
7297# Checking installed hestia version
73- dpkg_data=$( dpkg-query -s hestia)
74- pkg_date=$( stat -c " %Y" /var/lib/dpkg/info/hestia.list)
75- ARCH=$( echo " $dpkg_data " | grep Architecture | cut -f 2 -d ' ' )
76- VERSION=$( echo " $dpkg_data " | grep ^Version | cut -f 2 -d ' ' )
77- DATE=$( date -d @$pkg_date +" %F" )
78- TIME=$( date -d @$pkg_date +" %T" )
98+ if [ -f ' /etc/redhat-release' ]; then
99+ check_installed_rpm hestia
100+ else
101+ check_installed_deb hestia
102+ fi
79103
80104UPDATED=' yes'
81105if [ -n " $hesta_v " ] && [ " $hestia_v " \> " $VERSION " ]; then
@@ -86,12 +110,11 @@ data="NAME='hestia' VERSION='$VERSION' ARCH='$ARCH'"
86110data=" $data UPDATED='$UPDATED ' DESCR='core package' TIME='$TIME ' DATE='$DATE '"
87111
88112# Checking installed hestia-php version
89- dpkg_data=$( dpkg-query -s hestia-php)
90- pkg_date=$( stat -c " %Y" /var/lib/dpkg/info/hestia-php.list)
91- ARCH=$( echo " $dpkg_data " | grep Architecture | cut -f 2 -d ' ' )
92- VERSION=$( echo " $dpkg_data " | grep ^Version | cut -f 2 -d ' ' )
93- DATE=$( date -d @$pkg_date +" %F" )
94- TIME=$( date -d @$pkg_date +" %T" )
113+ if [ -f ' /etc/redhat-release' ]; then
114+ check_installed_rpm hestia-php
115+ else
116+ check_installed_deb hestia-php
117+ fi
95118
96119UPDATED=' yes'
97120if [ -n " $php_v " ] && [ " $php_v " \> " $VERSION " ]; then
@@ -103,12 +126,11 @@ data="$data ARCH='$ARCH' UPDATED='$UPDATED' DESCR='php interpreter'"
103126data=" $data TIME='$TIME ' DATE='$DATE '"
104127
105128# Checking installed hestia-nginx version
106- dpkg_data=$( dpkg-query -s hestia-nginx)
107- pkg_date=$( stat -c " %Y" /var/lib/dpkg/info/hestia-nginx.list)
108- ARCH=$( echo " $dpkg_data " | grep Architecture | cut -f 2 -d ' ' )
109- VERSION=$( echo " $dpkg_data " | grep ^Version | cut -f 2 -d ' ' )
110- DATE=$( date -d @$pkg_date +" %F" )
111- TIME=$( date -d @$pkg_date +" %T" )
129+ if [ -f ' /etc/redhat-release' ]; then
130+ check_installed_rpm hestia-nginx
131+ else
132+ check_installed_deb hestia-nginx
133+ fi
112134
113135UPDATED=' yes'
114136if [ -n " $nginx_v " ] && [ " $nginx_v " \> " $VERSION " ]; then
0 commit comments