Bash

(Updated: 2019-09-05)

Add DNS to BIND

#!/bin/bash
if [ "${1}X" = "X" ] ; then
  echo "USAGE: adddns DOMAIN IPADDRESS [RESELLER] [MAIL.IP]"
  exit
fi

ssh -i dns.id -l web2010 ns.web2010.com ~web2010/web2010adddns $1 $2 "'"$yourid"'" $3 $4 


Add Telnet

#!/bin/bash
INPUT=$1
if [ "${INPUT}X" = "X" ] ; then
  echo -n " Please enter domain or username :  "
  read INPUT
fi
DOMAIN_PRE=`echo $INPUT | awk -F\. '{print $1}'`
DOMAIN_EXT=`echo $INPUT | awk -F\. '{print $2}'`
if [ "${DOMAIN_EXT}X" = "X" ] ; then
  USER=`echo ${INPUT}`
   elif [ `grep -c "/web/guide/${DOMAIN_PRE}:" /etc/passwd` -gt 1 ] ; then
    echo " More than one user has this home directory!"
    echo " Aborting!"
    exit
     elif [ `grep -c "/web/guide/${DOMAIN_PRE}:" /etc/passwd` -lt 1 ] ; then
      echo " Could not find the master userid for this domain!!"
                  echo " Aborting!"
      exit
       else
      USER=`grep "/web/guide/${DOMAIN_PRE}:" /etc/passwd | awk -F\: '{print $1}'` 
fi
if [ `grep ^${USER}: /etc/master.passwd | awk -F\: '{print $10}'` = "/bin/bash" ] ; then
  echo " This user already has telnet enabled! "
  echo 
  exit
   else
  chpass -s /bin/bash $USER
fi


Make Guest Account

# USAGE makeguest.sh DOMAIN DIRECTORY EMAIL
DOMAIN=$1
DIRECTORY=$2
EMAIL=$3
cd /mnt/web/guide/$2
echo We Are In The $1 Home Directory
sleep 3s
echo ..
echo ..
echo Now We Are Going To Untar the Guestbook Into the Guestbook Directory 
sleep 2s
tar xfpvz /usr/ours/share/guestbook.tgz
sleep 2s
cd /mnt/web/guide/$2/guestbook
massreplace YOURDOMAIN $1 guestbook.cgi
massreplace YOURDIR $2 guestbook.cgi
massreplace YOUREMAIL $3 guestbook.cgi
sleep 2s
massreplace YOURDOMAIN $1 addguest.html
sleep 2s
massreplace YOURDOMAIN $1 index.html
chmod 755 guestbook.cgi
chmod 777 index.html
cd ..
sleep 2s
echo Guestbook has been installed
echo ..
echo ..
echo Have Fun and Thanks


New Disk Drive

disksetup -R sd1 /usr/root/diskproto
disksetup -B sd1
newfs sd1a &
newfs sd1h &
newfs sd1g &
newfs sd1f 
mount /dev/sd1a /2
mkdir /2/usr /2/var /2/mnt
mount /dev/sd1h /2/usr
mount /dev/sd1g /2/var
mount /dev/sd1f /2/mnt
if [ $MOUNTS = 9 ]; then
 echo all disks mounted, proceeding
else
 echo Disks not mounted right, aborting
fi
tar -cp /.logs /access_log /bin /boot /bsd /bsd.gen /dev /dump /error_log /etc 
/frontpage /lib /maillog /mnt /mnt2 /opt /root /sbin /secaccesslog 
/secerrorlog /shlib /stand /suspended_log /sys /system /tmp /usr /var /web 
/xferlog | tar -xpv --directory=/2


Reboot Server

JUNK=`/bin/ls /web/ssl_conf/httpd.conf.lock | wc -c | tr -d "        "`

# Check for someone else using the script
if [ $JUNK != 0 ]; then
  echo Sorry, someone is using this script.  Try later.
  exit
fi

# Lock the script
echo reboot.sh > /web/ssl_conf/conf.lock
w >> /web/ssl_conf/conf.lock

# echo killing sendmail+webserver+nameserver--
kill `cat /var/run/httpd.pid` >> /var/log/messages 
kill `cat /var/run/httpd.pid` >> /var/log/messages 
kill `cat /var/run/httpd.pid` >> /var/log/messages 
kill `cat /var/run/httpd.pid` >> /var/log/messages 
echo -n .
echo Down goes Apache...
echo -n .
cd /web
/web/httpd
echo Up goes Apache...
echo -n .
echo Checking secure server...
kill `cat /var/run/httpsd.pid` >> /var/log/messages
kill `cat /var/run/httpsd.pid` >> /var/log/messages
kill `cat /var/run/httpsd.pid` >> /var/log/messages
kill `cat /var/run/httpsd.pid` >> /var/log/messages


/usr/root/bin/ssl.check >> /var/adm/messages
echo -n .
echo Down goes sendmail...
kill `cat /var/run/sendmail.pid`
echo -n .
/usr/sbin/sendmail -bd -q30m
echo Up goes sendmail...
echo services restarted..

#release
rm /web/ssl_conf/conf.lock


Remove DNS

#!/bin/bash
if [ "${1}X" = "X" ] ; then
  echo "USAGE: rmvdns DOMAIN [RESELLER]"
  exit
fi

ssh -i dns.id -l web2010 ns.web2010.com ~web2010/web2010rmvdns $1 "'"$yourid"'" $2 


Show Mail

#!/bin/bash
USER_NAME=$1
cd /var/mail
ls -ald "$USER_NAME"* ".$USER_NAME"*


SSL

#! /bin/bash
kill `cat /var/run/httpsd.pid` >> /dev/null
kill `cat /var/run/httpsd.pid` >> /dev/null
kill `cat /var/run/httpsd.pid` >> /dev/null
/web/httpsd
sleep 5
echo "eof"


Unlock Apache Config

if [ "$1" = "?" ] ; then
  cat /web/ssl_conf/conf.lock
  exit
fi

#release
if [ -f /web/ssl_conf/conf.lock ] ; then
echo Unlocking conf
rm /web/ssl_conf/conf.lock
fi
if [ -f /etc/mailer.table.lock ] ; then
echo Unlocking eml
rm /etc/mailer.table.lock
fi