aboutsummaryrefslogtreecommitdiff
path: root/build/oracle/oracle
blob: 4d518fe331f79c0ef55349147f8d32c55c8c7eb7 (plain)
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
#! /usr/bin/env bash

# file      : build/oracle/oracle
# author    : Constantin Michael <constantin@codesynthesis.com>
# copyright : Copyright (c) 2009-2011 Code Synthesis Tools CC
# license   : GNU GPL v2; see accompanying LICENSE file

#
# Oracle driver wrapper.
#

while [ $# -gt 0 ]; do
  case $1 in
    --driver)
      driver=$2
      shift 2
      ;;
    --user)
      user="$2"
      shift 2
      ;;
    --password)
      passwd="$2"
      shift 2
      ;;
    --service)
      service="$2"
      shift 2
      ;;
    --host)
      host="$2"
      shift 2
      ;;
    --port)
      port="$2"
      shift 2
      ;;
    *)
      break
      ;;
  esac
done

if [ -z "$driver" ]; then
  driver=sqlplus
fi

conn=$user

if [ -n "$passwd" ]; then
  conn="$conn/$passwd"
fi

if [ -n "$host" ]; then
  conn="$conn@//$host"

  if [ -n "$port" ]; then
    conn="$conn:$port"
  fi

  if [ -n "$service" ]; then
    conn="$conn/$service"
  fi
elif [ -n "$service" ]; then
  conn="$conn@$service"
fi

opt="-L $opt"

if [ -n "$1" ]; then
  opt="-S $opt"
  exec $driver $opt $conn @$1
else
  exec $driver $opt $conn
fi