Last active
January 20, 2025 17:15
-
-
Save hasalex/d1a3b7b1083c4f38399baa4ded6db243 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# Tomcat auto-start | |
# | |
# description: Auto-starts tomcat | |
# processname: tomcat | |
# pidfile: /var/run/tomcat.pid | |
#export JAVA_HOME=/usr/lib/jvm/java-6-openjdk | |
# Retrouver le répertoire d'installation de Java | |
export JAVA_HOME=`update-java-alternatives -l | grep java-6-openjdk | awk '{ print $3 }'` | |
export CATALINA_HOME=/usr/java/apache-tomcat | |
USER=java | |
# Fonction de démarrage | |
start() | |
{ | |
su -p -s /bin/sh - $USER $CATALINA_HOME/bin/startup.sh | |
} | |
# Fonction d'arrêt | |
stop() | |
{ | |
sh $CATALINA_HOME/bin/shutdown.sh | |
} | |
case $1 in | |
start) | |
start | |
;; | |
stop) | |
stop | |
;; | |
restart) | |
stop | |
sleep 1 | |
start | |
;; | |
esac | |
exit 0 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# Variables | |
#MIRROR_HOME=ftp://ftp.inria.fr/pub/Apache | |
MIRROR_HOME=ftp://mirror.switch.ch/mirror/apache/dist/ | |
TOMCAT_VERSION=6.0.20 | |
SCRIPTS_HOME=http://download.jtips.info/scripts | |
TOMCAT_USER=java | |
TOMCAT_HOME=/usr/java/apache-tomcat | |
# Création des répertoires temporaires | |
mkdir /tmp/tomcat | |
cd /tmp/tomcat | |
# Installation de Java | |
# TODO : vérifier la présence de Java 6 (sun) | |
apt-get -y install openjdk-6-jdk | |
apt-get -y install java-common | |
# Téléchargement et installation de tomcat | |
wget $MIRROR_HOME/tomcat/tomcat-6/v6.0.20/bin/apache-tomcat-$TOMCAT_VERSION.tar.gz | |
mkdir /usr/java | |
tar -xvf apache-tomcat-$TOMCAT_VERSION.tar.gz -C /usr/java/ | |
chown -R $TOMCAT_USER:$TOMCAT_USER $TOMCAT_HOME-$TOMCAT_VERSION | |
ln -s $TOMCAT_HOME-$TOMCAT_VERSION/ $TOMCAT_HOME | |
# Retirer les applications inutiles | |
rm -r $TOMCAT_HOME/webapps/examples | |
rm -r $TOMCAT_HOME/webapps/docs | |
# Script d'initialisation de service | |
wget $SCRIPTS_HOME/tomcat-init-ubuntu.sh | |
mv tomcat-init-ubuntu.sh $TOMCAT_HOME/bin/init-ubuntu.sh | |
ln -s $TOMCAT_HOME/bin/init-ubuntu.sh /etc/init.d/tomcat | |
chmod +x /etc/init.d/tomcat | |
ln -s /etc/init.d/tomcat /etc/rc1.d/K80tomcat | |
ln -s /etc/init.d/tomcat /etc/rc2.d/S80tomcat | |
# LOG4J | |
wget $MIRROR_HOME/logging/log4j/1.2.15/apache-log4j-1.2.15.tar.gz | |
tar -xvf apache-log4j-1.2.15.tar.gz apache-log4j-1.2.15/log4j-1.2.15.jar | |
mv apache-log4j-1.2.15/log4j-1.2.15.jar $TOMCAT_HOME/lib/ | |
rm -r apache-log4j-* | |
wget $MIRROR_HOME/tomcat/tomcat-6/v$TOMCAT_VERSION/bin/extras/tomcat-juli-adapters.jar | |
mv tomcat-juli-adapters.jar $TOMCAT_HOME/lib/ | |
wget $MIRROR_HOME/tomcat/tomcat-6/v$TOMCAT_VERSION/bin/extras/tomcat-juli.jar | |
mv tomcat-juli.jar $TOMCAT_HOME/bin/ | |
wget $SCRIPTS_HOME/tomcat-log4j.properties | |
mv tomcat-log4j.properties $TOMCAT_HOME/lib/log4j.properties | |
# Suppression des répertoires temporaires | |
rm -r /tmp/tomcat | |
# Démarrage de Tomcat | |
/etc/init.d/tomcat start |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment