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