~geethas1/charms/trusty/ibm-was-nd/was-nd-fix

« back to all changes in this revision

Viewing changes to hooks/config-changed

  • Committer: Uma S V
  • Date: 2015-04-09 10:33:49 UTC
  • Revision ID: uveerann@in.ibm.com-20150409103349-j9lzn33g6e9ire3a
WAS ND Changes

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
#!/bin/bash
 
2
# config-changed occurs everytime a new configuration value is updated (juju set)
 
3
 
 
4
set -e
 
5
 
 
6
WAS_ND_INSTALL_PATH=/root/IBM/WebSphere/AppServer/V85/ND
 
7
# Check whether IM is installed
 
8
is_im_installed()
 
9
{
 
10
 if [ -f $IM_INSTALL_PATH/eclipse/IBMIM ]; then
 
11
     echo "True"
 
12
  else
 
13
     echo "False"
 
14
  fi
 
15
 
 
16
}
 
17
 
 
18
 
 
19
# Check whether WAS ND  is installed
 
20
is_was_nd_installed()
 
21
{
 
22
 if [ -d $WAS_ND_INSTALL_PATH/bin ]; then
 
23
     echo "True"
 
24
  else
 
25
     echo "False"
 
26
  fi
 
27
 
 
28
}
 
29
 
 
30
 
 
31
# Remove was nd, if installed
 
32
remove_was_nd_software()
 
33
{
 
34
 
 
35
        was_nd_installed=`is_was_nd_installed`
 
36
        if  [ $was_nd_installed == True ]; then
 
37
           juju-log "Removing WAS ND Installation"
 
38
           # Uninstalling WAS ND
 
39
           cd $IM_INSTALL_PATH/eclipse/tools
 
40
           sudo ./imcl uninstall com.ibm.websphere.liberty.ND.v85 -installationDirectory $WAS_ND_INSTALL_PATH
 
41
        fi
 
42
        juju-log "Uninstalling WAS ND software completed"
 
43
}
 
44
 
 
45
#Remove IM, if installed
 
46
remove_im_software()
 
47
{
 
48
 
 
49
        im_installed=`is_im_installed`
 
50
        if  [ $im_installed == True ]; then
 
51
            juju-log "Removing IBM WebSphere IM software."
 
52
            cd /root/var/ibm/InstallationManager/uninstall
 
53
        #Uninstalling IM
 
54
            ./uninstall --launcher.ini user-silent-uninstall.ini
 
55
        fi
 
56
 
 
57
}
 
58
 
 
59
# Remove WAS ND if license not accpeted
 
60
remove_unaccepted_software()
 
61
{
 
62
 
 
63
   if  [ $1 == False ]; then
 
64
       juju-log "Removing IBM WebSphere  (if installed) as the license agreement is not accepted."
 
65
         if [ -f $IM_INSTALL_PATH/eclipse/IBMIM ]; then
 
66
                juju-log "IM  exists "
 
67
                remove_was_nd_software 
 
68
         else
 
69
                juju-log "IM  not exists and hence exiting from WAS unistalling"
 
70
                exit 0 
 
71
         fi
 
72
   fi
 
73
 
 
74
 
 
75
   if  [ $2 == False ]; then
 
76
    juju-log "Removing IBM IM (if installed) as the license agreement is not accepted."
 
77
 
 
78
        #Check any dependent products exists like WAS
 
79
 
 
80
         if [ -d $WAS_ND_INSTALL_PATH/bin ]; then
 
81
                 juju-log "Can not uninstall IM as its has WAS product installed"
 
82
                 exit 0 
 
83
         else
 
84
                juju-log "Uninstall IM software"
 
85
                remove_im_software
 
86
        fi
 
87
   fi
 
88
 
 
89
}
 
90
 
 
91
 
 
92
juju-log "Websphere WAS ND: Begin config-change hook"
 
93
was_nd_license_accepted=`config-get accept-ibm-was-nd-license`
 
94
im_license_accepted=`config-get accept-ibm-im-license`
 
95
IM_INSTALL_PATH=`config-get im_install_path`
 
96
# Remove IM and WAS if license not accepted and exit. Else install it
 
97
remove_unaccepted_software $was_nd_license_accepted $im_license_accepted
 
98
if [ $im_license_accepted == False ]; then
 
99
        juju-log "Websphere IM License not accepted."
 
100
 
 
101
elif [ $im_license_accepted == True ]; then
 
102
 
 
103
        juju-log "License accepted"
 
104
        im_inst=`is_im_installed`
 
105
        if [ $im_inst == False ]; then   
 
106
                juju-log "IM installation start"
 
107
        # Check IM package availability
 
108
                        juju-log $CHARM_DIR
 
109
                if [ -f  $CHARM_DIR/files/archives/IM/userinstc ];
 
110
                then
 
111
                        juju-log "IM Packages available for installation.";
 
112
                         cp  $CHARM_DIR/files/archives/IM/install.xml $CHARM_DIR/files/archives/IM/silent_install.xml
 
