Repository navigation
Expand file tree
/
Copy pathstackscript.sh
More file actions
111 lines (89 loc) · 3.03 KB
/
Copy pathstackscript.sh
File metadata and controls
111 lines (89 loc) · 3.03 KB
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
#!/bin/bash
#
# Installs Ruby 1.9.3-p194, and Nginx with Passenger.
#
# <UDF name="db_password" Label="MySQL root password" />
# <UDF name="deploy_password" Label="Deployment user password" />
NGINX_INSTALL_PATH="/usr/local/nginx"
NGINX_DAEMON_PATH="/usr/local/nginx/sbin/nginx"
RUBY_VERSION="ruby-1.9.3-p194"
# Update packages and install essentials
apt-get update
apt-get -y upgrade
apt-get -y install \
build-essential \
zlib1g-dev \
libssl-dev \
libreadline5-dev \
libyaml-dev \
libcurl4-openssl-dev \
libxslt1-dev \
libxml2-dev \
git-core \
python-software-properties
add-apt-repository ppa:chris-lea/node.js
apt-get update
apt-get -y install nodejs
# Set up MySQL
echo "mysql-server-5.1 mysql-server/root_password password $DB_PASSWORD" | debconf-set-selections
echo "mysql-server-5.1 mysql-server/root_password_again password $DB_PASSWORD" | debconf-set-selections
apt-get -y install \
mysql-server \
mysql-client
sleep 5
PERCENT=40
MEM=$(awk '/MemTotal/ {print int($2/1024)}' /proc/meminfo) # how much memory in MB this system has
MYMEM=$((MEM*PERCENT/100)) # how much memory we'd like to tune mysql with
MYMEMCHUNKS=$((MYMEM/4)) # how many 4MB chunks we have to play with
# mysql config options we want to set to the percentages in the second list, respectively
OPTLIST=(key_buffer sort_buffer_size read_buffer_size read_rnd_buffer_size myisam_sort_buffer_size query_cache_size)
DISTLIST=(75 1 1 1 5 15)
for opt in ${OPTLIST[@]}; do
sed -i -e "/\[mysqld\]/,/\[.*\]/s/^$opt/#$opt/" /etc/mysql/my.cnf
done
for i in ${!OPTLIST[*]}; do
val=$(echo | awk "{print int((${DISTLIST[$i]} * $MYMEMCHUNKS/100))*4}")
if [ $val -lt 4 ]
then val=4
fi
config="${config}\n${OPTLIST[$i]} = ${val}M"
done
sed -i -e "s/\(\[mysqld\]\)/\1\n$config\n/" /etc/mysql/my.cnf
# Set up Postfix
echo "postfix postfix/main_mailer_type select Internet Site" | debconf-set-selections
echo "postfix postfix/mailname string localhost" | debconf-set-selections
echo "postfix postfix/destinations string localhost.localdomain, localhost" | debconf-set-selections
apt-get -y install postfix
/usr/sbin/postconf -e "inet_interfaces = loopback-only"
# Change to temp directory
cd /tmp
# Set up Ruby
wget ftp://ftp.ruby-lang.org/pub/ruby/1.9/$RUBY_VERSION.tar.gz
tar xzf $RUBY_VERSION.tar.gz
rm "$RUBY_VERSION.tar.gz"
cd $RUBY_VERSION
./configure
make
make install
cd ..
rm -rf $RUBY_VERSION
# Set up mysql-ruby
apt-get -y install \
libmysql-ruby \
libmysqlclient-dev
# Set up gems
gem update --system
gem install bundler --no-ri --no-rdoc
gem install passenger --no-ri --no-rdoc
# Set up nginx+passenger
passenger-install-nginx-module --auto --auto-download --prefix="$NGINX_INSTALL_PATH"
# Set up nginx init script
wget https://raw.github.com/jordanthomas/nginx-init-ubuntu/master/nginx
mv nginx /etc/init.d/
chmod +x /etc/init.d/nginx
/usr/sbin/update-rc.d -f nginx defaults
# Add deploy user
echo "deploy:$DEPLOY_PASSWORD:1000:1000::/home/deploy:/bin/bash" | newusers
cp -a /etc/skel/.[a-z]* /home/deploy/
chown -R deploy /home/deploy
echo "deploy ALL=(ALL) ALL" >> /etc/sudoers