| #!/bin/bash |
| # @@@ START COPYRIGHT @@@ |
| # |
| # Licensed to the Apache Software Foundation (ASF) under one |
| # or more contributor license agreements. See the NOTICE file |
| # distributed with this work for additional information |
| # regarding copyright ownership. The ASF licenses this file |
| # to you under the Apache License, Version 2.0 (the |
| # "License"); you may not use this file except in compliance |
| # with the License. You may obtain a copy of the License at |
| # |
| # http://www.apache.org/licenses/LICENSE-2.0 |
| # |
| # Unless required by applicable law or agreed to in writing, |
| # software distributed under the License is distributed on an |
| # "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY |
| # KIND, either express or implied. See the License for the |
| # specific language governing permissions and limitations |
| # under the License. |
| # |
| # @@@ END COPYRIGHT @@@ |
| |
| function print_usage { |
| cat << EOF |
| This script will uninstall Trafodion completely, including the Trafodion userid |
| and its $HOME_DIR/$TRAF_USER directory. This must be run from a userid with |
| sudo access. |
| |
| Usage: $(basename $0) [options] |
| |
| Options: |
| --help Print this message and exit. |
| |
| EOF |
| } |
| |
| #========================================= |
| #source trafodion_config file |
| |
| TRAF_CONFIG=/etc/trafodion/trafodion_config |
| if [[ ! -f $TRAF_CONFIG ]]; then |
| echo "***ERROR: $TRAF_CONFIG file does not exist" |
| echo "***ERROR: Uninstall by deleting Trafodion user id OR all Trafodion files and processes." |
| exit -1 |
| else |
| source $TRAF_CONFIG |
| fi |
| #========================================= |
| # define defaults |
| TRAF_GROUP="trafodion" |
| #HBASE_TRX="hbase-trx*" |
| |
| UNINSTALL_ALL="N" |
| UNINSTALL_DIR="" |
| |
| # Parse input parameters |
| while [[ $# -gt 0 ]]; do |
| case "$1" in |
| --help) |
| print_usage |
| exit -1 |
| ;; |
| *) |
| echo "***ERROR: unknown parameter '$1'" |
| print_usage |
| exit -1 |
| esac |
| shift |
| done |
| |
| #========================================= |
| #Confirmation |
| echo -n "Do you want to uninstall Trafodion (Everything will be removed)? (Y/N) " |
| read v |
| |
| if [[ $v != "Y" ]] && [[ $v != "y" ]]; then |
| echo "***INFO: Exiting..." |
| exit |
| fi |
| |
| #========================================= |
| #Create logs directory and logfile name |
| timestamp=$(date +%F-%H-%M-%S) |
| logsdir="/var/log/trafodion" |
| logfile="$logsdir/uninstall_$timestamp.log" |
| |
| #Check sudo access which is required for "--all" option |
| sudo echo "***INFO: testing sudo access" |
| if [ $? -ne 0 ]; then |
| echo "***ERROR: trafodion_uninstaller requires sudo access." |
| exit -1 |
| fi |
| |
| echo "***INFO: NOTE, rpms that were installed will not be removed." |
| |
| #Handle removing all of Trafodion |
| echo "***INFO: stopping Trafodion instance" |
| sudo su $TRAF_USER --login --command "sqstop" |
| sudo su $TRAF_USER --login --command "ckillall" |
| sudo su $TRAF_USER --login --command "vncserver -kill :1" |
| |
| # remove security stuff |
| if [[ "$SECURE_HADOOP" == "Y" ]]; then |
| echo "***INFO: Removing $TRAF_USER ID from Kerberos cache" |
| if [ $all_node_count -eq 1 ]; then |
| sudo su $TRAF_USER --login --command "kdestroy -q" |
| else |
| $TRAF_PDSH "sudo su $TRAF_USER --login --command \"kdestroy -q\"" |
| fi |
| |
| echo "***INFO: Stopping Kerberos ticket monitoring process" |
| if [ $all_node_count -eq 1 ]; then |
| sudo su $TRAF_USER --login --command "$TRAF_HOME/sql/scripts/krb5service stop 2>/dev/null" |
| else |
| $TRAF_PDSH "sudo su $TRAF_USER --login --command \"$TRAF_HOME/sql/scripts/krb5service stop 2>/dev/null\"" |
| fi |
| fi |
| |
| # Please don't start up another shell $TRAF_USER process after this point, |
| # the login process will create a new TGT in cache and start the ticket monitor |
| |
| echo "***INFO: restoring linux system files that were changed" |
| echo "***INFO: removing $HBASE_TRX from Hadoop directories" |
| if [ $all_node_count -eq 1 ]; then |
| sudo rm /etc/security/limits.d/trafodion.conf 2>/dev/null |
| sudo rm /usr/share/cmf/lib/plugins/$HBASE_TRX 2>/dev/null |
| #sudo rm /usr/lib/hbase/lib/$HBASE_TRX 2>/dev/null |
| #sudo rm /usr/hdp/current/hbase-regionserver/lib/$HBASE_TRX 2>/dev/null |
| else |
| $TRAF_PDSH "sudo rm /etc/security/limits.d/trafodion.conf 2>/dev/null" |
| $TRAF_PDSH "sudo rm /usr/share/cmf/lib/plugins/$HBASE_TRX 2>/dev/null" |
| #$TRAF_PDSH "sudo rm /usr/lib/hbase/lib/$HBASE_TRX 2>/dev/null" |
| #$TRAF_PDSH "sudo rm /usr/hdp/current/hbase-regionserver/lib/$HBASE_TRX 2>/dev/null" |
| fi |
| |
| echo "***INFO remove the Trafodion userid and group" |
| $TRAF_PDSH sudo rm -rf $TRAF_WORKDIR/$TRAF_USER |
| $TRAF_PDSH sudo rm -rf $LOCAL_WORKDIR/$TRAF_USER |
| $TRAF_PDSH sudo /usr/sbin/userdel --force --remove $TRAF_USER |
| $TRAF_PDSH sudo /usr/sbin/groupdel $TRAF_GROUP 2>/dev/null |
| |
| echo "***INFO: removing all files from $TRAF_HOME" |
| $TRAF_PDSH sudo rm -rf $TRAF_HOME |
| |
| echo "***INFO: removing all files from /usr/lib/trafodion and /var/log/trafodion" |
| $TRAF_PDSH sudo rm -rf /usr/lib/trafodion* |
| $TRAF_PDSH sudo rm -rf /var/log/trafodion* |
| |
| echo "***INFO: removing all files from /etc/trafodion" |
| $TRAF_PDSH sudo rm -rf /etc/trafodion* |
| $TRAF_PDSH sudo rm -rf $LOCAL_WORKDIR/trafodion_config |
| |
| echo "***INFO: Trafodion uninstall complete." |
| |