About the FreeBSD Daemon

Friends


Shepherd Business Group

Andersen Cabinet

Service Sales Corporation

Schmit Prototypes

Floral Merchandising Systems

Diskcopy vom Steinig Tal, Sch2

CSS v2Valid?

Hit Counter

Mycvsup.sh Bourne Shell Script


The script "mycvsup.sh" creates a running log file in the /var/log/ directory called mycvsup.log of your cvsup sessions. mycvsup.sh will run 2 passes of the cvsup update separated by a 2 minute delay. After mycvsup.sh completes you should view the log file /var/log/mycvsup.log, or use the scroll lock and arrow keys for your screen buffer, and confirm that the last session did not add or change any files from the previous cvsup session. This helps to alert you if the files you are updating in your /usr/src or /usr/ports directories are in the midst of an update themselves on the cvsup server. If your mycvsup.log does show changes between the first and second pass you should take a break and try your cvsup again later when the source tree has settled down.


Download mycvsup.sh.gz

Place the mycvsup.sh script in your /usr/local/bin/ directory and set the owner/group to root/wheel and the permissions to 0700 (rwx------).

To invoke a mycvsup.sh session referencing your /etc/cvsupfile, login as root and enter:

# /usr/local/bin/mycvsup.sh

From the mycvsup.sh startup message:

mycvsup.sh runs a cvsup session while keeping a running log file of the date and time that your sessions begin and end, and the cvsup listings of the modifications to your /usr/src directory tree.

If your cvsupfile includes updates to your ports tree also, then modifications could be made to your /usr/ports directory tree also.

mycvsup.sh runs 2 cvsup sessions with a pause of 120 seconds between updates. This helps identify if the source tree is undergoing updates while you cvsup. You should check your log file and confirm that pass 2 is not substantially different from the previous pass.

It is assumed that your internet connection is already active. If you are not online, then choose "Q" to quit, fire up the internet, and try again.

If your internet connection drops out during a cvsup session you will need to break out of your cvsup session with Ctrl+C, and try again.

You are logging to the file "/var/log/mycvsup.log".

Enter C to continue, Q to quit:

Script source for mycvsup.sh:

#!/bin/sh
# /usr/local/bin/mycvsup.sh
# Created by Stephen Hilton nospam@hiltonbsd.com
# Tuned for FreeBSD 4.x, should be adaptable to other *NIX systems.
# Last update: 12-08-2001
# Version: 01.02.00

################################################################################
# All of the documentation and software included in mycvsup.sh releases
# is copyrighted by Stephen Hilton.
# Copyright 2001 Stephen Hilton. All rights reserved. 
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions are met:
# Redistributions of source code must retain the above copyright notice, this
# list of conditions and the following disclaimer.
# Redistributions in binary form must reproduce the above copyright notice,
# this list of conditions and the following disclaimer in the documentation
# and/or other materials provided with the distribution. 

# THIS SOFTWARE IS PROVIDED BY STEPHEN HILTON AND CONTRIBUTORS ``AS IS'' AND
# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
# WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
# DISCLAIMED. IN NO EVENT SHALL STEPHEN HILTON OR CONTRIBUTORS BE LIABLE FOR
# ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
# (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
# LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
# ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
# SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.  
################################################################################

# mycvsup.sh is a bourne shell script to assist in the cvsup process and log the
# cvsup start and end times and update information to a running text log file.

# Thanks to Jim Conner (SnafuX/NOTJames) for help with this script :-)

#################################
# user editable variables
totalpass="2"
waitsecs="120"
mylogf="/var/log/mycvsup.log"
# end of user editable variables

myprog=`/usr/bin/basename "$0"`

################################
# start my defined functions.
# mybanner, myerrret, mylogit, mypound.


# Function "mybanner" creates up to a 3 line banner for the target file.
mybanner ()
{
     mypound
       if [ `echo "$1" | wc -c` -gt "1" ]
         then
             mylogit "$1"
       fi

       if [ `echo "$2" | wc -c` -gt "1" ]
         then
             mylogit "$2"
       fi

       if [ `echo "$3" | wc -c` -gt "1" ]
         then
             mylogit "$3"
       fi
      mypound
     mylogit
}


