UNPKG

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