vesta/bin/v_change_sys_user_shell
2011-06-14 00:22:25 +03:00

56 lines
1.3 KiB
Bash
Executable File

#!/bin/bash
# info: changing user shell
#----------------------------------------------------------#
# Variable&Function #
#----------------------------------------------------------#
# Argument defenition
user="$1"
shell="$2"
# Importing variables
source $VESTA/conf/vars.conf
source $V_FUNC/shared_func.sh
#----------------------------------------------------------#
# Verifications #
#----------------------------------------------------------#
# Checking arg number
check_args '2' "$#" 'user shell'
# Checking argument format
format_validation 'user' 'shell'
# Checking user
is_user_valid
# Checking user is active
is_user_suspended
#----------------------------------------------------------#
# Action #
#----------------------------------------------------------#
# Changing user shell
update_user_value "$user" '$SHELL' "$shell"
# Get shell full path
shell_path=$(get_shell_path)
# Changing passwd file
/usr/bin/chsh -s "$shell_path" "$user" >/dev/null 2>&1
#----------------------------------------------------------#
# Vesta #
#----------------------------------------------------------#
# Logging
log_event 'system' "$V_EVENT"
exit $OK