BIGTOP-959. get rid of hadoop specific init.d.tmpl
Project: http://git-wip-us.apache.org/repos/asf/bigtop/repo Commit: http://git-wip-us.apache.org/repos/asf/bigtop/commit/25463a41 Tree: http://git-wip-us.apache.org/repos/asf/bigtop/tree/25463a41 Diff: http://git-wip-us.apache.org/repos/asf/bigtop/diff/25463a41 Branch: refs/heads/master Commit: 25463a4144b34e293778ee47569de2657be85a1e Parents: d0aafdf Author: Roman Shaposhnik <[email protected]> Authored: Wed May 1 17:45:47 2013 -0700 Committer: Roman Shaposhnik <[email protected]> Committed: Wed May 1 18:20:21 2013 -0700 ---------------------------------------------------------------------- bigtop-packages/src/common/hadoop/init.d.tmpl | 279 ----------------- bigtop-packages/src/deb/hadoop/rules | 2 +- bigtop-packages/src/rpm/hadoop/SPECS/hadoop.spec | 8 +- 3 files changed, 2 insertions(+), 287 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/bigtop/blob/25463a41/bigtop-packages/src/common/hadoop/init.d.tmpl ---------------------------------------------------------------------- diff --git a/bigtop-packages/src/common/hadoop/init.d.tmpl b/bigtop-packages/src/common/hadoop/init.d.tmpl deleted file mode 100755 index 7e3d454..0000000 --- a/bigtop-packages/src/common/hadoop/init.d.tmpl +++ /dev/null @@ -1,279 +0,0 @@ -#!/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. - -# This is a poor man's templating engine for generating init.d scripts to -# support all the Apache services that Bigtop distro has. An actual init.d -# script gets generate via running this script under bash and giving it -# a mandatory argument of a file containing the configuration for the service. -# The argument file should be a valid piece of bash code since it gets directly -# source into this template. E.g. -# $ bash ./init.d.tmpl hadoop-hdfs-namenode.svc > hadoop-hdfs-namenode -# -# You must declare the following in your .svc configuration file: -# DAEMON="name of the resulting init.d script" -# DESC="Free form human readable description of the service" -# EXEC_PATH="path to the upstream daemon management script" -# SVC_USER="user to run this service as" -# DAEMON_FLAGS="flags to be passed to the $EXEC_PATH" -# CONF_DIR="path to the configuration directory" -# PIDFILE="file holding a PID of the running daemon" -# LOCKFILE="file signifying the service lock" -# -# CHKCONFIG="chkconfig(8) registration signature" -# INIT_DEFAULT_START="run levels to use" -# INIT_DEFAULT_STOP="run levels not to use ;-)" -# -# You can, also, override parts of the generated init.d script by providing -# function definitions for: generate_start, generate_stop and generate_extra_commands. -# See the default implemenations below and feel free to customize. Also look -# for exising .svc files in common to see how different services are tweaking -# the defaults. -# -# Of course, if this whole templating thing grows too big we might need to -# consider a real templating engine (I have played with m4, but it seems -# qutie brittle when used for manipulating pieces of the shell code -- think -# $0 the like). - -if [ $# -lt 1 ] ; then - echo "Usage: ${BASH_SOURCE-0} service.definition.svc" - exit 1 -fi - -generate_start() { - -cat <<'__EOT__' - -start() { - [ -x $EXEC_PATH ] || exit $ERROR_PROGRAM_NOT_INSTALLED - [ -d $CONF_DIR ] || exit $ERROR_PROGRAM_NOT_CONFIGURED - log_success_msg "Starting ${DESC}: " - - su -s /bin/bash $SVC_USER -c "$EXEC_PATH --config '$CONF_DIR' start $DAEMON_FLAGS" - - # Some processes are slow to start - sleep $SLEEP_TIME - checkstatusofproc - RETVAL=$? - - [ $RETVAL -eq $RETVAL_SUCCESS ] && touch $LOCKFILE - return $RETVAL -} - -__EOT__ - -} - -generate_stop() { - -cat <<'__EOT__' - -stop() { - log_success_msg "Stopping ${DESC}: " - start_daemon $EXEC_PATH --config "$CONF_DIR" stop $DAEMON_FLAGS - RETVAL=$? - - [ $RETVAL -eq $RETVAL_SUCCESS ] && rm -f $LOCKFILE $PIDFILE -} - -__EOT__ - -} - -generate_extra_commands() { - -cat <<'__EOT__' - *) - echo $"Usage: $0 {start|stop|status|restart|try-restart|condrestart}" - exit 1 -__EOT__ - -} - -################################################################### -# Some reasonable defaults for the run-level settings, these are -# tweaked on a per-OS basis from the SPEC/rules files that call us -# and can be further tweaked inside of individual .svc templates -CHKCONFIG=${CHKCONFIG:-"2345 85 15"} -INIT_DEFAULT_START=${INIT_DEFAULT_START:-"2 3 4 5"} -INIT_DEFAULT_STOP=${INIT_DEFAULT_STOP:-"0 1 6"} - -################################################################### -# NOTE how we are sourcing the argument here so that a user-defined -# settings have a chance to override the default values for -# generate_start, generate_stop and generate_extra_commands. If you -# ever want to make this template even more flexible -- define the -# default values above this line -. $1 - -cat <<__EOT__ -#!/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. -# -# Starts a $DESC -# -# chkconfig: $CHKCONFIG -# description: $DESC -# -### BEGIN INIT INFO -# Provides: $DAEMON -# Short-Description: $DESC -# Default-Start: $INIT_DEFAULT_START -# Default-Stop: $INIT_DEFAULT_STOP -# Required-Start: \$syslog \$remote_fs -# Required-Stop: \$syslog \$remote_fs -# Should-Start: -# Should-Stop: -### END INIT INFO - -. /lib/lsb/init-functions -. /etc/default/hadoop - -if [ -f /etc/default/$DAEMON ] ; then - . /etc/default/$DAEMON -fi - -# Autodetect JAVA_HOME if not defined -. /usr/lib/bigtop-utils/bigtop-detect-javahome - -RETVAL_SUCCESS=0 - -STATUS_RUNNING=0 -STATUS_DEAD=1 -STATUS_DEAD_AND_LOCK=2 -STATUS_NOT_RUNNING=3 -STATUS_OTHER_ERROR=102 - - -ERROR_PROGRAM_NOT_INSTALLED=5 -ERROR_PROGRAM_NOT_CONFIGURED=6 - - -RETVAL=0 -SLEEP_TIME=5 -PROC_NAME="java" - -DAEMON="$DAEMON" -DESC="$DESC" -EXEC_PATH="$EXEC_PATH" -SVC_USER="$SVC_USER" -DAEMON_FLAGS="$DAEMON_FLAGS" -CONF_DIR="$CONF_DIR" -PIDFILE="$PIDFILE" -LOCKDIR="$LOCKDIR" -LOCKFILE="\$LOCKDIR/$LOCKFILE" - -install -d -m 0755 -o $SVC_USER -g $SVC_USER $(dirname $PIDFILE) 1>/dev/null 2>&1 || : -[ -d "\$LOCKDIR" ] || install -d -m 0755 \$LOCKDIR 1>/dev/null 2>&1 || : -__EOT__ - -generate_start -generate_stop - -cat <<'__EOT__' -restart() { - stop - start -} - -checkstatusofproc(){ - pidofproc -p $PIDFILE $PROC_NAME > /dev/null -} - -checkstatus(){ - checkstatusofproc - status=$? - - case "$status" in - $STATUS_RUNNING) - log_success_msg "${DESC} is running" - ;; - $STATUS_DEAD) - log_failure_msg "${DESC} is dead and pid file exists" - ;; - $STATUS_DEAD_AND_LOCK) - log_failure_msg "${DESC} is dead and lock file exists" - ;; - $STATUS_NOT_RUNNING) - log_failure_msg "${DESC} is not running" - ;; - *) - log_failure_msg "${DESC} status is unknown" - ;; - esac - return $status -} - -condrestart(){ - [ -e $LOCKFILE ] && restart || : -} - -check_for_root() { - if [ $(id -ur) -ne 0 ]; then - echo 'Error: root user required' - echo - exit 1 - fi -} - -service() { - case "$1" in - start) - check_for_root - start - ;; - stop) - check_for_root - stop - ;; - status) - checkstatus - RETVAL=$? - ;; - restart) - check_for_root - restart - ;; - condrestart|try-restart) - check_for_root - condrestart - ;; -__EOT__ - -generate_extra_commands - -cat <<'__EOT__' - esac -} - -service "$1" - -exit $RETVAL -__EOT__ http://git-wip-us.apache.org/repos/asf/bigtop/blob/25463a41/bigtop-packages/src/deb/hadoop/rules ---------------------------------------------------------------------- diff --git a/bigtop-packages/src/deb/hadoop/rules b/bigtop-packages/src/deb/hadoop/rules index a27c205..80d870e 100755 --- a/bigtop-packages/src/deb/hadoop/rules +++ b/bigtop-packages/src/deb/hadoop/rules @@ -44,7 +44,7 @@ hadoop_svcs=hdfs-namenode hdfs-secondarynamenode hdfs-datanode hdfs-zkfc hdfs-jo mapreduce-historyserver httpfs $(hadoop_svcs): debian/init.d.tmpl - bash $< debian/[email protected] > debian/[email protected] + bash $< debian/[email protected] deb debian/[email protected] cp debian/$(firstword $(subst -, ,$@)).default debian/tmp/etc/default/hadoop-$@ echo /etc/default/hadoop-$@ >> debian/[email protected] # FIXME: workaround for BIGTOP-105 http://git-wip-us.apache.org/repos/asf/bigtop/blob/25463a41/bigtop-packages/src/rpm/hadoop/SPECS/hadoop.spec ---------------------------------------------------------------------- diff --git a/bigtop-packages/src/rpm/hadoop/SPECS/hadoop.spec b/bigtop-packages/src/rpm/hadoop/SPECS/hadoop.spec index 3854156..4bdf038 100644 --- a/bigtop-packages/src/rpm/hadoop/SPECS/hadoop.spec +++ b/bigtop-packages/src/rpm/hadoop/SPECS/hadoop.spec @@ -489,13 +489,7 @@ echo 'export JSVC_HOME=%{libexecdir}/bigtop-utils' >> $RPM_BUILD_ROOT/etc/defaul # Generate the init.d scripts for service in %{hadoop_services} do - init_file=$RPM_BUILD_ROOT/%{initd_dir}/%{name}-${service} - # On RedHat, SuSE and Mageia run-level 2 is networkless, hence excluding it - env CHKCONFIG="345 85 15" \ - INIT_DEFAULT_START="3 4 5" \ - INIT_DEFAULT_STOP="0 1 2 6" \ - bash $RPM_SOURCE_DIR/init.d.tmpl $RPM_SOURCE_DIR/%{name}-${service}.svc > $init_file - chmod 755 $init_file + bash %{SOURCE11} $RPM_SOURCE_DIR/%{name}-${service}.svc rpm $RPM_BUILD_ROOT/%{initd_dir}/%{name}-${service} cp $RPM_SOURCE_DIR/${service/-*/}.default $RPM_BUILD_ROOT/etc/default/%{name}-${service} chmod 644 $RPM_BUILD_ROOT/etc/default/%{name}-${service} done
