#!/bin/sh
############################################################################
##                                                                         #
##   This program is free software; you can redistribute it and/or modify  #
##   it under the terms of the GNU General Public License as published by  #
##   the Free Software Foundation; either version 2 of the License, or     #
##   (at your option) any later version.                                   #
##                                                                         #
############################################################################

bootcdroot=/var/lib/bootcd

# add a new user named ostf
chroot $bootcdroot /usr/sbin/shadowconfig off
echo "ostf::1000:100::/home/ostf:/bin/sh" >> $bootcdroot/etc/passwd
chroot $bootcdroot /usr/sbin/shadowconfig on
if [ -e $bootcdroot/etc/sudoers ]; then
  echo "ostf	ALL=(ALL) ALL" >> $bootcdroot/etc/sudoers
  #mkdir -p $bootcdroot/var/run/sudo/ostf
  cat <<-EOF > $bootcdroot/etc/init.d/sudo
#!/bin/sh
#left ostf have sudo permission
mkdir -p /var/run/sudo/ostf
EOF
fi

rm -rf $bootcdroot/home/*
mkdir -p $bootcdroot/home/ostf
chroot $bootcdroot chown -R ostf.users /home/ostf
