Vous êtes sur la page 1sur 2

#!

/bin/bash
# setting color
RED='\033[0;31m'
GREEN='\033[0;32m'
BLUE='\033[0;34m'
NC='\033[0m'
# Read Password
current_directory="$(pwd)"
echo -n Sudo Password:
read -s password
echo

update_repository(){
echo $password | sudo -S apt-get update
}
sudo_command(){
echo $password | sudo -S $*
}
# Run Command
install(){
echo -e "${BLUE}Now installing $1...${NC}"
# echo "${NC}"
typeset ret_code

sudo_command apt-get install $1 -y

ret_code=$?
if [ $ret_code != 0 ]; then
echo -e "${RED}Error : [%d] when executing command: $1${NC}" $ret_code
return 1
fi
echo -e "${GREEN}$1 Installation Success${NC}"
return 0

install_packages(){
install git
install curl
install python-pip
install python-virtualenv
install build-essential
install openssh-server
install gcc
install gdal-bin
install gettext
install git-core
install libgeos-dev
install libjpeg-dev
install libpng-dev
install libpq-dev
install libproj-dev
install libxslt-dev
install patch
install python
install python-dev
install default-jdk
install unzip
install zip
}
install_tomcat(){
echo -e "${BLUE}Now installing tomcat 8.5 ${NC}"
sudo_command groupadd tomcat
sudo_command useradd -s /bin/false -g tomcat -d /opt/tomcat tomcat
sudo_command mkdir /opt/tomcat

sudo_command tar xzf apache-tomcat-8*tar.gz -C /opt/tomcat --strip-components=1


sudo_command chown -R tomcat: /opt/tomcat
sudo_command chmod -R 777 /opt/tomcat/
#sudo_command chmod -R g+r /opt/tomcat/
#sudo_command chgrp -R tomcat /opt/tomcat
#sudo_command chmod -R g+r /opt/tomcat/conf
#sudo_command chmod g+x /opt/tomcat/conf
#sudo_command chown -R tomcat: /opt/tomcat/webapps/ /opt/tomcat/work/
/opt/tomcat/temp/ /opt/tomcat/logs/
sudo_command cp tomcat.service /etc/systemd/system/
#sudo_command +x /opt/tomcat/latest/bin/*.sh

sudo_command systemctl daemon-reload


sudo_command systemctl start tomcat
sudo_command ufw allow 8080
sudo_command systemctl enable tomcat
echo -e "${BLUE}Tomcat 8.5 installation done!!! ${NC}"
}

install_geoserver(){
echo -e "${BLUE}Now installing GeoServer 2.9 ${NC}"
eval "cd $current_directory"

sudo_command cp geoserver*.war /opt/tomcat/webapps/


sudo_command service tomcat start
sudo_command rm /opt/tomcat/webapps/geoserver/WEB-INF/lib/postgis-stubs-
1.3.3.jar

#sudo_command service tomcat restart


echo -e "${BLUE}GeoServer 2.9 installation done ${NC}"
}

run_system(){
echo -e "${BLUE}System booting... ${NC}"
sudo_command service tomcat start
echo -e "${BLUE}System Stated successfully... ${NC}"
}

#Execute commands
update_repository
install_packages
install_tomcat
install_geoserver
run_system
eval "cd $current_directory"

Vous aimerez peut-être aussi