From 4cc3c1d287058be0bd06fdd7038854fffb63b1e1 Mon Sep 17 00:00:00 2001 From: Serghey Rodin Date: Wed, 14 Feb 2018 17:10:14 +0200 Subject: [PATCH] Amazon linux support --- bin/v-add-sys-ip | 4 ++-- bin/v-add-sys-quota | 2 +- bin/v-add-vesta-softaculous | 8 ++++---- bin/v-change-sys-hostname | 10 ++++------ bin/v-list-sys-info | 11 ++++++----- bin/v-list-sys-services | 6 +++--- bin/v-list-sys-vesta-updates | 10 +++++----- bin/v-stop-firewall | 2 +- bin/v-update-firewall | 2 +- bin/v-update-sys-vesta | 2 +- bin/v-update-web-domain-stat | 2 +- bin/v-update-web-templates | 6 +++++- 12 files changed, 34 insertions(+), 31 deletions(-) diff --git a/bin/v-add-sys-ip b/bin/v-add-sys-ip index f278763b..54245bcc 100755 --- a/bin/v-add-sys-ip +++ b/bin/v-add-sys-ip @@ -60,8 +60,8 @@ if [ -z "$sys_ip_check" ]; then /sbin/ip addr add $ip/$cidr dev $interface \ broadcast $broadcast label $iface - # Adding RHEL/CentOS/Fedora startup script - if [ -e "/etc/redhat-release" ]; then + # Adding RHEL/CentOS/Fedora/Amazon startup script + if [ -d "/etc/sysconfig" ]; then sys_ip="# Added by vesta" sys_ip="$sys_ip\nDEVICE=$iface" sys_ip="$sys_ip\nBOOTPROTO=static" diff --git a/bin/v-add-sys-quota b/bin/v-add-sys-quota index 35423a5d..93687e9c 100755 --- a/bin/v-add-sys-quota +++ b/bin/v-add-sys-quota @@ -21,7 +21,7 @@ source $VESTA/conf/vesta.conf # Checking quota package quota=$(which --skip-alias --skip-functions quota 2>/dev/null) if [ $? -ne 0 ]; then - if [ -e "/etc/redhat-release" ]; then + if [ -d "/etc/sysconfig" ]; then yum -y install quota >/dev/null 2>&1 check_result $? "quota package installation failed" $E_UPDATE else diff --git a/bin/v-add-vesta-softaculous b/bin/v-add-vesta-softaculous index 2eb31635..b0cca53a 100755 --- a/bin/v-add-vesta-softaculous +++ b/bin/v-add-vesta-softaculous @@ -46,7 +46,7 @@ fi #----------------------------------------------------------# # Cleaning yum cache -if [ -e "/etc/redhat-release" ]; then +if [ -d "/etc/sysconfig" ]; then yum -q clean all yum="yum -q -y --noplugins --disablerepo=* --enablerepo=vesta" else @@ -57,7 +57,7 @@ fi # Updating php pacakge if [ -z "$($VESTA/php/bin/php -v|grep 'PHP 5.6')" ]; then - if [ -e "/etc/redhat-release" ]; then + if [ -d "/etc/sysconfig" ]; then $yum -y update vesta-php check_result $? "vesta-php package upgrade failed" $E_UPDATE else @@ -67,7 +67,7 @@ if [ -z "$($VESTA/php/bin/php -v|grep 'PHP 5.6')" ]; then fi # Adding vesta-ioncube package -if [ -e "/etc/redhat-release" ]; then +if [ -d "/etc/sysconfig" ]; then rpm -q vesta-ioncube >/dev/null 2>&1 if [ $? -ne 0 ]; then $yum -y install vesta-ioncube >/dev/null 2>&1 @@ -82,7 +82,7 @@ else fi # Adding vesta-softaculous package -if [ -e "/etc/redhat-release" ]; then +if [ -d "/etc/sysconfig" ]; then rpm -q vesta-softaculous >/dev/null 2>&1 if [ $? -ne 0 ]; then $yum -y install vesta-softaculous >/dev/null 2>&1 diff --git a/bin/v-change-sys-hostname b/bin/v-change-sys-hostname index bf1e8bae..c5a6adb1 100755 --- a/bin/v-change-sys-hostname +++ b/bin/v-change-sys-hostname @@ -31,18 +31,16 @@ is_format_valid 'domain' hostname $domain -# RHEL/CentOS -if [ -e "/etc/redhat-release" ]; then +if [ -d "/etc/sysconfig" ]; then + # RHEL/CentOS/Amazon touch /etc/sysconfig/network if [ -z "$(grep HOSTNAME /etc/sysconfig/network)" ]; then echo "HOSTNAME='$domain'" >> /etc/sysconfig/network else sed -i "s/HOSTNAME=.*/HOSTNAME='$domain'/" /etc/sysconfig/network fi -fi - -# Debian/Ubuntu -if [ ! -e "/etc/redhat-release" ]; then +else + # Debian/Ubuntu echo "$domain" > /etc/hostname fi diff --git a/bin/v-list-sys-info b/bin/v-list-sys-info index dabd3160..0072b82b 100755 --- a/bin/v-list-sys-info +++ b/bin/v-list-sys-info @@ -56,17 +56,18 @@ csv_list() { HOSTNAME=$(hostname) # Check OS/Release -if [ -e '/etc/redhat-release' ]; then - if [ ! -z "$(grep CentOS /etc/redhat-release)" ]; then +if [ -d '/etc/sysconfig' ]; then + if [ -e '/etc/redhat-release' ]; then OS='CentOS' + VERSION=$(cat /etc/redhat-release |tr ' ' '\n' |grep [0-9]) else - OS="RHEL" + OS="Amazon" + VERSION=$(cat /etc/issue |tr ' ' '\n' |grep [0-9]) fi - VERSION=$(cat /etc/redhat-release| tr ' ' '\n' |grep [0-9]) else if [ "$(lsb_release -si)" == "Ubuntu" ] && [ -e '/etc/debian_version' ]; then OS="Ubuntu" - VERSION=$(grep DISTRIB_RELEASE /etc/lsb-release| cut -f 2 -d '=') + VERSION=$(grep DISTRIB_RELEASE /etc/lsb-release |cut -f 2 -d '=') else distro=$(head -n1 /etc/issue |cut -f 1 -d ' ') if [ "$distro" = 'Debian' ]; then diff --git a/bin/v-list-sys-services b/bin/v-list-sys-services index f2622795..3718c171 100755 --- a/bin/v-list-sys-services +++ b/bin/v-list-sys-services @@ -191,7 +191,7 @@ fi # Checking MAIL ANTIVIRUS if [ ! -z "$ANTIVIRUS_SYSTEM" ] && [ "$ANTIVIRUS_SYSTEM" != 'remote' ]; then - if [ -e "/etc/redhat-release" ]; then + if [ -d "/etc/sysconfig" ]; then if [ "$ANTIVIRUS_SYSTEM" == 'clamav' ];then ANTIVIRUS_SYSTEM='clamd' fi @@ -220,7 +220,7 @@ if [ ! -z "$DB_SYSTEM" ] && [ "$DB_SYSTEM" != 'remote' ]; then proc_name='' service="$db" if [ "$service" = 'mysql' ]; then - if [ -e "/etc/redhat-release" ]; then + if [ -d "/etc/sysconfig" ]; then service='mysqld' proc_name='mysqld' if [ -e "/usr/lib/systemd/system/mariadb.service" ]; then @@ -231,7 +231,7 @@ if [ ! -z "$DB_SYSTEM" ] && [ "$DB_SYSTEM" != 'remote' ]; then if [ "$service" == 'pgsql' ]; then service='postgresql' proc_name='postmaster' - if [ ! -e "/etc/redhat-release" ]; then + if [ ! -d "/etc/sysconfig" ]; then proc_name='postgres' fi if [ ! -e '/etc/init.d/postgresql' ]; then diff --git a/bin/v-list-sys-vesta-updates b/bin/v-list-sys-vesta-updates index dcd40990..adcd6a1a 100755 --- a/bin/v-list-sys-vesta-updates +++ b/bin/v-list-sys-vesta-updates @@ -64,7 +64,7 @@ shell_list() { latest=$(wget -q -T 1 -t 1 http://c.vestacp.com/latest.txt -O -) # Checking installed vesta version -if [ -e "/etc/redhat-release" ]; then +if [ -d "/etc/sysconfig" ]; then rpm_format="VERSION='%{VERSION}'" rpm_format="$rpm_format RELEASE='%{RELEASE}'" rpm_format="$rpm_format ARCH='%{ARCH}'" @@ -89,7 +89,7 @@ data="NAME='vesta' VERSION='$VERSION' RELEASE='$RELEASE' ARCH='$ARCH'" data="$data UPDATED='$UPDATED' DESCR='core package' TIME='$TIME' DATE='$DATE'" # Checking installed vesta-php version -if [ -e "/etc/redhat-release" ]; then +if [ -d "/etc/sysconfig" ]; then eval $(rpm --queryformat="$rpm_format" -q vesta-php) DATE=$(date -d @$UTIME +%F) TIME=$(date -d @$UTIME +%T) @@ -107,7 +107,7 @@ data="$data ARCH='$ARCH' UPDATED='$UPDATED' DESCR='php interpreter'" data="$data TIME='$TIME' DATE='$DATE'" # Checking installed vesta-nginx version -if [ -e "/etc/redhat-release" ]; then +if [ -d "/etc/sysconfig" ]; then eval $(rpm --queryformat="$rpm_format" -q vesta-nginx) DATE=$(date -d @$UTIME +%F) TIME=$(date -d @$UTIME +%T) @@ -126,7 +126,7 @@ data="$data TIME='$TIME' DATE='$DATE'" # Checking installed vesta-ioncube version if [ "$SOFTACULOUS" = 'yes' ]; then - if [ -e "/etc/redhat-release" ]; then + if [ -d "/etc/sysconfig" ]; then eval $(rpm --queryformat="$rpm_format" -q vesta-ioncube) DATE=$(date -d @$UTIME +%F) TIME=$(date -d @$UTIME +%T) @@ -146,7 +146,7 @@ fi # Checking installed vesta-softaculous version if [ "$SOFTACULOUS" = 'yes' ]; then - if [ -e "/etc/redhat-release" ]; then + if [ -d "/etc/sysconfig" ]; then eval $(rpm --queryformat="$rpm_format" -q vesta-softaculous) DATE=$(date -d @$UTIME +%F) TIME=$(date -d @$UTIME +%T) diff --git a/bin/v-stop-firewall b/bin/v-stop-firewall index 4087190d..2cd653a6 100755 --- a/bin/v-stop-firewall +++ b/bin/v-stop-firewall @@ -56,7 +56,7 @@ bash $tmp 2>/dev/null rm -f $tmp # Saving rules to the master iptables file -if [ -e "/etc/redhat-release" ]; then +if [ -d "/etc/sysconfig" ]; then /sbin/iptables-save > /etc/sysconfig/iptables if [ -z "$(ls /etc/rc3.d/S*iptables 2>/dev/null)" ]; then /sbin/chkconfig iptables off diff --git a/bin/v-update-firewall b/bin/v-update-firewall index ccea7f3f..da91acc8 100755 --- a/bin/v-update-firewall +++ b/bin/v-update-firewall @@ -157,7 +157,7 @@ if [ ! -z "$FIREWALL_EXTENSION" ]; then fi # Saving rules to the master iptables file -if [ -e "/etc/redhat-release" ]; then +if [ -d "/etc/sysconfig" ]; then /sbin/iptables-save > /etc/sysconfig/iptables if [ -z "$(ls /etc/rc3.d/S*iptables 2>/dev/null)" ]; then /sbin/chkconfig iptables on diff --git a/bin/v-update-sys-vesta b/bin/v-update-sys-vesta index a42e4d71..39cd33a2 100755 --- a/bin/v-update-sys-vesta +++ b/bin/v-update-sys-vesta @@ -33,7 +33,7 @@ check_args '1' "$#" 'PACKAGE' # Action # #----------------------------------------------------------# -if [ -e "/etc/redhat-release" ]; then +if [ -d "/etc/sysconfig" ]; then # Clean yum chache yum -q clean all diff --git a/bin/v-update-web-domain-stat b/bin/v-update-web-domain-stat index c77b750b..c2c793e3 100755 --- a/bin/v-update-web-domain-stat +++ b/bin/v-update-web-domain-stat @@ -62,7 +62,7 @@ build_webalizer() { } build_awstats() { - if [ -e "/etc/redhat-release" ]; then + if [ -d "/etc/sysconfig" ]; then awstats="/usr/share/awstats/wwwroot/cgi-bin/awstats.pl" wwwroot="/usr/share/awstats/wwwroot" if [ ! -e "$awstats" ]; then diff --git a/bin/v-update-web-templates b/bin/v-update-web-templates index 3196c8b4..df882dd7 100755 --- a/bin/v-update-web-templates +++ b/bin/v-update-web-templates @@ -33,7 +33,11 @@ esac # Detecting release if [ "$version" = 'rhel' ]; then - release=$(grep -o "[0-9]" /etc/redhat-release |head -n1) + if [ -e '/etc/redhat-release' ]; then + release=$(grep -o "[0-9]" /etc/redhat-release |head -n1) + else + release=6 + fi fi if [ "$version" = 'ubuntu' ]; then release=$(lsb_release -r |awk '{print $2}')