-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbuild.bash
65 lines (53 loc) · 1.23 KB
/
build.bash
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
#!/bin/bash
docker info > /dev/null 2>&1
# Ensure that Docker is running...
if [ $? -ne 0 ]; then
echo "Docker is not running."
exit 1
fi
if [ -z "${1}" ]; then
DIR_NAME="."
else
DIR_NAME=${1}
fi
if [ "${DIR_NAME}" == "." ]; then
DIR_NAME="_temp-dir"
fi
if [ "${2}" == "php82" ]; then
PHP_VER="php82"
else
PHP_VER="php82"
fi
docker run --rm \
--pull=always \
-v "$(pwd)":/opt \
-w /opt \
laravelsail/${PHP_VER}-composer:latest \
bash -c "laravel new ${DIR_NAME}"
CYAN='\033[0;36m'
LIGHT_CYAN='\033[1;36m'
BOLD='\033[1m'
NC='\033[0m'
if [ "${DIR_NAME}" == "_temp-dir" ]; then
CD_TEXT="docker compose up"
else
CD_TEXT="cd ${DIR_NAME} && docker compose up"
fi
if sudo -n true 2>/dev/null; then
sudo chown -R $USER: .
echo -e "${BOLD}Get started with:${NC} ${CD_TEXT}"
else
echo -e "${BOLD}Please provide your password so we can make some final adjustments to your application's permissions.${NC}"
echo ""
sudo chown -R $USER: .
echo ""
echo -e "${BOLD}Thank you! We hope you build something incredible. Dive in with:${NC} ${CD_TEXT}"
fi
shopt -s dotglob
cp -rf files/* $DIR_NAME
if [ "${DIR_NAME}" == "_temp-dir" ]; then
mv $DIR_NAME/* .
rm -d $DIR_NAME
rm -dR "files"
rm "build.bash"
fi