blob: fc8022b72cbd31b25a5a2c8cb6365e6551da3cdc [file] [log] [blame]
#!/bin/sh
#
# 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.
# postinst script for hive
set -e
case "$1" in
configure)
chown hive:hive -R /var/run/hive /var/log/hive
chown hive:hive -R /var/lib/hive
# Install config alternatives
update-alternatives --install /etc/hive/conf hive-conf /etc/hive/conf.dist 30
# Set up directories on HDFS
# TODO(todd) should this stuff be something like "hive create-warehosue"?
su -s /bin/bash - ${hadoop_username} -c 'hadoop fs -mkdir /tmp' 1>/dev/null 2>/dev/null || :
su -s /bin/bash - ${hadoop_username} -c 'hadoop fs -mkdir /user/hive/warehouse' 1>/dev/null 2>/dev/null || :
su -s /bin/bash - ${hadoop_username} -c 'hadoop fs -chmod g+w /tmp' 1>/dev/null 2>/dev/null || :
su -s /bin/bash - ${hadoop_username} -c 'hadoop fs -chmod g+w /user/hive/warehouse' 1>/dev/null 2>/dev/null || :
# Ensure sticky bit on metastore dir - debian likes this to be done in postinst rather than the package
chmod 1777 /var/lib/hive/metastore
if [ "$2" ]; then
old_metastore="/var/lib/hive/metastore/\${user.name}_db"
new_metastore="/var/lib/hive/metastore/metastore_db"
if [ -d $old_metastore ]; then
mv $old_metastore $new_metastore || echo "Failed to automatically rename old metastore. Make sure to resolve this before running Hive."
fi
fi
;;
abort-upgrade|abort-remove|abort-deconfigure)
;;
*)
echo "postinst called with unknown argument \`$1'" >&2
exit 1
;;
esac
#DEBHELPER#