Description:
The following script will determine the shared user type I.E normal shared user, reseller or resold. In addition the script will also display the number of number of ModRails or Mongrel instances and the port used. While entering a reseller or resold account name the details of Mongrel / ModRails instances of all the users under the reseller will be displayed. The script will be very handy while adding Vhost entries for either a reseller or a resold account. The script will create custom.conf file under the path /usr/local/apache/conf/userdata/std/2/USER_NAME/DOMAIN_NAME/ and add necessary content to this file. Finally, it will output the exact /scripts/ensure_vhost_includes command that needs to be executed to include the custom.conf file to the apache Vhost.
Working:
The script will take the account name as the input and it will check the user’s existence in the /etc/userdomains file. If the user is existing there then the user’s existence will be verified in the /var/cpanel/resellers file. If the result is positive then the Mongrel/ ModRails details of reseller account along with resold account will be displayed. If the username is not existing in the /var/cpanel/resellers file then the based on the owner of the user from the file /etc/trueuserowners the account type will be determined. Once the type of the username is determined, for a resold account the complete Mongrel / ModRails details of the other resold accounts along with reseller will be displayed. For the normal shared account the no: of mongrel (it’s port) and the ModRails will be displayed.
For adding vhost entry the script will take input from the following list of options.
Mongrel (M/m), Passenger (P/p), SVN (S/s) or Trac (T/t) ?
Usage:
Mongrel : We need to provide with the domain name, port on which mongrel is started and the number of instances.
Mod_rails : Requires only the domain name.
SVN : Requires only the domain name.
TRAC : We need to specify the domain name , CGI file and the trac_env.
————————————————————————
#!/bin/bash
echo -ne “enter the account name:”
read accnameif [ “$accname” == “” ]
then
echo “———————————————————————–”
echo ” Please enter an account name”
echo “———————————————————————–”
exit
fi# Funtion to initialize parameters
initi () {
a=0
b=0
o=0
r=0
R=0
}resellershow ()
{
initi
echo “========================================><==========================================”
echo -e ” The Reseller account – 33[1;38m $reseller 33[0m details ”
echo “========================================><==========================================”
for i in `grep -w $reseller /etc/trueuserowners | cut -f1 -d :`
do
if [ -d /usr/local/apache/conf/userdata/std/2/$i ] && [ $reseller != $i ]
then
a=`grep BalancerMember /usr/local/apache/conf/userdata/std/2/$i/* -R | wc -l`
b=`expr “$a” + “$b”`
p=`grep BalancerMember /usr/local/apache/conf/userdata/std/2/$i/* -R | cut -f4 -d :`
r=`grep RailsBaseURI /usr/local/apache/conf/userdata/std/2/$i/* -R | wc -l`
R=`expr “$r” + “$R”`
if [ $a -ne “0” ] || [ $r -ne “0” ]
then
echo ” Resold : ‘$i’ –> ‘$r’ModRails – $a mongrel (” $p “) ”
fi
elif [ -d /usr/local/apache/conf/userdata/std/2/$i ] && [ $reseller == $i ]
then
a=`grep BalancerMember /usr/local/apache/conf/userdata/std/2/$i/* -R | wc -l`
p=`grep BalancerMember /usr/local/apache/conf/userdata/std/2/$i/* -R | cut -f4 -d :`
b=`expr “$a” + “$b”`
r=`grep RailsBaseURI /usr/local/apache/conf/userdata/std/2/$i/* -R | wc -l`
R=`expr “$r” + “$R”`
if [ $a -ne “0” ] || [ $r -ne “0” ]
then
echo ” Reseller : ‘$i’ –> ‘$r’ModRails – $a mongrel (” $p “) ”
fifi
done
echo ” ”
echo “Reseller has a total of ‘$b’ mongrel instance(s) and ‘$R’ Modrails instance(s)”
echo ” ”
}
cut -f2 -d : /etc/userdomains | grep -w $accname > /dev/null 2>&1
if [ $? == 0 ]
thengrep -w $accname /var/cpanel/resellers > /dev/null 2>&1
if [ $? == 0 ]
then
echo “You have entered a reseller name”
reseller=$accname
resellershow
else
initi
if [ -d /usr/local/apache/conf/userdata/std/2/$accname ]
then
a=`grep BalancerMember /usr/local/apache/conf/userdata/std/2/$accname/* -R | wc -l`
b=`expr “$a” + “$b”`
p=`grep BalancerMember /usr/local/apache/conf/userdata/std/2/$accname/* -R | cut -f4 -d :`
r=`grep RailsBaseURI /usr/local/apache/conf/userdata/std/2/$accname/* -R | wc -l`
fireseller=`grep -w $accname /etc/trueuserowners | cut -f2 -d : | head -1`
if [ $reseller == “root” ]
thenTYPE=`grep PLAN /var/cpanel/users/$accname | cut -f2 -d =`
if [ $a -gt ‘0’ ] || [ $r -gt ‘0’ ]
thenecho ” ”
echo -e “