This repository has been archived by the owner on Feb 3, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 16
/
Copy pathinstall.sh
executable file
·148 lines (134 loc) · 4.66 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
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
#!/bin/bash
set -o errexit
set -o pipefail
set -o nounset
# Install provided ddev release
RED='\033[31m'
GREEN='\033[32m'
YELLOW='\033[33m'
RESET='\033[0m'
OS=$(uname)
ARCH=$(arch)
if [ ${ARCH} = "i386" ] || [ ${ARCH} = "x86_64" ]; then ARCH=amd64; fi
USER=$(whoami)
SHACMD=""
FILEBASE=""
CURRENT_DIR=$PWD
DDEV_VERSION=$(cat ./.ddev_version.txt)
# Check Docker is running
if docker run --rm -t busybox:latest ls >/dev/null
then
printf "docker is running, continuing."
else
printf "${RED}Docker is not running and is required for this script, exiting.\n${RESET}"
exit 1
fi
# Explain what the script does
printf "
${GREEN}
####
# This script will install everything you need to participate in this
# contribution event.
#
# Feel free to first inspect the script before continuing if you like.
# -To do this just open it with a text editor
#
# It does the following:
# -Install the DDEV-Local development tool
# -Copy required components to ~/sprint
# -Pre-loads docker images for the toolkit:
#
####
${RESET}"
echo ""
printf "Installing docker images for ddev to use...\n"
# Allow faster turnaround on testing by export QUICKSPRINT_SKIP_IMAGE_INSTALL=true
if [ -z "${QUICKSPRINT_SKIP_IMAGE_INSTALL:-}" ]; then
if command -v xzcat >/dev/null; then
xzcat ddev_tarballs/ddev_docker_images.${ARCH}.*.tar.xz | docker load
elif [[ "$OS" == "Darwin" ]]; then
gzip -dc ddev_tarballs/ddev_docker_images.${ARCH}.*.tar.xz | docker load
else
printf "${YELLOW}Unable to load ddev_docker_images. They will load at first 'ddev start'.${RESET}\n"
fi
fi
TARBALL=""
case "${OS}/${ARCH}" in
Linux/amd64)
TARBALL=ddev_tarballs/ddev_linux-amd64.${DDEV_VERSION}.tar.gz
;;
Linux/arm64)
TARBALL=ddev_tarballs/ddev_linux-arm64.${DDEV_VERSION}.tar.gz
;;
Darwin/amd64)
TARBALL=ddev_tarballs/ddev_macos-amd64.${DDEV_VERSION}.tar.gz
;;
Darwin/arm64)
TARBALL=ddev_tarballs/ddev_macos-arm64.${DDEV_VERSION}.tar.gz
;;
MINGW64_NT*)
echo ""
# Assume if DDEV_INSTALL_DIR is set that we *do* need ddev on Windows, install it.
# Otherwise, we'll do the install using the installer below.
if [ ! -z "${DDEV_INSTALL_DIR:-}" ]; then
TARBALL=ddev_tarballs/ddev_windows-amd64.${DDEV_VERSION}.tar.gz
fi
;;
*)
printf "${RED}No ddev binary is available for ${OS}/${ARCH}${RESET}\n"
exit 2
;;
esac
if [ ! -z "$TARBALL" ] ; then
tar -xzf ${TARBALL} -C /tmp
chmod ugo+x /tmp/ddev
if command -v ddev >/dev/null && [ -z "${DDEV_INSTALL_DIR:-}" ] ; then
printf "\n${RED}A version of ddev already exists in $(command -v ddev); You may upgrade it using your normal upgrade technique. Not installing a new version.${RESET}\n"
else
# Calling script may have already set DDEV_INSTALL_DIR, otherwise we respect and use it.
if [ ! -z "${DDEV_INSTALL_DIR:-}" ]; then
# It's the responsibility of the caller to have created the directory
# and to have added the directory to $PATH
echo "Installing for tests into DDEV_INSTALL_DIR='${DDEV_INSTALL_DIR:-}'"
fi
DDEV_INSTALL_DIR=${DDEV_INSTALL_DIR:-/usr/local/bin}
if [ ! -d ${DDEV_INSTALL_DIR:-} ] ; then
echo "DDEV_INSTALL_DIR '${DDEV_INSTALL_DIR:-}' does not exist"
exit 3
fi
printf "Ready to place ddev in directory ${DDEV_INSTALL_DIR:-}.\n"
BINOWNER=$(ls -ld ${DDEV_INSTALL_DIR:-} | awk '{print $3}')
if [[ "$BINOWNER" == "$USER" ]]; then
mv -f /tmp/ddev /tmp/mkcert ${DDEV_INSTALL_DIR:-}
else
printf "${YELLOW}Running \"sudo mv /tmp/ddev $DDEV_INSTALL_DIR\" Please enter your password if prompted.${RESET}\n"
sudo mv /tmp/ddev /tmp/mkcert ${DDEV_INSTALL_DIR:-}
fi
fi
fi
if ! command -v ddev >/dev/null && [[ "$OS" =~ "MINGW64" ]] ; then
printf "${YELLOW}Running the ddev_windows_installer. Please allow privileges as requested${RESET}\n"
# Silent install of ddev for windows
cmd //c $PWD/ddev_tarballs/ddev_windows_installer.${DDEV_VERSION}.exe //S
printf "${GREEN}Installed ddev using the ddev_windows_installer. It may not be in your PATH until you open a new window.${RESET}\n"
fi
mkdir -p ~/sprint
cp start_sprint.sh ~/sprint
cp sprint.tar.xz ~/sprint
printf "
${GREEN}
######
#
# Your ddev and the contribution event kit are now ready to use,
# Please open a NEW WINDOW to make sure you have any additional PATHs
# and execute the following commands to start:
#
# IN A NEW WINDOW:
#
# ${YELLOW}mkcert -install${GREEN}
# ${YELLOW}cd ~/sprint${GREEN}
# ${YELLOW}./start_sprint.sh${GREEN}
#
######
${RESET}
"