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.

103 lines
2.5 KiB

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