mirror of
https://github.com/myvesta/vesta.git
synced 2025-01-12 14:02:54 -08:00
55 lines
1.4 KiB
Bash
Executable File
55 lines
1.4 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
|
|
|
|
# Includes
|
|
source $VESTA/func/main.sh
|
|
source $VESTA/conf/vesta.conf
|
|
|
|
|
|
#----------------------------------------------------------#
|
|
# Verifications #
|
|
#----------------------------------------------------------#
|
|
|
|
check_args '2' "$#" 'USER SHELL'
|
|
validate_format 'user' 'shell'
|
|
is_object_valid 'user' 'USER' "$user"
|
|
is_object_unsuspended 'user' 'USER' "$user"
|
|
|
|
|
|
#----------------------------------------------------------#
|
|
# Action #
|
|
#----------------------------------------------------------#
|
|
|
|
# Get shell full path
|
|
shell_path=$(grep -w "$shell" /etc/shells | head -n1)
|
|
|
|
# Changing passwd file
|
|
/usr/bin/chsh -s "$shell_path" "$user" &>/dev/null
|
|
shell=$(basename $shell_path)
|
|
|
|
|
|
#----------------------------------------------------------#
|
|
# Vesta #
|
|
#----------------------------------------------------------#
|
|
|
|
# Changing user shell
|
|
update_user_value "$user" '$SHELL' "$shell"
|
|
|
|
# Logging
|
|
log_history "changed $user shell to $shell" '' 'admin'
|
|
log_event "$OK" "$EVENT"
|
|
|
|
exit
|