#!/bin/bash # # makeinits -- Shell script to make start/stop scripts for squid and jeanne. # # By Marion Bates # # Last revision November 8, 2001. # If you need to change HOME, change the line below to reflect the path to the # reverse proxy stuff. HOME=/usr/mrp # Default to N so we loop through the question at least once CHECK1="N" CHECK2="N" CHECK3="N" echo "" echo "My HOME variable is set to $HOME, so this is where I will put a symlink to the squid start/stop script, which will in turn be used by getlist. Is this correct? If so, please type Y or y and hit return. If that's NOT correct, please answer N or n and edit this script such that HOME is set correctly." read CHECK0 if [ "$CHECK0" = "Y" ] || [ "$CHECK0" = "y" ] ; then echo "" echo "Here we go! Please answer the following questions, and I will generate the start and stop scripts based on your answers." echo "" while [ "$CHECK1" = "N" ] || [ "$CHECK1" = "n" ] ; do echo "What's the path to the \"squid_init\" script that came with this distribution? No trailing slash, please." read SCRIPTPATH echo "You entered $SCRIPTPATH. Is this correct? Y(y) or N(n)" read CHECK1 done if [ "$CHECK1" = "Y" ] || [ "$CHECK1" = "y" ] ; then while [ "$CHECK2" = "N" ] || [ "$CHECK2" = "n" ] ; do echo "What is the path to your init scripts? (It is probably /etc/init.d but on some versions of Linux, it is /etc/rc.d/init.d.) No trailing slash, please." read INITPATH echo "You entered $INITPATH. Is this correct? Y(y) or N(n)" read CHECK2 done if [ "$CHECK2" = "Y" ] || [ "$CHECK2" = "y" ] ; then while [ "$CHECK3" = "N" ] || [ "$CHECK3" = "n" ] ; do echo "What is the path to your rc scripts? (It is probably /etc/rc.d.) No trailing slash, please." read RUNPATH echo "You entered $RUNPATH. Is this correct? Y(y) or N(n)" read CHECK3 done if [ "$CHECK3" = "Y" ] || [ "$CHECK3" = "y" ] ; then echo "Okay. I am going to place this script in $INITPATH and I'm going to make symlinks to that script for all the appropriate runlevel directories in $RUNPATH. I will also make a symlink in $HOME so the getlist script can find start and stop the proxy." # See if the source squid script exists in the user-specified path. if [ ! -e $SCRIPTPATH/squid_init ] ; then echo "squid_init not found in $SCRIPTPATH, exiting." exit 1 fi # Copy the init script to /etc/init.d if it's not already there (if it is, hose it) if [ -e $INITPATH/squid ] then rm -f $INITPATH/squid fi cp $SCRIPTPATH/squid_init $INITPATH/squid # Make it executable chmod 755 $INITPATH/squid # I am afraid of this line. I hope it is specific enough not to do any serious harm... find $RUNPATH -type l -iname 'S*squid' | xargs rm -f find $RUNPATH -type l -iname 'K*squid' | xargs rm -f find $HOME -type l -iname 'squid' | xargs rm -f # Start it in runlevels 2-5, kill it in 0,1, and 6 ln -s $INITPATH/squid $RUNPATH/rc0.d/K50squid ln -s $INITPATH/squid $RUNPATH/rc1.d/K50squid ln -s $INITPATH/squid $RUNPATH/rc2.d/S50squid ln -s $INITPATH/squid $RUNPATH/rc3.d/S50squid ln -s $INITPATH/squid $RUNPATH/rc4.d/S50squid ln -s $INITPATH/squid $RUNPATH/rc5.d/S50squid ln -s $INITPATH/squid $RUNPATH/rc6.d/K50squid ln -s $INITPATH/squid $HOME/squid sleep 1 echo "Done." fi fi fi fi