# Function "myerrret" creates an error return code and text message regarding
#  the specific error. The $1 argument is the return value from $myerrcode
#   the $2 argument is the text message defined in $myerrmsg.
myerrret ()
{
       if [ $myerrcode -ne 0 ]
         then
              echo $2
              exit $1
      fi 
}


# Function "mylogit" directs text lines to the target file.
mylogit ()
{
      echo -e "$1" 
}


# Function "mypound" directs a hash bar into the target file.
mypound ()
{
  mylogit "##################################################################\
#############"
}

# end my defined functions.
################################

################################

# write the info screen.

    clear

echo "${myprog} runs a cvsup session while keeping a running log file of the\
 date"
echo "and time that your sessions begin and end, and the cvsup listings of the"
echo "modifications to your /usr/src directory tree."
echo
echo "If your cvsupfile includes updates to your ports tree also, then\
 modifications"
echo "will be made to your /usr/ports directory tree."
echo 
echo "${myprog} runs ${totalpass} cvsup sessions with a pause of ${waitsecs}\
 seconds between updates."
echo "This helps identify if the source tree is undergoing updates while you\
 cvsup."
echo "You should check your log file and confirm that pass ${totalpass} is not\
 substantially"
echo "different from the previous pass."
echo
echo "It is assumed that your internet connection is already active.\
 If you are"
echo "not online, then choose \"Q\" to quit, fire up the internet,\
 and try again."
echo
echo "If your internet connection drops out during a cvsup session\
 you will need"
echo "to break out of your cvsup session with Ctrl+C, and try again."
echo 
echo "You are logging to the file \"${mylogf}\"."
echo 

    while true
     do
       echo -n "Enter C to continue, Q to quit: "
        read answer
         answer=`echo "$answer" | tr "[:lower:]" "[:upper:]"`

          if [ "$answer" = "C" ]
            then
                 echo "  Working ..."
                 break
          fi

          if [ "$answer" = "Q" ]
            then
                exit 0
          fi
    done

# done with info screen
################################

################################
# error, you are not root.
UID=$(/usr/bin/id | cut -d = -f 2 | awk -F '(' '{print $1}')
    if [ $UID != 0 ]
      then
       myerrcode="3"
       myerrmsg="You must be superuser to use $myprog"
       myerrret "$myerrcode" "$myerrmsg"
    fi

# error, you do not have cvsup installed in /usr/local/bin/.
    myerrcode=$(test -x /usr/local/bin/cvsup > /dev/null 2>&1;echo $?)
    myerrmsg="Problem: cvsup program not found in /usr/local/bin/"
    myerrret "$myerrcode" "$myerrmsg"

# error, you do not have a cvsupfile in /etc/.
    myerrcode=$(test -r /etc/cvsupfile > /dev/null 2>&1;echo $?)
    myerrmsg="Problem: cvsupfile not found in /etc"
    myerrret "$myerrcode" "$myerrmsg"

################################

################################
mypass="1"

while true
 do
  startdate=`date "+%m-%d-%Y %H:%M:%S %Z"`

# run function mybanner
  mybanner "           Started cvsup session at: ${startdate}"  \
 "       Starting pass ${mypass} of ${totalpass}, with a ${waitsecs} second\
 delay between passes" | tee -a "$mylogf"

    /usr/local/bin/cvsup -g -L 2 /etc/cvsupfile | tee -a "$mylogf"

   enddate=`date "+%m-%d-%Y %H:%M:%S %Z"`

# run function mybanner
  mybanner "          Ended cvsup pass ${mypass} of ${totalpass}\
 at: ${enddate}" | tee -a "$mylogf"


   if [ "${mypass}" = "${totalpass}" ]
    then
     exit 0
    else
     echo
     echo "Please wait, pausing for ${waitsecs} seconds between cvsup passes."
     echo
     sleep "${waitsecs}"
     mypass=`expr "${mypass}" + "1"`
   fi

done

################################
# End of script.
################################

Corrections? / Additions? / Suggestions? / Links?
Please email any and all such to:


nospam@hiltonbsd.com