Commit 15a62c9e authored by Rodrigo Souto's avatar Rodrigo Souto
Browse files

debian-package: fix package install

  * Fix bundle call that was crashing install.
  * Ask if the database should be configured before install (avoid
    crashes on custom db setups).
  * Move private files cache to production script.
parent 60b25977
......@@ -102,9 +102,6 @@ Depends: adduser,
ruby-slim,
unicorn (>= 4.8),
pkg-config,
postgresql,
postgresql-client,
postgresql-contrib,
zlib1g-dev,
${misc:Depends}
Description: free web-based platform for social networks
......
production:
adapter: _DBC_DBTYPE_
adapter: postgresql
database: _DBC_DBNAME_
encoding: unicode
username: _DBC_DBUSER_
......
......@@ -2,9 +2,6 @@
set -e
# dbconfig-common uses "pgsql", but we want "postgresql"
sed -i -e 's/adapter: pgsql/adapter: postgresql/' /etc/noosfero/database.yml
cd /usr/share/noosfero && rake rails:update:bin
cd /usr/share/noosfero && su noosfero -c "rake db:schema:load RAILS_ENV=production"
cd /usr/share/noosfero && su noosfero -c "rake db:migrate RAILS_ENV=production SCHEMA=/dev/null"
......
......@@ -7,10 +7,16 @@ if [ -f /usr/share/dbconfig-common/dpkg/config ]; then
# comma-separated, e.g. "mysql, pgsql, sqlite3"
dbc_dbtypes="pgsql"
. /usr/share/dbconfig-common/dpkg/config
dbc_go noosfero $@
db_input high noosfero/default_database_config || true
db_go || true
db_get noosfero/default_database_config
if [ "$RET" = "true" ]; then
. /usr/share/dbconfig-common/dpkg/config
dbc_go noosfero $@
db_input high noosfero/initial_domain || true
fi
db_input high noosfero/initial_domain || true
db_input high noosfero/email_setup_warning || true
db_go || true
fi
......@@ -18,7 +18,7 @@ if [ -r $thin_config ]; then
if [ "$thin_sha1" != "$thin_orig_sha1" ]; then
port=$(awk '{ if ($1 == "port:") { print($2) } }' $thin_config)
servers=$(awk '{ if ($1 == "servers:") { print($2) } }' $thin_config)
if test -n "$port" && test "$port" -ne 50000 || test -n "$servers" && test "$servers" -ne 1 ; then
if test -n "$port" && test "$port" -ne 50000 || test -n "$servers" && test "$servers" -ne 1 ; then
# thin configuration was changed; update unicorn configuration
# accordingly
sed -i -e "s/listen.*/listen '127.0.0.1:$port'/" $unicorn_config
......@@ -42,7 +42,13 @@ chown noosfero /var/log/noosfero 2>/dev/null ||
# Install unavailable dependencies with RubyGems
##############################################################################
cd /usr/share/noosfero && bundle
cd /usr/share/noosfero && bundle > /dev/null
# Avoid "Not a git repository" error messages
# This happens due to gem dependencies that uses git on the gemspec file
##############################################################################
cd /usr/share/noosfero && git init > /dev/null
# create noosfero dynamic data directories
##############################################################################
......@@ -55,36 +61,34 @@ makedir $noosfero_data_dir/public/articles
makedir $noosfero_data_dir/public/image_uploads
makedir $noosfero_data_dir/public/thumbnails
# Instruct dbconfig-common to generate database configuration file
##############################################################################
noosfero_database_yml="/etc/noosfero/database.yml"
dbc_generate_include="template:$noosfero_database_yml"
dbc_generate_include_args="-o template_infile=/usr/share/noosfero/config/database.yml.template"
dbc_generate_include_owner="root:noosfero"
dbc_generate_include_perms="640"
. /usr/share/debconf/confmodule
db_get noosfero/initial_domain
if [ ! -z "$RET" ]; then
# this is going to be used by the db:data:minimal rake task, called by
# /usr/lib/noosfero/dbinstall
export NOOSFERO_DOMAIN="$RET"
fi
db_get noosfero/default_database_config
if [ "$RET" = "true" ]; then
# Instruct dbconfig-common to generate database configuration file
##############################################################################
noosfero_database_yml="/etc/noosfero/database.yml"
dbc_generate_include="template:$noosfero_database_yml"
dbc_generate_include_args="-o template_infile=/usr/share/noosfero/config/database.yml.template"
dbc_generate_include_owner="root:noosfero"
dbc_generate_include_perms="640"
db_get noosfero/initial_domain
if [ ! -z "$RET" ]; then
# this is going to be used by the db:data:minimal rake task, called by
# /usr/lib/noosfero/dbinstall
export NOOSFERO_DOMAIN="$RET"
fi
/etc/init.d/noosfero setup
/etc/init.d/noosfero setup
# dbconfig-common magic
. /usr/share/dbconfig-common/dpkg/postinst
dbc_go noosfero $@
# dbconfig-common magic
. /usr/share/dbconfig-common/dpkg/postinst
dbc_go noosfero $@
if [ ! -f /usr/share/noosfero/cache/private_files.pag ] && [ $1 = "configure" ] && [ -n $2 ]; then
echo "Creating private files dbm map..."
cd /usr/share/noosfero && su noosfero -c "rake cache:private_files RAILS_ENV=production"
# stop debconf to avoid the problem with infinite hanging, cfe
# http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=295477
db_stop
fi
# stop debconf to avoid the problem with infinite hanging, cfe
# http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=295477
db_stop
#DEBHELPER#
......@@ -19,3 +19,14 @@ Description: Noosfero needs a working e-mail setup
Basically, your local MTA needs to deliver e-mail to the internet. Please
check /usr/share/doc/noosfero/README.Debian for detailed instructions on
setting this up.
Template: noosfero/default_database_config
Type: boolean
Description: Do you want to use default local database configuration?
Noosfero provides a default database configurations in order to facilitate the
installation process. If you intend to use a local database or don't know how
to configure the database it's highly recommended that you answer "yes" on
this question.
.
If you want to use and external database or want a custom database configuration
answer "no" and configure your database manually.
......@@ -98,12 +98,18 @@ environments_loop() {
RAILS_ENV=$env bundle exec ./script/feed-updater "$action" -i $env
./script/whenever $action $env
RAILS_ENV=$env ./script/noosfero-plugins services "$action"
if [ ! -f /usr/share/noosfero/cache/private_files.pag ] && [ "$action" = "start" ]; then
RAILS_ENV=$env rake cache:private_files
fi
done
else
bundle exec ./script/delayed_job "$action"
bundle exec ./script/feed-updater "$action"
./script/whenever $action
./script/noosfero-plugins services "$action"
if [ ! -f /usr/share/noosfero/cache/private_files.pag ] && [ "$action" = "start" ]; then
rake cache:private_files
fi
fi
}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment