Skip to content

Commit

Permalink
Use openrc's functions.sh if possible, otherwise use only emulations
Browse files Browse the repository at this point in the history
  • Loading branch information
vaeth committed Aug 31, 2016
1 parent d816630 commit 48bd7e8
Showing 1 changed file with 17 additions and 12 deletions.
29 changes: 17 additions & 12 deletions bin/openrc-wrapper
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,18 @@ then [ $# -ge 2 ] || wrapper_usage
exec >/dev/null
else [ $# -ge 1 ] || wrapper_usage
fi
PATH='/lib/rc/bin:'${PATH:-/usr/local/bin:/usr/local/sbin:/usr/sbin:/usr/bin:/sbin:/bin:/opt/bin}
if ! command -v ebegin >/dev/null 2>&1
then
: ${PATH:=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/opt/bin}
# If openrc's functions.sh can be used, then use it
source_functions() {
for wrapper_i in /lib64 /lib
do ! test -r $wrapper_i/rc/sh/functions.sh || continue
. $wrapper_i/rc/sh/functions.sh
return 0
done
return 1
}
# Otherwise provide emulations of the most important functions
source_functions || {
output_n() {
[ x"$LAST_E_CMD" != x'ebegin' ] || echo
printf '%s' "$1$RC_INDENTATION$2"
Expand Down Expand Up @@ -47,7 +56,7 @@ init_colors() {
then RC_NOCOLOR=1
RC_ENDCOL=0
fi
if yesno "${RC_NOCOLOR-}"
if yesno "${RC_NOCOLOR-}" || ! yesno "${EINFO_COLOR:-y}" || ! test -t 1
then NORMAL=
GOOD=
WARN=
Expand Down Expand Up @@ -77,7 +86,7 @@ init_colors() {
init_colors=`$init_colors
printf '%s' "$2"`
: ${init_colors:=0}
}
}
[ "$init_colors" -ge 6 ] && [ "$init_colors" -le 80 ] || init_colors=80
init_colors=$(( $init_colors - 6 ))
if yesno "$RC_ENDCOL"
Expand Down Expand Up @@ -217,22 +226,18 @@ veoutdent() {
! yesno "${EINFO_VERBOSE-}" || eoutdent
}

die() {
eerror ${1+"$@"}
exit 1
}

yesno() {
case ${1:-n} in
[nNFf0-]*|[oO][fF]*)
return 1;;
esac
:
}
fi
}

RC_UNAME=`uname`
RC_VERSION=1
RC_TMPDIR='/run'
RC_TMPDIR=/run
RC_WRAPPER=1
if test -r "/etc/conf.d/$SVCNAME"
then . "/etc/conf.d/$SVCNAME"
Expand Down

0 comments on commit 48bd7e8

Please sign in to comment.