O problema foi o comando de saída. Eu coloquei no final do meu script. Funciona perfeitamente. Aqui está o meu script:
#!/bin/bash
#################
# Change this values
#################
psqluser="koko28" # Database username
psqlpass="pass123" # Database password
psqldb="kokodb28" # Database name
#################################################
# #
# PLEASE DO NOT CHANGE THE FOLLOWING CODES #
# #
#################################################
#################
# Dependicies
#################
sudo apt-get update
sudo apt-get update
sudo apt-get install unzip apache2 php5 php5-gd php5-curl php5-pgsql postgresql-9.4 postgis postgresql-9.4-postgis-2.1 postgresql-contrib-9.4 tomcat8 git g++ php5-dev libgdal1-dev drush -y
#################
# Database
#################
sudo printf "CREATE USER $psqluser WITH PASSWORD '$psqlpass';\nCREATE DATABASE $psqldb WITH OWNER $psqluser;" > cartaro.sql
sudo -u postgres psql -f cartaro.sql
echo "Running postgis.sql"
sudo -u postgres psql -d $psqldb -f /usr/share/postgresql/9.4/contrib/postgis-2.1/postgis.sql
echo "Running postgis_comments.sql"
sudo -u postgres psql -d $psqldb -f /usr/share/postgresql/9.4/contrib/postgis-2.1/postgis_comments.sql
echo "Running spatial_ref_sys.sql"
sudo -u postgres psql -d "$psqldb" -f /usr/share/postgresql/9.4/contrib/postgis-2.1/spatial_ref_sys.sql
sudo -u postgres psql -d "$psqldb" -c "grant all on geometry_columns to '$psqluser';"
sudo -u postgres psql -d "$psqldb" -c "grant all on spatial_ref_sys to '$psqluser';"
echo "Finished Database section"
#################
# Tomcat configuration
#################
cd /tmp
echo "Backing up tomcat web.xml origin file"
sudo mv /var/lib/tomcat8/conf/web.xml /var/lib/tomcat8/conf/web.bak
echo "Getting custom one"
wget http://qgis.fr/script/tomcat.xml
echo "Replacing"
sudo mv tomcat.xml /var/lib/tomcat8/conf/web.xml
echo "Tomcat configration finished"
#################
# Geoserver
#################
echo "Getting goserverip file"
wget http://qgis.fr/script/geoserver.zip
echo "Putting in the riht places"
sudo unzip -o geoserver.zip geoserver.war -d /var/lib/tomcat8/webapps/
echo "Backing up geoserver web.xml origin file"
sudo mv /var/lib/tomcat8/webapps/geoserver/WEB-INF/web.xml /var/lib/tomcat8/webapps/geoserver/WEB-INF/web.bak
echo "Getting custom one"
wget http://qgis.fr/script/geoserver.xml
echo "Replacing"
sudo mv geoserver.xml /var/lib/tomcat8/conf/web.xml
echo "Restart tomcat service to take effect the changes"
service tomcat8 restart
echo "Geoserver configration finished"
#################
# Gdal
#################
git clone https://github.com/geonef/php5-gdal.git && cd php5-gdal
phpize
./configure
make
sudo make install
printf '; configuration for GDAL module\n extension=gdal.so\n' > /etc/php5/mods-available/gdal.ini
php5enmod gdal
sudo service apache2 restart
#################
# Preparing Cartaro
#################
echo "Getting goserverip file"
wget http://qgis.fr/script/cartaro.zip
echo "Putting in the riht places"
sudo unzip -o cartaro.zip
sudo cp -r cartaro/* /var/www/html/
sudo cp /var/www/html/sites/default/default.settings.php /var/www/html/sites/default/settings.php
sudo mkdir /var/www/html/sites/default/files/
sudo chmod -R 777 /var/www/html/sites/default/*
sudo rm /var/www/html/index.html
#################
# Cartaro
#################
cd /var/www/html/
echo "Installing Cartaro"
sudo drush site-install cartaro --db-url="pgsql://$psqluser:$psqlpass@localhost/$psqldb" --site-name=Koko site --account-name=admin [email protected] --account-pass=geoserver --yes
#################
# Cleaning up
#################
echo "Cleaning"
sudo rm -r /tmp/cartaro* /tmp/geo*
echo "Cleaned"
echo "End of the script"
exit