Skip to content

Commit 8633879

Browse files
committed
Added suspend/unsuspend user function
1 parent 496c3f5 commit 8633879

File tree

2 files changed

+167
-0
lines changed

2 files changed

+167
-0
lines changed

bin/v_suspend_sys_user

Lines changed: 85 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,85 @@
1+
#!/bin/bash
2+
# info: Suspending sys user
3+
4+
#----------------------------------------------------------#
5+
# Variable&Function #
6+
#----------------------------------------------------------#
7+
8+
# Argument defenition
9+
user=$1
10+
11+
# Importing variables
12+
source $VESTA/conf/vars.conf
13+
source $V_CONF/vesta.conf
14+
source $V_FUNC/shared.func
15+
16+
17+
#----------------------------------------------------------#
18+
# Verifications #
19+
#----------------------------------------------------------#
20+
21+
# Checking arg number
22+
check_args '1' "$#" 'user'
23+
24+
# Checking argument format
25+
format_validation 'user'
26+
27+
# Checking user
28+
is_user_valid
29+
30+
# Checking user status
31+
is_user_suspended
32+
33+
# Checking user vesta
34+
if [ "$user" = 'vesta' ]; then
35+
exit
36+
fi
37+
38+
39+
#----------------------------------------------------------#
40+
# Action #
41+
#----------------------------------------------------------#
42+
43+
# Adding '!' in front of the password
44+
/usr/sbin/usermod --lock $user
45+
46+
# Suspending web domains
47+
if [ ! -z "$WEB_SYSTEM" ] && [ "$WEB_SYSTEM" != 'no' ]; then
48+
$V_BIN/v_suspend_web_domains $user
49+
fi
50+
51+
# Suspending dns domains
52+
if [ ! -z "$DNS_SYSTEM" ] && [ "$DNS_SYSTEM" != 'no' ]; then
53+
$V_BIN/v_suspend_dns_domains $user
54+
fi
55+
56+
# Suspending mail domains
57+
# TBD
58+
59+
# Suspending datbabases
60+
if [ ! -z "$DB_SYSTEM" ] && [ "$DB_SYSTEM" != 'no' ]; then
61+
$V_BIN/v_suspend_db_bases $user
62+
fi
63+
64+
# Suspending cron jobs
65+
if [ ! -z "$CRON_SYSTEM" ] && [ "$CRON_SYSTEM" != 'no' ]; then
66+
$V_BIN/v_suspend_sys_cron_jobs $user
67+
fi
68+
69+
70+
#----------------------------------------------------------#
71+
# Vesta #
72+
#----------------------------------------------------------#
73+
74+
# Adding task to the vesta pipe
75+
restart_schedule 'cron'
76+
restart_schedule 'web'
77+
restart_schedule 'dns'
78+
79+
# Changing suspend value
80+
update_user_value "$user" '$SUSPEND' 'yes'
81+
82+
# Logging
83+
log_event 'system' "$V_EVENT"
84+
85+
exit

bin/v_unsuspend_sys_user

Lines changed: 82 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,82 @@
1+
#!/bin/bash
2+
# info: Unsuspending sys user
3+
4+
#----------------------------------------------------------#
5+
# Variable&Function #
6+
#----------------------------------------------------------#
7+
8+
# Argument defenition
9+
user=$1
10+
11+
# Importing variables
12+
source $VESTA/conf/vars.conf
13+
source $V_CONF/vesta.conf
14+
source $V_FUNC/shared.func
15+
16+
17+
#----------------------------------------------------------#
18+
# Verifications #
19+
#----------------------------------------------------------#
20+
21+
# Checking arg number
22+
check_args '1' "$#" 'user'
23+
24+
# Checking argument format
25+
format_validation 'user'
26+
27+
# Checking user
28+
is_user_valid
29+
30+
# Checking user vesta
31+
if [ "$user" = 'vesta' ]; then
32+
exit
33+
fi
34+
35+
36+
#----------------------------------------------------------#
37+
# Action #
38+
#----------------------------------------------------------#
39+
40+
# Deleting '!' in front of the password
41+
/usr/sbin/usermod --unlock $user
42+
43+
# Unsuspending web domains
44+
if [ ! -z "$WEB_SYSTEM" ] && [ "$WEB_SYSTEM" != 'no' ]; then
45+
$V_BIN/v_unsuspend_web_domains $user
46+
fi
47+
48+
# Unsuspending dns domains
49+
if [ ! -z "$DNS_SYSTEM" ] && [ "$DNS_SYSTEM" != 'no' ]; then
50+
$V_BIN/v_unsuspend_dns_domains $user
51+
fi
52+
53+
# Unsuspending mail domains
54+
# TBD
55+
56+
# Unsuspending datbabases
57+
if [ ! -z "$DB_SYSTEM" ] && [ "$DB_SYSTEM" != 'no' ]; then
58+
$V_BIN/v_unsuspend_db_bases $user
59+
fi
60+
61+
# Unsuspending cron jobs
62+
if [ ! -z "$CRON_SYSTEM" ] && [ "$CRON_SYSTEM" != 'no' ]; then
63+
$V_BIN/v_unsuspend_sys_cron_jobs $user
64+
fi
65+
66+
67+
#----------------------------------------------------------#
68+
# Vesta #
69+
#----------------------------------------------------------#
70+
71+
# Adding task to the vesta pipe
72+
restart_schedule 'cron'
73+
restart_schedule 'web'
74+
restart_schedule 'dns'
75+
76+
# Changing suspend value
77+
update_user_value "$user" '$SUSPEND' 'no'
78+
79+
# Logging
80+
log_event 'system' "$V_EVENT"
81+
82+
exit

0 commit comments

Comments
 (0)