-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbootstrap.sh
More file actions
68 lines (51 loc) · 2.28 KB
/
bootstrap.sh
File metadata and controls
68 lines (51 loc) · 2.28 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
#!/bin/bash
# Ask for deploy user name
read -p "Deploy user name [deploy]: " username
deploy_user=${username:-deploy}
echo -n ""
# Ask for MySQL root password
read -p "MySQL root password: " -s mysql_root_password
if [ ! -n "$mysql_root_password" ]; then
echo "MySQL root password must be given. Cannot continue."
exit 1
fi
if [ ! -d /home/$deploy_user ]; then
# Add deploy user
sudo adduser --disabled-password --gecos "" $deploy_user
fi
# Add deploy to sudoers
sudo sh -c "echo '$deploy_user ALL=(ALL) NOPASSWD:ALL' > /etc/sudoers.d/99-$deploy_user"
# Add public key file
sudo su $deploy_user -c "curl -s ssh.keychain.io/mail@marceldegraaf.net/install | bash"
# Install Ruby
sudo apt-get install -y python-software-properties
sudo apt-add-repository ppa:brightbox/ruby-ng
sudo apt-get update
sudo apt-get install -y ruby1.9.1
# Install bundler
sudo gem install bundler --no-ri --no-rdoc --update
# Set MySQL root password
sudo debconf-set-selections <<< "mysql-server mysql-server/root_password password $mysql_root_password"
sudo debconf-set-selections <<< "mysql-server mysql-server/root_password_again password $mysql_root_password"
# Install support software
sudo apt-get install -y build-essential vim imagemagick wget git-core htop libmagickwand-dev libcurl4-openssl-dev libpcre3-dev ruby-dev libssl0.9.8 libmysql-ruby libmysqlclient-dev nodejs mysql-server
# Install Passenger
sudo gem install passenger --no-ri --no-rdoc --update
# Create application dirs
sudo mkdir -p /apps
# Give deploy user access to application dirs
sudo chown $deploy_user: /apps
# Install nginx init script and config file
sudo mkdir -p /etc/init.d
sudo mkdir -p /etc/nginx
sudo su -c "curl -s https://raw.github.com/exodusbv/bootstrap/master/files/nginx.init.sh > /etc/init.d/nginx"
sudo su -c "curl -s https://raw.github.com/exodusbv/bootstrap/master/files/nginx.conf > /etc/nginx/nginx.conf"
sudo chmod +x /etc/init.d/nginx
# Install create-database script
sudo rm -f /usr/bin/create-database
sudo su -c "curl -s https://raw.github.com/exodusbv/bootstrap/master/create-database.sh > /usr/bin/create-database"
sudo chmod go+rx /usr/bin/create-database
# Install Passenger/Nginx module
sudo su -c "passenger-install-nginx-module --auto --auto-download"
# Done!
echo "Done! This server is now ready to host Ruby/Rails apps."