CentOS의 biz라는 계정에 java 관련 프로그램(java, tomcat, maven, etc) 설치하는 간단한 bash 쉘 스크립트(install.sh)
해당 내용으로 쉘 파일을 만들고 사용 (디렉토리 먼저 생성 필요)
ex) install.sh dir 후에 install.sh java
#!/bin/sh
#Enter user account
USER=biz
check_user()
{
if [ $USER != `/usr/bin/whoami` ] ; then
echo "=== Error. User is not $USER"
exit -1;
fi
}
make_dir()
{
echo "=== Install default directory : Start"
mkdir ~/apps ~/deploy ~/scripts ~/logs ~/logs/nginx ~/src
echo "=== Install default directory : End"
}
install_java()
{
echo "=== Install java : Start"
http://download.oracle.com/otn-pub/java/jdk/8u181-b13/96a7b8442fe848ef90c96a2fad6ed6d1/jdk-8u181-linux-x64.tar.gz?AuthParam=1537253298_036a93e056704f23f51ee0e1e5140908
wget "http://download.oracle.com/otn-pub/java/jdk/8u181-b13/96a7b8442fe848ef90c96a2fad6ed6d1/jdk-8u181-linux-x64.tar.gz?AuthParam=1537253594_0606413d75133608b6bf7ca2136e364e" -O ~/apps/jdk-8u181-linux-x64.tar.gz
tar -xzf ~/apps/jdk-8u181-linux-x64.tar.gz -C ~/apps && rm ~/apps/jdk-8u181-linux-x64.tar.gz && ln -s ~/apps/jdk1.8.0_181 ~/apps/jdk
#JAVA DNS TTL Modify
echo 'networkaddress.cache.ttl=60' >> ~/apps/jdk/jre/lib/security/java.security
#set java path
echo 'export JAVA_HOME=~/apps/jdk' >> ~/.bashrc
echo 'export PATH=$JAVA_HOME/bin:$PATH' >> ~/.bashrc
source ~/.bashrc
#print java version
java -version
echo "=== Install java : End"
}
install_maven()
{
echo "=== Install maven : Start"
wget "http://apache.tt.co.kr/maven/maven-3/3.5.4/binaries/apache-maven-3.5.4-bin.tar.gz" -O ~/apps/apache-maven-3.5.4-bin.tar.gz
tar -xzf ~/apps/apache-maven-3.5.4-bin.tar.gz -C ~/apps && rm ~/apps/apache-maven-3.5.4-bin.tar.gz && ln -s ~/apps/apache-maven-3.5.4 ~/apps/maven
#set maven path
echo 'export M2_HOME=~/apps/maven' >> ~/.bashrc
echo 'export PATH=$PATH:$M2_HOME/bin' >> ~/.bashrc
source ~/.bashrc
#print maven version
mvn -version
echo "=== Install maven : End"
}
install_tomcat()
{
echo "=== Install tomcat : Start"
wget 'http://mirror.navercorp.com/apache/tomcat/tomcat-8/v8.5.34/bin/apache-tomcat-8.5.34.tar.gz' -O ~/apps/apache-tomcat-8.5.34.tar.gz
tar -xzf ~/apps/apache-tomcat-8.5.34.tar.gz -C ~/apps && rm ~/apps/apache-tomcat-8.5.34.tar.gz
#remove default tomcat webapps
rm -rf ~/apps/apache-tomcat-8.5.34/webapps && mkdir ~/apps/apache-tomcat-8.5.34/webapps
echo "=== Install tomcat : End"
}
#check user account
check_user
case "$1" in
dir)
echo "### Run make default dir ###"
make_dir
;;
java)
echo "### Run install java ###"
install_java
;;
maven)
echo "### Run install maven ###"
install_maven
;;
tomcat)
echo "### Run install tomcat ###"
install_tomcat
;;
*)
echo "Usage : $0 {dir|java|maven|tomcat}"
exit 1
esac
'리눅스 및 서버' 카테고리의 다른 글
CentOS 7 최소 설치 후 기본셋팅 (0) | 2017.04.24 |
---|---|
시간동기화 ntpd 실행 (0) | 2017.04.14 |
virtualbox 설치 및 셋팅, 리눅스 기본 셋팅 정리 (0) | 2016.06.18 |