diff options
Diffstat (limited to 'eclass')
-rw-r--r-- | eclass/einput.eclass | 26 |
1 files changed, 26 insertions, 0 deletions
diff --git a/eclass/einput.eclass b/eclass/einput.eclass index 136e7dc..5cc113e 100644 --- a/eclass/einput.eclass +++ b/eclass/einput.eclass @@ -258,3 +258,29 @@ einput_multi_prompt() { EINPUT_ANSWER="$answer" EINPUT_IANSWER=`echo -n ${EINPUT_ANSWER} | tr [:upper:] [:lower:]` } + +# Usage: einput_add_init prompt +# +# Displays a simple predefined prompt with the package name ($1) asking if +# a packages init script should be added to the $2 runlevel. If an init +# script already exists, no prompt will be shown and the function will return +# 0. +# +# Returns: The exit code from rc-update if an existing entry does not exist. +# If an existing entry exists, returns 0. +# Default: none +# +# Example: einput_add_init "postgresql" "default" +# +einput_add_init() { + check_if_exists=`${ROOT}/sbin/rc-update show $2 | grep $1 | wc -l` + if [ "${check_if_exists}" == "0" ]; then + if einput_confirm "Do you want to add $1 to your default runlevel?" "0"; + then + ${ROOT}/sbin/rc-update add $1 $2 + return $? + fi + else + return 0 + fi +} |