#!/bin/sh
#
#Sample script for Alt OS to use in postinstall tasks for domain join
#

while getopts "d:n:p:" option; do
   case $option in
      d) domain=$OPTARG;;
      n) username=$OPTARG;;
	  p) password=$OPTARG;;
     \?) # Invalid option
         echo "Error: Invalid option"
         exit 1;;
   esac
done

compname=$(hostname | cut -d. -f1)
workgroup=$( cut -d. -f1 <<< "$domain" )

apt-get update
apt-get install task-auth-ad-sssd -y
system-auth write ad $domain $compname $workgroup $username $password
net time set -S $domain

roleadd 'Domain Users' users
roleadd 'Domain Admins' localadmins