Skip to content

Commit

Permalink
make the install script precise (#463)
Browse files Browse the repository at this point in the history
* make the install script precise

* add the promopt to input the installation directory
  • Loading branch information
haoel authored Jan 14, 2022
1 parent 8a94330 commit 60fcbfc
Showing 1 changed file with 15 additions and 13 deletions.
28 changes: 15 additions & 13 deletions scripts/install.sh
Original file line number Diff line number Diff line change
Expand Up @@ -35,41 +35,43 @@ ARTIFACT="easegress-${LATEST_VERSION}-${OS}-${ARCH}.tar.gz"
ARTIFACT_URL="${GITHUB_URL}/releases/download/${LATEST_VERSION}/${ARTIFACT}"


DIR=$(pwd)/easegress
read -p "Enter the install directory [$(pwd)/easegress]: " DIR
DIR=${DIR:-$(pwd)/easegress}
BINDIR=${DIR}/bin

mkdir -p ./easegress
mkdir -p ${DIR}
echo "Create the directory - \"${DIR}\" successfully."
echo "Downloading the release file - \"${ARTIFACT}\" ..."
curl -sL ${ARTIFACT_URL} -o ./easegress/${ARTIFACT}
curl -sL ${ARTIFACT_URL} -o ${DIR}/${ARTIFACT}
echo "Downloaded \"${ARTIFACT}\""
tar -zxf ./easegress/${ARTIFACT} -C easegress
tar -zxf ${DIR}/${ARTIFACT} -C easegress
echo "Extract the files successfully"

# Fourth - configure the easegress
echo "Download the config.yaml file"
RAW_GITHUB_URL=https://raw.githubusercontent.com/megaease/easegress
curl -sL ${RAW_GITHUB_URL}/main/scripts/config.yaml -o ./easegress/config.yaml
sed -i -e "s~##DIR##~${DIR}~g" ./easegress/config.yaml
curl -sL ${RAW_GITHUB_URL}/main/scripts/config.yaml -o ${DIR}/config.yaml
sed -i -e "s~##DIR##~${DIR}~g" ${DIR}/config.yaml

if [[ "${OS}" == "linux" ]]; then

# SELinux prevents you from running a system service where the binary is in a user's home directory.
# We have to copy the binary to a proper directory, such as /usr/local/bin
if [[ "${DISTRO}" == "CentOS"* ]] && [[ $(getenforce) != "Disabled" ]]; then
if [[ "${DISTRO}" == "CentOS"* ]] && [[ $(getenforce) != "Disabled" ]] && [[ "$(pwd)" == "/home"* ]]; then
BINDIR=/usr/local/bin
echo "Dealing with SELinux, copy Easegress to ${BINDIR}"
sudo cp -f ./easegress/bin/* ${BINDIR}
echo "SELinux enabled, cannot install in home, copy Easegress to ${BINDIR}"
sudo cp -f ${DIR}/bin/* ${BINDIR}
fi

# Prepare the unit file for Systemd
echo "Configuring the systemd unit file..."
curl -sL ${RAW_GITHUB_URL}/main/scripts/easegress.service -o ./easegress/easegress.service
sed -i -e "s~##BINDIR##~${BINDIR}~g" ./easegress/easegress.service
sed -i -e "s~##DIR##~${DIR}~g" ./easegress/easegress.service
curl -sL ${RAW_GITHUB_URL}/main/scripts/easegress.service -o ${DIR}/easegress.service
sed -i -e "s~##BINDIR##~${BINDIR}~g" ${DIR}/easegress.service
sed -i -e "s~##DIR##~${DIR}~g" ${DIR}/easegress.service

# install the systemd unit file
echo "Enable the easegress service"
sudo cp -f ./easegress/easegress.service /etc/systemd/system
sudo cp -f ${DIR}/easegress.service /etc/systemd/system
sudo systemctl daemon-reload
sudo systemctl enable easegress

Expand Down

0 comments on commit 60fcbfc

Please sign in to comment.