mirror of
https://github.com/myvesta/vesta.git
synced 2024-11-03 04:00:20 -08:00
f5cc2bb7f2
Credits to: Numan Türle @numanturle
81 lines
2.2 KiB
Bash
Executable File
81 lines
2.2 KiB
Bash
Executable File
#!/bin/bash
|
|
# info: update vesta package/configs
|
|
# options: PACKAGE [VERSION]
|
|
#
|
|
# The function runs as rpm update trigger. It pulls shell script from vesta
|
|
# server and runs it.
|
|
|
|
|
|
#----------------------------------------------------------#
|
|
# Variable&Function #
|
|
#----------------------------------------------------------#
|
|
|
|
# Argument definition
|
|
package=$1
|
|
|
|
# Importing system environment
|
|
source /etc/profile
|
|
|
|
# Includes
|
|
source $VESTA/func/main.sh
|
|
source $VESTA/conf/vesta.conf
|
|
|
|
|
|
#----------------------------------------------------------#
|
|
# Verifications #
|
|
#----------------------------------------------------------#
|
|
|
|
# Checking arg number
|
|
check_args '1' "$#" 'PACKAGE'
|
|
|
|
valid=0
|
|
if [ "$package" = "vesta" ]; then
|
|
valid=1
|
|
fi
|
|
if [ "$package" = "vesta-nginx" ]; then
|
|
valid=1
|
|
fi
|
|
if [ "$package" = "vesta-php" ]; then
|
|
valid=1
|
|
fi
|
|
if [ "$package" = "vesta-softaculous" ]; then
|
|
valid=1
|
|
fi
|
|
if [ $valid -eq 0 ]; then
|
|
echo "Package $package is not valid"
|
|
exit 1
|
|
fi
|
|
|
|
#----------------------------------------------------------#
|
|
# Action #
|
|
#----------------------------------------------------------#
|
|
|
|
if [ -n "$(command -v yum)" ]; then
|
|
# Clean yum chache
|
|
yum -q clean all
|
|
|
|
# Define yum cmd
|
|
yum="yum -q -y --noplugins --disablerepo=* --enablerepo=vesta"
|
|
|
|
# Update vesta package
|
|
$yum update $package > /dev/null 2>&1
|
|
check_result $? "$package update failed" $E_UPDATE
|
|
else
|
|
# Update repo
|
|
apt-get update -o Dir::Etc::sourcelist="sources.list.d/vesta.list" -o Dir::Etc::sourceparts="-" -o APT::Get::List-Cleanup="0" > /usr/local/vesta/log/update-$package.log 2>&1
|
|
|
|
# Update vesta package
|
|
apt-get -y -qq -o Dpkg::Options::="--force-confdef" -o Dpkg::Options::="--force-confold" -o Dpkg::Options::="--force-confmiss" install $package >> /usr/local/vesta/log/update-$package.log 2>&1
|
|
check_result $? "$package update failed" $E_UPDATE
|
|
fi
|
|
|
|
|
|
#----------------------------------------------------------#
|
|
# Vesta #
|
|
#----------------------------------------------------------#
|
|
|
|
# Logging
|
|
log_event "$OK" "$ARGUMENTS"
|
|
|
|
exit
|