summaryrefslogblamecommitdiffstats
path: root/satellit_installer/includes/10-handle_users.inc
blob: 79ad9eb915385eeb5c1cfdeb30e87811c9a5a74f (plain) (tree)






























                                                                                               
add_group() {
	echo -n "# Adding group: $1, gid $2..."
	groupadd -g "$2" "$1" 2>/dev/null || echo "Could not add group $1 / gid $2!"
	echo "ok."
}

add_user() {
	echo -n "# Adding user: $1, uid $2, to gid $3..."
	useradd -u "$2" -m -d /home/"$1" -s /bin/bash -g "$3" "$1" 2>/dev/null \
		|| echo "Could not add user ${1}/${2} / gid $3!"
	echo "ok."
}


kill_user() {
	echo -n "# Terminating user account id $1, leaving user home/files as they were: "
	userdel $(getent passwd "$1" | cut -f 1 -d ":") || echo "# could not kill userid ${1}!"
	echo "ok."
}

check_users() {
	echo "#"
	echo "# Checking for users to kill with id>=1000: "
	for userid in $(cat /etc/passwd|cut -f 3 -d ":"|sort -n); do
		case $userid in
			65534)	echo "# Ignoring user 65534/sync."	;;
			*)	[ "$userid" -ge 1000 ] && kill_user "$userid"
		esac
	done
}