Добрый день, не могу выловить причину "unexpected end of file".
Если закомментировать все циклы и условия (именно все) то все в порядке
#!/bin/bash
#Some setup
ARROW=$(echo -e "\\e[1G------> ")
CNONE=$(echo -e "\\e[00m")
CGREEN=$(echo -e "\\e[1;32m")
CBLUE=$(echo -e "\\e[1;34m")
CRED=$(echo -e "\\e[1;31m")
#Copying git changes...
REPO_DIR="/opt/repo"
GIT_DIR="/opt/git/blabla.git"
BRANCH="master"
cd /opt/git/blabla.git || exit
while read -r oldref newref ref;
do
if [ "$newref" -eq "0000000000000000000000000000000000000000" ]; then continue; fi
if [ "$REPO_DIR" ] && [ -d "$REPO_DIR" ]; then
echo -e "${ARROW}${CBLUE}Deploying branch:${CNONE} ${BRANCH}"
cd $GIT_DIR || exit
sudo git --work-tree="$REPO_DIR" --git-dir="$GIT_DIR" checkout -q -f "$BRANCH"
break
fi
done
#Tomcat stop script
echo -e "${CBLUE}Stopping tomcat...${CNONE}"
if sudo service tomcat stop; then
echo -e "${CGREEN}Tomcat stopped${CNONE}"
else
echo -e "${CRED}Tomcat stop failed${CNONE}"
fi
#Kill java process
if sudo pkill -9 java; then
echo -e "${CGREEN}kill of JAVA successful${CNONE}"
else
echo -e "${CRED}kill of JAVA failed${CNONE}"
fi
# Maven deploy to ROOT
cd /opt/repo || exit
sudo mvn -e -f pom.xml clean package -s /opt/git/settings.xml
# Change folder access rights
cd /opt/tomcat #|| exit
sudo chown -R tomcat webapps
sudo chmod -R u+rx webapps
# Start Tomcat
echo -e "${CBLUE}Starting tomcat...${CNONE}"
if sudo service tomcat start; then
echo -e "${CGREEN}Tomcat started${CNONE}"
else
echo -e "${CRED}Tomcat start failed${CNONE}"
fi