Files
VestaCP/bin/v_change_user_shell
2012-03-08 23:37:03 +02:00

61 lines
1.5 KiB
Bash
Executable File

#!/bin/bash
# info: change user shell
# options: user shell
#
# The function changes system shell of a user. Shell gives abilty to use ssh.
#----------------------------------------------------------#
# Variable&Function #
#----------------------------------------------------------#
# Argument defenition
user=$1
shell=$2
# Importing variables
source $VESTA/conf/vesta.conf
source $VESTA/func/shared.sh
#----------------------------------------------------------#
# Verifications #
#----------------------------------------------------------#
# Checking arg number
check_args '2' "$#" 'user shell'
# Checking argument format
validate_format 'user' 'shell'
# Checking user
is_object_valid 'user' 'USER' "$user"
# Checking user is active
is_object_unsuspended 'user' 'USER' "$user"
#----------------------------------------------------------#
# Action #
#----------------------------------------------------------#
# Get shell full path
shell_path=$(/usr/bin/chsh --list-shells | grep -w "$shell" )
# Changing passwd file
/usr/bin/chsh -s "$shell_path" "$user" &>/dev/null
#----------------------------------------------------------#
# Vesta #
#----------------------------------------------------------#
# Changing user shell
update_user_value "$user" '$SHELL' "$shell"
# Logging
log_event "$OK" "$EVENT"
exit