#!/bin/sh # # (c) spd_at_daphne.cps.unizar.es # Thu Nov 18 09:05:31 CET 2004 # License: Cantoware - Si te gusta ya te puedes dar con un canto en los dientes # # This script will change some user's shell # Needs: root privileges # ECHO=/usr/bin/echo DO= usage() { echo "Use: `basename $0` [-hqn] name newshell" echo "-q: quiet" echo "-n: do nothing" } set -- `getopt hqn $*` for i in $* do case $i in -q) ECHO=:; shift;; -n) DO=echo; shift;; -h) usage exit 0 ;; esac done umask 077 set -e name=$2 shell="$3" if [ "_$name" = "_" ] then echo "Empty name" usage exit 1 fi if [ "_$shell" = "_" ] then echo "Empty shell" usage exit 1 fi egrep -e "^$shell\$" /etc/shells || ( echo Warning: \""$shell"\" is not in /etc/shells ) test -x ${shell} || echo "Warning: \"$shell\" is not executable" echo Setting $name shell to \""$shell"\" domain=`domainname` # passwd # name passwd uid gid gcos home shell shadow # cred # cname auth_type auth_name public_data private_data nismatch name=$name passwd.org_dir && \ ( $DO nistbladm -m shell="$shell" "[name=$name]",passwd.org_dir ) || \ echo user \"$name\" not found