?login_element?

Subversion Repositories NedoOS

Rev

Rev 626 | Blame | Compare with Previous | Last modification | View Log | Download

  1. #!/bin/bash
  2. set -e
  3. DMIMG="$0"
  4. DMIMG="${DMIMG%/*}/dmimg"
  5. if [ ! -x "$DMIMG" ]; then
  6.         echo "ERROR: \"$DMIMG\" not found."
  7.         exit 1
  8. fi
  9. if [ $# != 2 ]; then
  10.         echo 'Usage:'
  11.         echo "  $0 IMAGE_FILE SOURCE_DIR"
  12.         echo 'Where:'
  13.         echo "  IMAGE_FILE is an image file, supported by \"$DMIMG\"."
  14.         echo '  SOURCE_DIR is a source directory to add files from.'
  15.         exit 1
  16. fi
  17. IMAGEFILE="$1"
  18. SOURCEDIR="$2"
  19. SOURCEDIR="${SOURCEDIR%%/}/"
  20. SCRIPTFILE=script.tmp
  21. echo "Scanning directory \"$SOURCEDIR\"..."
  22. rm -f "$SCRIPTFILE"
  23. for i in `find "$SOURCEDIR" -depth -type d|sort`; do
  24.         j="${i#$SOURCEDIR}"
  25.         if [ -n "$j" ]; then echo "mkdir /$j">>"$SCRIPTFILE"; fi
  26. done
  27. for i in `find "$SOURCEDIR" -depth -type f|sort`; do
  28.         echo "put $i /${i#$SOURCEDIR}">>"$SCRIPTFILE"
  29. done
  30. if [ -f "$SCRIPTFILE" ]; then
  31.         echo "Adding files from directory \"$SOURCEDIR\" to the image \"$IMAGEFILE\"..."
  32.         "$DMIMG" "$IMAGEFILE" conf "$SCRIPTFILE"
  33.         rm -f "$SCRIPTFILE"
  34.         echo "File \"$IMAGEFILE\" is successfully updated."
  35. else
  36.         echo "Nothing to add - skipping. File \"$IMAGEFILE\" was not modified."
  37. fi
  38.