2 dnl Macros for creating the SysV init scripts with nice or raw output
4 dnl --- T2-COPYRIGHT-NOTE-BEGIN ---
5 dnl This copyright note is auto-generated by ./scripts/Create-CopyPatch.
7 dnl T2 SDE: package/.../sysvinit/init_macros.m4
8 dnl Copyright (C) 2004 - 2019 The T2 SDE Project
9 dnl Copyright (C) 1998 - 2003 ROCK Linux Project
11 dnl More information can be found in the files COPYING and README.
13 dnl This program is free software; you can redistribute it and/or modify
14 dnl it under the terms of the GNU General Public License as published by
15 dnl the Free Software Foundation; version 2 of the License. A copy of the
16 dnl GNU General Public License can be found in the file COPYING.
17 dnl --- T2-COPYRIGHT-NOTE-END ---
21 initstyle = sysv_nice ....... Nice colored output
22 initstyle = sysv_text ....... Raw text output
24 ifelse(initstyle, `sysv_nice',
32 define(`this_is_not_the_first_option', `')
33 define(`default_restart', ` restart)
39 define(`end_restart', ` | restart')
41 ifelse(initstyle, `sysv_nice', `
42 define(`main_begin', `title() {
43 local x w="`$'(stty size 2>/dev/null </dev/tty | cut -d" " -f2)"
44 [ -z "`$'w" ] && w="`$'(stty size </dev/console | cut -d" " -f2)"
45 printf "%0$((w/2-1))s" | sed "s/ /. /g"
46 echo -e "\e[255G\e[4D vv \r\e[36m`$'* \e[0m"
53 echo -e "\e[1A\e[255G\e[5D|\e[32m OK \e[0m|"
55 echo -e "\e[1A\e[255G\e[5D\a|\e[1;31mFAIL\e[0m|"
61 define(`main_begin', `case "`$'1" in')
63 define(`main_end', `default_restart *)
64 echo "Usage: `$'0 { undivert(1)end_restart }"
71 ifelse(initstyle, `sysv_nice', `
73 define(`echo_title', `ifelse(`$1', `', `define(`dostatus', 0)dnl', `define(`dostatus', 1) title "$1"')')
75 define(`echo_status', `ifelse(dostatus, 1, ` status', `dnl')')
77 define(`check', `ifelse(dostatus, 1, `$* || error=$?', `$*')')
81 define(`echo_title', `ifelse(`$1', `', `dnl', ` echo "$1"')')
82 define(`echo_status', `dnl')
86 define(`block_begin', `$1)
88 this_is_not_the_first_option`$1'dnl
89 define(`this_is_not_the_first_option',` | ')dnl
90 define(`default_$1', `')dnl
91 define(`end_$1', `')dnl
95 define(`block_split', `echo_status
99 define(`block_end', `echo_status