diff --git a/.env.sample b/.env.sample index 8fabd872..65926e57 100644 --- a/.env.sample +++ b/.env.sample @@ -1,5 +1,10 @@ # Yavsc parameters +BASEAPPDIR=/srv/www/yavsc +USER_AND_GROUP=yavsc:yavsc +CONFIGURATION=Release +DOTNET_FRAMEWORK=net10.0 + MODERATION_AUTO_REJECT_THRESHOLD=0.9 MODERATION_AUTO_APPROVE_THRESHOLD=0.7 diff --git a/.gitignore b/.gitignore index 08c4a907..8f23f904 100644 --- a/.gitignore +++ b/.gitignore @@ -22,7 +22,7 @@ package-lock.json *.csproj.lscache data/ appsettings.*.json -appsettings-*.json +appsettings-*.*.json generated/ *.tmp diff --git a/contrib/Makefile b/contrib/Makefile index 4f097daa..ea2c4b9f 100644 --- a/contrib/Makefile +++ b/contrib/Makefile @@ -1,10 +1,5 @@ APP_PROJECT_NAMES=Api Org Blogs -APP_PROJECTS=src/Yavsc.Org/Yavsc.Org.csproj src/Yavsc.Api/Yavsc.Api.csproj SLNDIR=.. -DESTDIR=/srv/www/yavsc -USER_AND_GROUP=yavsc:yavsc -CONFIGURATION=Release -DOTNET_FRAMEWORK=net10.0 include $(SLNDIR)/.env include .env @@ -20,7 +15,7 @@ generated/yavsc%.service: generated/ template.service $(SLNDIR)/.env @cat template.service | APP_NAME="$*" \ HTTP_HOST="$(HTTP_HOST)" \ HTTP_PORT="$*_$(HTTP_PORT)" \ - DESTDIR="$(DESTDIR)" \ + BASEAPPDIR="$(BASEAPPDIR)" \ APP_SYSLOG_ID="yavsc$*" \ POSTGRES_HOST="$(POSTGRES_HOST)" \ POSTGRES_PORT="$(POSTGRES_PORT)" \ @@ -39,34 +34,39 @@ copy-service-Api: /etc/systemd/system/yavscApi.service copy-service-Blogs: /etc/systemd/system/yavscBlogs.service copy-binaries: build_publish_Org build_publish_Api build_publish_Blogs stop-services - for project in $(APP_PROJECT_NAMES); do LCAPI=$$(echo $${project}|tr [:upper:] [:lower:]) ; \ - mv $(SLNDIR)/src/Yavsc.$${project}/bin/$(CONFIGURATION)/$(DOTNET_FRAMEWORK)/publish/appsettings-$${LCAPI}.json \ - $(SLNDIR)/src/Yavsc.$${project}/bin/$(CONFIGURATION)/$(DOTNET_FRAMEWORK)/publish/appsettings-$${LCAPI}-dist.json ;\ - sudo cp -a $(SLNDIR)/src/Yavsc.$${project}/bin/$(CONFIGURATION)/$(DOTNET_FRAMEWORK)/publish/* $(DESTDIR) ; \ + @for project in $(APP_PROJECT_NAMES); \ + do LCAPI=$$(echo $${project}|tr [:upper:] [:lower:]) ; \ + echo "$${project} -> $${LCAPI}" ; \ + BINDIR="$(SLNDIR)/src/Yavsc.$${project}/bin/$(CONFIGURATION)/$(DOTNET_FRAMEWORK)/publish" ; \ + echo BINDIR: $${BINDIR} ; \ + ls $${BINDIR}/appsettings* 2>&1 ; \ + mv $${BINDIR}/appsettings-$${LCAPI}.json \ + $${BINDIR}/appsettings-$${LCAPI}-dist.json ; \ + sudo cp -a $${BINDIR}/* $(BASEAPPDIR) ; \ done - sudo chown -R $(USER_AND_GROUP) $(DESTDIR) + @sudo chown -R $(USER_AND_GROUP) $(BASEAPPDIR) /etc/systemd/system/yavsc%.service: generated/yavsc%.service sudo cp $^ $@ sudo chown root:root $@ build_publish_%: - ASPNETCORE_ENV=$(CONFIGURATION) dotnet publish $(SLNDIR)/src/Yavsc.$*/Yavsc.$*.csproj + @ASPNETCORE_ENV=$(CONFIGURATION) dotnet publish $(SLNDIR)/src/Yavsc.$*/Yavsc.$*.csproj install: build_publish copy-binaries copy-services - sudo systemctl daemon-reload - for project in $(APP_PROJECT_NAMES); \ + @sudo systemctl daemon-reload + @for project in $(APP_PROJECT_NAMES); \ do \ sudo systemctl enable yavsc$${project} ; \ sudo systemctl start yavsc$${project} ; \ done reinstall: copy-binaries - for project in $(APP_PROJECT_NAMES); do \ + @for project in $(APP_PROJECT_NAMES); do \ sudo systemctl start yavsc$${project} ; done stop-services: - for project in $(APP_PROJECT_NAMES); \ + @for project in $(APP_PROJECT_NAMES); \ do \ sudo systemctl stop yavsc$${project} ; \ done @@ -75,13 +75,11 @@ $(SLNDIR)/src/Yavsc.Org/bin/$(CONFIGURATION)/$(DOTNET_FRAMEWORK)/publish: build_ $(SLNDIR)/src/Yavsc.Blogs/bin/$(CONFIGURATION)/$(DOTNET_FRAMEWORK)/publish: build_publish $(SLNDIR)/src/Yavsc.Api/bin/$(CONFIGURATION)/$(DOTNET_FRAMEWORK)/publish: build_publish - - showConfig: @echo CONFIGURATION: $(CONFIGURATION) - @echo DESTDIR: $(DESTDIR) + @echo BASEAPPDIR: $(BASEAPPDIR) clean: - rm -rf generated + @rm -rf generated .PHONY: build_publish mep showConfig copy-service-Api copy-service-Org copy-service-Blogs reinstall clean diff --git a/src/Yavsc.Api/appsettings-api.json b/src/Yavsc.Api/appsettings-api.json new file mode 100644 index 00000000..04ea211e --- /dev/null +++ b/src/Yavsc.Api/appsettings-api.json @@ -0,0 +1,23 @@ +{ + "Site": { + "Authority": "https://localhost:5001", + "CorsAllowedOrigins": [ + "https://localhost:5003" + ] + }, + "Logging": { + "LogLevel": { + "Default": "Information", + "Microsoft": "Warning", + "Microsoft.Hosting.Lifetime": "Information" + } + }, + "AllowedHosts": "*", + "Kestrel": { + "Endpoints": { + "Https":{ + "Url": "https://localhost:3004" + } + } + } +} diff --git a/src/Yavsc.Blogs/appsettings-blogs.json b/src/Yavsc.Blogs/appsettings-blogs.json new file mode 100644 index 00000000..00a11c7a --- /dev/null +++ b/src/Yavsc.Blogs/appsettings-blogs.json @@ -0,0 +1,26 @@ +{ + "Site": { + "Title": "Yavsc Blogs", + "Description": "A collection of blogs about software development, technology, and programming.", + "Keywords": "software development, technology, programming, coding, blogs", + "Authority": "https://localhost:5001", + "CorsAllowedOrigins": [ + "https://localhost:5005" + ] + }, + "Logging": { + "LogLevel": { + "Default": "Information", + "Microsoft": "Warning", + "Microsoft.Hosting.Lifetime": "Information" + } + }, + "AllowedHosts": "*", + "Kestrel": { + "Endpoints": { + "Https": { + "Url": "https://localhost:3003" + } + } + } +} diff --git a/src/Yavsc.Org/appsettings-org.json b/src/Yavsc.Org/appsettings-org.json new file mode 100644 index 00000000..e69f60ea --- /dev/null +++ b/src/Yavsc.Org/appsettings-org.json @@ -0,0 +1,96 @@ +{ + "Logging": { + "LogLevel": { + "Default": "Information", + "Microsoft.AspNetCore": "Warning", + "Microsoft.AspNetCore.SignalR": "Debug", + "Microsoft.AspNetCore.Http.Connections": "Debug" + } + }, + "AllowedHosts": "*", + "ConnectionStrings": { + "YavscConnection": "*** via dotnet user-secrets ou variable d'environnement *** Server=[YOURSERVERNAME];Port=5432;Database=[YOURDBNAME];Username=[YOURDBUSERNAME];Password=[YOURDBPASSW];" + }, + "Site": { + "Title": "yavsc", + "Slogan": "Yavsc!", + "StyleSheet": "/css/default.css", + "Authority": "https://localhost:5001", + "ExternalUrl": "https://localhost:5001", + "CorsAllowedOrigins": [ + "https://localhost:5001", + "http://localhost:5000" + ], + "Banner": "/images/banner-dewang.jpg", + "Owner": { + "Name": "[Site owner's name]", + "EMail": "[Site owner's e-mail address]" + }, + "Admin": { + "Name": "[a name for a site admin]", + "EMail": "[an e-mail for a site admin]" + }, + "Avatars": "avatars", + "Quota": 200000000, + "Bills": "bills", + "Blog": "blog", + "TempDir": "temp", + "DataDir": "data" + }, + "Smtp": { + "Host": "[YOURSMTPHOST]", + "Port": 465 + }, + "DataProtection": { + "Keys": { + "Dir": "DataProtection" + }, + "RSAParamFile": "RSA-Params.json", + "ExpiresInHours": 168 + }, + "Authentication": { + "PayPal": { + "Mode": "[sandbox|production]", + "ClientId": "[Your PayPal REST API ClientId]", + "Secret": "[Your PayPal REST API Secret]" + }, + "Google": { + "ApiKey": "[Your ApiKey]", + "ClientId": "[Your ClientId]", + "ClientSecret": "[Your ClientSecret]", + "ServiceAccount": { + "project_id": "[Yours]", + "private_key_id": "[Yours]", + "private_key": "-----[Yours]---\n", + "client_email": "[Yours]@appspot.gserviceaccount.com", + "client_id": "[Yours]", + "auth_uri": "https://accounts.google.com/o/oauth2/auth", + "token_uri": "https://accounts.google.com/o/oauth2/token", + "auth_provider_x509_cert_url": "https://www.googleapis.com/oauth2/v1/certs", + "client_x509_cert_url": "https://www41.googleapis.com/robot/v1/[Yours].com" + } + }, + "Facebook": { + "ClientId": "[Your ClientId]", + "ClientSecret": "[Your ClientSecret]" + }, + "Twitter": { + "ClientId": "[Your ClientId]", + "ClientSecret": "[Your ClientSecret]" + } + }, + "Moderation": { + "AutoApproveThreshold": 0.7, + "AutoRejectThreshold": 0.9 + }, + "Kestrel": { + "Endpoints": { + "Http": { + "Url": "http://localhost:3003" + }, + "Https": { + "Url": "https://localhost:3004" + } + } + } +} diff --git a/src/Yavsc.Web/appsettings-web.json b/src/Yavsc.Web/appsettings-web.json new file mode 100755 index 00000000..e0dc676d --- /dev/null +++ b/src/Yavsc.Web/appsettings-web.json @@ -0,0 +1,24 @@ +{ + "Authencication": { + "Issuer": "https://localhost:5001", + "Client": { + "Id": "mvc", + "Secret": "lame-secret" + } + }, + "Logging": { + "LogLevel": { + "Default": "Information", + "Microsoft.AspNetCore": "Warning" + } + }, + "AllowedHosts": "*", + "Kestrel": { + "Endpoints": + { + "Https": { + "Url": "https://localhost:5003" + } + } + } +} diff --git a/src/cli/appsettings-cli.json b/src/cli/appsettings-cli.json new file mode 100644 index 00000000..99bcc71b --- /dev/null +++ b/src/cli/appsettings-cli.json @@ -0,0 +1,36 @@ +{ + "ConnectionSettings" : { + "Site": { + "Title": "[Site title]", + "Slogan": "[Site Slogan]", + "Banner": "/images/[bannerAsset]", + "HomeViewName": "Home", + "FavIcon": "/favicon.ico", + "Icon": "/images/[Site Icon]" + }, + "ServerApi": { + "Authority": "oauth.server-example.com", + "ClientId": "[OAuth2NativeClientId]", + "ClientSecret": "[OAuth2ClientSecret]" + } + }, + "Logging": { + "IncludeScopes": true, + "LogLevel": { + "Default": "Debug", + "System": "Warning", + "Microsoft": "Warning" + } + }, + "ConnectionStrings": { + "Default":"[your default connection string]" + }, + "gen_mvc" : { + "NameSpace": "Yavsc", + "AppBase": "../Yavsc", + "RelativePath": "../Yavsc/Controllers/Generated", + "DbContextFullName": "Yavsc.Models.ApplicationDbContext", + "ControllerName": "LiveFlowController", + "ModelFullName": "Yavsc.Models.Streaming.LiveFlow" + } +}