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.

59 lines
1.2 KiB

  1. # vim: set ft=sh:
  2. # --- SDE-COPYRIGHT-NOTE-BEGIN ---
  3. # This copyright note is auto-generated by ./scripts/Create-CopyPatch.
  4. #
  5. # Filename: package/.../runit/overlay.d/runit/D%libdir_runit-run.in.txt
  6. # Copyright (C) 2010 The OpenSDE Project
  7. #
  8. # More information can be found in the files COPYING and README.
  9. #
  10. # This program is free software; you can redistribute it and/or modify
  11. # it under the terms of the GNU General Public License as published by
  12. # the Free Software Foundation; version 2 of the License. A copy of the
  13. # GNU General Public License can be found in the file COPYING.
  14. # --- SDE-COPYRIGHT-NOTE-END ---
  15. usage() {
  16. cat <<EOT >&2
  17. usage: $0 <run_script>
  18. ln -s $0 <run_script>; <run_script>
  19. EOT
  20. exit 1
  21. }
  22. die() {
  23. [ $# -eq 0 ] || echo "$*" >&2
  24. exit 1
  25. }
  26. progname() {
  27. case "$1" in
  28. /*) echo "$1" ;;
  29. */*) echo "$(cd "${1%/*}"; pwd)/${1##*/}" ;;
  30. *) if [ "$PWD" = / ]; then
  31. echo "/$1"
  32. else
  33. echo "$PWD/$1"
  34. fi ;;
  35. esac
  36. }
  37. case "$0" in
  38. D_sbindir/${TEMPLATE:-runit-run})
  39. # Sha-Bang'ed
  40. [ $# -gt 0 ] || usage
  41. if [ -s "$1" ] && ${SHELL:-sh} -n "$1"; then
  42. PROGNAME="$(progname "$1")"; shift
  43. SCRIPT=yes
  44. else
  45. die "$PROGNAME: invalid script" >&2
  46. fi
  47. ;;
  48. *)
  49. # symlinked
  50. PROGNAME="$(progname "$0")"
  51. SCRIPT=
  52. esac
  53. cd "${PROGNAME%/*}"