#!/bin/bash # Author: Blake, Kuo-Lien Huang # License: GPL # Description: reset use's home directory as initial status. # # Modified by Steven Shiau to be used in DRBL for RedHat # Load DRBL setting and functions DRBL_SCRIPT_PATH="${DRBL_SCRIPT_PATH:-/usr/share/drbl}" . $DRBL_SCRIPT_PATH/sbin/drbl-conf-functions # check_if_root # run_cmd="`basename $0`" # usage() { echo "Reset the files in user's home directory." echo "Usage: $run_cmd [OPTION]" echo "Options:" language_help_prompt_by_idx_no echo "-g, --group GROUP: set the GROUP to be processed." echo "-a, --all: process all user except root." echo "-u, --auto-login: process auto-login accounts." echo "-v, --verbose prints out verbose information" echo "If no group or user is assigned, only auto-login account will be reset" echo "Ex:" echo "$run_cmd -g students" } # while [ $# -gt 0 ]; do case "$1" in -l|--language) shift; specified_lang="$1" shift;; -g|--group) shift if [ -z "$(echo $1 |grep ^-.)" ]; then # skip the -xx option, in case chosen_group="$1" shift fi ;; -a|--all) shift; chosen_group="all" ;; -u|--auto-login) shift; chosen_group="auto_login" ;; -v|--verbose) shift; VERBOSE="on" ;; -*) echo "${0}: ${1}: invalid option" >&2 usage >& 2 exit 2 ;; *) break ;; esac done ask_and_load_lang_set $specified_lang # check if group exists if [ -n "$chosen_group" -a "$chosen_group" != "all" -a "$chosen_group" != "auto_login" -a -z "`grep \"^$chosen_group:\" /etc/group 2>/dev/null`" ]; then echo "group $chosen_group does NOT exist!!!" exit 1 fi # the default one for chosen_group is auto_login [ -z "$chosen_group" ] && chosen_group="auto_login" # if [ -n "$VERBOSE" ]; then echo "chosen_group=$chosen_group" fi # main account_list= case "$chosen_group" in all) echo "Process all users..." # IFS_org=$IFS IFS=':' while read uname x uid gid x x x; do # nfs user create a user called "nfsnobody", skip it. if [ "$uid" -ge "$UID_BEGIN_DEFAULT" -a "$uname" != "nfsnobody" ]; then account_list="$account_list $uname" fi done