diff --git a/.gitpod.yml b/.gitpod.yml index afc1ba76f..3916d0d4d 100644 --- a/.gitpod.yml +++ b/.gitpod.yml @@ -28,8 +28,22 @@ tasks: docker-compose run --rm api python manage.py createsuperuser --no-input --username gitpod --email gitpod@example.com docker-compose run --rm api python manage.py fw users set --password "gitpod" gitpod --no-input - # Compile frontent + # Compile frontend locales docker-compose run --rm front yarn run i18n-compile + + # Login with cURL to create actors + docker-compose up -d nginx + gp ports await 8000 + python .gitpod/init_actor.py + + # Import music + git clone https://dev.funkwhale.audio/funkwhale/catalog.git + sudo mv catalog/music data + sudo chown -R root:root data/music + rm -rf catalog + LIBRARY_ID=`cat .gitpod/create_library.py | docker-compose run --rm -T api python manage.py shell -i python` + docker-compose run --rm api python manage.py import_files $LIBRARY_ID "/music/" --recursive --noinput --in-place + docker-compose stop command: | docker-compose up -d nginx docker-compose up front api diff --git a/.gitpod/create_library.py b/.gitpod/create_library.py new file mode 100644 index 000000000..7991417f7 --- /dev/null +++ b/.gitpod/create_library.py @@ -0,0 +1,17 @@ +from funkwhale_api.music.models import Library +from django.contrib.auth import get_user_model + +actor = get_user_model().objects.get(username='gitpod').actor + +try: + library = Library.objects.get(actor=actor) +except: + # Create library + library = Library() + library.actor = actor + library.description = 'Libre music to build a starter catalog for your instance' + library.name = 'funkwhale/catalog' + library.privacy_level = 'everyone' + library.save() + +print(str(library.uuid)) \ No newline at end of file diff --git a/.gitpod/init_actor.py b/.gitpod/init_actor.py new file mode 100644 index 000000000..7d011c17d --- /dev/null +++ b/.gitpod/init_actor.py @@ -0,0 +1,20 @@ +import subprocess +import requests + +INSTANCE_URL = subprocess.check_output(['gp', 'url', '8000']).decode()[:-1] + +# Login to initialize user actor +req = requests.Session() + +res = req.get(INSTANCE_URL + '/login') +token = res.cookies['csrftoken'] + +req.post(INSTANCE_URL + '/api/v1/users/login', data={ + 'username': 'gitpod', + 'password': 'gitpod' +}, headers={ + 'Referer': INSTANCE_URL + '/login', + 'X-CSRFTOKEN': token +}) + +req.get(INSTANCE_URL) \ No newline at end of file