#!/bin/bash

minuid=6000
home=/home/rhome

[ ! -d "${home}" ]  && mkdir ${home}
date=$( echo $(( $(date +%s)/60/60/24 + 1)) )
ufile=/root/ldap/ldapuser.ldif
gfile=/root/ldap/ldapgroup.ldif
[ -f "${ufile}" ] && mv ${ufile} ${ufile}.backup
[ -f "${gfile}" ] && mv ${gfile} ${gfile}.backup

for i in $( seq 1 10)
do
        username="ldapuser${i}"
        userid=$( echo $(( ${minuid} + ${i} )) )

echo "${這裡加上由 user.ldif 的內容
homeDirectory: /home/rhome/${username}
" >> ${ufile}

echo "${這裡加上 group.ldif 的內容
gidNumber: ${userid}
" >> ${gfile}

	cp -a /etc/skel ${home}/${username}
	chown ${userid}:${userid} -R ${home}/${username}
	chmod 700 ${home}/${username}
done