[go: up one dir, main page]

File: svdir

package info (click to toggle)
svtools 0.5-3
  • links: PTS
  • area: contrib
  • in suites: etch, etch-m68k, lenny, sarge
  • size: 132 kB
  • ctags: 25
  • sloc: sh: 972; makefile: 132
file content (97 lines) | stat: -rwxr-xr-x 2,011 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
#!/bin/sh
#
# svdir
# Find daemontools service directory
# Klaus Reimer <k@ailis.de>

TITLE=svdir
VERSION=0.3
AUTHOR="Klaus Reimer"
EMAIL=k@ailis.de
COPYRIGHT="Copyright (C) 2000-2003 by $AUTHOR"

showHelp() {
  echo "Usage: $TITLE [OPTION]..."
  echo "Find daemontools service directory"
  echo ""
  echo "  -h, --help     Display help and exit"
  echo "  -V, --version  Display version and exit"
  echo ""
  echo "This utility tries to find the daemontools service directory and"
  echo "print it to stdout. It first checks the current directory of a"
  echo "running svscan process and then it checks some default locations"
  echo "like /var/lib/svscan and /service. It returns 0 if it have found"
  echo "the location and 1 if not."
  echo ""
  echo "Report bugs to $AUTHOR <$EMAIL>"
}

showVersion() {
  echo "$TITLE $VERSION"
  echo ""
  echo "$COPYRIGHT"
  echo "This is free software; you can redistribute it and/or modify it under"
  echo "the terms of the GNU General Public License as published by the Free"
  echo "Software Foundation; either version 2 of the License, or (at your"
  echo "option) any later version."
}

while getopts "hV-:" NAME
do
  case "$NAME" in
    h)
      showHelp
      exit 0
      ;;
    V)
      showVersion
      exit 0
      ;;
    -)
      case "$OPTARG" in
        help)
          showHelp
          exit 0
          ;;
        version)
          showVersion
          exit 0
          ;;
        *)
          echo "Unknown option: $OPTARG"
          showHelp
          exit 1
      esac  
      ;;
    *)
      echo "Unknown option: $OPTARG"
      showHelp
      exit 1
  esac
done

shift `expr $OPTIND - 1`
if [ $# -ne 0 ]
then
  showHelp
  exit 1
fi

if ! SVDIR=`readlink /proc/\`pidof svscan\`/cwd`
then
  if [ -d "/var/lib/svscan" ]
  then
    SVDIR="/var/lib/svscan"
  else
    if [ -d "/service" ]
    then
      SVDIR="/service"
    else
      echo "$TITLE: Unable to determine daemontools service dir" >&2
      exit 1
    fi
  fi
fi

echo "$SVDIR"
exit 0