head	1.6;
access;
symbols
	VER_0_3:1.6
	VER_0_2:1.5;
locks; strict;
comment	@# @;


1.6
date	95.03.24.11.43.35;	author coulter;	state Exp;
branches;
next	1.5;

1.5
date	95.03.10.02.42.22;	author coulter;	state Exp;
branches;
next	1.4;

1.4
date	95.03.01.07.10.23;	author coulter;	state Exp;
branches;
next	1.3;

1.3
date	95.02.19.17.53.11;	author coulter;	state Exp;
branches;
next	1.2;

1.2
date	95.02.19.16.06.41;	author coulter;	state Exp;
branches;
next	1.1;

1.1
date	95.02.18.08.36.38;	author coulter;	state Exp;
branches;
next	;


desc
@copy the logged files to the hard disk.
@


1.6
log
@Checkin version for 0.3 distribution.
@
text
@#! /bin/ksh
USAGE='USAGE: logiso_copy [ -d config_prefix ]
   Get the iso log and install the logged files on the hard disk.

USAGE: logiso_preview  [ -d config_prefix ]
   List the files that would have been installed by logiso_copy.

If -d is specified, then the config file, ${drive_or_mirror_prefix}config
is used instead of config.  This allows a set of config files to be defined
one for each unique combination of cd-rom mount point and mirror directory
for users with multiple cd-rom drives or who what to populate different
mirror directories, e.g. to mirror different cd-rom volumes.
'
# (C) Copyright 1995 by Michael Coulter.  All rights reserved.

# Process parameters

      COMMAND="$(basename "$0")"
      CONFIG_PREFIX=""
      if [ $# -eq 2 -a "$1" = "-d" ]
      then
         shift  # done with -d
         CONFIG_PREFIX="$1"; shift
      fi
      if [ $# -ne 0 ]
      then
         echo "$USAGE" >&2
         echo "Expected zero or 2 arguments, got $#" >&2
         exit 1
      fi

# Set variables

   ISOFS_UTIL_DIR="${ISOFS_UTIL_DIR:-/usr/src/linux/fs/isofs/Utils}"

# Source in user definitions
# MOUNT_PATH
# MAP_TO_PATH
# CD_FILE

   CONFIG_FILE="${ISOFS_UTIL_DIR}/${CONFIG_PREFIX}config"
   if [ ! -r "$CONFIG_FILE" ]
   then
      echo "Unable to find config file, $CONFIG_FILE" >&2
      exit 1
   fi
   . "${ISOFS_UTIL_DIR}/${CONFIG_PREFIX}config"
   export ISOFS_UTIL_DIR

# Set up temp files

    INODE_LIST="/tmp/logisoina$$"
    INSTALL_LIST="/tmp/logisoinb$$"
    trap "rm -f $INODE_LIST $INSTALL_LIST" 0 1 2 3 15

# Define standard functions

   . "$ISOFS_UTIL_DIR/ksh_fns"

# Check for root if doing copy

   if [ "$COMMAND" = "logiso_copy" ]
   then
      if [ "$(id -u)" -ne 0 ]
      then
	 echo "$USAGE" >&2
	 echo "You are not root. Do you want to continue (type y for yes)?" >&2
	 read RESPONSE
	 if [ "$RESPONSE" != "y" ]
	 then
	    exit 1
	 fi
      fi
   fi


# Do it

   logiso_get "$MOUNT_PATH" | cut -f1 | sort -n | uniq >  "$INODE_LIST"
   rm -f "$ISOFS_UTIL_DIR/last_inodes"  2> /dev/null
   cp "$INODE_LIST" "$ISOFS_UTIL_DIR/last_inodes"

# If CD_FILES does not exist, create it.

   USE_GZIP="FALSE"
   if [ -f "${CD_FILES}.gz" -a ! -f "$CD_FILES" ]
   then
      USE_GZIP="TRUE"
      echo "Uncompressing $CD_FILES"
      gunzip < "${CD_FILES}.gz" > "$CD_FILES"
   fi
   if [ ! -f "$CD_FILES" ]
   then
      echo "$CD_FILES does not exist."
      echo "Creating it will take a while."
      find  "$MOUNT_PATH" 2> /dev/null | xargs ls -i -d 2> /dev/null 	\
	 | sort -n > "$CD_FILES" 2> /dev/null
      check_return 0 1 "Error making $CD_FILE"
      echo "You should probably clear the log and try again." >&2
      exit 1
   fi

# Compare logged files against cd_files.

   echo "Comparing logged inodes against list in $CD_FILES"
   process_lists "$INODE_LIST" "$CD_FILES" > "$INSTALL_LIST"

   if [ "$COMMAND" = "logiso_copy" ]
   then
      ##echo logiso_copy: do install
      cp "$INSTALL_LIST" "$ISOFS_UTIL_DIR/last_install"
      ## echo logiso_copy: install_list -d "$CONFIG_PREFIX" "$INSTALL_LIST" "$MOUNT_PATH" "$MAP_TO_PATH"
      install_list -d "$CONFIG_PREFIX" "$INSTALL_LIST" "$MOUNT_PATH" "$MAP_TO_PATH"
   else
      ##echo logiso_copy: do preview
      cat "$INSTALL_LIST"
   fi   

# If we uncompressed the cd_files, file, remove the uncompressed copy.

   if [ "$USE_GZIP" = "TRUE" ]
   then
      rm -f "$CD_FILES"
   fi
@


1.5
log
@Checkin files modified to make version 0.2
@
text
@d14 1
@


1.4
log
@Checkpoint files.  Can now compress cd_files.
@
text
@d1 2
a2 2
#! /bin/bash
USAGE='USAGE: logiso_copy
d4 9
d17 7
d27 1
a27 1
         echo "Too many arguments." >&2
d40 7
a46 1
   . "${ISOFS_UTIL_DIR}/config"
d59 1
a59 1
# Check for root
d61 1
a61 1
   if [ "$EUID" -ne 0 ]
d63 1
a63 4
      echo "$USAGE" >&2
      echo "You are not root. Do you want to continue (type y for yes)?" >&2
      read RESPONSE
      if [ "$RESPONSE" != "y" ]
d65 7
a71 1
	 exit 1
d79 1
d89 1
a89 1
      gunzip "${CD_FILES}.gz"
d106 14
a119 2
   cp "$INSTALL_LIST" "$ISOFS_UTIL_DIR/last_install"
   install_list "$INSTALL_LIST" "$MOUNT_PATH" "$MAP_TO_PATH"
d122 1
a122 2
      echo "Compressing $CD_FILES"
      gzip "${CD_FILES}"
@


1.3
log
@Get log before creating cd_files.
@
text
@d50 6
d58 7
d76 1
a76 1
# Do it
a77 2
   logiso_get "$MOUNT_PATH" | cut -f1 | sort -n | uniq >  "$INODE_LIST"
   cp "$INODE_LIST" "$ISOFS_UTIL_DIR/last_inodes"
d82 5
@


1.2
log
@Checkpoint version 0.1
@
text
@d59 2
@


1.1
log
@Checkpoint version before fixing /usr/bin install
@
text
@d63 1
a63 1
   logiso_get | cut -f1 | sort -n | uniq >  "$INODE_LIST"
@
