Initial
This commit is contained in:
65
bin/v-start-service
Executable file
65
bin/v-start-service
Executable file
@@ -0,0 +1,65 @@
|
||||
#!/bin/bash
|
||||
# info: start service
|
||||
# options: SERVICE
|
||||
#
|
||||
# example: v-start-service mysql
|
||||
#
|
||||
# This function starts system service.
|
||||
|
||||
#----------------------------------------------------------#
|
||||
# Variables & Functions #
|
||||
#----------------------------------------------------------#
|
||||
|
||||
# Argument definition
|
||||
service=$1
|
||||
|
||||
# Includes
|
||||
# shellcheck source=/etc/hestiacp/hestia.conf
|
||||
source /etc/hestiacp/hestia.conf
|
||||
# shellcheck source=/usr/local/hestia/func/main.sh
|
||||
source $HESTIA/func/main.sh
|
||||
# load config file
|
||||
source_conf "$HESTIA/conf/hestia.conf"
|
||||
|
||||
#----------------------------------------------------------#
|
||||
# Verifications #
|
||||
#----------------------------------------------------------#
|
||||
|
||||
check_args '1' "$#" 'SERVICE'
|
||||
is_format_valid 'service'
|
||||
|
||||
#----------------------------------------------------------#
|
||||
# Action #
|
||||
#----------------------------------------------------------#
|
||||
|
||||
if [ "$service" = "php-fpm" ]; then
|
||||
for php_ver in $(multiphp_versions); do
|
||||
service_list="${service_list} php${php_ver}-fpm"
|
||||
done
|
||||
else
|
||||
service_list="$service"
|
||||
fi
|
||||
|
||||
for service in $service_list; do
|
||||
if [ "$service" = "iptables" ]; then
|
||||
$BIN/v-update-firewall
|
||||
else
|
||||
systemctl start "$service"
|
||||
result=$?
|
||||
if [ "$result" -ne 0 ]; then
|
||||
$BIN/v-log-action "system" "Error" "System" "Service failed to start (Name: $service)."
|
||||
else
|
||||
$BIN/v-log-action "system" "Info" "System" "Service started (Name: $service)."
|
||||
fi
|
||||
fi
|
||||
check_result $? "ERROR: $service start failed" "$E_RESTART"
|
||||
done
|
||||
|
||||
#----------------------------------------------------------#
|
||||
# Hestia #
|
||||
#----------------------------------------------------------#
|
||||
|
||||
# Logging
|
||||
log_event "$OK" "$ARGUMENTS"
|
||||
|
||||
exit
|
||||
Reference in New Issue
Block a user