-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathinstall.sh
executable file
·64 lines (53 loc) · 2.27 KB
/
install.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
#!/bin/bash
# Repository info
VERSION='0.9.0' #can be '0.0.1', 'master', 'develop', 'whatever'
TAGS_OR_HEADS='tags' # 'heads' for branches, 'tags' for tag-releases
REPOSITORY_OWNER='strategio-digital'
REPOSITORY_NAME='megio-starter'
# Github
GITHUB_FOLDER_NAME="${REPOSITORY_NAME}-${VERSION}"
GITHUB_ZIP_URL="https://github.com/${REPOSITORY_OWNER}/${REPOSITORY_NAME}/archive/refs/${TAGS_OR_HEADS}/${VERSION}.zip"
# Colors
RED='\033[0;31m'
GREEN='\033[0;32m'
YELLOW='\033[1;33m'
NC='\033[0m'
help() {
echo -e "${YELLOW}COMMANDS:"
echo -e "${GREEN}./install.sh create <project-folder>"
echo -e "./install.sh update"
echo -e "${NC}"
}
if test "$1" = "create"; then
echo -e ""
echo -e "${GREEN}Project creation started...${NC}"
mkdir $2
curl -L0 ${GITHUB_ZIP_URL} --output "./$2/project.zip"
unzip -q "./$2/project.zip" -d "./$2/"
cp -r "./$2/${GITHUB_FOLDER_NAME}/" "./$2/"
rm -rf "./$2/${GITHUB_FOLDER_NAME}" "./$2/project.zip"
echo -e ""
echo -e "${GREEN}Project successfully created!"
echo -e "Now, you can follow installation guide in ${YELLOW}readme.md${NC}"
elif test "$1" = "update"; then
echo -e ""
echo -e "${GREEN}Project update started...${NC}"
curl -L0 ${GITHUB_ZIP_URL} --output "./project.zip"
unzip -q "./project.zip" -d "./.temp-folder/"
cp -r "./.temp-folder/${GITHUB_FOLDER_NAME}/bin/console" "./bin/console"
cp -r "./.temp-folder/${GITHUB_FOLDER_NAME}/docker/" "./docker/"
cp -r "./.temp-folder/${GITHUB_FOLDER_NAME}/www/index.php" "./www/index.php"
cp -r "./.temp-folder/${GITHUB_FOLDER_NAME}/.env.example" "./.env.example"
cp -r "./.temp-folder/${GITHUB_FOLDER_NAME}/.gitignore" "./.gitignore"
cp -r "./.temp-folder/${GITHUB_FOLDER_NAME}/docker-compose.yml" "./docker-compose.yml"
cp -r "./.temp-folder/${GITHUB_FOLDER_NAME}/docker-entrypoint.sh" "./docker-entrypoint.sh"
cp -r "./.temp-folder/${GITHUB_FOLDER_NAME}/Dockerfile" "./Dockerfile"
cp -r "./.temp-folder/${GITHUB_FOLDER_NAME}/project.sh" "./project.sh"
cp -r "./.temp-folder/${GITHUB_FOLDER_NAME}/vite.config.ts" "./vite.config.ts"
rm -rf "./project.zip" "./.temp-folder" "./temp/*", "./www/temp"
echo -e ""
echo -e "${GREEN}Project successfully updated!"
echo -e "Now, you can run command ${YELLOW}'docker-compose up --build -d'${NC}."
else
help
fi