113
                        sed -i "2 a \<profile kind='self' installLocation='$IM_INSTALL_PATH' id='IBM Installation Manager'>\n <data key='eclipseLocation' value='$IM_INSTALL_PATH' />\n</profile>" $CHARM_DIR/files/archives/IM/silent_install.xml
 
114
                         $CHARM_DIR/files/archives/IM/userinstc  -input  $CHARM_DIR/files/archives/IM/silent_install.xml -acceptlicense
 
115
                         if [ $? == 0 ]
 
116
                         then
 
117
                               juju-log "IM Is installed successfully"
 
118
                         else
 
119
                               juju-log "Error while installing  IM"
 
120
                               exit 1
 
121
                         fi
 
122
 
 
123
                else
 
124
                        juju-log "IM Packages missing. Please check README file.";
 
125
                        juju-log "Upgrade IM charm after adding the IM packages";
 
126
                        exit 1
 
127
                fi
 
128
        fi
 
129
else
 
130
        juju-log " Acceptable values for license is 'True' or 'False'"
 
131
 
 
132
fi
 
133
 
 
134
if [ $was_nd_license_accepted == False ]; then
 
135
        juju-log "Websphere ND License not accepted."
 
136
 
 
137
elif [ $was_nd_license_accepted == True ]; then
 
138
       juju-log "Check WAS ND package availability"
 
139
        # check WAS package availability
 
140
        if [ -d "$CHARM_DIR/files/archives/disk1" ]; then       
 
141
                 juju-log "WAS ND Packages available for installation.";
 
142
                #Check IM installation
 
143
                 im_installed=`is_im_installed`
 
144
                if  [ $im_installed == True ]; then
 
145
                         juju-log "Installing WAS ND "
 
146
                         cd $IM_INSTALL_PATH/eclipse/tools
 
147
                         sudo ./imcl install com.ibm.websphere.ND.v85 -repositories  $CHARM_DIR/files/archives/ -installationDirectory $WAS_ND_INSTALL_PATH -sharedResourcesDirectory $IM_INSTALL_PATH/IMShared -acceptLicense -showProgress
 
148
                        if [ $? == 0 ]
 
149
                        then
 
150
                               juju-log " WAS Base is installed successfully"
 
151
                        else
 
152
                               juju-log "Error while installing  WAS"
 
153
                               exit 1
 
154
                        fi
 
155
                 else
 
156
                        juju-log "IM is not installaed to install WAS"
 
157
                        exit 0
 
158
                 fi
 
159
 
 
160
                juju-log "creating a profile"
 
161
                cd $WAS_ND_INSTALL_PATH/bin
 
162
                #sh does not work in ubuntu so linking to bash
 
163
 
 
164
                juju-log "Unlink /bin/sh"
 
165
                sudo unlink /bin/sh
 
166
                sudo ln -s /bin/bash /bin/sh
 
167
                juju-log "creating a profile"
 
168
 
 
169
                juju-log "updating /etc/hosts with hostname"
 
170
                # Need to update hostname in /etc/hosts
 
171
                private_address=`unit-get private-address`
 
172
                juju-log "private_address : $private_address"
 
173
                echo "$private_address `hostname`" >> /etc/hosts
 
174
                if [ $? == 0 ]
 
175
                then    
 
176
                        juju-log "hostname updated"
 
177
                else
 
178
                        juju-log "Error while updating /etc/hosts"
 
179
                fi
 
180
 
 
181
                sudo  ./manageprofiles.sh -create -profileName "test" -profilePath "$WAS_ND_INSTALL_PATH/profiles/test" -templatePath "$WAS_ND_INSTALL_PATH/profileTemplates/default/" -nodeName "node1" -cellName "cell1" -serverName "server1" -adminUserName "wasadmin" -adminPassword "wasadmin"
 
182
                juju-log "Profile creation completed"   
 
183
 
 
184
                #Apply fixpack 8.5.5.4 to upgrade was nd version from 8.5.5.0 to 8.5.5.4
 
185
                
 
186
                juju-log "Upgrading WAS Base"
 
187
                cd $IM_INSTALL_PATH/eclipse/tools       
 
188
                sudo ./imcl  install com.ibm.websphere.ND.v85_8.5.5004.20141119_1746 -repositories  $CHARM_DIR/files/archives/was_fixpack/  -installationDirectory $WAS_ND_INSTALL_PATH -sharedResourcesDirectory $IM_INSTALL_PATH/IMShared -acceptLicense -showProgress
 
189
                  if [ $? == 0 ]
 
190
                  then
 
191
                               juju-log " WAS fixpack installed successfully"
 
192
                  else
 
193
                               juju-log "Error while installing  WAS fixpack"
 
194
                               exit 1
 
195
                  fi
 
196
 
 
197
        else
 
198
                juju-log "WAS ND Packages are not available "
 
199
        fi
 
200
 
 
201
fi
 
202