Fix : #338 python not found for key generation
This commit is contained in:
+19
-7
@@ -7,19 +7,31 @@ if "%1"=="full" (
|
|||||||
echo !msg!
|
echo !msg!
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@echo off
|
||||||
where openssl >nul 2>&1
|
openssl rand -hex 32 >nul 2>&1
|
||||||
if %ERRORLEVEL% == 0 (
|
if %ERRORLEVEL% == 0 (
|
||||||
for /f %%i in ('openssl rand -hex 32') do set SEARXNG_SECRET_KEY=%%i
|
for /f %%i in ('openssl rand -hex 32') do set SEARXNG_SECRET_KEY=%%i
|
||||||
) else (
|
goto :key_generated
|
||||||
where python >nul 2>&1
|
)
|
||||||
|
|
||||||
|
python --version >nul 2>&1
|
||||||
if %ERRORLEVEL% == 0 (
|
if %ERRORLEVEL% == 0 (
|
||||||
for /f %%i in ('python -c "import secrets; print(secrets.token_hex(32))"') do set SEARXNG_SECRET_KEY=%%i
|
for /f %%i in ('python -c "import secrets; print(secrets.token_hex(32))"') do set SEARXNG_SECRET_KEY=%%i
|
||||||
) else (
|
goto :key_generated
|
||||||
|
)
|
||||||
|
|
||||||
|
py --version >nul 2>&1
|
||||||
|
if %ERRORLEVEL% == 0 (
|
||||||
|
for /f %%i in ('py -c "import secrets; print(secrets.token_hex(32))"') do set SEARXNG_SECRET_KEY=%%i
|
||||||
|
goto :key_generated
|
||||||
|
)
|
||||||
|
|
||||||
echo Error: Neither openssl nor python is available to generate a secret key.
|
echo Error: Neither openssl nor python is available to generate a secret key.
|
||||||
|
echo Please install Python from https://python.org or OpenSSL
|
||||||
exit /b 2
|
exit /b 2
|
||||||
)
|
|
||||||
)
|
:key_generated
|
||||||
|
echo Secret key generated successfully
|
||||||
|
|
||||||
REM Generate secret key
|
REM Generate secret key
|
||||||
for /f %%i in ('powershell -command "[System.Web.Security.Membership]::GeneratePassword(64,0)"') do set SEARXNG_SECRET_KEY=%%i
|
for /f %%i in ('powershell -command "[System.Web.Security.Membership]::GeneratePassword(64,0)"') do set SEARXNG_SECRET_KEY=%%i
|
||||||
|
|||||||
Reference in New Issue
Block a user