| 1 | #!/bin/sh |
|---|
| 2 | |
|---|
| 3 | set -euf |
|---|
| 4 | |
|---|
| 5 | settings=$(dirname "$0") |
|---|
| 6 | base="$settings/.." |
|---|
| 7 | |
|---|
| 8 | echo Creating config files... |
|---|
| 9 | secret=$(python -c "import random; print(''.join([random.choice('abcdefghijklmnopqrstuvwxyz0123456789@#%&-_=+') for i in range(50)]))") |
|---|
| 10 | secret_re="s/^#SECRET_KEY = something$/SECRET_KEY = '$secret'/" |
|---|
| 11 | sed -e "$secret_re" < "$settings/local.dev-template.py" > "$settings/local.py" |
|---|
| 12 | touch "$settings/local_after.py" |
|---|
| 13 | |
|---|
| 14 | echo |
|---|
| 15 | echo Creating database and doing basic sync... |
|---|
| 16 | $base/manage.py syncdb && $base/manage.py migrate |
|---|
| 17 | |
|---|
| 18 | echo |
|---|
| 19 | echo Creating accounts... |
|---|
| 20 | $base/util/setup.py |
|---|
| 21 | $base/util/add_accounts Accounts.Assets <<EOF |
|---|
| 22 | Officers 1234567 |
|---|
| 23 | Officers.President |
|---|
| 24 | Officers.President.Gifts |
|---|
| 25 | Officers.Treasurer |
|---|
| 26 | Officers.Treasurer.Stamps |
|---|
| 27 | Officers.Publicity |
|---|
| 28 | Officers.Publicity.Copying |
|---|
| 29 | Committees 1234567 |
|---|
| 30 | Committees.Art |
|---|
| 31 | Committees.Art.Software |
|---|
| 32 | Committees.Logistics |
|---|
| 33 | Committees.Logistics.Food |
|---|
| 34 | Committees.Logistics.Rooms |
|---|
| 35 | EOF |
|---|
| 36 | |
|---|
| 37 | echo |
|---|
| 38 | echo Creating budget term... |
|---|
| 39 | $base/manage.py shell <<EOF |
|---|
| 40 | from finance_core.models import BudgetTerm |
|---|
| 41 | import datetime |
|---|
| 42 | today = datetime.date.today() |
|---|
| 43 | year = today.year |
|---|
| 44 | term, created = BudgetTerm.objects.get_or_create(name=year, defaults=dict( |
|---|
| 45 | slug=year, |
|---|
| 46 | start_date=datetime.date(year, 1, 1), |
|---|
| 47 | end_date=datetime.date(year, 12, 31), |
|---|
| 48 | submit_deadline=datetime.date(year+1, 4, 15), |
|---|
| 49 | )) |
|---|
| 50 | if created: |
|---|
| 51 | term.save() |
|---|
| 52 | EOF |
|---|
| 53 | |
|---|
| 54 | echo; echo |
|---|
| 55 | echo Done! |
|---|
| 56 | echo 'Run the server with "./manage.py runserver 8006" or similar.' |
|---|