v_suspend_sys_user 1.9 KB

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