/usr/sbin/drbl-user-env-reset is in drbl 2.6.15-1.
This file is owned by root:root, with mode 0o755.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 | #!/bin/bash
# Author: Blake, Kuo-Lien Huang
# License: GPL
# Description: reset use's home directory as initial status.
#
# Modified by Steven Shiau <steven@nchc.org.tw> 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 </etc/passwd
IFS=$IFS_org
;;
auto_login)
echo "You did NOT specify group or all users, so process \"auto-login\" users only..."
echo -n "Finding the auto login accounts..."
# get the autologin account
for ihost in `get-client-ip-list`; do
iaccount="`get_existing_autologin_account $drblroot/$ihost`"
account_list="$account_list $iaccount"
echo -n "."
done
echo " done!"
;;
*)
echo "Process the users in the chosen group \"$chosen_group\"... "
# process the chosen group
account_list=$(grep "^$chosen_group:" /etc/group | awk -F':' '{print $4}' | sed -e "s/,/ /g")
;;
esac
# remove the leading space if it exists
account_list=`echo $account_list | sed -e "s/^ //g"`
# check the account list
if [ -z "$account_list" ]; then
[ "$BOOTUP" = "color" ] && $SETCOLOR_FAILURE
echo "No any account you assigned exists! Program terminated!"
[ "$BOOTUP" = "color" ] && $SETCOLOR_NORMAL
exit 1
fi
[ -n "$VERBOSE" ] && echo "account_list=$account_list"
[ "$BOOTUP" = "color" ] && $SETCOLOR_WARNING
echo "$msg_warning_home_dir_will_be_deleted!!!"
echo "$msg_these_accounts_are:"
[ "$BOOTUP" = "color" ] && $SETCOLOR_FAILURE
echo "$account_list"
[ "$BOOTUP" = "color" ] && $SETCOLOR_WARNING
echo "$msg_are_u_sure_u_want_to_continue"
[ "$BOOTUP" = "color" ] && $SETCOLOR_NORMAL
echo -n "[y/N] "
read reset_account_confirm
case "$reset_account_confirm" in
Y|y|[yY][eE][sS])
echo "$msg_ok_let_do_it!"
;;
*)
echo "$msg_do_not_reset_autologin_home_dir! $msg_program_stop!"
exit 0
esac
# store the LC_ALL
LC_ALL_org=$LC_ALL
export LC_ALL=C
# main
for id in $account_list; do
USER_HOME_DIR="$(grep "^$id:" /etc/passwd | awk -F':' '{print $6}')"
[ -z "$USER_HOME_DIR" -o ! -d "$USER_HOME_DIR" ] && continue
login_group="$(id -n -g $id)"
echo -n "Reseting account $id's home directory $USER_HOME_DIR... "
[ -n "$verbose" ] && rsync_opt_verbose="--progress"
rsync -a --delete $rsync_opt_verbose /etc/skel/ $USER_HOME_DIR/
chown -R $id.$login_group /etc/skel/ $USER_HOME_DIR/
echo "done!"
done
# restore the LC_ALL
export LC_ALL=$LC_ALL_org
|