Sysadmin > NetBSD > NetBSDmyupd
#!/bin/sh
#!/bin/sh -xv
#########################################################
#                                                       #
#              NetBSD Update Script 1.2                 #
#               <pitz@uni-konstanz.de>                  #
#                    15. Mar. 2005                       #
#                                                       #
#########################################################
#
# Documentation:
# http://www.kr.netbsd.org/Documentation/updating.html
# cd /usr/src; cvs status -v Makefile
# check for latest autobuld status page:"
# http://releng.netbsd.org/ab/"
#
# rsync specific
#CVSROOT=anoncvs@grappa.unix-ag.uni-kl.de:/cvsroot
CVSROOT=anoncvs@anoncvs.se.netbsd.org:/cvsroot
#CVSROOT=anoncvs@anoncvs3.de.NetBSD.org:/cvsroot
#CVSROOT=anoncvs@anoncvs4.us.NetBSD.org:/cvsroot
#CVSROOT=anoncvs@anoncvs3.de.NetBSD.org:/cvsroot
#CVSROOT=anoncvs@sunsite.univie.ac.at:/cvsroot
#CVSROOT=anoncvs@anoncvs.pl.netbsd.org:/cvs
#CVSROOT=anoncvs@anoncvs.fr.NetBSD.org:/pub/NetBSD-CVS
CVS_RSH=ssh
ARCH=i386
# PATHS
SRCSRC=/usr/src
#SRCXSRC=/usr/xsrc
PKGSRC=/usr/pkgsrc
SRCTOOL=/usr/tools
SRCOBJ=/usr/obj
SRCDIST=/usr/${ARCH}dist
SRCLOG=/var/tmp
SRCAUTOLOG=/var/tmp/upd.out
BRANCH=netbsd-6
PKGSRCBRANCH=pkgsrc-2017Q2
#PKGSRCBRANCH=HEAD
SRCKERNEL=GENERIC
export CVSROOT CVS_RSH BRANCH
#date
#
# f?r den Anfang
# cd /usr/
# cvs -d $CVSROOT checkout -r netbsd-1-6 -P src
# cvs -d $CVSROOT checkout -r netbsd-1-6-PATCH001 -P xsrc
# cvs -d $CVSROOT checkout -r netbsd-1-6-1 -P pkgsrc
# 
case $1 in
upd)
   cd $SRCSRC
   cvs -q -d $CVSROOT update -r $BRANCH -dPA
   echo " ### /usr/src erledigt ### "
   if [ $SRCXSRC ]; then
      cd $SRCXSRC
      cvs -q -d $CVSROOT update -r $BRANCH -dPA
      echo " ### /usr/xsrc erledigt ### "
   fi
   cd $PKGSRC
   cvs -q -d $CVSROOT update -r $PKGSRCBRANCH -dPA
   echo " ### /usr/pkgsrc erledigt ### "
   exit 0
   ;;
