Newer
Older
tconfigfiles / tconfigfiles
@tundra tundra on 13 Feb 2013 1 KB Changed $CFBASE to $CFREPO.
  1. #!/bin/sh
  2. # tconfigfiles - Manage Configuration Files
  3. # Copyright (c) 2007-2013 TundraWare Inc., Des Plaines, IL USA
  4. # All Rights Reserved
  5. # $Id: tconfigfiles,v 1.118 2013/02/13 15:33:42 tundra Exp $
  6.  
  7. # Where things live
  8.  
  9. CFREPO=${CFREPO:-$HOME/configfiles} # The directory that holds everything below
  10. # Can be overridden with $CFREPO env var
  11.  
  12. ARCHIVES=archives # Where archives go
  13. FILES=tree # Where tree of individual files lives
  14.  
  15. ARCHIVEDIR="$CFREPO/$ARCHIVES"
  16. FILEDIR="$CFREPO/$FILES"
  17.  
  18. # Make sure the container directories exist
  19.  
  20. mkdir -p $ARCHIVEDIR
  21. mkdir -p $FILEDIR
  22.  
  23. # The name used to invoke the program tells us what to do
  24.  
  25. CMD=`basename $0`
  26. case $CMD
  27. in
  28.  
  29.  
  30. "cfarchive") # Make archival copy of current tree
  31. timestamp=`date "+%Y-%m-%d-%H%M%S"`
  32. cd $CFREPO
  33. MACHNAME=`hostname -f`
  34. archdir=$MACHNAME-$FILES-$timestamp
  35. cp -pvR $FILES $archdir
  36. tar -czvf $ARCHIVES/$archdir.tar.gz $archdir
  37. rm -rf $archdir
  38. ;;
  39.  
  40.  
  41. "cfbku") # Backup configuration files to tree
  42. for f in $*
  43. do
  44. abspath=`readlink -f $f`
  45. bkudir=$FILEDIR`dirname $abspath`/
  46. mkdir -p $bkudir
  47. cp -pvR $f $bkudir
  48. done
  49. ;;
  50.  
  51.  
  52. "cfinstall") # Install configuration files from tree
  53. for f in $*
  54. do
  55. abspath=`readlink -f $f`
  56. targetdir=`echo $abspath | sed s?$FILEDIR??`
  57. cp -pvR $f $targetdir
  58. done
  59. ;;
  60.  
  61.  
  62. "tconfigfiles")
  63. INSTALLDIR=`dirname $0`
  64. ln -s $0 $INSTALLDIR/cfarchive
  65. ln -s $0 $INSTALLDIR/cfbku
  66. ln -s $0 $INSTALLDIR/cfinstall
  67. ;;
  68.  
  69. *)
  70. echo "Unknown Command ===> $CMD"
  71. exit 1
  72. ;;
  73.  
  74.  
  75. esac