-
Notifications
You must be signed in to change notification settings - Fork 9
/
install.sh
81 lines (72 loc) · 1.93 KB
/
install.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
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
#!/bin/bash
if [ -z "$QHOME" ]
then
echo "ERROR: QHOME environment not set. Installation failed."
exit 1
fi
echo "Detected System"
echo "* OS: $OSTYPE"
echo "* TYPE: $HOSTTYPE"
echo "* MACHINE TYPE: $MACHTYPE"
# DETECT OS TYPE BEING USED
Q_PATH_SEP="/"
Q_HOST_TYPE=""
if [[ "$OSTYPE" == "linux-gnu" ]]; then
Q_HOST_TYPE="l"
elif [[ "$OSTYPE" == "darwin"* ]]; then
# Mac OSX
Q_HOST_TYPE="m"
elif [[ "$OSTYPE" == "cygwin" ]]; then
# POSIX compatibility layer and Linux environment emulation for Windows
Q_HOST_TYPE="w"
Q_PATH_SEP="\\"
elif [[ "$OSTYPE" == "msys" ]]; then
# Lightweight shell and GNU utilities compiled for Windows (part of MinGW)
Q_HOST_TYPE="w"
Q_PATH_SEP="\\"
elif [[ "$OSTYPE" == "win32" ]]; then
Q_HOST_TYPE="w"
Q_PATH_SEP="\\"
elif [[ "$OSTYPE" == "freebsd"* ]]; then
Q_HOST_TYPE="l"
else
echo "ERROR: OSTYPE $OSTYPE not currently supported by this script"
echo "Please view README.md for installation instructions"
exit 1
fi
# DETECT WHETHER 32 OR 64 BIT
Q_MACH_TYPE=""
if [[ "$HOSTTYPE" == "x86_64" ]]; then
Q_MACH_TYPE="64"
else
Q_MACH_TYPE="32"
fi
Q_SCRIPT_DIR=${QHOME}${Q_PATH_SEP}
Q_SHARED_LIB_DIR="${QHOME}${Q_PATH_SEP}${Q_HOST_TYPE}${Q_SHARED_LIB_DIR}${Q_MACH_TYPE}${Q_PATH_SEP}"
# check destination directory exists
if [ ! -w "$Q_SCRIPT_DIR" ]; then
echo "ERROR: Directory '$Q_SCRIPT_DIR' does not exist"
exit 1
fi
if [ ! -w "$Q_SHARED_LIB_DIR" ]; then
echo "ERROR: Directory '$Q_SHARED_LIB_DIR' does not exist"
exit 1
fi
if [ -d q ]; then
echo "Copying q script to $Q_SCRIPT_DIR ..."
cp q/* $Q_SCRIPT_DIR
if [ $? -ne 0 ]; then
echo "ERROR: copy failed"
exit 1
fi
fi
if [ -d lib ]; then
echo "Copying shared lib to $Q_SHARED_LIB_DIR ..."
cp lib/* $Q_SHARED_LIB_DIR
if [ $? -ne 0 ]; then
echo "ERROR: copy failed"
exit 1
fi
fi
echo "Install complete"
exit 0