generated from pavel.muhortov/template-bash
add printing number of Zimbra stopped services
This commit is contained in:
parent
a140e5f6ad
commit
a3541096ee
|
@ -25,6 +25,7 @@ ____
|
||||||
|-----------|--------------|------------------------|---------------|
|
|-----------|--------------|------------------------|---------------|
|
||||||
| 1 |**[qn]**|execution without pauses||
|
| 1 |**[qn]**|execution without pauses||
|
||||||
| 2 |**que**|print length of all zimbra queues|`None`|
|
| 2 |**que**|print length of all zimbra queues|`None`|
|
||||||
|
| 2 |**svc**|print number of stopped services|`None`|
|
||||||
| 2 |**ssl**|letsencrypt certificate update procedure|`None`|
|
| 2 |**ssl**|letsencrypt certificate update procedure|`None`|
|
||||||
| 3 |**[/path/to/conf]**|custom configuration file path|`./zimbra-man.conf`|
|
| 3 |**[/path/to/conf]**|custom configuration file path|`./zimbra-man.conf`|
|
||||||
|
|
||||||
|
|
|
@ -17,6 +17,7 @@
|
||||||
# PARAMETERS:
|
# PARAMETERS:
|
||||||
# 1: "qn" - execution without pauses
|
# 1: "qn" - execution without pauses
|
||||||
# 2: "que" - print length of all zimbra queues
|
# 2: "que" - print length of all zimbra queues
|
||||||
|
# 2: "svc" - print number of stopped services
|
||||||
# 2: "ssl" - letsencrypt certificate update procedure
|
# 2: "ssl" - letsencrypt certificate update procedure
|
||||||
# 3: custom configuration file path
|
# 3: custom configuration file path
|
||||||
#
|
#
|
||||||
|
@ -123,6 +124,28 @@ calcqueue(){
|
||||||
return "${object}"
|
return "${object}"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#######################################
|
||||||
|
# Counting zimbra stopped services.
|
||||||
|
# Globals:
|
||||||
|
# None
|
||||||
|
# Arguments:
|
||||||
|
# None
|
||||||
|
# return:
|
||||||
|
# number of stopped services
|
||||||
|
#######################################
|
||||||
|
isrunning(){
|
||||||
|
counter=0
|
||||||
|
while read -r service; do
|
||||||
|
if ! grep -q "$(cat /etc/hostname)" <<< "${service}"; then
|
||||||
|
if grep -q "Stopped" <<< "${service}"; then
|
||||||
|
(( counter++ ))
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
done <<< "$(su - zimbra -c '/opt/zimbra/bin/zmcontrol status')"
|
||||||
|
printf "%s\n" "${counter}"
|
||||||
|
return "${counter}"
|
||||||
|
}
|
||||||
|
|
||||||
#######################################
|
#######################################
|
||||||
# Print certificate expiration date in epoch
|
# Print certificate expiration date in epoch
|
||||||
# Globals:
|
# Globals:
|
||||||
|
@ -236,9 +259,7 @@ fi
|
||||||
#
|
#
|
||||||
|
|
||||||
if checkroot; then
|
if checkroot; then
|
||||||
if [ "${does}" = "que" ]; then
|
if [ "${does}" = "ssl" ]; then
|
||||||
calcqueue && exit 0
|
|
||||||
elif [ "${does}" = "ssl" ]; then
|
|
||||||
expired=$(certcheck "/etc/letsencrypt/live/${certfirst}/cert.pem")
|
expired=$(certcheck "/etc/letsencrypt/live/${certfirst}/cert.pem")
|
||||||
targets=$(( expired - 2592000 ))
|
targets=$(( expired - 2592000 ))
|
||||||
if [[ "${time}" -le "${targets}" ]]; then
|
if [[ "${time}" -le "${targets}" ]]; then
|
||||||
|
@ -248,6 +269,16 @@ if checkroot; then
|
||||||
certrenew && addtologs "${certfirst} certificates renewed"
|
certrenew && addtologs "${certfirst} certificates renewed"
|
||||||
startsendmail
|
startsendmail
|
||||||
fi
|
fi
|
||||||
|
elif [ "${does}" = "que" ]; then
|
||||||
|
result=$(calcqueue)
|
||||||
|
addtologs "Zimbra queue has ${result} objects" > /dev/null
|
||||||
|
printf "%s\n" "${result}"
|
||||||
|
execquite > /dev/null
|
||||||
|
elif [ "${does}" = "svc" ]; then
|
||||||
|
result=$(isrunning)
|
||||||
|
addtologs "Zimbra has ${result} stopped services" > /dev/null
|
||||||
|
printf "%s\n" "${result}"
|
||||||
|
execquite > /dev/null
|
||||||
else
|
else
|
||||||
printf "%s\n" "Usage example: $0 qn ssl"
|
printf "%s\n" "Usage example: $0 qn ssl"
|
||||||
printf "%s\n" "Usage example: $0 - que"
|
printf "%s\n" "Usage example: $0 - que"
|
||||||
|
|
Loading…
Reference in New Issue
Block a user