UNPKG

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