blob: 795f638fb47723fa90a09ea5463a5371005cf223 [file] [log] [blame]
#!/usr/bin/env bash
# description: ambari-server daemon
# processname: ambari-server
# 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.
# /etc/init.d/ambari-server
export PATH=/usr/lib/ambari-server/*:$PATH
export AMBARI_CONF_DIR=/etc/ambari-server/conf:$PATH
if [ -a /usr/bin/python2.6 ]; then
PYTHON=/usr/bin/python2.6
fi
if [ -a /var/lib/ambari-server/ambari-env.sh ]; then
. /var/lib/ambari-server/ambari-env.sh
fi
if [ "x$PYTHON" == "x" ]; then
PYTHON=/usr/bin/python
fi
if [ "x$AMBARI_PASSPHRASE" == "x" ]; then
AMBARI_PASSPHRASE="DEV"
fi
if [ "x$JAVA_HOME" != "x" ]; then
export JAVA_HOME=$JAVA_HOME
fi
export AMBARI_PASSPHRASE=$AMBARI_PASSPHRASE
# check for version
majversion=`$PYTHON -V 2>&1 | awk '{print $2}' | cut -d'.' -f1`
minversion=`$PYTHON -V 2>&1 | awk '{print $2}' | cut -d'.' -f2`
numversion=$(( 10 * $majversion + $minversion))
if (( $numversion < 26 )); then
echo "Need python version > 2.6"
exit 1
fi
echo "Using python " $PYTHON
case "$1" in
start)
echo -e "Starting ambari-server"
$PYTHON /usr/sbin/ambari-server.py $@
;;
stop)
echo -e "Stopping ambari-server"
$PYTHON /usr/sbin/ambari-server.py $@
;;
reset)
echo -e "Resetting ambari-server"
$PYTHON /usr/sbin/ambari-server.py $@
;;
restart)
echo -e "Restarting ambari-server"
$0 stop
$0 start
;;
upgrade)
echo -e "Upgrading ambari-server"
$PYTHON /usr/sbin/ambari-server.py $@
;;
upgradestack)
echo -e "Upgrading stack of ambari-server"
$PYTHON /usr/sbin/ambari-server.py $@
;;
setup)
echo -e "Run postgresql initdb"
initdb_res=`/sbin/service postgresql initdb`
if [ "0" == "$?" ]; then
echo -e "${initdb_res}"
fi
echo -e "Run postgresql start"
/sbin/service postgresql start
echo -e "Setup ambari-server"
$PYTHON /usr/sbin/ambari-server.py $@
;;
*)
echo "Usage: /usr/sbin/ambari-server {start|stop|restart|setup|upgrade|upgradestack} [options]"
exit 1
esac
exit 0