-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathinstall.sh
More file actions
executable file
·33 lines (28 loc) · 989 Bytes
/
Copy pathinstall.sh
File metadata and controls
executable file
·33 lines (28 loc) · 989 Bytes
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
#!/usr/bin/env bash
set -euo pipefail
# Installer for phpenv.
#
# Works in two ways:
# 1. Run from a local checkout: ./install.sh
# 2. Piped from the web: curl -fsSL <raw-url>/install.sh | bash
# (clones the repo into ~/.phpenv first)
REPO_URL="${PHPENV_REPO_URL:-https://github.com/patchlevel/php.git}"
DEFAULT_ROOT="${PHPENV_ROOT:-$HOME/.phpenv}"
# Figure out whether we are running from inside a checkout.
SCRIPT_DIR=""
if [ -n "${BASH_SOURCE[0]:-}" ] && [ -f "${BASH_SOURCE[0]}" ]; then
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
fi
if [ -n "$SCRIPT_DIR" ] && [ -f "$SCRIPT_DIR/bin/phpenv" ]; then
PHPENV_ROOT="$SCRIPT_DIR"
else
PHPENV_ROOT="$DEFAULT_ROOT"
if [ -d "$PHPENV_ROOT/.git" ]; then
echo "Updating existing checkout at $PHPENV_ROOT ..."
git -C "$PHPENV_ROOT" pull --ff-only
else
echo "Cloning $REPO_URL into $PHPENV_ROOT ..."
git clone "$REPO_URL" "$PHPENV_ROOT"
fi
fi
exec "$PHPENV_ROOT/bin/phpenv" install