v_suspend_user 2.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889
  1. #!/bin/bash
  2. # info: suspend user
  3. # options: user
  4. #
  5. # The function suspends a certain user and all his objects.
  6. #----------------------------------------------------------#
  7. # Variable&Function #
  8. #----------------------------------------------------------#
  9. # Argument defenition
  10. user=$1
  11. # Importing variables
  12. source $VESTA/conf/vars.conf
  13. source $V_CONF/vesta.conf
  14. source $V_FUNC/shared.func
  15. #----------------------------------------------------------#
  16. # Verifications #
  17. #----------------------------------------------------------#
  18. # Checking arg number
  19. check_args '1' "$#" 'user'
  20. # Checking argument format
  21. format_validation 'user'
  22. # Checking user
  23. is_user_valid
  24. # Checking user status
  25. is_user_suspended
  26. # Checking user vesta
  27. if [ "$user" = 'vesta' ]; then
  28. exit
  29. fi
  30. #----------------------------------------------------------#
  31. # Action #
  32. #----------------------------------------------------------#
  33. # Adding '!' in front of the password
  34. /usr/sbin/usermod --lock $user
  35. # Suspending web domains
  36. if [ ! -z "$WEB_SYSTEM" ] && [ "$WEB_SYSTEM" != 'no' ]; then
  37. $V_BIN/v_suspend_web_domains $user
  38. fi
  39. # Suspending dns domains
  40. if [ ! -z "$DNS_SYSTEM" ] && [ "$DNS_SYSTEM" != 'no' ]; then
  41. $V_BIN/v_suspend_dns_domains $user
  42. fi
  43. # Suspending mail domains
  44. # TBD
  45. # Suspending datbabases
  46. if [ ! -z "$DB_SYSTEM" ] && [ "$DB_SYSTEM" != 'no' ]; then
  47. $V_BIN/v_suspend_db_bases $user
  48. fi
  49. # Suspending cron jobs
  50. if [ ! -z "$CRON_SYSTEM" ] && [ "$CRON_SYSTEM" != 'no' ]; then
  51. $V_BIN/v_suspend_cron_jobs $user
  52. fi
  53. #----------------------------------------------------------#
  54. # Vesta #
  55. #----------------------------------------------------------#
  56. # Adding task to the vesta pipe
  57. restart_schedule 'cron'
  58. restart_schedule 'web'
  59. restart_schedule 'dns'
  60. # Changing suspend value
  61. update_user_value "$user" '$SUSPENDED' 'yes'
  62. # Logging
  63. log_event 'system' "$V_EVENT"
  64. exit