forked from Rickfdalton/aliases-and-scripts
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathwso2-init
43 lines (35 loc) · 1.17 KB
/
wso2-init
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
34
35
36
37
38
39
40
41
42
43
#!/bin/bash
# This script unzips a WSO2 product pack into the current directory.
# The script expects the product version as an argument.
# Eg: wso2-init --apim-4.0.0
# Check if an argument is passed
if [ -z "$1" ]; then
echo "Usage: wso2-init --<product-version>"
exit 1
fi
# Extract the product version from the argument
ARG=${1#--} # Remove the leading "--" from the argument
# Define the folder containing the zip files
FRESH_PACKS_DIR="/Users/jathavan/Desktop/wso2-products/fresh-packs"
# Check if the folder exists
if [ ! -d "$FRESH_PACKS_DIR" ]; then
echo "Error: Directory '$FRESH_PACKS_DIR' does not exist."
exit 1
fi
# Construct the expected zip file name
ZIP_FILE="$FRESH_PACKS_DIR/$ARG.zip"
# Check if the zip file exists in the folder
if [ ! -f "$ZIP_FILE" ]; then
echo "Error: File '$ZIP_FILE' does not exist in '$FRESH_PACKS_DIR'."
exit 1
fi
# Unzip the specified file into the current directory
echo "Unzipping '$ZIP_FILE' into the current directory..."
unzip -q "$ZIP_FILE" -d .
# Verify if the unzipping was successful
if [ $? -eq 0 ]; then
echo "Successfully unzipped '$ZIP_FILE'."
else
echo "Failed to unzip '$ZIP_FILE'."
exit 1
fi