v_change_sys_user_shell 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  1. #!/bin/bash
  2. # info: changing user shell
  3. #----------------------------------------------------------#
  4. # Variable&Function #
  5. #----------------------------------------------------------#
  6. # Argument defenition
  7. user=$1
  8. shell=$2
  9. # Importing variables
  10. source $VESTA/conf/vars.conf
  11. source $V_CONF/vesta.conf
  12. source $V_FUNC/shared.func
  13. #----------------------------------------------------------#
  14. # Verifications #
  15. #----------------------------------------------------------#
  16. # Checking arg number
  17. check_args '2' "$#" 'user shell'
  18. # Checking argument format
  19. format_validation 'user' 'shell'
  20. # Checking user
  21. is_user_valid
  22. # Checking user is active
  23. is_user_suspended
  24. #----------------------------------------------------------#
  25. # Action #
  26. #----------------------------------------------------------#
  27. # Changing user shell
  28. update_user_value "$user" '$SHELL' "$shell"
  29. # Get shell full path
  30. shell_path=$(/usr/bin/chsh --list-shells | grep -w "$shell" )
  31. # Changing passwd file
  32. /usr/bin/chsh -s "$shell_path" "$user" >/dev/null 2>&1
  33. #----------------------------------------------------------#
  34. # Vesta #
  35. #----------------------------------------------------------#
  36. # Logging
  37. log_event 'system' "$V_EVENT"
  38. exit