#!/bin/bash
# info: restart service
# options: service
#
# The function restarts system service.


#----------------------------------------------------------#
#                    Variable&Function                     #
#----------------------------------------------------------#

# Argument definition
service=$1

# Includes
source $VESTA/func/main.sh
PATH="$PATH:/usr/local/sbin:/sbin:/usr/sbin:/root/bin"


#----------------------------------------------------------#
#                    Verifications                         #
#----------------------------------------------------------#

check_args '1' "$#" 'SERVICE'


#----------------------------------------------------------#
#                       Action                             #
#----------------------------------------------------------#

if [ "$service" != "iptables" ]; then
    service $service restart >/dev/null 2>&1
    if [ $? -ne 0 ]; then
        check_result $E_RESTART "$service restart failed"
    fi
else
    $BIN/v-stop-firewall
    $BIN/v-update-firewall
    if [ $? -ne 0 ]; then
        check_result $E_RESTART "$service restart failed"
    fi
fi


#----------------------------------------------------------#
#                       Vesta                              #
#----------------------------------------------------------#

exit