# Copyright (c) 2014 by David L. Craig, all rights reserved
# and licensed under version 2 of the GPL.
# http://dlc.casita.net/~dlc       mailto:dlc.usa@gmail.com
#
cd backups
bd=(`{ls})
if ( ~ $#bd 0 ) {echo backups directory not found ; exit 'no_dir' }
if ( ! ~ $#bd 1 ) { echo multiple backup directories found ; exit 'too_many' }
echo 'bd=<'^$bd^'>'
cd $bd
if ( test -f auth        ) cp auth         /lib/ndb/auth       && rm auth       
if ( test -f cpurc       ) cp cpurc        /rc/bin/cpurc       && rm cpurc      
if ( test -f cpurc.local ) cp cpurc.local  /rc/bin/cpurc.local && rm cpurc.local
if ( test -f local       ) cp local        /lib/ndb/local      && rm local      
if ( test -f plan9.ini   ) cp plan9.ini    /n/9fat/plan9.ini   && rm plan9.ini  
if ( test -f nvram       ) cp nvram        /dev/sdC0/nvram     && rm nvram
bc=(`{lc}) ; if ( ! ~ $#bc 0 ) echo 'bc=<'^$bc^'>'
cd ..
if ( ! ~ $#bc 0 ) echo Not all $bd files moved
if not rm $bd
cd ..
hd=(`{ls /cfg | grep -v 'example' | grep -v 'pxe'})
if ( ! ~ $#hd 1 ) echo Host /cfg directory not found
if not rm -r $hd
rm /env/bc /env/bd /env/hd
