-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathinstall.sh
More file actions
executable file
·115 lines (99 loc) · 3.29 KB
/
install.sh
File metadata and controls
executable file
·115 lines (99 loc) · 3.29 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
112
113
114
115
#!/bin/bash
echo "================== ssh keygen ======================="
ssh-keygen
echo ""
sudo apt-get install libgmp3-dev -y
echo "================== Install RVM ======================="
echo "gem: --no-document" >> ~/.gemrc
echo "Do you wish to install rvm?"
select yn in "Yes" "No"; do
case $yn in
Yes )
curl -sSL https://rvm.io/mpapis.asc | gpg --import -
curl -sSL https://get.rvm.io | bash -s stable
source ~/.rvm/scripts/rvm
rvm requirements
break
;;
No ) break;;
esac
done
echo ""
echo "================== Install Ruby ======================"
echo "Do you wish to install ruby?"
select yn_ruby in "Yes" "No"; do
case $yn_ruby in
Yes )
read -p "Enter ruby version you want : 2.2.4 is default" ruby_version
ruby_version=${ruby_version:-2.2.4}
rvm install $ruby_version
rvm use $ruby_version --default
rvm rubygems current
break
;;
No ) break;;
esac
done
echo ""
echo "================== Define application ================"
read -p "Enter your application name : " app_name
until [[ ! ${#app_name} = 0 ]]; do
echo "Application name are not filled"
read -p "Enter your application name : " app_name
done
echo ""
echo "Your application name is : $app_name"
rvm gemset create $app_name
echo ""
echo "================== Install default gems =============="
rvm @global do gem install bundler
# gem install rails --no-ri --no-rdoc
echo ""
echo "================== Install postgresql ================"
echo "Do you wish to install postgresql?"
select yn_psql in "Yes" "No"; do
case $yn_psql in
Yes )
sudo apt-get install -y postgresql libpq-dev
sudo -u postgres createuser rails
sudo -u postgres createdb $app_name --owner=rails
sudo service postgresql restart
break
;;
No ) break;;
esac
done
echo ""
echo "================== Download unicorn conf ============"
wget https://raw.githubusercontent.com/ayann/vps/master/unicorn.conf.rb
mkdir -p $app_name/shared/config
mv unicorn.conf.rb $app_name/shared/config/unicorn.conf.rb
echo ""
echo "================== Download unicorn init script ============"
wget https://raw.githubusercontent.com/ayann/vps/master/unicorn.sh
sed -i.bak -e "s/rails-demo/$app_name/g" unicorn.sh
chmod +x unicorn.sh
sudo mv ~/unicorn.sh /etc/init.d/unicorn
sudo update-rc.d unicorn defaults
echo ""
echo "================== Instal nginx ============"
sudo apt-get install nginx -y
echo ""
echo "================== Download & set nginx host ============="
sudo rm /etc/nginx/sites-enabled/*
wget https://raw.githubusercontent.com/ayann/vps/master/nginx.host
sed -i.bak -e "s/rails-demo/$app_name/g" nginx.host
sudo mv ~/nginx.host /etc/nginx/sites-available/$app_name
sudo ln -s /etc/nginx/sites-available/$app_name /etc/nginx/sites-enabled/$app_name
echo ""
echo "================== Reload nginx ============"
# Reload nginx. Make sure to use the `reload` action so that nginx can check
# your configuration before reloading, thereby saving you from causing downtime.
sudo nginx -t && sudo service nginx reload
echo ""
echo "================== Reload nginx ============"
sudo ufw allow 80
echo ""
echo "================== Reboot VPS ============"
sudo reboot
echo ""