This repository has been archived by the owner on Sep 7, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 2
/
bootstrap.sh
137 lines (113 loc) · 4.33 KB
/
bootstrap.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
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
#!/bin/bash
set -e
# Boostraps a Wrektranet dev box. This is primarily for use with Vagrant on a
# Ubuntu box, could be used on any real Ubuntu box, in theory.
#
# REQUIRES:
# Download of the "Oracle InstantClient RPM files for Linux x86-64" from
# <http://www.oracle.com/technetwork/topics/linuxx86-64soft-092277.html>.
# These files are: basic, sqlplus, and SDK (listed as 'devel' for the RPM).
# Download those files, and put them in the top-level Wrektranet git directory.
#
# Here's a rough set of steps that will be taken to get everything provisioned:
# 01. Setup a simple directory structure.
# 02. Update apt-get
# 03. Install needed mysql packages with apt-get
# 04. Convert the RPM files to DEB files, and install them.
# 05. Setup ORACLE environment variables and symlinks
# 06. Install RVM
# 07. Install Node.js
# 08. Download the correct ruby version with RVM
# 09. Install bundler
# 10. Install project dependencies
#
# That should settle everything. Rails is downloaded as a Gem dependency, so
# no worries about that. Let's get started.
cd /home/vagrant
# 1. Move files around, get the version of the oracle client
mkdir oracle_raws/
cd wrektranet/
for file in $(ls | grep 'oracle-instantclient');
do cp $file /home/vagrant/oracle_raws/;
done
cd /home/vagrant/oracle_raws
ORACLE_CLIENT_VERSION=$(ls |
grep 'oracle' |
sed 's/oracle-instantclient\([0-9]*.[0-9]*\).*/\1/p' |
head -n1)
cd /home/vagrant
# 2. Update apt-get
printf "Updating apt-get..."
sudo DEBIAN_FRONTEND=noninteractive apt-get update
sudo DEBIAN_FRONTEND=noninteractive apt-get --assume-yes upgrade
sudo DEBIAN_FRONTEND=noninteractive apt-get --assume-yes dist-upgrade
printf "done\n"
# 3. Install neeeded mysql packages
printf "Installing libaio1..."
sudo DEBIAN_FRONTEND=noninteractive apt-get --assume-yes install libaio1
printf "done\n"
printf "Installing mysql-server..."
sudo DEBIAN_FRONTEND=noninteractive apt-get install -y mysql-server
printf "done\n"
# 4. Convert/install RPM files
printf "Installing alien..."
sudo DEBIAN_FRONTEND=noninteractive apt-get --assume-yes install alien
printf "done\n"
cd oracle_raws/
for file in $(ls);
do printf "Converting $file to .deb file...";
sudo alien -i $file > /dev/null;
printf "done\n";
done
# 5. Setup Oracle env files and symlinks
echo "
export ORACLE_HOME=/usr/lib/oracle/$ORACLE_CLIENT_VERSION/client64
export PATH=\$PATH:\$ORACLE_HOME/bins
export LD_LIBRARY_PATH=/usr/lib/oracle/$ORACLE_CLIENT_VERSION/client64/lib/\${LD_LIBRARY_PATH:+:\$LD_LIBRARY_PATH}" > oracle.sh
sudo mv oracle.sh /etc/profile.d/oracle.sh
sudo chmod o+r /etc/profile.d/oracle.sh
sudo ln -s /usr/include/oracle/$ORACLE_CLIENT_VERSION/client64 /usr/lib/oracle/$ORACLE_CLIENT_VERSION/client64/include
source /etc/profile.d/oracle.sh
# 6. Install RVM
printf "Installing curl..."
sudo DEBIAN_FRONTEND=noninteractive apt-get --assume-yes install curl
printf "done\n"
RVM_KEY=409B6B1796C275462A1703113804BB82D39DC0E3
gpg --keyserver hkp://keys.gnupg.net --recv-keys $RVM_KEY > /dev/null
printf "Installing RVM..."
curl -sSL https://get.rvm.io | bash -s stable --ruby
printf "done\n"
source ~/.rvm/scripts/rvm
sudo DEBIAN_FRONTEND=noninteractive apt-get autoremove --assume-yes
# 7. Install Node.js
curl -sL https://deb.nodesource.com/setup_4.x | sudo -E bash -
printf "Installing nodejs..."
sudo DEBIAN_FRONTEND=noninteractive apt-get --assume-yes install -y nodejs
printf "done\n"
# 8. Download project ruby version (if there's an automated way for RVM to do
# this, go ahead and replace what's here with that).
cd /home/vagrant/wrektranet
RUBY_VERSION=$(cat Gemfile |
grep "^ruby" |
sed "s/ruby '\([0-9]*\.[0-9]*\.[0-9]*\)'/\1/")
NANO_VERSION=p247
#FULL_VERSION=ruby-$RUBY_VERSION-$NANO_VERSION
printf "Installing $RUBY_VERSION..."
rvm install $RUBY_VERSION > /dev/null
printf "done\n"
rvm --default use 2.0.0
# 9. Install bundler and git
printf "Installing git..."
sudo DEBIAN_FRONTEND=noninteractive apt-get --assume-yes install git
printf "dont\n"
printf "Installing bundler..."
gem install bundler
printf "done\n"
# 10. Install project dependencies
printf "Installing libmysqlclient-dev..."
sudo DEBIAN_FRONTEND=noninteractive apt-get --assume-yes install libmysqlclient-dev
printf "done\n"
printf "Running bundle install..."
bundle install
printf "done\n"
exit 0