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.

164 lines
4.2 KiB

  1. #!/bin/sh
  2. # --- SDE-COPYRIGHT-NOTE-BEGIN ---
  3. # This copyright note is auto-generated by ./scripts/Create-CopyPatch.
  4. #
  5. # Filename: package/.../runit/parse-config
  6. # Copyright (C) 2008 The OpenSDE Project
  7. # Copyright (C) 2004 - 2006 The T2 SDE Project
  8. # Copyright (C) 1998 - 2003 Clifford Wolf
  9. #
  10. # More information can be found in the files COPYING and README.
  11. #
  12. # This program is free software; you can redistribute it and/or modify
  13. # it under the terms of the GNU General Public License as published by
  14. # the Free Software Foundation; version 2 of the License. A copy of the
  15. # GNU General Public License can be found in the file COPYING.
  16. # --- SDE-COPYRIGHT-NOTE-END ---
  17. #
  18. # add init scripts
  19. #
  20. if [ "$SDECFG_INIT" == "runit" ]; then
  21. # runit_substitute
  22. #
  23. runit_substitute() {
  24. local logdir=
  25. if [ "${localstatedir%$pkg}" != "$localstatedir" ]; then
  26. logdir=$localstatedir/log
  27. else
  28. logdir=$localstatedir/log/$pkg
  29. fi
  30. sed -e "s,D_logdir,$logdir,g" $1
  31. }
  32. # runit_tail_install $pkg-$service.tail
  33. #
  34. runit_tail_install() {
  35. local tailfile=
  36. local service=
  37. local servicedir=
  38. for tailfile; do
  39. service=$(echo $tailfile | sed -e "s,^$pkg-,," -e "s,\.tail\$,," -e "s,_,/,g")
  40. if [ "${service#runit-}" != "$service" ]; then
  41. servicedir="$root/etc/runit/${service#runit-}"
  42. else
  43. servicedir="$root$sysconfdir/$service"
  44. fi
  45. echo_status "runit: $tailfile -> ${servicedir#$root}"
  46. tail_install runit "$(pkgdesc confdir runit)/packages/$tailfile" "$servicedir"
  47. done
  48. }
  49. runitconfdir=$(pkgdesc confdir runit)
  50. runit_has_script=0
  51. runit_files="$(cd "$runitconfdir/packages" && ls -1 $pkg-*.tail 2> /dev/null | tr '\n' ' ')"
  52. if [ -n "$runit_files" ]; then
  53. hook_add postdoc 5 "runit_tail_install $runit_files"
  54. runit_has_script=1
  55. fi
  56. runit_files="$(cd "$runitconfdir/packages" && ls -1 $pkg-*.txt 2> /dev/null | tr '\n' ' ')"
  57. if [ -n "$runit_files" ]; then
  58. hook_add postmake 5 "runit_raw_install $runit_files"
  59. runit_has_script=1
  60. fi
  61. runit_raw_install() {
  62. local x= y=
  63. for x; do
  64. y=${x#$pkg-}; y=${y%.txt}; y=${y//_/\/}
  65. if [ "${y#runit-}" != "$y" ]; then
  66. y="$root/etc/runit/${y#runit-}"
  67. else
  68. y="$root$sysconfdir/$y"
  69. fi
  70. echo_status "runit: $x -> ${y#$root}"
  71. mkdir -p "${y%/*}"
  72. cat "$(pkgdesc confdir runit)/packages/$x" | rock_substitute |
  73. runit_substitute > "$y"
  74. case "${y##*/}" in
  75. run|finish) chmod 755 "$y" ;;
  76. esac
  77. done
  78. }
  79. if [ "$SDECFG_PKG_DJB_LAYOUT" == "1" ]; then
  80. for x in package command service; do
  81. var_append flistroot ' ' $x
  82. done
  83. fi
  84. runit_layout() {
  85. if [ -z "$pkg_djb_servicedir" ]; then
  86. if [ "$SDECFG_PKG_DJB_LAYOUT" == "1" ]; then
  87. for x in package command service; do
  88. eval "pkg_djb_${x}dir='$root/$x'"
  89. done
  90. else
  91. pkg_djb_packagedir=
  92. pkg_djb_commanddir="$root$bindir"
  93. pkg_djb_servicedir="$root/var/service"
  94. fi
  95. fi
  96. # create them if it doesn't exist
  97. for x in package command service; do
  98. y=$( eval echo \$pkg_djb_${x}dir )
  99. if [ -n "$y" ]; then
  100. mkdir -p "$y"
  101. # TODO: research where 1755 comes from
  102. [ "$x" = command ] || chmod 1755 "$y"
  103. fi
  104. done
  105. }
  106. hook_add preconf 5 'runit_layout'
  107. if [ $runit_has_script -eq 1 ]; then
  108. install_init() {
  109. # i have already installed the script
  110. true
  111. }
  112. else
  113. install_init() {
  114. name=$1 ; file=$2 ; initdir="$root/etc/rc.d"
  115. echo -n "Install SysV Init script '$name' (xx/xx): "
  116. m4 -Dinitstyle=$SDECFG_INIT_STYLE \
  117. -D"D_prefix=/$prefix" -D"D_sysconfdir=$sysconfdir" \
  118. -D"D_docdir=$docdir" -D"D_localstatedir=$localstatedir" \
  119. -D"D_datadir=$datadir" -D"D_infodir=$infodir" \
  120. -D"D_bindir=$bindir" -D"D_sbindir=$sbindir" \
  121. -D"D_libdir=$libdir" -D"D_mandir=$mandir" \
  122. $base/package/base/sysvinit/init_macros.m4 \
  123. $file > $initdir/init.d/$name
  124. chmod +x $initdir/init.d/$name
  125. echo " done."
  126. }
  127. fi
  128. # minimal services
  129. case "$pkg" in
  130. cron)
  131. hook_add postmake 9 'ln -svnf /etc/runit/cron $pkg_djb_servicedir/cron'
  132. ;;
  133. sysklogd)
  134. hook_add postmake 9 'ln -svnf /etc/runit/syslogd $pkg_djb_servicedir/syslogd'
  135. hook_add postmake 9 'ln -svnf /etc/runit/klogd $pkg_djb_servicedir/klogd'
  136. ;;
  137. esac
  138. unset runitconfdir runitxmode runit_has_script
  139. fi