Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

make the install script precise #463

Merged
merged 2 commits into from
Jan 14, 2022
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 12 additions & 12 deletions scripts/install.sh
Original file line number Diff line number Diff line change
Expand Up @@ -38,38 +38,38 @@ ARTIFACT_URL="${GITHUB_URL}/releases/download/${LATEST_VERSION}/${ARTIFACT}"
DIR=$(pwd)/easegress
BINDIR=${DIR}/bin

mkdir -p ./easegress
mkdir -p ${DIR}/easegress
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}/easegress/${ARTIFACT}
echo "Downloaded \"${ARTIFACT}\""
tar -zxf ./easegress/${ARTIFACT} -C easegress
tar -zxf ${DIR}/easegress/${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}/easegress/config.yaml
sed -i -e "s~##DIR##~${DIR}~g" ${DIR}/easegress/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}/easegress/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/easegress.service
sed -i -e "s~##BINDIR##~${BINDIR}~g" ${DIR}/easegress/easegress.service
sed -i -e "s~##DIR##~${DIR}~g" ${DIR}/easegress/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/easegress.service /etc/systemd/system
sudo systemctl daemon-reload
sudo systemctl enable easegress

Expand Down