-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathInstallFreeTDS.sh
54 lines (46 loc) · 1.28 KB
/
InstallFreeTDS.sh
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
# must be ran as sudo
if ! [ $(id -u) = 0 ]; then
echo "I am not root!"
exit 1
fi
writeToFile (){
echo "[FreeTDS]
Description = FreeTDS Driver
Driver = $soPath
" > /etc/odbcinst.ini
echo "FreeTDS installed successfully"
}
echo "Installing FreeTDS"
sudo apt-get install unixodbc unixodbc-dev freetds-dev freetds-bin tdsodbc -y
# find libtdsodbc.so in /usr/lib/ and store it in a variable
soPath=$(find /usr/lib/ -name "libtdsodbc.so")
# if soPath is empty, then the file was not found
if [ -z "$soPath" ]
then
echo "libtdsodbc.so not found"
exit
fi
# check if /etc/odbcinst.ini contains [FreeTDS] section
if grep -q "\[FreeTDS\]" "/etc/odbcinst.ini"; then
echo "FreeTDS already installed"
# do you want to overwrite the file?
read -p "Do you want to overwrite the file? [y/n] " choice
case "$choice" in
y|Y ) writeToFile;;
n|N ) echo "Not overwriting file";;
* ) echo "invalid";;
esac
case "$choice" in
n|N ) echo "FreeTDS not installed";;
esac
exit
fi
echo "Warning: This will overwrite /etc/odbcinst.ini"
read -p "Do you want to continue? [y/n] " choice
case "$choice" in
y|Y ) echo "Installing FreeTDS"
writeToFile;;
n|N ) echo "Not installing FreeTDS";;
* ) echo "invalid";;
esac
exit 0