#!/bin/bash

# This script adds the user htx with gid and gid =0 (root authority)
# It establishes bash as the shell and /usr/lpp/htx as the home directory 
# Use this for the pre-install script.

# 

set -e
# Create a group, htx
echo $PATH
echo "Creating a new group, htx"
niutil -create . /groups/htx
niutil -createprop . /groups/htx gid 0
niutil -createprop . /groups/htx users htx

echo "Creating a new user, htx"
# Create the user htx
niutil -create . /users/htx
niutil -createprop . /users/htx gid 0
niutil -createprop . /users/htx uid 0
niutil -createprop . /users/htx shell /bin/bash
niutil -createprop . /users/htx realname "htx"

echo "Creating home directory /usr/lpp/htx for user htx"
# Note, the directory must exist before you can set it as a home directory
mkdir -p /usr/lpp/htx
niutil -createprop . /users/htx home /usr/lpp/htx

echo "Changing ownerships of all files in /usr/lpp/htx to htx"
# Make sure htx owns his own files.
chown -R htx /usr/lpp/htx
chgrp htx /usr/lpp/htx
exit 0
