~charmers/charms/precise/syncope/trunk

« back to all changes in this revision

Viewing changes to hooks/install

  • Committer: Francesco Chicchiriccò
  • Date: 2014-03-05 13:39:50 UTC
  • Revision ID: francesco.chicchiricco@tirasa.net-20140305133950-01o0bysa4iwcxqju
Fixing issues as per observations raised in bug 1284738

Show diffs side-by-side

added added

removed removed

Lines of Context:
2
2
set -eu
3
3
source inc/common
4
4
 
5
 
# 1. Generate and build Maven overlay project (if not already available)
 
5
# Generate and build Maven overlay project (if not already available)
6
6
 
7
7
add-apt-repository -y ppa:natecarlson/maven3
8
8
apt-get update
15
15
        -DarchetypeGroupId=org.apache.syncope \
16
16
        -DarchetypeArtifactId=syncope-archetype \
17
17
        -DarchetypeRepository=http://repo1.maven.org/maven2 \
18
 
        -DarchetypeVersion=1.1.5 \
 
18
        -DarchetypeVersion=1.1.6 \
19
19
        -DgroupId=net.tirasa.syncope \
20
20
        -DartifactId=$PROJECT_NAME \
21
21
        -Dversion=1.0-SNAPSHOT \
29
29
else
30
30
    juju-log "Apache Syncope overlay project already present"
31
31
fi
32
 
 
33
 
# 2. Download the configured JEE container and do some basic setup
34
 
 
35
 
shopt -s nocasematch
36
 
if [ "$JEE_CONTAINER" == "glassfish" ]; then 
37
 
    juju-log "Go for Glassfish"
38
 
else
39
 
    if [ "$JEE_CONTAINER" == "jboss" ]; then
40
 
        juju-log "Go for JBoss"
41
 
    else
42
 
        TOMCAT_VERSION="7.0.52"
43
 
        juju-log "Go for Tomcat $TOMCAT_VERSION under $TOMCAT_HOME"
44
 
        
45
 
        if [ ! -d $TOMCAT_HOME ]; then
46
 
            juju-log "Downloading Tomcat $TOMCAT_VERSION..."
47
 
 
48
 
            cd /tmp
49
 
            wget_output=$(wget -qN https://archive.apache.org/dist/tomcat/tomcat-7/v$TOMCAT_VERSION/bin/apache-tomcat-$TOMCAT_VERSION.tar.gz)
50
 
            if [ $? -ne 0 ]; then
51
 
                juju-log "Cannot download Tomcat $TOMCAT_VERSION: aborting"
52
 
                exit $?
53
 
            fi
54
 
            wget_output=$(wget -qN https://archive.apache.org/dist/tomcat/tomcat-7/KEYS)
55
 
            if [ $? -ne 0 ]; then
56
 
                juju-log "Cannot download Tomcat KEYS: aborting"
57
 
                exit $?
58
 
            fi
59
 
            wget_output=$(wget -qN https://archive.apache.org/dist/tomcat/tomcat-7/v$TOMCAT_VERSION/bin/apache-tomcat-$TOMCAT_VERSION.tar.gz.asc)
60
 
            if [ $? -ne 0 ]; then
61
 
                juju-log "Cannot download Tomcat $TOMCAT_VERSION ASC: aborting"
62
 
                exit $?
63
 
            fi
64
 
            wget_output=$(wget -qN https://archive.apache.org/dist/tomcat/tomcat-7/v$TOMCAT_VERSION/bin/apache-tomcat-$TOMCAT_VERSION.tar.gz.md5)
65
 
            if [ $? -ne 0 ]; then
66
 
                juju-log "Cannot download Tomcat $TOMCAT_VERSION MD5: aborting"
67
 
                exit $?
68
 
            fi
69
 
 
70
 
            # Verify the downloaded archive
71
 
            md5sum --status -c apache-tomcat-$TOMCAT_VERSION.tar.gz.md5
72
 
            if [ $? -ne 0 ]; then
73
 
                juju-log "$TOMCAT_VERSION MD5 verification failed: aborting"
74
 
                exit $?
75
 
            fi
76
 
            gpg_output=$(gpg --import KEYS)
77
 
            gpg_output=$(gpg --verify apache-tomcat-$TOMCAT_VERSION.tar.gz.asc)
78
 
            if [ $? -ne 0 ]; then
79
 
                juju-log "$TOMCAT_VERSION ASC verification failed: aborting"
80
 
                exit $?
81
 
            fi
82
 
            
83
 
            # Install Tomcat and perform basic configuration
84
 
            cd /opt
85
 
            tar xvzf /tmp/apache-tomcat-$TOMCAT_VERSION.tar.gz
86
 
            ln -s apache-tomcat-$TOMCAT_VERSION apache-tomcat
87
 
 
88
 
            cp $TOMCAT_HOME/conf/server.xml $TOMCAT_HOME/conf/server.xml.orig
89
 
            sed -i "s/8080/$HTTP_PORT/g" $TOMCAT_HOME/conf/server.xml
90
 
 
91
 
            cat > $TOMCAT_HOME/bin/setenv.sh <<EOF
92
 
JAVA_OPTS="-Djava.awt.headless=true -Dfile.encoding=UTF-8 
93
 
-server -Xms1536m -Xmx1536m
94
 
-XX:+CMSClassUnloadingEnabled -XX:+UseConcMarkSweepGC
95
 
-XX:NewSize=256m -XX:MaxNewSize=256m -XX:PermSize=256m 
96
 
-XX:MaxPermSize=512m -XX:+DisableExplicitGC"
97
 
 
98
 
EOF
99
 
            chmod 755 $TOMCAT_HOME/bin/setenv.sh
100
 
            
101
 
            cat > /etc/init.d/apache-tomcat <<EOF
102
 
### BEGIN INIT INFO
103
 
# Provides:          apache-tomcat
104
 
# Required-Start:    \$local_fs \$remote_fs \$network
105
 
# Required-Stop:     \$local_fs \$remote_fs \$network
106
 
# Should-Start:      \$named
107
 
# Should-Stop:       \$named
108
 
# Default-Start:     2 3 4 5
109
 
# Default-Stop:      0 1 6
110
 
# Short-Description: Start Tomcat.
111
 
# Description:       Start the Tomcat servlet engine.
112
 
### END INIT INFO
113
 
 
114
 
case \$1 in
115
 
 
116
 
start)
117
 
  sh $TOMCAT_HOME/bin/startup.sh
118
 
  ;;
119
 
 
120
 
stop)
121
 
  sh $TOMCAT_HOME/bin/shutdown.sh
122
 
  ;;
123
 
 
124
 
restart)
125
 
  sh $TOMCAT_HOME/bin/shutdown.sh
126
 
  sh $TOMCAT_HOME/bin/startup.sh
127
 
  ;;
128
 
esac
129
 
 
130
 
exit
131
 
 
132
 
EOF
133
 
            chmod 755 /etc/init.d/apache-tomcat
134
 
            update-rc.d apache-tomcat defaults
135
 
        else
136
 
            juju-log "Tomcat already set up under $TOMCAT_HOME"
137
 
        fi
138
 
    fi
139
 
fi
140
 
shopt -u nocasematch
141
 
 
142
 
# Make it publicly visible, once the syncope service is exposed
143
 
open-port $HTTP_PORT/tcp