initializr/static/install.sh

96 lines
2.3 KiB
Bash
Raw Normal View History

2013-08-04 20:50:06 +08:00
#!/bin/sh
set -e
# set -x
VERSION="1.0.0.RC1"
2013-08-04 20:50:06 +08:00
if [ -z "${PREFIX}" ]; then
PREFIX="/usr/local/bin"
fi
if [ -z "${JAR_FILE}" ]; then
2013-08-05 19:53:16 +08:00
JAR_FILE="/tmp/spring.zip"
2013-08-04 20:50:06 +08:00
if [ -z "${JAR_URL}" ]; then
echo "Downloading spring ${VERSION} distribution"
echo
JAR_URL="https://repo.spring.io/milestone/org/springframework/boot/spring-boot-cli/${VERSION}/spring-boot-cli-${VERSION}-bin.zip"
2013-08-04 20:50:06 +08:00
curl --progress-bar --fail "$JAR_URL" -o "$JAR_FILE"
fi
fi
trap "echo Installation failed." EXIT
test -f "${JAR_FILE}"
2013-08-05 19:53:16 +08:00
if [ -z "${SPRING_HOME}" ]; then
SPRING_HOME="${HOME}/.spring"
fi
mkdir -p "${SPRING_HOME}"
2013-08-04 20:50:06 +08:00
cd "${SPRING_HOME}"
2013-08-05 19:53:16 +08:00
rm -rf spring* bin lib
unzip -o "$JAR_FILE"
mv spring*/* .
rm -rf spring*
2013-08-04 20:50:06 +08:00
echo
2013-08-05 19:53:16 +08:00
test -x "${SPRING_HOME}/bin/spring"
2013-08-04 20:50:06 +08:00
echo "spring ${VERSION} has been installed in your home directory (~/.spring)."
echo
2013-08-05 19:53:16 +08:00
if rm -f "$PREFIX/spring" && ln -sf "${SPRING_HOME}/bin/spring" "$PREFIX/spring" >/dev/null 2>&1; then
2013-08-04 20:50:06 +08:00
echo
2013-08-05 19:53:16 +08:00
echo "Linking ${SPRING_HOME}/bin/spring to $PREFIX/spring for your convenience."
2013-08-04 20:50:06 +08:00
cat <<"EOF"
To get started:
$ spring --version
$ spring help
And take a look at the README at https://github.com/springsource/spring-boot#readme.
EOF
elif type sudo >/dev/null 2>&1; then
2013-08-05 19:53:16 +08:00
echo "Linking ${SPRING_HOME}/bin/spring to $PREFIX/spring for your convenience."
2013-08-04 20:50:06 +08:00
echo "This may prompt for your password."
2013-08-05 19:53:16 +08:00
if sudo rm -f "$PREFIX/spring" && sudo ln -sf "${SPRING_HOME}/bin/spring" "$PREFIX/spring" >/dev/null 2>&1; then
2013-08-04 20:50:06 +08:00
cat <<"EOF"
To get started:
$ spring --version
$ spring help
And take a look at the README at https://github.com/springsource/spring-boot#readme.
EOF
else
cat <<"EOF"
Couldn't create the symlink. Please either:
(1) Run the following as root:
2013-08-05 19:53:16 +08:00
cp ${SPRING_HOME}/bin/spring /usr/bin/spring
(2) Add ${SPRING_HOME}/bin to your path, or
2013-08-04 20:50:06 +08:00
(3) Rerun this command to try again.
Then to get started, take a look at 'spring help' or see the README at
https://github.com/springsource/spring-boot#readme.
EOF
fi
else
cat <<"EOF"
Now you need to do one of the following:
(1) Add ~/.spring to your path, or
(2) Run this command as root:
2013-08-05 19:53:16 +08:00
cp ${SPRING_HOME}/bin /usr/bin/spring
2013-08-04 20:50:06 +08:00
Then to get started, take a look at 'spring help' or see the README at
https://github.com/springsource/spring-boot#readme.
EOF
fi
trap - EXIT