Guest User

Untitled

a guest
Mar 23rd, 2024
171
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Batch 4.47 KB | None | 0 0
  1. @echo off
  2. setlocal enabledelayedexpansion
  3.  
  4. cd /D "%~dp0"
  5.  
  6. set PATH=%PATH%;%SystemRoot%\system32
  7.  
  8. echo "%CD%"| findstr /C:" " >nul && echo This script relies on Miniconda which can not be silently installed under a path with spaces. && goto end
  9.  
  10. @rem Check for special characters in installation path
  11. set "SPCHARMESSAGE="WARNING: Special characters were detected in the installation path!" "         This can cause the installation to fail!""
  12. echo "%CD%"| findstr /R /C:"[!#\$%&()\*+,;<=>?@\[\]\^`{|}~]" >nul && (
  13.     call :PrintBigMessage %SPCHARMESSAGE%
  14. )
  15. set SPCHARMESSAGE=
  16.  
  17. @rem fix failed install when installing to a separate drive
  18. set TMP=%cd%\installer_files
  19. set TEMP=%cd%\installer_files
  20.  
  21. @rem deactivate existing conda envs as needed to avoid conflicts
  22. (call conda deactivate && call conda deactivate && call conda deactivate) 2>nul
  23.  
  24. @rem config
  25. set INSTALL_DIR=%cd%\installer_files
  26. set CONDA_ROOT_PREFIX=%cd%\installer_files\conda
  27. set INSTALL_ENV_DIR=%cd%\installer_files\env
  28. set MINICONDA_DOWNLOAD_URL=https://repo.anaconda.com/miniconda/Miniconda3-py310_23.3.1-0-Windows-x86_64.exe
  29. set MINICONDA_CHECKSUM=307194e1f12bbeb52b083634e89cc67db4f7980bd542254b43d3309eaf7cb358
  30. set conda_exists=F
  31.  
  32. @rem figure out whether git and conda needs to be installed
  33. call "%CONDA_ROOT_PREFIX%\_conda.exe" --version >nul 2>&1
  34. if "%ERRORLEVEL%" EQU "0" set conda_exists=T
  35.  
  36. @rem (if necessary) install git and conda into a contained environment
  37. @rem download conda
  38. if "%conda_exists%" == "F" (
  39.     echo Downloading Miniconda from %MINICONDA_DOWNLOAD_URL% to %INSTALL_DIR%\miniconda_installer.exe
  40.  
  41.     mkdir "%INSTALL_DIR%"
  42.     call curl -Lk "%MINICONDA_DOWNLOAD_URL%" > "%INSTALL_DIR%\miniconda_installer.exe" || ( echo. && echo Miniconda failed to download. && goto end )
  43.  
  44.     for /f %%a in ('CertUtil -hashfile "%INSTALL_DIR%\miniconda_installer.exe" SHA256 ^| find /i /v " " ^| find /i "%MINICONDA_CHECKSUM%"') do (
  45.         set "output=%%a"
  46.     )
  47.  
  48.     if not defined output (
  49.         echo The checksum verification for miniconda_installer.exe has failed.
  50.         del "%INSTALL_DIR%\miniconda_installer.exe"
  51.         goto end
  52.     ) else (
  53.         echo The checksum verification for miniconda_installer.exe has passed successfully.
  54.     )
  55.  
  56.     echo Installing Miniconda to %CONDA_ROOT_PREFIX%
  57.     start /wait "" "%INSTALL_DIR%\miniconda_installer.exe" /InstallationType=JustMe /NoShortcuts=1 /AddToPath=0 /RegisterPython=0 /NoRegistry=1 /S /D=%CONDA_ROOT_PREFIX%
  58.  
  59.     @rem test the conda binary
  60.     echo Miniconda version:
  61.     call "%CONDA_ROOT_PREFIX%\_conda.exe" --version || ( echo. && echo Miniconda not found. && goto end )
  62.  
  63.     @rem delete the Miniconda installer
  64.     del "%INSTALL_DIR%\miniconda_installer.exe"
  65. )
  66.  
  67. @rem create the installer env
  68. if not exist "%INSTALL_ENV_DIR%" (
  69.     echo Packages to install: %PACKAGES_TO_INSTALL%
  70.     call "%CONDA_ROOT_PREFIX%\_conda.exe" create --no-shortcuts -y -k --prefix "%INSTALL_ENV_DIR%" python=3.11 || ( echo. && echo Conda environment creation failed. && goto end )
  71. )
  72.  
  73. @rem check if conda environment was actually created
  74. if not exist "%INSTALL_ENV_DIR%\python.exe" ( echo. && echo Conda environment is empty. && goto end )
  75.  
  76. @rem environment isolation
  77. set PYTHONNOUSERSITE=1
  78. set PYTHONPATH=
  79. set PYTHONHOME=
  80. set "CUDA_PATH=%INSTALL_ENV_DIR%"
  81. set "CUDA_HOME=%CUDA_PATH%"
  82.  
  83. @rem activate installer env
  84. call "%CONDA_ROOT_PREFIX%\condabin\conda.bat" activate "%INSTALL_ENV_DIR%" || ( echo. && echo Miniconda hook not found. && goto end )
  85.  
  86. @rem source https://docs.openwebui.com/getting-started/#how-to-install-without-docker
  87. @rem also much command line malding...
  88.  
  89. REM Install git
  90. where git >nul 2>nul && goto gitok
  91. powershell -command "(New-Object Net.WebClient).DownloadFile('https://git-scm.com/download/win', 'GitInstaller.exe')"
  92. start GitInstaller.exe /SILENT /NORESTART
  93. del GitInstaller.exe
  94. :gitok
  95.  
  96. REM Install open-webui
  97. if not exist "open-webui" ( git clone https://github.com/open-webui/open-webui.git open-webui || exit )
  98. if not exist "open-webui\.env" ( copy "open-webui\.env.example" "open-webui\.env" )
  99.  
  100. REM Frontend
  101. cd open-webui
  102. call npm i
  103. call npm run build
  104.  
  105. REM Backend
  106. cd ./backend
  107. pip install -r requirements.txt -U
  108. call start_windows.bat
  109.  
  110. @rem below are functions for the script   next line skips these during normal execution
  111. goto end
  112.  
  113. :PrintBigMessage
  114. echo. && echo.
  115. echo *******************************************************************
  116. for %%M in (%*) do echo * %%~M
  117. echo *******************************************************************
  118. echo. && echo.
  119. exit /b
  120.  
  121. :end
  122. pause
Advertisement
Add Comment
Please, Sign In to add comment