This repository was archived by the owner on Aug 6, 2023. It is now read-only.
forked from fcoury/phd
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathrails3.sh
More file actions
77 lines (64 loc) · 2.57 KB
/
Copy pathrails3.sh
File metadata and controls
77 lines (64 loc) · 2.57 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
if [[ "$WEB_SERVER" == "apache" ]]; then
PHD_VIRTUALHOST_TEXT='<VirtualHost *:80>
ServerName $host
ServerAlias $dns_alias
DocumentRoot $dir/public
PassengerAppRoot $dir
</VirtualHost>'
else
PHD_VIRTUALHOST_TEXT='server {
listen 80;
server_name $host $dns_alias;
root $dir/public;
passenger_enabled on;
}'
fi
echo "Configuring Rails 3 application..."
configure_vhost
already_existed=$?
rails2=`gem list rails | grep rails | grep \(3`
if [ "$?" == "1" ]; then
echo " => Missing Rails 3 gems, installing..."
sudo apt-get install -q -y libpq-dev > $LOG_DIR/rails3_prereq.log 2>&1
sudo gem install tzinfo builder memcache-client rack rack-test rack-mount erubis mail text-format thor bundler i18n rake --source http://gemcutter.org/ > $LOG_DIR/rails3_install.log 2>&1
sudo gem install rails --pre --source http://gemcutter.org/ > $LOG_DIR/rails3_install.log 2>&1
fi
echo " => Configuring database..."
sudo config_app_db $app_name > $LOG_DIR/config_db.log 2>&1
check_error 'configuring database' 'config_db'
# checks the db/username
name=$app_name
name=${name//[-._]/}
if [ ${#name} -gt 15 ]; then
name=$(echo $name | cut -c1-15)
fi
if [[ ! -f "$dir/config/database.yml" ]]; then
echo " => Configuring database.yml..."
sed "s/@app_name@/$name/g" /var/webbynode/templates/rails/database.yml > $dir/config/database.yml
fi
cd $dir
echo " => Bundling gems..."
unset GIT_DIR && bundle install --without test development > $LOG_DIR/bundler.log 2>&1
check_error 'bundling gems' 'bundler'
ruby -e "require 'rubygems'; require 'bundler'" -e "sqlite3 = Bundler.definition.dependencies.select { |d| d.name == 'sqlite3-ruby' }.first; exit(0) unless sqlite3; groups = sqlite3.groups - [:test, :development]; if groups.any?; exit(1); else; exit(0); end" > $LOG_DIR/check_sqlite3.log 2>&1
if [ $? -eq 1 ]; then
echo ""
echo "---------------------"
echo " W A R N I N G "
echo "---------------------"
echo ""
echo "It seems that you have sqlite3-ruby gem listed in your Gemfile. Please visit the URL:"
echo ""
echo " http://guides.webbynode.com/articles/rapidapps/rails3warning.html"
echo ""
echo "If you receive the following error while starting your application:"
echo ""
echo " Cannot spawn application '/var/rails/your_app': The spawn server has exited unexpectedly."
echo ""
fi
echo " => Migrating database..."
RAILS_ENV=production bundle exec rake db:migrate > $LOG_DIR/db_migrate.log 2>&1
check_error 'migrating database' 'db_migrate'
sudo chown -R git:www-data * > $LOG_DIR/chown.log 2>&1
cd -
restart_webserver $already_existed