diff --git a/conf/app-frontend.src b/conf/app-frontend.src new file mode 100644 index 0000000..084e202 --- /dev/null +++ b/conf/app-frontend.src @@ -0,0 +1,6 @@ +SOURCE_URL=https://code.eliotberriot.com/funkwhale/funkwhale/builds/artifacts/0.12/download?job=build_front +SOURCE_SUM=9c83b90877c6025654c071a87dd60dd69c5548df0fdfa77abcc27a259c846c64 +SOURCE_SUM_PRG=sha256sum +SOURCE_FORMAT=zip +SOURCE_IN_SUBDIR=false +SOURCE_FILENAME= \ No newline at end of file diff --git a/conf/nginx.conf b/conf/nginx.conf index aaec7f5..202ed07 100644 --- a/conf/nginx.conf +++ b/conf/nginx.conf @@ -1,4 +1,5 @@ location / { + alias __FINALPATH__/front/dist/; try_files $uri $uri/ @rewrites; } diff --git a/manifest.json b/manifest.json index 3556d1d..3f02275 100644 --- a/manifest.json +++ b/manifest.json @@ -25,18 +25,18 @@ "name": "domain", "type": "domain", "ask": { - "en": "Choose a domain for Weblate:" + "en": "Choose a domain" }, - "example": "domain.org" + "example": "domain.fr" }, { "name": "path", "type": "path", "ask": { - "en": "Choose a path for Weblate:" + "en": "Choose a path" }, - "example": "/weblate", - "default": "/weblate" + "example": "/funkwhale", + "default": "/funkwhale" }, { "name": "is_public", @@ -52,7 +52,7 @@ "ask": { "en": "Choose an admin user for Funkwhale?" }, - "example": "jean-baptiste" + "example": "jibec" } ] } diff --git a/scripts/install b/scripts/install index b84e00a..3dc9fb4 100644 --- a/scripts/install +++ b/scripts/install @@ -25,7 +25,6 @@ domain=$YNH_APP_ARG_DOMAIN path_url=$YNH_APP_ARG_PATH is_public=$YNH_APP_ARG_IS_PUBLIC admin=$YNH_APP_ARG_ADMIN -port=$(ynh_find_port 5000) app=$YNH_APP_INSTANCE_NAME @@ -53,11 +52,22 @@ ynh_app_setting_set "$app" domain "$domain" ynh_app_setting_set "$app" path "$path_url" ynh_app_setting_set "$app" is_public "$is_public" ynh_app_setting_set "$app" admin "$admin" -ynh_app_setting_set "$app" port "$port" #================================================= # STANDARD MODIFICATIONS #================================================= +# FIND AND OPEN A PORT +#================================================= + +# Find a free port +port=$(ynh_find_port 5000) +# Open this port +yunohost firewall allow --no-upnp TCP "$port" 2>&1 +ynh_app_setting_set "$app" port "$port" + +#================================================= +# INSTALL DEPENDENCIES +#================================================= # add backports (required to install ffmpeg) echo "deb http://httpredir.debian.org/debian jessie-backports main" | tee /etc/apt/sources.list.d/jessie-backports.list @@ -89,6 +99,7 @@ systemctl reload postgresql ynh_app_setting_set "$app" final_path "$final_path" # Download, check integrity, uncompress and patch the source from app.src ynh_setup_source "$final_path" +ynh_setup_source "$final_path" "app-frontend" ( cd "$final_path" @@ -158,7 +169,7 @@ ynh_replace_string "__DBNAME__" "$app" "$configfile" ynh_replace_string "__FINALPATH__" "$final_path" "$configfile" ynh_replace_string "__KEY__" "$key" "$configfile" -cat > "$final_path/load_env" < "$final_path/load_env" <<'EOL' #!/bin/bash export $(cat "$final_path/config/.env" | grep -v ^# | xargs) EOL @@ -182,10 +193,7 @@ admin_mail=$(ynh_user_get_info "$admin" "mail") ynh_psql_execute_as_root "ALTER USER $db_user WITH SUPERUSER;" python api/manage.py migrate ynh_psql_execute_as_root "ALTER USER $db_user WITH NOSUPERUSER;" - python api/manage.py createsuperuser \ - --username "$admin" \ - --email "$admin_mail" \ - --noinput + echo "from django.contrib.auth import get_user_model; User = get_user_model(); User.objects.create_superuser('$admin', '$admin_mail', 'funkwhale') " | python api/manage.py shell python api/manage.py collectstatic ) @@ -194,6 +202,8 @@ admin_mail=$(ynh_user_get_info "$admin" "mail") #================================================= cp ../conf/funkwhale.target "/etc/systemd/system/$app.target" +ynh_replace_string "__APP__" "$app" "/etc/systemd/system/$app.target" + # Create a dedicated systemd config ynh_add_systemd_config "$app-server" "funkwhale-server.service" ynh_add_systemd_config "$app-worker" "funkwhale-worker.service" @@ -230,4 +240,5 @@ fi # RELOAD NGINX #================================================= +systemctl start "$app-server" "$app-worker" "$app-beat" systemctl reload nginx \ No newline at end of file diff --git a/scripts/remove b/scripts/remove index 5460423..abe5c16 100644 --- a/scripts/remove +++ b/scripts/remove @@ -19,6 +19,7 @@ domain=$(ynh_app_setting_get $app domain) db_name=$(ynh_app_setting_get $app db_name) db_user=$db_name final_path=$(ynh_app_setting_get $app final_path) +port=$(ynh_app_setting_get $app port) #================================================= # STANDARD REMOVE @@ -30,6 +31,9 @@ final_path=$(ynh_app_setting_get $app final_path) ynh_remove_systemd_config "$app-server" ynh_remove_systemd_config "$app-worker" ynh_remove_systemd_config "$app-beat" + +systemctl disable "$app".target +systemctl stop "$app".target ynh_secure_remove "/etc/systemd/system/$app.target" #================================================= @@ -67,6 +71,16 @@ ynh_secure_remove "$final_path" # Remove the dedicated nginx config ynh_remove_nginx_config +#================================================= +# CLOSE A PORT +#================================================= + +if yunohost firewall list | grep -q "\- $port$" +then + echo "Close port $port" + yunohost firewall disallow TCP $port 2>&1 +fi + #================================================= # GENERIC FINALIZATION #=================================================