Hello,
Could someone please help to tidy this script a little..
The script will be run inside the jail to create the user and install the full web server.
I am not sure that my syntax is correct and I haven't got the jail setup up yet to test it
Will case statement more suited for the job?
Thank you in advance
Fred
Could someone please help to tidy this script a little..
The script will be run inside the jail to create the user and install the full web server.
Code:
#!/bin/sh
#
# FreeBSD 10 -RELEASE ZFS - jail post installation script
if [ "$(whoami)" != 'root' ]; then
echo "You have no permission to run $0 as non-root user."
exit 1;
fi
hostname=$(hostname -s)
if [$hostname == webjail]
then
pw groupadd -q -n webadmin -g 1001
echo -n '$1$p75bbfK.$Kz3dwkoVlgZrfLZdAXQt91' |\
pw useradd -n webadmin -u 1001 -c "System Administrator" -g webadmin -G wheel -s /bin/csh -d /home/webadmin -m -H 0
pw usermod webadmin -p 01 01 01
chown -R webadmin:webadmin /home/webadmin
elif [$hostname == sqljail]
then
pw groupadd -q -n dbadmin -g 1002
echo -n '$1$p75bbfK.$Kz3dwkoVlgZrfLZdAXQt91' |\
pw useradd -n dbadmin -u 1002 -c "Database Administrator" -g dbadmin -G wheel -s /bin/csh -d /home/dbadmin -m -H 0
pw usermod dbadmin -p 01 01 01
chown -R dbadmin:dbadmin /home/dbadmin
elif [$hostname == mailjail]
then
pw groupadd -q -n mailadmin -g 1003
echo -n '$1$p75bbfK.$Kz3dwkoVlgZrfLZdAXQt91' |\
pw useradd -n mailadmin -u 1003 -c "Mail Administrator" -g mailadmin -G wheel -s /bin/csh -d /home/mailadmin -m -H 0
pw usermod mailadmin -p 01 01 01
chown -R mailadmin:mailadmin /home/mailadmin
else
echo "no match found"
exit 1;
fi
I am not sure that my syntax is correct and I haven't got the jail setup up yet to test it
Will case statement more suited for the job?
Thank you in advance
Fred