-
Notifications
You must be signed in to change notification settings - Fork 0
/
scripts.sh
76 lines (61 loc) · 1.77 KB
/
scripts.sh
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
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
#!/bin/bash
# Color output
GREEN='\033[0;32m'
RED='\033[0;31m'
YELLOW="\033[0;33m"
WHITE='\033[0;37m'
RESET='\033[0m'
VERSION=$2
################################################################################
# CHECK REQUIREMENTS #
################################################################################
CheckRequirements()
{
echo -e "${YELLOW}Checking for wget and unzip ${RESET}"
# check we have composer and unzip
if command -v wget &> /dev/null
then
echo -e "${GREEN}Found wget.${RESET}"
else
echo -e "${RED}Could not find wget :(${RESET}"
exit 1
fi
if command -v unzip &> /dev/null
then
echo -e "${GREEN}Found unzip.${RESET}"
else
echo -e "${RED}Could not find unzip :(${RESET}"
fi
}
################################################################################
Help()
{
# Display Help
echo "Fetches scripts"
echo
echo "Syntax: scripts.sh [-h|v] VERSION"
echo "options:"
echo "h Print this Help."
echo "v Fetches scripts with a specific version"
echo
}
while getopts 'hb' flag; do
case "${flag}" in
h) Help ;;
v) GetVersion ;;
*) error "Unexpected option ${flag}" ;;
esac
done
# Check if we have the requirements
CheckRequirements
url="https://github.com/digihum/omeka-project-scripts/archive/refs/tags/v0.1.zip"
message="Downloaded latest scripts version"
getVersion(){
url="https://github.com/digihum/omeka-project-scripts/archive/refs/tags/v${VERSION}.zip"
message="Downloaded specific scripts version v${VERSION}"
}
rm -r scripts
wget $url -O scripts.zip
unzip -d scripts/ -j scripts.zip
rm scripts.zip
echo -e "${GREEN}${message}${RESET}"