Fixes on orchestra deployment
This commit is contained in:
parent
d44adc957b
commit
2c6bd0469b
|
@ -39,10 +39,9 @@ Django-orchestra can be installed on any Linux system, however it is **strongly
|
||||||
5. Create and configure a Postgres database
|
5. Create and configure a Postgres database
|
||||||
```bash
|
```bash
|
||||||
sudo python3 manage.py setuppostgres --db_password <password>
|
sudo python3 manage.py setuppostgres --db_password <password>
|
||||||
python3 manage.py migrate auth
|
# admin_tools needs accounts and does not have migrations
|
||||||
python3 manage.py migrate accounts
|
python3 manage.py migrate accounts
|
||||||
python3 manage.py migrate
|
python3 manage.py migrate
|
||||||
python3 manage.py syncdb
|
|
||||||
```
|
```
|
||||||
|
|
||||||
7. Configure celeryd
|
7. Configure celeryd
|
||||||
|
|
2
TODO.md
2
TODO.md
|
@ -296,3 +296,5 @@ https://code.djangoproject.com/ticket/24576
|
||||||
|
|
||||||
# admin edit relevant djanog settings
|
# admin edit relevant djanog settings
|
||||||
# django SITE_NAME vs ORCHESTRA_SITE_NAME ?
|
# django SITE_NAME vs ORCHESTRA_SITE_NAME ?
|
||||||
|
|
||||||
|
# accounts.migrations link to last auth migration instead of first
|
||||||
|
|
|
@ -70,4 +70,3 @@ LOCALE_PATHS = (
|
||||||
|
|
||||||
|
|
||||||
ORCHESTRA_SITE_NAME = '{{ project_name }}'
|
ORCHESTRA_SITE_NAME = '{{ project_name }}'
|
||||||
|
|
||||||
|
|
|
@ -10,8 +10,8 @@ import django.contrib.auth.models
|
||||||
class Migration(migrations.Migration):
|
class Migration(migrations.Migration):
|
||||||
|
|
||||||
dependencies = [
|
dependencies = [
|
||||||
('auth', '__first__'),
|
# Permissions and contenttypes
|
||||||
('contenttypes', '__first__'),
|
('auth', '0006_require_contenttypes_0002'),
|
||||||
('systemusers', '0001_initial'),
|
('systemusers', '0001_initial'),
|
||||||
]
|
]
|
||||||
|
|
||||||
|
|
|
@ -31,8 +31,8 @@ class DomainSerializer(AccountSerializerMixin, HyperlinkedModelSerializer):
|
||||||
def clean_name(self, attrs, source):
|
def clean_name(self, attrs, source):
|
||||||
""" prevent users creating subdomains of other users domains """
|
""" prevent users creating subdomains of other users domains """
|
||||||
name = attrs[source]
|
name = attrs[source]
|
||||||
top = Domain.get_parent_domain(name)
|
parent = Domain.get_parent_domain(name)
|
||||||
if top and top.account != self.account:
|
if parent and parent.account != self.account:
|
||||||
raise ValidationError(_("Can not create subdomains of other users domains"))
|
raise ValidationError(_("Can not create subdomains of other users domains"))
|
||||||
return attrs
|
return attrs
|
||||||
|
|
||||||
|
|
|
@ -32,7 +32,7 @@ class AutoresponseInline(admin.StackedInline):
|
||||||
|
|
||||||
class MailboxAdmin(ChangePasswordAdminMixin, SelectAccountAdminMixin, ExtendedModelAdmin):
|
class MailboxAdmin(ChangePasswordAdminMixin, SelectAccountAdminMixin, ExtendedModelAdmin):
|
||||||
list_display = (
|
list_display = (
|
||||||
'name', 'account_link', 'filtering', 'display_addresses', 'display_active',
|
'name', 'account_link', 'display_filtering', 'display_addresses', 'display_active',
|
||||||
)
|
)
|
||||||
list_filter = (IsActiveListFilter, HasAddressListFilter, 'filtering')
|
list_filter = (IsActiveListFilter, HasAddressListFilter, 'filtering')
|
||||||
search_fields = ('account__username', 'account__short_name', 'account__full_name', 'name')
|
search_fields = ('account__username', 'account__short_name', 'account__full_name', 'name')
|
||||||
|
@ -75,6 +75,13 @@ class MailboxAdmin(ChangePasswordAdminMixin, SelectAccountAdminMixin, ExtendedMo
|
||||||
display_addresses.short_description = _("Addresses")
|
display_addresses.short_description = _("Addresses")
|
||||||
display_addresses.allow_tags = True
|
display_addresses.allow_tags = True
|
||||||
|
|
||||||
|
def display_filtering(self, mailbox):
|
||||||
|
""" becacuse of allow_tags = True """
|
||||||
|
return mailbox.get_filtering_display()
|
||||||
|
display_filtering.short_description = _("Filtering")
|
||||||
|
display_filtering.admin_order_field = 'filtering'
|
||||||
|
display_filtering.allow_tags = True
|
||||||
|
|
||||||
def get_actions(self, request):
|
def get_actions(self, request):
|
||||||
if settings.MAILBOXES_LOCAL_ADDRESS_DOMAIN:
|
if settings.MAILBOXES_LOCAL_ADDRESS_DOMAIN:
|
||||||
self.actions = (SendMailboxEmail(),)
|
self.actions = (SendMailboxEmail(),)
|
||||||
|
|
|
@ -75,13 +75,13 @@ MAILBOXES_MAILBOX_FILTERINGS = Setting('MAILBOXES_MAILBOX_FILTERINGS',
|
||||||
{
|
{
|
||||||
# value: (verbose_name, filter)
|
# value: (verbose_name, filter)
|
||||||
'DISABLE': (_("Disable"), ''),
|
'DISABLE': (_("Disable"), ''),
|
||||||
'REJECT': (mark_safe_lazy(_("Reject spam (X-Spam-Score≥9)")), textwrap.dedent("""
|
'REJECT': (mark_safe_lazy(_("Reject spam (Score≥9)")), textwrap.dedent("""
|
||||||
require ["fileinto","regex","envelope","vacation","reject","relational","comparator-i;ascii-numeric"];
|
require ["fileinto","regex","envelope","vacation","reject","relational","comparator-i;ascii-numeric"];
|
||||||
if header :value "ge" :comparator "i;ascii-numeric" "X-Spam-Score" "9" {
|
if header :value "ge" :comparator "i;ascii-numeric" "X-Spam-Score" "9" {
|
||||||
discard;
|
discard;
|
||||||
stop;
|
stop;
|
||||||
}""")),
|
}""")),
|
||||||
'REDIRECT': (mark_safe_lazy(_("Archive spam (X-Spam-Score≥9)")), textwrap.dedent("""
|
'REDIRECT': (mark_safe_lazy(_("Archive spam (Score≥9)")), textwrap.dedent("""
|
||||||
require ["fileinto","regex","envelope","vacation","reject","relational","comparator-i;ascii-numeric"];
|
require ["fileinto","regex","envelope","vacation","reject","relational","comparator-i;ascii-numeric"];
|
||||||
if header :value "ge" :comparator "i;ascii-numeric" "X-Spam-Score" "9" {
|
if header :value "ge" :comparator "i;ascii-numeric" "X-Spam-Score" "9" {
|
||||||
fileinto "Spam";
|
fileinto "Spam";
|
||||||
|
|
|
@ -67,7 +67,7 @@ class WebsiteAdmin(SelectAccountAdminMixin, ExtendedModelAdmin):
|
||||||
form = WebsiteAdminForm
|
form = WebsiteAdminForm
|
||||||
filter_by_account_fields = ['domains']
|
filter_by_account_fields = ['domains']
|
||||||
list_prefetch_related = ('domains', 'content_set__webapp')
|
list_prefetch_related = ('domains', 'content_set__webapp')
|
||||||
search_fields = ('name', 'account__username', 'domains__name')
|
search_fields = ('name', 'account__username', 'domains__name', 'content__webapp__name')
|
||||||
|
|
||||||
def display_domains(self, website):
|
def display_domains(self, website):
|
||||||
domains = []
|
domains = []
|
||||||
|
@ -84,7 +84,7 @@ class WebsiteAdmin(SelectAccountAdminMixin, ExtendedModelAdmin):
|
||||||
for content in website.content_set.all():
|
for content in website.content_set.all():
|
||||||
webapp = content.webapp
|
webapp = content.webapp
|
||||||
url = change_url(webapp)
|
url = change_url(webapp)
|
||||||
name = "%s on %s" % (webapp.get_type_display(), content.path or '/')
|
name = "%s on %s" % (webapp.name, content.path or '/')
|
||||||
webapps.append('<a href="%s">%s</a>' % (url, name))
|
webapps.append('<a href="%s">%s</a>' % (url, name))
|
||||||
return '<br>'.join(webapps)
|
return '<br>'.join(webapps)
|
||||||
display_webapps.allow_tags = True
|
display_webapps.allow_tags = True
|
||||||
|
|
|
@ -44,7 +44,7 @@ def running_syncdb():
|
||||||
|
|
||||||
|
|
||||||
def database_ready():
|
def database_ready():
|
||||||
return not running_syncdb() and 'setuppostgres' not in sys.argv and 'test' not in sys.argv
|
return not running_syncdb() and 'setuppostgres' not in sys.argv and 'test' not in sys.argv and 'celerybeat' not in sys.argv
|
||||||
|
|
||||||
|
|
||||||
def dict_setting_to_choices(choices):
|
def dict_setting_to_choices(choices):
|
||||||
|
|
|
@ -4,8 +4,7 @@
|
||||||
|
|
||||||
# This script is safe to run several times, for example in order to upgrade your deployment
|
# This script is safe to run several times, for example in order to upgrade your deployment
|
||||||
|
|
||||||
set -u
|
set -ue
|
||||||
set -e
|
|
||||||
|
|
||||||
bold=$(tput bold)
|
bold=$(tput bold)
|
||||||
normal=$(tput sgr0)
|
normal=$(tput sgr0)
|
||||||
|
@ -46,10 +45,18 @@ CURRENT_VERSION=$($PYTHON_BIN -c "from orchestra import get_version; print(get_v
|
||||||
if [[ ! $CURRENT_VERSION ]]; then
|
if [[ ! $CURRENT_VERSION ]]; then
|
||||||
# First Orchestra installation
|
# First Orchestra installation
|
||||||
run "apt-get -y install git python3-pip"
|
run "apt-get -y install git python3-pip"
|
||||||
surun "git clone https://github.com/glic3rinu/django-orchestra.git ~/django-orchestra" || surun "export GIT_DIR=~/django-orchestra/.git; git pull"
|
surun "git clone https://github.com/glic3rinu/django-orchestra.git ~/django-orchestra" || {
|
||||||
|
# Finishing partial installation
|
||||||
|
surun "export GIT_DIR=~/django-orchestra/.git; git pull"
|
||||||
|
}
|
||||||
PYTHON_PATH=$($PYTHON_BIN -c "import sys; print([path for path in sys.path if path.startswith('/usr/local/lib/python')][0]);")
|
PYTHON_PATH=$($PYTHON_BIN -c "import sys; print([path for path in sys.path if path.startswith('/usr/local/lib/python')][0]);")
|
||||||
echo $HOME/django-orchestra/ | sudo tee "$PYTHON_PATH/orchestra.pth"
|
echo $HOME/django-orchestra/ | sudo tee "$PYTHON_PATH/orchestra.pth"
|
||||||
run "cp $HOME/django-orchestra/orchestra/bin/orchestra-admin /usr/local/bin/"
|
run "cp $HOME/django-orchestra/orchestra/bin/orchestra-admin /usr/local/bin/"
|
||||||
|
else
|
||||||
|
# Upgrade and relay on postguprade for finishing up the installation
|
||||||
|
export GIT_DIR=~/django-orchestra/.git; git pull
|
||||||
|
$PYTHON_BIN $MANAGE migrate postupgradeorchestra --from $CURRENT_VERSION
|
||||||
|
exit
|
||||||
fi
|
fi
|
||||||
|
|
||||||
sudo orchestra-admin install_requirements --testing
|
sudo orchestra-admin install_requirements --testing
|
||||||
|
@ -58,6 +65,8 @@ if [[ ! -e $BASE_DIR ]]; then
|
||||||
cd $HOME
|
cd $HOME
|
||||||
surun "orchestra-admin startproject $PROJECT_NAME"
|
surun "orchestra-admin startproject $PROJECT_NAME"
|
||||||
cd -
|
cd -
|
||||||
|
else
|
||||||
|
echo "$BASE_DIT already existis, doing nothing."
|
||||||
fi
|
fi
|
||||||
|
|
||||||
MANAGE="$BASE_DIR/manage.py"
|
MANAGE="$BASE_DIR/manage.py"
|
||||||
|
@ -78,24 +87,23 @@ if [[ ! $(sudo su postgres -c "psql -lqt" | awk {'print $1'} | grep '^orchestra$
|
||||||
sudo su postgres -c 'psql -c "ALTER USER orchestra CREATEDB;"'
|
sudo su postgres -c 'psql -c "ALTER USER orchestra CREATEDB;"'
|
||||||
fi
|
fi
|
||||||
|
|
||||||
run "$PYTHON_BIN $MANAGE migrate --noinput auth"
|
# admin_tools needs accounts and does not have migrations
|
||||||
run "$PYTHON_BIN $MANAGE migrate --noinput accounts"
|
run "$PYTHON_BIN $MANAGE migrate --noinput accounts"
|
||||||
run "$PYTHON_BIN $MANAGE migrate --noinput"
|
run "$PYTHON_BIN $MANAGE migrate --noinput"
|
||||||
run "$PYTHON_BIN $MANAGE syncdb --noinput"
|
|
||||||
|
|
||||||
sudo $PYTHON_BIN $MANAGE setupcelery --username $USER --processes 2
|
sudo $PYTHON_BIN $MANAGE setupcelery --username $USER --processes 2
|
||||||
|
|
||||||
# Install and configure Nginx web server
|
# Install and configure Nginx+uwsgi web services
|
||||||
surun "mkdir -p $BASE_DIR/static"
|
surun "mkdir -p $BASE_DIR/static"
|
||||||
surun "$PYTHON_BIN $MANAGE collectstatic --noinput"
|
surun "$PYTHON_BIN $MANAGE collectstatic --noinput"
|
||||||
run "apt-get install -y nginx uwsgi uwsgi-plugin-python3"
|
run "apt-get install -y nginx uwsgi uwsgi-plugin-python3"
|
||||||
run "$PYTHON_BIN $MANAGE setupnginx"
|
run "$PYTHON_BIN $MANAGE setupnginx"
|
||||||
run "service nginx start"
|
run "service nginx start"
|
||||||
|
|
||||||
# Apply changes
|
# Apply changes on related services
|
||||||
run "$PYTHON_BIN $MANAGE restartservices"
|
run "$PYTHON_BIN $MANAGE restartservices"
|
||||||
|
|
||||||
# Create a orchestra user
|
# Create orchestra superuser
|
||||||
cat <<- EOF | $PYTHON_BIN $MANAGE shell
|
cat <<- EOF | $PYTHON_BIN $MANAGE shell
|
||||||
from orchestra.contrib.accounts.models import Account
|
from orchestra.contrib.accounts.models import Account
|
||||||
if not Account.objects.filter(username="$USER").exists():
|
if not Account.objects.filter(username="$USER").exists():
|
||||||
|
|
Loading…
Reference in New Issue