2 ##############################################
3 # Script for Secure Linux Project #
4 # Copyright(c) 2005, 2006 by Roland Haeder #
5 ##############################################
6 # Purpose: Copys choosen directories/files #
8 ##############################################
9 # This software is licensed under the GNU #
10 # General Public License Version 2 or either #
11 # and comes with ABSOLUTELY NO WARRANTY #
12 # neither implied nor explicit. #
13 ##############################################
15 . ./.settings.sh || exit 3
18 #find bin dev etc home lib mnt opt root sbin sys tmp usr var -print0 | \
19 if test "$FORCE_CPIO" != "1"; then
20 # Check size of given targets
22 for target in $CPIO_FILES; do
24 if test -d "$target"; then
26 if test "$VERBOSE" == "-v"; then
27 echo "$0: $target is a directory."
29 sh $BASEDIR/sizes.sh $target
30 elif test -f "$target"; then
32 TOTAL=`stat --format="%s" $target`
33 if test "$VERBOSE" == "-v"; then
34 echo "$0: $target is $TOTAL Bytes large."
37 # Something else is not counted
38 if test "$VERBOSE" == "-v"; then
39 echo "$0: $target is no file/directory -> 0 Bytes forced."
42 ALL_TOTAL="$(($ALL_TOTAL + $TOTAL))"
45 # Size for below if command
46 CHECK="$((ALL_TOTAL/1024))"
48 # Begin looking for right unit (GB/MB/kB/Bytes)
50 SIZE="$((ALL_TOTAL/1024/1024/1024))"
51 if test "$SIZE" == "0"; then
53 SIZE="$((ALL_TOTAL/1024/1024))"
54 if test "$SIZE" == "0"; then
56 SIZE="$((ALL_TOTAL/1024))"
57 if test "$SIZE" == "0"; then
64 echo -n "$0: Total size: $SIZE $UNIT -> "
65 if test $SIZE_ROOT -gt $CHECK; then
71 echo "$0: Press RETURN if this is also okay for you."
74 # Do not check sizes of targets in CPIO_FILES
75 echo "$0: Warning: Will copy targets in CPIO_FILES regardless if you have"
76 echo "$0: enough space on $BASEDIR/root/!"
78 echo "Press RETURN to begin copy process or CTRL+C to abort..."
84 if test "$CPIO_FILES" != ""; then
85 TEST=`grep "$BASEDIR" $CPIO_FILES`
86 if test "$TEST" != ""; then
87 echo "$0: Found my own path $BASEDIR in CPIO_FILES! Aborting..."
91 find $CPIO_FILES -print0 | \
92 cpio --pass-through --make-directories --null --reset-access-time \
93 --make-directories --preserve-modification-time --verbose $BASEDIR/root/
99 # Create additional directories
100 mkdir $VERBOSE $BASEDIR/root/{boot,cdrom,floppy,proc}
102 echo "$0: When no error ('no space left on device' may"
103 echo "$0: occur on testing images) then please continue"
104 echo "$0: with stick.sh to setup your USB stick(s)!"