OpenSDE Packages Database (without history before r20070)
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

102 lines
2.4 KiB

  1. dnl
  2. dnl Macros for creating the SysV init scripts with nice or raw output
  3. dnl
  4. dnl --- T2-COPYRIGHT-NOTE-BEGIN ---
  5. dnl This copyright note is auto-generated by ./scripts/Create-CopyPatch.
  6. dnl
  7. dnl T2 SDE: package/.../sysvinit/init_macros.m4
  8. dnl Copyright (C) 2004 - 2006 The T2 SDE Project
  9. dnl Copyright (C) 1998 - 2003 Clifford Wolf
  10. dnl
  11. dnl More information can be found in the files COPYING and README.
  12. dnl
  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 ---
  18. dnl
  19. divert(-1)
  20. initstyle = sysv_nice ....... Nice colored output
  21. initstyle = sysv_text ....... Raw text output
  22. ifelse(initstyle, `sysv_nice',
  23. `define(`IT', `dnl')
  24. define(`IN', `')'
  25. ,
  26. `define(`IT', `')
  27. define(`IN', `dnl')'
  28. )
  29. define(`this_is_not_the_first_option', `')
  30. define(`default_restart', ` restart)
  31. `$'0 stop; `$'0 start
  32. ;;
  33. ')
  34. define(`end_restart', ` | restart')
  35. ifelse(initstyle, `sysv_nice', `
  36. define(`main_begin', `title() {
  37. local x w="`$'( stty size 2>/dev/null </dev/tty | cut -d" " -f2 )"
  38. [ -z "`$'w" ] && w="`$'( stty size </dev/console | cut -d" " -f2 )"
  39. for (( x=1; x<w; x++ )) do echo -n .; done
  40. echo -e "\e[222G\e[3D v \r\e[36m`$'* \e[0m"
  41. error=0
  42. }
  43. status() {
  44. if [ `$'error -eq 0 ]
  45. then
  46. echo -e "\e[1A\e[222G\e[4D\e[32m :-)\e[0m"
  47. else
  48. echo -e "\e[1A\e[222G\e[4D\a\e[1;31m :-(\e[0m"
  49. fi
  50. }
  51. case "`$'1" in')
  52. ' , `
  53. define(`main_begin', `case "`$'1" in')
  54. ')
  55. define(`main_end', `default_restart *)
  56. echo "Usage: `$'0 { undivert(1)end_restart }"
  57. exit 1 ;;
  58. esac
  59. exit 0')
  60. ifelse(initstyle, `sysv_nice', `
  61. define(`echo_title', `ifelse(`$1', `', `define(`dostatus', 0)dnl', `define(`dostatus', 1) title "$1"')')
  62. define(`echo_status', `ifelse(dostatus, 1, ` status', `dnl')')
  63. define(`check', `ifelse(dostatus, 1, `$* || error=$?', `$*')')
  64. ' , `
  65. define(`echo_title', `ifelse(`$1', `', `dnl', ` echo "$1"')')
  66. define(`echo_status', `dnl')
  67. define(`check', `$*')
  68. ')
  69. define(`block_begin', `$1)
  70. divert(1)dnl
  71. this_is_not_the_first_option`$1'dnl
  72. define(`this_is_not_the_first_option',` | ')dnl
  73. define(`default_$1', `')dnl
  74. define(`end_$1', `')dnl
  75. divert(0)dnl
  76. echo_title(`$2')')
  77. define(`block_split', `echo_status
  78. echo_title(`$1')')
  79. define(`block_end', `echo_status
  80. ;;')
  81. divert(0)dnl