summaryrefslogtreecommitdiffstats
path: root/a
diff options
context:
space:
mode:
authorFlorian Pritz <f-p@gmx.at>2009-05-21 23:35:27 +0200
committerFlorian Pritz <f-p@gmx.at>2009-05-21 23:35:27 +0200
commiteb55b0c3880705be8684a4da02b78368e0448b84 (patch)
treee72fd3450fb51a27f214295321c5a8ab4e724c71 /a
parent55b2b41529c5ac3912969bf5468f7ad54cf61096 (diff)
downloadbin-eb55b0c3880705be8684a4da02b78368e0448b84.tar.gz
bin-eb55b0c3880705be8684a4da02b78368e0448b84.tar.xz
rename a to a.sh
Diffstat (limited to 'a')
-rwxr-xr-xa112
1 files changed, 0 insertions, 112 deletions
diff --git a/a b/a
deleted file mode 100755
index 4818c76..0000000
--- a/a
+++ /dev/null
@@ -1,112 +0,0 @@
-#!/bin/bash
-######################################################
-#+ Simple archive script with multiple backends
-#+ Rev. 3 - 2/07/09 - optimum.reflex@gmail.com
-######################################################
-hlp () { # Help function
- echo "usage: $0 [--help] [archive] [sources]"
- echo "[sources] is the files or folder you want added to the archive."
- echo
- echo "[archive] is the name of the archive generated, including extension."
- echo "Extensions are: .7z .zip .bz2 .gz .lzma .tar.*"
- exit 0
-}
-
-if [ $# -lt 2 ]; then # Need atleast an archive and one source
- hlp
-fi
-
-tarfunc () { # function that does the work
- MSG="packing [$SRCD] to [$DIR/$TAR]... "
- case "$TAR" in
- *.7z )
- echo -n $MSG
- /usr/bin/7z a -mx=9 $DIR/$TAR $SRC
- ;;
- *.tar )
- echo -n $MSG
- /bin/tar -acf $DIR/$TAR $SRC
- ;;
- *.t* )
- echo -n $MSG
- /bin/tar -acZf $DIR/$TAR $SRC
- ;;
- *.bz2 )
- echo -n $MSG
- /bin/bzip2 -cq9 $SRC > $DIR/$TAR
- ;;
- *.gz )
- echo -n $MSG
- /bin/gzip -cq9 $SRC > $DIR/$TAR
- ;;
- *.zip )
- echo -n $MSG
- /usr/bin/zip -qr9 $DIR/$TAR $SRC
- ;;
- *.lzma )
- echo -n $MSG
- /usr/bin/lzma -cq9 $SRC > $DIR/$TAR
- ;;
- *)
- hlp;;
- esac
-}
-
-tdir () { # Determin target directory for archive
- if [ -d $1 ]; then
- if [ "$1" == "." ]; then
- DIR="$PWD"
- else
- DIR="$1"
- fi
- else
- DIR="$PWD"
- fi
-}
-
-case "$@" in
- *--help*) hlp;;
-esac
-
-TAR="`basename $1`"
-tdir `dirname $1` && shift
-
-if [ $# -gt 1 ]; then # If more than one source
- SRCD="$@" # all sources to $SRCD
- i=0 # counter
- while [ "$1" ]; do
- if [ $i -eq 0 ]; then # only if the first source
- SRC="$1" && shift
- if [ ! -r "$SRC" ]; then
- echo "Location [$SRC] does not exist or is unreadable."
- exit 1
- fi
- ((i++)) # increment
- else # if sources after the first
- if [ ! -r "$1" ]; then
- echo "Location [$1] does not exist or is unreadable."
- exit 1
- fi
- SRC="$SRC $1" && shift # copy current $SRC and append next source
- fi
- done
- tarfunc # do the work
-else # else if there is only one source
- SRC="$1"
- SRCD="$SRC" # copy $SRC
- if [ ! -r "$SRC" ]; then
- echo "Location [$SRC] does not exist or is unreadable."; exit 1
- elif [ -d "$SRC" ]; then # if source is a directory
- cd `dirname $SRC` # goto the directory one up from $SRC
- SRC="`basename $SRC`/" # change $SRC for correct directory packing structure
- fi
- tarfunc # do the work
-fi
-
-if [ $? -ne 0 ]; then # if last command failed
- cd $DIR
- rm -f $TAR && echo "failure detected, archive deleted."
- exit 1
-else
- echo "success!"; exit 0
-fi