Go to:
Gentoo Home
Documentation
Forums
Lists
Bugs
Planet
Store
Wiki
Get Gentoo!
Gentoo's Bugzilla – Attachment 282237 Details for
Bug 377905
app-emulation/ganeti-2.4.2 init script/daemon management script uses deprecated start-stop-daemon functions
Home
|
New
–
[Ex]
|
Browse
|
Search
|
Privacy Policy
|
[?]
|
Reports
|
Requests
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
Fixed version of daemon-util from ganeti
daemon-util (text/plain), 4.88 KB, created by
Alexander BrĂ¼ning
on 2011-08-05 19:22:49 UTC
(
hide
)
Description:
Fixed version of daemon-util from ganeti
Filename:
MIME Type:
Creator:
Alexander BrĂ¼ning
Created:
2011-08-05 19:22:49 UTC
Size:
4.88 KB
patch
obsolete
>#!/bin/bash ># > ># Copyright (C) 2009 Google Inc. ># ># This program is free software; you can redistribute it and/or modify ># it under the terms of the GNU General Public License as published by ># the Free Software Foundation; either version 2 of the License, or ># (at your option) any later version. ># ># This program is distributed in the hope that it will be useful, but ># WITHOUT ANY WARRANTY; without even the implied warranty of ># MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU ># General Public License for more details. ># ># You should have received a copy of the GNU General Public License ># along with this program; if not, write to the Free Software ># Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA ># 02110-1301, USA. > >set -e > >defaults_file=/etc/default/ganeti > ># This is a list of all daemons and the order in which they're started. The ># order is important as there are dependencies between them. On shutdown, ># they're stopped in reverse order. >DAEMONS=( > ganeti-noded > ganeti-masterd > ganeti-rapi > ganeti-confd > ) > >NODED_ARGS= >MASTERD_ARGS= >CONFD_ARGS= >RAPI_ARGS= > ># Read defaults file if it exists >if [[ -s $defaults_file ]]; then > . $defaults_file >fi > >_daemon_pidfile() { > echo "/var/run/ganeti/$1.pid" >} > >_daemon_executable() { > echo "/usr/sbin/$1" >} > >_daemon_usergroup() { > case "$1" in > masterd) > echo "root:root" > ;; > confd) > echo "root:root" > ;; > rapi) > echo "root:root" > ;; > noded) > echo "root:root" > ;; > *) > echo "root:root" > ;; > esac >} > ># Checks whether the local machine is part of a cluster >check_config() { > local server_pem=/var/lib/ganeti/server.pem > local fname > > for fname in $server_pem; do > if [[ ! -f $fname ]]; then > echo "Missing configuration file $fname" >&2 > return 1 > fi > done > > return 0 >} > ># Checks the exit code of a daemon >check_exitcode() { > if [[ "$#" -lt 1 ]]; then > echo 'Missing exit code.' >&2 > return 1 > fi > > local rc="$1"; shift > > case "$rc" in > 0) ;; > 11) > echo "not master" > ;; > *) > echo "exit code $rc" > return 1 > ;; > esac > > return 0 >} > ># Prints a list of all daemons in the order in which they should be started >list_start_daemons() { > local name > > for name in "${DAEMONS[@]}"; do > echo "$name" > done >} > ># Prints a list of all daemons in the order in which they should be stopped >list_stop_daemons() { > list_start_daemons | tac >} > ># Checks whether a daemon name is known >is_daemon_name() { > if [[ "$#" -lt 1 ]]; then > echo 'Missing daemon name.' >&2 > return 1 > fi > > local name="$1"; shift > > for i in "${DAEMONS[@]}"; do > if [[ "$i" == "$name" ]]; then > return 0 > fi > done > > echo "Unknown daemon name '$name'" >&2 > return 1 >} > ># Checks whether daemon is running >check() { > if [[ "$#" -lt 1 ]]; then > echo 'Missing daemon name.' >&2 > return 1 > fi > > local name="$1"; shift > > start-stop-daemon --stop --signal 0 --quiet \ > --pidfile $(_daemon_pidfile $name) >} > ># Starts a daemon >start() { > if [[ "$#" -lt 1 ]]; then > echo 'Missing daemon name.' >&2 > return 1 > fi > > local name="$1"; shift > > # Convert daemon name to uppercase after removing "ganeti-" prefix > local plain_name=${name#ganeti-} > local ucname=$(tr a-z A-Z <<<$plain_name) > > # Read $<daemon>_ARGS and $EXTRA_<daemon>_ARGS > eval local args="\"\$${ucname}_ARGS \$EXTRA_${ucname}_ARGS\"" > > /usr/lib64/ganeti/ensure-dirs > > start-stop-daemon --start \ > --pidfile $(_daemon_pidfile $name) \ > --exec $(_daemon_executable $name) \ > --user $(_daemon_usergroup $plain_name) \ > -- $args "$@" >} > ># Stops a daemon >stop() { > if [[ "$#" -lt 1 ]]; then > echo 'Missing daemon name.' >&2 > return 1 > fi > > local name="$1"; shift > > start-stop-daemon --stop --retry 30 \ > --pidfile $(_daemon_pidfile $name) >} > ># Starts a daemon if it's not yet running >check_and_start() { > local name="$1" > > if ! check $name; then > start $name > fi >} > ># Starts the master role >start_master() { > start ganeti-masterd > start ganeti-rapi >} > ># Stops the master role >stop_master() { > stop ganeti-rapi > stop ganeti-masterd >} > ># Start all daemons >start_all() { > for i in $(list_start_daemons); do > local rc=0 > > # Try to start daemon > start $i || rc=$? > > if ! errmsg=$(check_exitcode $rc); then > echo "$errmsg" >&2 > return 1 > fi > done > > return 0 >} > ># Stop all daemons >stop_all() { > for i in $(list_stop_daemons); do > stop $i > done >} > ># Reloads the SSH keys >reload_ssh_keys() { > /etc/init.d/sshd restart >} > >if [[ "$#" -lt 1 ]]; then > echo "Usage: $0 <action>" >&2 > exit 1 >fi > >orig_action=$1; shift > >if [[ "$orig_action" == *_* ]]; then > echo "Command must not contain underscores" >&2 > exit 1 >fi > ># Replace all dashes (-) with underlines (_) >action=${orig_action//-/_} > ># Is it a known function? >if ! declare -F "$action" >/dev/null 2>&1; then > echo "Unknown command: $orig_action" >&2 > exit 1 >fi > ># Call handler function >$action "$@"
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Raw
Actions:
View
Attachments on
bug 377905
: 282237