mirror of
https://github.com/myvesta/vesta
synced 2025-08-14 18:49:21 -07:00
i18n + service manager + web updater
This commit is contained in:
parent
3612d08933
commit
6e631c32a1
84 changed files with 1806 additions and 1458 deletions
107
bin/v-list-sys-vesta-updates
Executable file
107
bin/v-list-sys-vesta-updates
Executable file
|
@ -0,0 +1,107 @@
|
|||
#!/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
|
||||
|
||||
# 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)
|
||||
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
|
||||
eval $(rpm --queryformat="$rpm_format" -q vesta-php)
|
||||
DATE=$(date -d @$UTIME +%F)
|
||||
TIME=$(date -d @$UTIME +%T)
|
||||
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
|
||||
eval $(rpm --queryformat="$rpm_format" -q vesta-nginx)
|
||||
DATE=$(date -d @$UTIME +%F)
|
||||
TIME=$(date -d @$UTIME +%T)
|
||||
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
|
|
@ -1,8 +1,8 @@
|
|||
#!/bin/bash
|
||||
# info: update vesta after rpm update
|
||||
# options: VERSION
|
||||
# info: update vesta package/configs
|
||||
# options: PACKAGE [VERSION]
|
||||
#
|
||||
# The function is runs as rpm update trigger. It pulls shell script from vesta
|
||||
# The function runs as rpm update trigger. It pulls shell script from vesta
|
||||
# server and runs it.
|
||||
|
||||
|
||||
|
@ -11,8 +11,9 @@
|
|||
#----------------------------------------------------------#
|
||||
|
||||
# Argument defenition
|
||||
version=$1
|
||||
updates=''
|
||||
package=$1
|
||||
version=$2
|
||||
release=$3
|
||||
|
||||
# Importing system enviroment
|
||||
source /etc/profile
|
||||
|
@ -27,79 +28,27 @@ source $VESTA/func/main.sh
|
|||
#----------------------------------------------------------#
|
||||
|
||||
# Checking arg number
|
||||
check_args '1' "$#" 'VERSION'
|
||||
check_args '1' "$#" 'PACKAGE [VERSION] [RELEASE]'
|
||||
|
||||
|
||||
#----------------------------------------------------------#
|
||||
# Action #
|
||||
#----------------------------------------------------------#
|
||||
|
||||
# Compare versions
|
||||
if [ "$version" != "$VERSION" ]; then
|
||||
# Downloading version tree
|
||||
upd_host="yum.vestacp.com"
|
||||
wget -O "/tmp/versions" http://$V_UPD_HOST/upd_scripts/version_tree.txt \
|
||||
&>/dev/null
|
||||
# Clean yum chache
|
||||
yum -q clean all
|
||||
|
||||
# Checking download result
|
||||
if [ "$?" -ne "0" ]; then
|
||||
echo "Error: version tree update failed"
|
||||
# Define yum cmd
|
||||
yum="yum -q -y --noplugins --disablerepo=* --enablerepo=vesta"
|
||||
|
||||
# Update vesta package
|
||||
if [ -z "$version" ]; then
|
||||
$yum update $package > /dev/null 2>&1
|
||||
if [ $? -ne 0 ]; then
|
||||
echo "Error: $package update failed"
|
||||
log_event "$E_UPDATE" "$EVENT"
|
||||
exit $E_UPDATE
|
||||
fi
|
||||
|
||||
# Deviding version
|
||||
v1=$(echo "$version" |cut -f 1 -d '.')
|
||||
v2=$(echo "$version" |cut -f 2 -d '.')
|
||||
v3=$(echo "$version" |cut -f 3 -d '.')
|
||||
V1=$(echo "$VERSION" |cut -f 1 -d '.')
|
||||
V2=$(echo "$VERSION" |cut -f 2 -d '.')
|
||||
V3=$(echo "$VERSION" |cut -f 3 -d '.')
|
||||
|
||||
|
||||
# Checking difference between versions
|
||||
# Too nested tests, sory about complexity
|
||||
if [ "$V1" -lt "$v1" ]; then
|
||||
for ver in $(seq $V1 $v1); do
|
||||
updates="$updates $(grep "^$ver." /tmp/versions|grep ":1$"|\
|
||||
cut -f 1 -d :)"
|
||||
done
|
||||
else
|
||||
if [ "$V2" -lt "$v2" ]; then
|
||||
for ver in $(seq $V2 $v2); do
|
||||
updates="$updates $(grep "^$v1.$ver." /tmp/versions |\
|
||||
grep ":1$"|cut -f 1 -d :)"
|
||||
done
|
||||
else
|
||||
V4=$((V3 + 1))
|
||||
for ver in $(seq $V4 $v3); do
|
||||
updates="$updates $(grep "^$v1.$v2.$ver" /tmp/versions |\
|
||||
grep ":1$"|cut -f 1 -d :)"
|
||||
done
|
||||
fi
|
||||
fi
|
||||
|
||||
# Executing update scripts
|
||||
if [ ! -z "$updates" ]; then
|
||||
mkdir $BIN/updates &>/dev/null
|
||||
|
||||
for update in $updates; do
|
||||
wget -O $BIN/updates/$update.sh \
|
||||
http://$V_UPD_HOST/upd_scripts/$update.sh &>/dev/null
|
||||
|
||||
# Checking download result
|
||||
if [ "$?" -ne "0" ]; then
|
||||
echo "Error: version tree update failed"
|
||||
log_event "$E_UPDATE" "$EVENT"
|
||||
exit $E_UPDATE
|
||||
fi
|
||||
bash $BIN/updates/$update.sh
|
||||
done
|
||||
rm -rf $BIN/updates
|
||||
fi
|
||||
|
||||
# Updating config version
|
||||
sed -i "s/VERSION='$VERSION'/VERSION='$version'/g" $VESTA/conf/vesta.conf
|
||||
fi
|
||||
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue