-
Notifications
You must be signed in to change notification settings - Fork 41
Expand file tree
/
Copy pathgetsqlcl.sh
More file actions
96 lines (90 loc) · 2.36 KB
/
Copy pathgetsqlcl.sh
File metadata and controls
96 lines (90 loc) · 2.36 KB
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
#!/bin/ksh
#
# Standard disclaimer - anything in here can be used at your own risk.
#
# edit the first three variables for your environment
#
# No warranty or liability etc etc etc. See the license file in the git repo root
#
# USE AT YOUR OWN RISK
#
tmpdir=/tmp
tmpfile=sqlcl-latest.zip
target=/u01/app/oracle/product
if [ ! -d $target ] ; then
echo "Fail on the target: $target"
exit 1
fi
if [ ! -d $tmp ] ; then
echo "Fail on the tmp: $tmp"
exit 1
fi
GetLatest()
{
cd $tmpdir
rm -f $tmpfile
rm -rf sqlcl
curl -s -o $tmpfile https://download.oracle.com/otn_software/java/sqldeveloper/sqlcl-latest.zip
if [ -f $tmpfile ] ; then
unzip -q $tmpfile
if [ ! -d sqlcl ] ; then
echo "Drama unzipping the zip"
exit 1
fi
else
echo "Drama downloading the zip"
exit
fi
}
if [ -d $target/sqlcl ] ; then
echo SQLCL already present. Checking version
curver=`$target/sqlcl/bin/sql -version 2>/dev/null | grep Production | awk '{print $NF}'`
case "x$curver" in
x*.*) echo "Current version is: $curver"
;;
*) echo "Got unexpected value for curver: $curver"
exit 1
;;
esac
echo Getting version for latest on oracle site
GetLatest
cd $tmpdir
latestver=`sqlcl/bin/sql -version 2>/dev/null | grep Production | awk '{print $NF}'`
case "x$latestver" in
x$curver) echo "Latest = current, no work to do"
exit 0
;;
x*.*) echo "Latest version is: $latestver, installing over existing"
cd $target
mv sqlcl sqlcl.$curver
unzip -q $tmpdir/$tmpfile
if [ -d sqlcl ] ; then
echo "SQLCL upgrade to $latestver, old version in directory sqlcl.$curver"
exit 0
else
echo "Drama unzipping the zip"
fi
;;
*) echo "Got unexpected value for latest version: $latestver"
exit 1
;;
esac
else
echo No SQLCL found. Grabbing latest
GetLatest
cd $target
unzip -q $tmpdir/$tmpfile
if [ -d sqlcl ] ; then
newver=`sqlcl/bin/sql -version 2>/dev/null | grep Production | awk '{print $NF}'`
case "x$newver" in
x*.*) echo "SQLCL version $newver installed"
exit 0
;;
*) echo "Could not get a version ($newver) for SQLCL. Check installation before using"
exit 1
;;
esac
else
echo "Drama unzipping the zip"
fi
fi