1 | #!/usr/bin/env bash
|
2 |
|
3 |
|
4 |
|
5 |
|
6 |
|
7 |
|
8 |
|
9 |
|
10 | if [ -d "/usr/lib/yottadb" ]; then
|
11 | echo "YottaDB appears to have already been installed - aborting"
|
12 | return
|
13 | fi
|
14 |
|
15 |
|
16 |
|
17 | echo 'Preparing environment'
|
18 |
|
19 | sudo apt-get update
|
20 | sudo apt-get install -y build-essential libssl-dev dos2unix
|
21 | sudo apt-get install -y wget gzip openssh-server curl python-minimal libelf1
|
22 |
|
23 |
|
24 |
|
25 | ydbversion=r1.24
|
26 |
|
27 | echo "Installing YottaDB $ydbversion"
|
28 |
|
29 | mkdir /tmp/tmp
|
30 | cd /tmp/tmp
|
31 | wget https://gitlab.com/YottaDB/DB/YDB/raw/master/sr_unix/ydbinstall.sh
|
32 | chmod +x ydbinstall.sh
|
33 |
|
34 |
|
35 | gtmroot=/usr/lib/yottadb
|
36 | gtmcurrent=$gtmroot/current
|
37 | if [ -e "$gtmcurrent"] ; then
|
38 | mv -v $gtmcurrent $gtmroot/previous_`date -u +%Y-%m-%d:%H:%M:%S`
|
39 | fi
|
40 | sudo mkdir -p $gtmcurrent
|
41 | sudo ./ydbinstall.sh --utf8 default --verbose --linkenv $gtmcurrent --linkexec $gtmcurrent $ydbversion
|
42 | echo "Configuring YottaDB $ydbversion"
|
43 |
|
44 | gtmprof=$gtmcurrent/gtmprofile
|
45 | gtmprofcmd="source $gtmprof"
|
46 | $gtmprofcmd
|
47 | tmpfile=`mktemp`
|
48 | if [ `grep -v "$gtmprofcmd" ~/.profile | grep $gtmroot >$tmpfile`] ; then
|
49 | echo "Warning: existing commands referencing $gtmroot in ~/.profile may interfere with setting up environment"
|
50 | cat $tmpfile
|
51 | fi
|
52 |
|
53 | echo 'copying ' $gtmprofcmd ' to profile...'
|
54 | echo $gtmprofcmd >> ~/.profile
|
55 |
|
56 | rm $tmpfile
|
57 | unset tmpfile gtmprofcmd gtmprof gtmcurrent gtmroot
|
58 |
|
59 | echo 'YottaDB has been installed and configured, ready for use'
|
60 | echo 'Enter the YottaDB shell by typing the command: gtm Exit it by typing the command H'
|
61 |
|
62 |
|
63 |
|
64 | echo 'Installing Node.js'
|
65 |
|
66 | cd ~
|
67 |
|
68 | curl -o- https://raw.githubusercontent.com/creationix/nvm/v0.32.1/install.sh | bash
|
69 | export NVM_DIR="$HOME/.nvm"
|
70 | [ -s "$NVM_DIR/nvm.sh" ] && . "$NVM_DIR/nvm.sh"
|
71 |
|
72 | VERSION=${1:-8}
|
73 |
|
74 | nvm install $VERSION
|
75 |
|
76 | PLATFORM=$(uname -m)
|
77 | if [[ "$PLATFORM" != "armv"* ]]; then
|
78 |
|
79 |
|
80 |
|
81 | sudo ln -s /usr/local/bin/node /usr/bin/node
|
82 | sudo ln -s /usr/local/lib/node /usr/lib/node
|
83 | sudo ln -s /usr/local/bin/npm /usr/bin/npm
|
84 | sudo ln -s /usr/local/bin/node-waf /usr/bin/node-waf
|
85 | n=$(which node);n=${n%/bin/node}; chmod -R 755 $n/bin/*; sudo cp -r $n/{bin,lib,share} /usr/local
|
86 | fi
|
87 |
|
88 |
|
89 |
|
90 | echo 'Installing QEWD and associated modules'
|
91 |
|
92 | cd ~
|
93 | mkdir qewd
|
94 | cd qewd
|
95 | npm install qewd qewd-monitor
|
96 |
|
97 |
|
98 |
|
99 | echo 'Installing NodeM'
|
100 |
|
101 | npm install nodem
|
102 | sudo ln -sf $gtm_dist/libgtmshr.so /usr/local/lib/
|
103 | sudo ldconfig
|
104 | base=~/qewd
|
105 | [ -f "$GTMCI" ] || export GTMCI="$(find $base -iname nodem.ci)"
|
106 | export ydb_ci="$(find $base -iname nodem.ci)"
|
107 | nodemgtmr="$(find $base -iname v4wnode.m | tail -n1 | xargs dirname)"
|
108 | echo "$gtmroutines" | fgrep "$nodemgtmr" || export gtmroutines="$nodemgtmr $gtmroutines"
|
109 | echo "$ydb_routines" | fgrep "$nodemgtmr" || export ydb_routines="$nodemgtmr $ydb_routines"
|
110 |
|
111 | echo 'base=~/qewd' >> ~/.profile
|
112 | echo '[ -f "$GTMCI" ] || export GTMCI="$(find $base -iname nodem.ci)"' >> ~/.profile
|
113 | echo 'export ydb_ci="$(find $base -iname nodem.ci)"' >> ~/.profile
|
114 | echo 'nodemgtmr="$(find $base -iname v4wnode.m | tail -n1 | xargs dirname)"' >> ~/.profile
|
115 | echo 'echo "$gtmroutines" | fgrep "$nodemgtmr" || export gtmroutines="$nodemgtmr $gtmroutines"' >> ~/.profile
|
116 | echo 'echo "$ydb_routines" | fgrep "$nodemgtmr" || export ydb_routines="$nodemgtmr $ydb_routines"' >> ~/.profile
|
117 |
|
118 |
|
119 |
|
120 | dos2unix ~/qewd/node_modules/qewd/installers/*
|
121 |
|
122 | echo 'Moving QEWD files into place'
|
123 |
|
124 | mv ~/qewd/node_modules/qewd/example/qewd-gtm.js ~/qewd/qewd.js
|
125 |
|
126 | cd ~/qewd
|
127 | mkdir www
|
128 | cd www
|
129 | mkdir qewd-monitor
|
130 | cp ~/qewd/node_modules/qewd-monitor/www/bundle.js ~/qewd/www/qewd-monitor
|
131 | cp ~/qewd/node_modules/qewd-monitor/www/*.html ~/qewd/www/qewd-monitor
|
132 | cp ~/qewd/node_modules/qewd-monitor/www/*.css ~/qewd/www/qewd-monitor
|
133 |
|
134 | cd ~/qewd
|
135 |
|
136 | echo 'Done!'
|
137 | echo 'You should now be able to start QEWD by typing: node qewd'
|