rendered paste body#!/bin/bash
echo "MSP Shared New User Setup"
echo "Enter New DOMAIN:"
read DOMAIN
if [ -d "/var/www/vhosts/$DOMAIN" ];
then
echo "Enter New USER:"
read USER
if id -u $USER >/dev/null 2>&1; then
echo "...username is valid continuing."
echo "setting bash as default shell"
chsh -s /bin/bash $USER
echo "vhost.conf processing for $DOMAIN"
chmod 775 /var/www/vhosts/$DOMAIN/conf/
if [ -f "/var/www/vhosts/$DOMAIN/conf/vhost.conf" ];
then
echo "vhost.conf is present, adjusting permissions"
else
echo "creating vhost.conf and adjusting permissions"
touch /var/www/vhosts/$DOMAIN/conf/vhost.conf
fi
chmod 777 /var/www/vhosts/$DOMAIN/conf/vhost.conf
if [ -d "/var/www/vhosts/$DOMAIN/httpdocs/tmp" ];
then
echo "Temp Dir Exists..."
else
echo "Creating Temp Dir..."
mkdir /var/www/vhosts/$DOMAIN/httpdocs/tmp
fi
chmod 777 /var/www/vhosts/$DOMAIN/httpdocs/tmp
uid="$(id "$USER" -u)"
gid="$(id "$USER" -g)";
chown "$uid:$gid" /var/www/vhosts/$DOMAIN/httpdocs/tmp
echo "Entering Install Mode as user $USER"
su "$USER" -c 'cd ~ && cp /installers/files/mapserv_ubuntu cgi-bin/mapserv'
echo "Verifying mapserv cgi installed..."
if [ -f "/var/www/vhosts/$DOMAIN/cgi-bin/mapserv" ];
then
echo "Present, Installing MSP DemoPack..."
su "$USER" -c 'sh /installers/install_demopack_mapserver-new.sh'
echo "Applying New vhost.conf configuration..."
/opt/psa/admin/bin/httpdmng --reconfigure-domain $DOMAIN
exit 0;
else
echo "Severe Permissions Error, Contact Technical Support."; exit 0;
fi
else
echo "username not found, exiting"; exit 0;
fi
else echo "Domain invalid or Path Error, Please verify and retry."
fi