| #!/bin/bash |
| |
| # 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. |
| |
| set -x |
| |
| [ "$3" == "" ] && echo "usage: $0 <kube.yml> <namespace> <jar>" && exit 1 |
| |
| set -o pipefail |
| #set -x |
| set -e |
| |
| k="kubectl --kubeconfig=$1 --namespace=$2" |
| |
| if [ "${NS/warehouse*}" == "" ];then |
| podName="metastore-0" |
| else |
| podName="hiveserver2-0" |
| fi |
| |
| echo "@@@ podName: $podName" |
| |
| |
| JAR=$3 |
| |
| JAR_PATH="`$k logs pod/$podName -c init-custom-jars-localizer| grep -a CUSTOM_JARS_PATH | tr ' ' '\n'|grep '^s3a'|tail -n1|tee >(cat >&2)`" |
| |
| JAR_PATH="${JAR_PATH%.}" |
| [ "$JAR_PATH" == "" ] && echo error JAR_PATH && exit 2 |
| |
| echo $JAR_PATH |
| |
| set -x |
| F="`basename "$JAR_PATH"`" |
| |
| S=/tmp/cj_script |
| cat > $S << EOF |
| #!/bin/bash |
| #hdfs dfs -mkdir -p $(dirname $(dirname $JAR_PATH)) |
| hdfs dfs -mkdir -p $(dirname $JAR_PATH) |
| #hdfs dfs -rm -r -f $(dirname $JAR_PATH) |
| hdfs dfs -rm -r -f $JAR_PATH |
| hdfs dfs -mkdir -p $JAR_PATH |
| hdfs dfs -copyFromLocal /tmp/`basename $JAR` $JAR_PATH/ |
| hdfs dfs -ls $JAR_PATH/ |
| EOF |
| |
| chmod +x $S |
| cat $S |
| |
| $k cp $JAR ${podName}:/tmp/ |
| $k cp $S ${podName}:$S |
| |
| $k exec -t ${podName} $S |
| |
| $k delete pod/${podName} |
| banner ok |
| #$k delete hiveserver2-0 |
| |