clean)
   if [ ! -d "$SRCSRC" ]; then
      cd /usr
      cvs -d $CVSROOT checkout -r $BRANCH -P src
   fi
   if [ ! -d "$PKGSRC" ]; then
      cd /usr
      cvs -d $CVSROOT checkout -r $PKGSRCBRANCH -P pkgsrc
   fi
   if [ ! -d "$SRCTOOL" ]; then
      mkdir -p "$SRCTOOL"
   fi
   rm -rf $SRCTOOL/*
   if [ ! -d "$SRCOBJ" ]; then
      mkdir -p "$SRCOBJ"
   fi
   rm -rf $SRCOBJ/*
   if [ ! -d "$SRCDIST" ]; then
      mkdir -p "$SRCDIST"
   fi
   rm -rf $SRCDIST/*
   exit 0
   ;;
kern)
   cd $SRCSRC
   nohup $SRCSRC/build.sh -u -T $SRCTOOL tools kernel=$SRCKERNEL > $SRCLOG/bld_kern.out 2> $SRCLOG/bld_kern.err &
   echo "tail -f $SRCLOG/bld_kern.out"
   exit $?
   ;;
switch)
   cp -p /netbsd /netbsd.old
   cp $SRCSRC/sys/arch/$ARCH/compile/obj/$SRCKERNEL/netbsd /
   echo -n "New Kernel installed " >> $SRCAUTOLOG
   stat -f "%Sm" /netbsd >> $SRCAUTOLOG
   echo "now you have to reboot"
   exit 0
   ;;
dist)
   cd $SRCSRC
   nohup $SRCSRC/build.sh -u -U -D $SRCDIST -T $SRCTOOL distribution > $SRCLOG/bld_dist.out 2> $SRCLOG/bld_dist.err &
   echo "tail -f $SRCLOG/bld_dist.out"
   exit $?
   ;;
inst)
   cd $SRCSRC
   nohup $SRCSRC/build.sh -u -U -D $SRCDIST -T $SRCTOOL install=/ > $SRCLOG/bld_inst.out 2> $SRCLOG/bld_inst.err &
   echo "tail -f $SRCLOG/bld_inst.out"
   exit 0
   ;;
all)
   echo -n `date`" " >> $SRCLOG/myupdlog
   $0 upd > $SRCLOG/upd.out 2>&1
   cat $SRCLOG/upd.out | grep "^U\|^P" | wc -l | tr -d '\012' >> $SRCLOG/myupdlog
   echo -n " " >> $SRCLOG/myupdlog
   cat $SRCLOG/upd.out >> $SRCLOG/updold.out
## update source tree 
#12 5 * * * /usr/local/sbin/myupd upd >>/var/tmp/upd.out 2>&1
#13 8 * * * /usr/local/sbin/myupd all >>>/var/tmp/bld_all.out 2>&1
   cd $SRCSRC
   $SRCSRC/build.sh -u -T $SRCTOOL tools kernel=$SRCKERNEL
   echo -n $?" " >> $SRCLOG/myupdlog
   $SRCSRC/build.sh -u -U -D $SRCDIST -T $SRCTOOL distribution
   echo $? >> $SRCLOG/myupdlog
   ;;
etcupdate)
   etcupdate
   exit 0
   ;;
checksum)
   mtree -s4711 -x -e -c -K cksum -K md5 -K sha1digest -p / -f /etc/mtree/set.base > /root/mtree/set.base.uracil.md5
   mtree -s4711 -x -e -c -K cksum -K md5 -K sha1digest -p / -f /etc/mtree/set.comp > /root/mtree/set.comp.uracil.md5
   mtree -s4711 -x -e -c -K cksum -K md5 -K sha1digest -p / -f /etc/mtree/set.etc > /root/mtree/set.etc.uracil.md5
   mtree -s4711 -x -e -c -K cksum -K md5 -K sha1digest -p / -f /etc/mtree/set.games > /root/mtree/set.games.uracil.md5
   mtree -s4711 -x -e -c -K cksum -K md5 -K sha1digest -p / -f /etc/mtree/set.man > /root/mtree/set.man.uracil.md5
   mtree -s4711 -x -e -c -K cksum -K md5 -K sha1digest -p / -f /etc/mtree/set.misc > /root/mtree/set.misc.uracil.md5
   mtree -s4711 -x -e -c -K cksum -K md5 -K sha1digest -p / -f /etc/mtree/set.text > /root/mtree/set.text.uracil.md5
   mtree -s4711 -x -e -c -K cksum -K md5 -K sha1digest -p / -f /etc/mtree/special > /root/mtree/special.uracil.md5
   exit 0
   ;;
check)
   mtree -s4711 -p / -f /root/mtree/set.base.uracil.md5 | grep -B3 cksum
   mtree -s4711 -p / -f /root/mtree/set.comp.uracil.md5 | grep -B3 cksum
   mtree -s4711 -p / -f /root/mtree/set.etc.uracil.md5 | grep -B3 cksum
   mtree -s4711 -p / -f /root/mtree/set.games.uracil.md5 | grep -B3 cksum
   mtree -s4711 -p / -f /root/mtree/set.man.uracil.md5 | grep -B3 cksum
   mtree -s4711 -p / -f /root/mtree/set.misc.uracil.md5 | grep -B3 cksum
   mtree -s4711 -p / -f /root/mtree/set.text.uracil.md5 | grep -B3 cksum
   mtree -s4711 -p / -f /root/mtree/special.uracil.md5 | grep -B3 cksum
   exit 0
   ;;
esac

   
#
# "-------------------------------------------------"
# "tar czvf /etc.tgz /etc"
# "Now you can clean /usr/obj"
# "cd /usr/src"
# "./build.sh tools"
# "NEW ./build.sh -O /usr/obj -T /usr/tools tools"
# "NEW ./build.sh -O /usr/obj -T /usr/tools kernel=GENERIC"
# "NEW ./build.sh -O /usr/obj -T /usr/tools -U build"
# "NEW ./build.sh -O /usr/obj -T /usr/tools tools"
# "NEW mv /netbsd /netbsd.old"
# "NEW etcupdate -s ./etc"
# "NEW reboot"
# "./build.sh kernel=GENERIC"
# "mv /netbsd /netbsd.old"
# "mv /usr/src/sys/arch/i386/compile/obj/MALI/netbsd /"
# "--------------------------------"
# "cd /home/destdir"
# "rm -rf *"
# "cd /usr/src"
# "./build.sh -U -D /home/destdir distribution"
# "./build.sh -U -D /home/destdir install=/"
# "etcupdate"
# "evtl. postinstall script starten"
# "--------------------------------"
# "pkg_chk -i"
# "setenv LYNX_SCREEN_LIB ncurses"
# "setenv MUTT_USE_NCURSES YES"
# "setenv USE_IDEA YES"
# "pkg_chk -u"
# "--------------------------------"
# "mkdir /home/xdestdir"
# "cd /usr/xsrc"
# "setenv RELEASEDIR /home/xreldir"
# "setenv DESTDIR /home/xdestdir"
# "make release"
# "cd /usr"
# "mv X11R6 X11R6.old"
# "mv /home/xdestdir/usr/X11R6 /usr"
# "vgl. http://www.netbsd.org/Documentation/updating.html"
# "-------------------------------------------------"
# "-------------------------------------------------"
# ""
# "-------------------------------------------------"
# "-------------------------------------------------"