-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathunzip
More file actions
executable file
·33 lines (29 loc) · 1.06 KB
/
unzip
File metadata and controls
executable file
·33 lines (29 loc) · 1.06 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
#!/bin/bash
[[ -z "$INFO_LEVEL" ]] && source ./bits/bootstrap/logging
OWNER=${OWNER-$USER}
SRC_FILE=$SRC_FILE
TARGET_DIR=$TARGET_DIR
TARGET_NAME=$TARGET_NAME
UNZIP_OUTPUT=/tmp/unzip.log
if [[ "`which unzip 2> /dev/null`" == "" ]]; then
if [[ "$OS" == "ubuntu" ]]; then
debug " -- Installing wget via apt-get"
$SUDO apt-get update > $UNZIP_OUTPUT 2>&1
ERROR="Unable to update apt-get due to ..." ./bits/bootstrap/failonerrors $? $UNZIP_OUTPUT
[ $? -ne 0 ] && exit 1
$SUDO apt-get install -y unzip > $UNZIP_OUTPUT 2>&1
ERROR="Unable to install unzip due to ..." ./bits/bootstrap/failonerrors $? $UNZIP_OUTPUT
[ $? -ne 0 ] && exit 1
else
error " -- Don't know how to install unzip on $OS"
exit 1
fi
fi
if [[ -e "$TARGET_DIR/$TARGET_NAME" ]]; then
debug " -- Already unzipped $SRC_FILE to $TARGET_DIR/$TARGET_NAME"
else
OWNER=$OWNER ./bits/bootstrap/mkdir $TARGET_DIR
unzip $SRC_FILE -d $TARGET_DIR > $UNZIP_OUTPUT 2>&1
ERROR="Unable to unzip due to ..." ./bits/bootstrap/failonerrors $? $UNZIP_OUTPUT
[ $? -ne 0 ] && exit 1
fi