You can not select more than 25 topics
			Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
		
		
		
		
		
			
		
			
				
					
					
						
							57 lines
						
					
					
						
							1.6 KiB
						
					
					
				
			
		
		
	
	
							57 lines
						
					
					
						
							1.6 KiB
						
					
					
				#!/bin/bash
 | 
						|
# info: Suspending sys cron jobs
 | 
						|
# options: USER [RESTART]
 | 
						|
#
 | 
						|
# example: v-suspend-cron-jobs admin
 | 
						|
#
 | 
						|
# This function suspends all user cron jobs.
 | 
						|
 | 
						|
#----------------------------------------------------------#
 | 
						|
#                Variables & Functions                     #
 | 
						|
#----------------------------------------------------------#
 | 
						|
 | 
						|
# Argument definition
 | 
						|
user=$1
 | 
						|
restart=$2
 | 
						|
 | 
						|
# 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' "$#" 'USER'
 | 
						|
is_format_valid 'user'
 | 
						|
is_object_valid 'user' 'USER' "$user"
 | 
						|
 | 
						|
# Perform verification if read-only mode is enabled
 | 
						|
check_hestia_demo_mode
 | 
						|
 | 
						|
#----------------------------------------------------------#
 | 
						|
#                       Action                             #
 | 
						|
#----------------------------------------------------------#
 | 
						|
 | 
						|
# Suspendn all jobs
 | 
						|
for job in $(search_objects 'cron' 'SUSPENDED' 'no' 'JOB'); do
 | 
						|
	$BIN/v-suspend-cron-job "$user" "$job" 'no'
 | 
						|
done
 | 
						|
 | 
						|
#----------------------------------------------------------#
 | 
						|
#                       Hestia                             #
 | 
						|
#----------------------------------------------------------#
 | 
						|
 | 
						|
# Restarting crond
 | 
						|
$BIN/v-restart-cron "$restart"
 | 
						|
check_result $? "Cron restart failed" > /dev/null
 | 
						|
 | 
						|
# Logging
 | 
						|
log_event "$OK" "$ARGUMENTS"
 | 
						|
 | 
						|
exit
 |