2024-01-25 19:33:10 +00:00
|
|
|
|
:: -----------------------------------------------------------------------------------
|
|
|
|
|
:: OPEN SERVER PANEL | COMMAND LINE INTERFACE
|
|
|
|
|
:: -----------------------------------------------------------------------------------
|
|
|
|
|
@set "ESC="
|
|
|
|
|
@if "{terminal_ansi_fix}"=="on" @if not defined OSP_FIXED @if exist "{root_dir}\system\bin\ansicon.exe" @set "OSP_FIXED=YES" & "{root_dir}\system\bin\ansicon.exe" -p >nul 2>nul
|
|
|
|
|
@if exist "{root_dir}\system\bin\colortest.exe" "{root_dir}\system\bin\colortest.exe"
|
|
|
|
|
@if %ERRORLEVEL% gtr 0 @if "{terminal_ansi_fix}"=="auto" @if /i not "%ConEmuANSI%"=="ON" @if not defined OSP_FIXED @if exist "{root_dir}\system\bin\ansicon.exe" @set "OSP_FIXED=YES" & "{root_dir}\system\bin\ansicon.exe" -p >nul 2>nul
|
|
|
|
|
@for /f "tokens=2 delims=:." %%a in ('chcp') do @set "OSP_CODEPAGE=%%a"
|
|
|
|
|
@call :trim %OSP_CODEPAGE% OSP_CODEPAGE
|
|
|
|
|
@chcp 65001 > nul
|
|
|
|
|
@if not exist "{root_dir}\temp\OSPanel.lock" goto notrunning
|
|
|
|
|
:gettempname
|
|
|
|
|
@set "OSP_TMPVAL=~OSP_%RANDOM%%RANDOM%%RANDOM%%RANDOM%%RANDOM%.tmp"
|
|
|
|
|
@if exist "{root_dir}\temp\%OSP_TMPVAL%" goto gettempname
|
|
|
|
|
@(for /f %%N in ("1") do call,) > "{root_dir}\temp\%OSP_TMPVAL%"
|
|
|
|
|
@for %%S in ("{root_dir}\temp\%OSP_TMPVAL%") do @if %%~zS==0 (set "OSP_ECHO_STATE=OFF") else (set "OSP_ECHO_STATE=ON")
|
|
|
|
|
@echo off
|
|
|
|
|
del "{root_dir}\temp\%OSP_TMPVAL%"
|
|
|
|
|
if "%OSP_ACTIVE_ENV%"=="" set "OSP_ACTIVE_ENV=System" & set "OSP_ACTIVE_ENV_VAL=:System:"
|
2024-04-14 07:04:47 +00:00
|
|
|
|
set "OSP_PROG_LIST=curl tail fd bat getbit getparent ansicon colortest syspreptool"
|
2024-04-07 05:24:50 +00:00
|
|
|
|
for %%a in (%OSP_PROG_LIST%) do (
|
|
|
|
|
if not exist "{root_dir}\system\bin\%%a.exe" set "OSP_ERR_MSG=%%a.exe {lang_err_not_found}" & goto error
|
|
|
|
|
)
|
2024-01-25 19:33:10 +00:00
|
|
|
|
set "OSP_MODULES_LIST={modules_list}"
|
|
|
|
|
set "OSP_MODULES_LIST_=:%OSP_MODULES_LIST: =:%:"
|
2024-04-01 12:36:18 +00:00
|
|
|
|
set "OSP_ADDONS_LIST={addons_list}"
|
|
|
|
|
set "OSP_ADDONS_LIST_=:%OSP_ADDONS_LIST: =:%:"
|
2024-04-08 23:35:25 +00:00
|
|
|
|
call "{root_dir}\system\bin\getparent.exe" >nul 2>nul
|
|
|
|
|
@if %ERRORLEVEL% gtr 0 set "OSP_ERR_MSG={lang_err_powershell_detect}" & goto error
|
2024-01-25 19:33:10 +00:00
|
|
|
|
:: -----------------------------------------------------------------------------------
|
|
|
|
|
:: ROUTER
|
|
|
|
|
:: -----------------------------------------------------------------------------------
|
|
|
|
|
:router
|
|
|
|
|
if /i "%1"=="add" goto env_add
|
2024-04-07 04:28:39 +00:00
|
|
|
|
if /i "%1"=="addons" goto request
|
|
|
|
|
if /i "%1"=="cacert" goto cacertinit
|
|
|
|
|
if /i "%1"=="convert" goto convert
|
|
|
|
|
if /i "%1"=="domains" goto request
|
2024-01-25 19:33:10 +00:00
|
|
|
|
if /i "%1"=="exit" goto shutdown
|
|
|
|
|
if /i "%1"=="help" goto help
|
2024-04-07 04:28:39 +00:00
|
|
|
|
if /i "%1"=="-h" goto help
|
2024-04-01 00:17:40 +00:00
|
|
|
|
if /i "%1"=="info" echo: & echo {lang_current_env}: %ESC%[36m%OSP_ACTIVE_ENV%%ESC%[0m & goto end
|
2024-01-25 19:33:10 +00:00
|
|
|
|
if /i "%1"=="init" goto mod_cmd
|
|
|
|
|
if /i "%1"=="log" goto log
|
2024-04-07 04:28:39 +00:00
|
|
|
|
if /i "%1"=="modules" goto request
|
|
|
|
|
if /i "%1"=="node" goto node
|
2024-01-25 19:33:10 +00:00
|
|
|
|
if /i "%1"=="off" goto mod_cmd
|
|
|
|
|
if /i "%1"=="on" goto mod_cmd
|
|
|
|
|
if /i "%1"=="project" goto project
|
|
|
|
|
if /i "%1"=="reset" goto env_windows
|
|
|
|
|
if /i "%1"=="restart" goto mod_cmd
|
|
|
|
|
if /i "%1"=="shell" goto mod_shell
|
|
|
|
|
if /i "%1"=="status" goto mod_cmd
|
|
|
|
|
if /i "%1"=="sysprep" goto sysprep
|
2024-04-14 08:42:05 +00:00
|
|
|
|
if /i "%1"=="tasks" goto request
|
2024-04-07 04:28:39 +00:00
|
|
|
|
if /i "%1"=="use" goto env_set
|
2024-01-25 19:33:10 +00:00
|
|
|
|
if /i "%1"=="-v" echo: & echo {lang_version_info}: Open Server Panel v{osp_version} x64 {osp_version_datetime} & goto end
|
|
|
|
|
if /i "%1"=="version" echo: & echo {lang_version_info}: Open Server Panel v{osp_version} x64 {osp_version_datetime} & goto end
|
|
|
|
|
if "%1"=="" goto help
|
|
|
|
|
set "OSP_ERR_MSG={lang_err_unknown_command}" & goto error
|
|
|
|
|
:: -----------------------------------------------------------------------------------
|
|
|
|
|
:: LOGO
|
|
|
|
|
:: -----------------------------------------------------------------------------------
|
|
|
|
|
:logo
|
|
|
|
|
echo ___ ____ ____ _
|
|
|
|
|
echo / _ \ _ __ ___ _ __ / ___^| ___ _ ____ _____ _ __ ^| _ \ __ _ _ __ ___^| ^|
|
|
|
|
|
echo ^| ^| ^| ^| '_ \ / _ \ '_ \ \___ \ / _ \ '__\ \ / / _ \ '__^| ^| ^|_) / _` ^| '_ \ / _ \ ^|
|
|
|
|
|
echo ^| ^|_^| ^| ^|_) ^| __/ ^| ^| ^| ___) ^| __/ ^| \ V / __/ ^| ^| __/ (_^| ^| ^| ^| ^| __/ ^|
|
|
|
|
|
echo \___/^| .__/ \___^|_^| ^|_^| ^|____/ \___^|_^| \_/ \___^|_^| ^|_^| \__,_^|_^| ^|_^|\___^|_^|
|
|
|
|
|
echo ^|_^|
|
|
|
|
|
echo:
|
2024-04-01 00:17:40 +00:00
|
|
|
|
echo {lang_calling_help}: %ESC%[32mosp help%ESC%[0m ^| {lang_program_version}: %ESC%[33m{osp_version}%ESC%[0m ^| © 2010-2024 ^«OSPanel.io^»
|
2024-01-25 19:33:10 +00:00
|
|
|
|
@exit /b 0
|
|
|
|
|
:: -----------------------------------------------------------------------------------
|
|
|
|
|
:: HELP
|
|
|
|
|
:: -----------------------------------------------------------------------------------
|
|
|
|
|
:help
|
|
|
|
|
call :logo
|
|
|
|
|
echo:
|
2024-04-03 01:36:43 +00:00
|
|
|
|
echo %ESC%[33m{lang_usage}:%ESC%[0m %ESC%[32mosp ^<{lang_command_param}^> [^<{lang_arguments}^>]%ESC%[0m
|
2024-01-25 19:33:10 +00:00
|
|
|
|
echo:
|
2024-04-01 00:17:40 +00:00
|
|
|
|
echo %ESC%[33m{lang_env_management}:%ESC%[0m
|
2024-01-25 19:33:10 +00:00
|
|
|
|
echo:
|
2024-04-03 02:13:45 +00:00
|
|
|
|
echo %ESC%[32madd ^<MODULE^|ADDON^>%ESC%[0m {lang_merge_env}
|
2024-04-01 00:17:40 +00:00
|
|
|
|
echo %ESC%[32minfo%ESC%[0m {lang_show_current_env}
|
2024-04-06 18:19:12 +00:00
|
|
|
|
echo %ESC%[32mproject ^<DOMAIN^> [start]%ESC%[0m {lang_activate_project}
|
|
|
|
|
echo {lang_activate_project_info}
|
2024-04-01 00:17:40 +00:00
|
|
|
|
echo %ESC%[32mreset [init]%ESC%[0m {lang_reset_current_env}
|
2024-01-25 19:33:10 +00:00
|
|
|
|
echo {lang_init_flag}
|
2024-04-03 02:13:45 +00:00
|
|
|
|
echo %ESC%[32muse ^<MODULE^|ADDON^>%ESC%[0m {lang_apply_mod_env}
|
2024-01-25 19:33:10 +00:00
|
|
|
|
echo {lang_disabled_mod_note_1}
|
|
|
|
|
echo {lang_disabled_mod_note_2}
|
|
|
|
|
echo:
|
2024-04-01 00:17:40 +00:00
|
|
|
|
echo %ESC%[33m{lang_mod_management}:%ESC%[0m
|
2024-01-25 19:33:10 +00:00
|
|
|
|
echo:
|
2024-04-01 00:17:40 +00:00
|
|
|
|
echo %ESC%[32minit ^<MODULE^> [PROFILE]%ESC%[0m {lang_reinit}
|
2024-01-25 19:33:10 +00:00
|
|
|
|
echo {lang_switch_profile_note}
|
|
|
|
|
echo {lang_reinit_note}
|
|
|
|
|
echo {lang_apply_mod_env_again_1}
|
|
|
|
|
echo {lang_apply_mod_env_again_2}
|
2024-04-01 00:17:40 +00:00
|
|
|
|
echo %ESC%[32moff ^<MODULE^>%ESC%[0m {lang_disable_mod}
|
|
|
|
|
echo %ESC%[32mon ^<MODULE^> [PROFILE]%ESC%[0m {lang_enable_mod}
|
|
|
|
|
echo %ESC%[32mrestart ^<MODULE^> [PROFILE]%ESC%[0m {lang_restart_mod}
|
|
|
|
|
echo %ESC%[32mshell ^<MODULE^>%ESC%[0m {lang_launch_shell_descr}
|
|
|
|
|
echo %ESC%[32mstatus ^<MODULE^>%ESC%[0m {lang_show_mod_status}
|
2024-04-07 01:18:46 +00:00
|
|
|
|
if not exist "{root_dir}\addons\NVM\nvm.exe" goto help2
|
|
|
|
|
echo:
|
|
|
|
|
echo %ESC%[33m{lang_nvm_management}:%ESC%[0m
|
|
|
|
|
echo:
|
|
|
|
|
echo %ESC%[32mnode install ^<N^> [ARCH]%ESC%[0m {lang_nvm_install_1}
|
|
|
|
|
echo {lang_nvm_install_2}
|
|
|
|
|
echo {lang_nvm_install_3}
|
|
|
|
|
echo {lang_nvm_install_4}
|
|
|
|
|
echo {lang_nvm_install_5}
|
2024-04-08 18:00:59 +00:00
|
|
|
|
echo {lang_nvm_install_6}
|
|
|
|
|
echo {lang_nvm_install_7}
|
2024-04-07 01:18:46 +00:00
|
|
|
|
echo %ESC%[32mnode list [available]%ESC%[0m {lang_nvm_list_1}
|
|
|
|
|
echo {lang_nvm_list_2}
|
2024-04-07 21:48:53 +00:00
|
|
|
|
echo %ESC%[32mnode mode ^<N^> [ARCH]%ESC%[0m {lang_nvm_mode_1}
|
2024-04-07 01:18:46 +00:00
|
|
|
|
echo {lang_nvm_mode_2}
|
|
|
|
|
echo %ESC%[32mnode node_mirror [URL]%ESC%[0m {lang_nvm_node_mirror_1}
|
|
|
|
|
echo {lang_nvm_node_mirror_2}
|
|
|
|
|
echo %ESC%[32mnode npm_mirror [URL]%ESC%[0m {lang_nvm_npm_mirror_1}
|
|
|
|
|
echo {lang_nvm_npm_mirror_2}
|
|
|
|
|
echo %ESC%[32mnode proxy [URL]%ESC%[0m {lang_nvm_proxy_1}
|
|
|
|
|
echo {lang_nvm_proxy_2}
|
|
|
|
|
echo {lang_nvm_proxy_3}
|
2024-04-07 21:48:53 +00:00
|
|
|
|
echo %ESC%[32mnode uninstall ^<N^>%ESC%[0m {lang_nvm_uninstall}
|
2024-04-07 01:18:46 +00:00
|
|
|
|
:help2
|
2024-01-25 19:33:10 +00:00
|
|
|
|
echo:
|
2024-04-01 00:17:40 +00:00
|
|
|
|
echo %ESC%[33m{lang_other_commands}:%ESC%[0m
|
2024-01-25 19:33:10 +00:00
|
|
|
|
echo:
|
2024-04-01 13:48:03 +00:00
|
|
|
|
echo %ESC%[32maddons%ESC%[0m {lang_show_addons_info}
|
2024-04-01 00:17:40 +00:00
|
|
|
|
echo %ESC%[32mcacert ^<init^|show^|deinit^>%ESC%[0m {lang_gen_and_install_root_cert}
|
2024-01-25 19:33:10 +00:00
|
|
|
|
echo {lang_about_gen_root_cert}
|
2024-04-01 00:17:40 +00:00
|
|
|
|
echo %ESC%[32mconvert ^<DOMAIN^>%ESC%[0m {lang_convert_from_to_punycode}
|
|
|
|
|
echo %ESC%[32mdomains%ESC%[0m {lang_show_info_about_domains}
|
|
|
|
|
echo %ESC%[32mexit%ESC%[0m {lang_shutting_down_program}
|
2024-04-14 08:42:05 +00:00
|
|
|
|
echo %ESC%[32mlog ^<PATTERN^> [N]%ESC%[0m {lang_show_log}
|
2024-01-26 17:56:39 +00:00
|
|
|
|
echo {lang_show_log_descr}
|
2024-04-14 08:42:05 +00:00
|
|
|
|
echo {lang_show_log_descr_2}
|
|
|
|
|
echo {lang_show_log_descr_3}
|
|
|
|
|
echo {lang_show_log_descr_4}
|
|
|
|
|
echo {lang_show_log_descr_5}
|
2024-04-01 00:17:40 +00:00
|
|
|
|
echo %ESC%[32mmodules%ESC%[0m {lang_show_mod_info}
|
2024-04-17 09:10:45 +00:00
|
|
|
|
echo %ESC%[32mstatus%ESC%[0m {lang_show_all_status}
|
2024-04-01 00:17:40 +00:00
|
|
|
|
echo %ESC%[32msysprep [silent^|ssd]%ESC%[0m {lang_launch_sp_tool}
|
2024-01-25 19:33:10 +00:00
|
|
|
|
echo {lang_silent_flag}
|
|
|
|
|
echo {lang_ssd_flag}
|
|
|
|
|
echo {lang_about_silent_mode_1}
|
|
|
|
|
echo {lang_about_silent_mode_2}
|
2024-04-14 08:42:05 +00:00
|
|
|
|
echo %ESC%[32mtasks%ESC%[0m {lang_show_tasks}
|
2024-04-01 00:17:40 +00:00
|
|
|
|
echo %ESC%[32mversion%ESC%[0m {lang_show_version_info}
|
2024-01-25 19:33:10 +00:00
|
|
|
|
echo:
|
2024-04-01 00:17:40 +00:00
|
|
|
|
echo %ESC%[33m{lang_usage_examples}:%ESC%[0m
|
2024-01-25 19:33:10 +00:00
|
|
|
|
echo:
|
2024-04-01 00:17:40 +00:00
|
|
|
|
echo %ESC%[32mosp exit ^& ospanel%ESC%[0m {lang_restarting_program}
|
2024-04-03 01:36:43 +00:00
|
|
|
|
echo %ESC%[32mosp use PostgreSQL-9.6%ESC%[0m {lang_usage_postgresql}
|
2024-04-01 00:17:40 +00:00
|
|
|
|
echo %ESC%[32mosp on PHP-8.1 myprofile%ESC%[0m {lang_enabling_php}
|
|
|
|
|
echo %ESC%[32mosp restart mysql-8.0%ESC%[0m {lang_restarting_mysql}
|
|
|
|
|
echo %ESC%[32mosp reset ^& osp add bind%ESC%[0m {lang_combining_with_bind}
|
2024-04-14 09:20:24 +00:00
|
|
|
|
echo:
|
|
|
|
|
echo %ESC%[33m{lang_available_utilities}:%ESC%[0m
|
|
|
|
|
echo:
|
|
|
|
|
echo %ESC%[32maria2c%ESC%[0m {lang_utilite_aria2c}
|
|
|
|
|
echo %ESC%[32mbat%ESC%[0m {lang_utilite_bat}
|
|
|
|
|
echo %ESC%[32mbrotli%ESC%[0m {lang_utilite_brotli}
|
|
|
|
|
echo %ESC%[32mcurl%ESC%[0m {lang_utilite_curl}
|
|
|
|
|
echo %ESC%[32mdust%ESC%[0m {lang_utilite_dust}
|
|
|
|
|
echo %ESC%[32mfd%ESC%[0m {lang_utilite_fd}
|
|
|
|
|
echo %ESC%[32mgzip%ESC%[0m {lang_utilite_gzip}
|
|
|
|
|
echo %ESC%[32mjq%ESC%[0m {lang_utilite_jq}
|
|
|
|
|
echo %ESC%[32mmmdbinspect%ESC%[0m {lang_utilite_mmdbinspect}
|
|
|
|
|
echo %ESC%[32msass%ESC%[0m {lang_utilite_sass}
|
|
|
|
|
echo %ESC%[32msd%ESC%[0m {lang_utilite_sd}
|
|
|
|
|
echo %ESC%[32mwget%ESC%[0m {lang_utilite_wget}
|
|
|
|
|
echo %ESC%[32mxh%ESC%[0m {lang_utilite_xh}
|
2024-01-25 19:33:10 +00:00
|
|
|
|
goto end
|
|
|
|
|
:: -----------------------------------------------------------------------------------
|
|
|
|
|
:: SHUTTING DOWN THE APPLICATION
|
|
|
|
|
:: -----------------------------------------------------------------------------------
|
|
|
|
|
:shutdown
|
|
|
|
|
if not "%OSP_MODULES_LIST%"=="" for %%a in (%OSP_MODULES_LIST%) do (
|
2024-04-04 23:25:29 +00:00
|
|
|
|
if exist "{root_dir}\data\cli\env_%%a.bat" call "{root_dir}\data\cli\env_%%a.bat" resetenv
|
2024-01-25 19:33:10 +00:00
|
|
|
|
)
|
2024-04-01 21:38:12 +00:00
|
|
|
|
if not "%OSP_ADDONS_LIST%"=="" for %%a in (%OSP_ADDONS_LIST%) do (
|
2024-04-04 23:25:29 +00:00
|
|
|
|
if exist "{root_dir}\data\cli\env_%%a.bat" call "{root_dir}\data\cli\env_%%a.bat" resetenv
|
2024-04-01 21:38:12 +00:00
|
|
|
|
)
|
2024-01-25 19:33:10 +00:00
|
|
|
|
{system_environment}
|
|
|
|
|
set "OSP_ACTIVE_ENV=System" & set "OSP_ACTIVE_ENV_VAL=:System:"
|
|
|
|
|
if /i not "{terminal_codepage}"=="" set "OSP_CODEPAGE={terminal_codepage}"
|
|
|
|
|
"{root_dir}\system\bin\curl.exe" -f -s {cmd_api_url}/exit > nul
|
|
|
|
|
if exist "{root_dir}\temp\OSPanel.lock" goto error
|
|
|
|
|
echo: & echo {lang_exiting_program}
|
|
|
|
|
goto end
|
|
|
|
|
:: -----------------------------------------------------------------------------------
|
|
|
|
|
:: INIT CACERT
|
|
|
|
|
:: -----------------------------------------------------------------------------------
|
|
|
|
|
:cacertinit
|
|
|
|
|
if "%2"=="" goto eargument
|
|
|
|
|
if /i "%2"=="show" "%SystemRoot%\System32\certutil.exe" -user -store "Root" "Open Server Panel" & goto end
|
|
|
|
|
if /i "%2"=="deinit" goto cacertdeinit
|
|
|
|
|
if not exist "{root_dir}\system\ssl\gen_root_cert.bat" set "OSP_ERR_MSG={root_dir}\system\ssl\gen_root_cert.bat {lang_err_not_found}" & goto error
|
|
|
|
|
if exist "{root_dir}\data\ssl\root\cert.crt" del /Q "{root_dir}\data\ssl\root\cert.crt"
|
|
|
|
|
"%SystemRoot%\System32\certutil.exe" -user -delstore "Root" "Open Server Panel"
|
|
|
|
|
"%SystemRoot%\System32\certutil.exe" -urlcache * delete > nul 2> nul
|
|
|
|
|
call "{root_dir}\system\ssl\gen_root_cert.bat"
|
|
|
|
|
if not exist "{root_dir}\data\ssl\root\cert.crt" set "OSP_ERR_MSG={lang_err_failed_gen_root_cert}" & goto error
|
|
|
|
|
"%SystemRoot%\System32\certutil.exe" -user -addstore "Root" "{root_dir}\data\ssl\root\cert.crt"
|
|
|
|
|
"%SystemRoot%\System32\certutil.exe" -urlcache * delete > nul 2> nul
|
|
|
|
|
goto end
|
|
|
|
|
:: -----------------------------------------------------------------------------------
|
|
|
|
|
:: DEINIT CACERT
|
|
|
|
|
:: -----------------------------------------------------------------------------------
|
|
|
|
|
:cacertdeinit
|
|
|
|
|
if exist "{root_dir}\data\ssl\root\cert.crt" del /Q "{root_dir}\data\ssl\root\cert.crt"
|
|
|
|
|
"%SystemRoot%\System32\certutil.exe" -user -delstore "Root" "Open Server Panel"
|
|
|
|
|
"%SystemRoot%\System32\certutil.exe" -urlcache * delete > nul 2> nul
|
|
|
|
|
goto end
|
|
|
|
|
:: -----------------------------------------------------------------------------------
|
2024-04-07 04:28:39 +00:00
|
|
|
|
:: NODE MANAGEMENT
|
|
|
|
|
:: -----------------------------------------------------------------------------------
|
|
|
|
|
:node
|
|
|
|
|
if "%2"=="" goto eargument
|
|
|
|
|
call :strfind "%OSP_ADDONS_LIST_%" ":NVM:"
|
|
|
|
|
if not defined OSP_TMPVAL set "OSP_ERR_MSG={lang_nvm_not_installed}" & goto error
|
2024-04-17 05:58:25 +00:00
|
|
|
|
if not exist "{root_dir}\data\cli\env_NVM.bat" set "OSP_ERR_MSG={lang_err_no_env_config} NVM" & goto error
|
2024-04-07 04:28:39 +00:00
|
|
|
|
if /i "%2"=="install" goto nodeinstall
|
|
|
|
|
if /i "%2"=="list" goto nodelist
|
2024-04-07 05:14:48 +00:00
|
|
|
|
if /i "%2"=="mode" goto nodemode
|
2024-04-07 04:28:39 +00:00
|
|
|
|
if /i "%2"=="node_mirror" goto nodeurl
|
|
|
|
|
if /i "%2"=="npm_mirror" goto nodeurl
|
2024-04-08 18:00:59 +00:00
|
|
|
|
if /i "%2"=="proxy" goto nodeurl
|
|
|
|
|
if /i "%2"=="uninstall" goto nodeinstall
|
2024-04-07 04:28:39 +00:00
|
|
|
|
if /i "%2"=="add" goto nodeadd
|
|
|
|
|
if /i "%2"=="use" goto nodeuse
|
|
|
|
|
goto invalid
|
|
|
|
|
:nodeadd
|
|
|
|
|
if /i "%3"=="" goto invalid
|
2024-04-08 01:12:59 +00:00
|
|
|
|
set "OSP_TMP_NAME=%3"
|
|
|
|
|
set "OSP_TMP_NAME=%OSP_TMP_NAME:Node-=%"
|
|
|
|
|
if not exist "{root_dir}\addons\NVM\v%OSP_TMP_NAME%" set "OSP_ERR_MSG={lang_nvm_node_not_installed}" & goto error
|
2024-04-07 04:28:39 +00:00
|
|
|
|
call :strfind "%OSP_ACTIVE_ENV_VAL%" ":Node"
|
|
|
|
|
if defined OSP_TMPVAL set "OSP_ERR_MSG={lang_err_env_modules_exist}" & goto error
|
2024-04-08 01:12:59 +00:00
|
|
|
|
call :strfind "%OSP_ACTIVE_ENV_VAL%" ":Node-%OSP_TMP_NAME%:"
|
2024-04-07 04:28:39 +00:00
|
|
|
|
if defined OSP_TMPVAL set "OSP_ERR_MSG={lang_err_env_already_active}" & goto error
|
2024-04-14 23:42:06 +00:00
|
|
|
|
goto nodeenv
|
2024-04-07 04:28:39 +00:00
|
|
|
|
:nodeuse
|
|
|
|
|
if /i "%3"=="" goto invalid
|
2024-04-08 01:12:59 +00:00
|
|
|
|
set "OSP_TMP_NAME=%3"
|
|
|
|
|
set "OSP_TMP_NAME=%OSP_TMP_NAME:Node-=%"
|
|
|
|
|
if not exist "{root_dir}\addons\NVM\v%OSP_TMP_NAME%" set "OSP_ERR_MSG={lang_nvm_node_not_installed}" & goto error
|
2024-04-07 04:28:39 +00:00
|
|
|
|
call :env_reset post
|
2024-04-14 23:42:06 +00:00
|
|
|
|
goto nodeenv
|
2024-04-07 05:14:48 +00:00
|
|
|
|
:nodemode
|
2024-04-08 18:00:59 +00:00
|
|
|
|
if /i "%3"=="" goto invalid
|
|
|
|
|
set "OSP_TMP_NAME=%3"
|
|
|
|
|
set "OSP_TMP_NAME=%OSP_TMP_NAME:Node-=%"
|
|
|
|
|
if /i "%4"=="" echo: & call "{root_dir}\system\bin\getbit.exe" "{root_dir}\addons\NVM\v%OSP_TMP_NAME%\node.exe" & goto end
|
2024-04-07 05:14:48 +00:00
|
|
|
|
if /i not "%4"=="" if /i not "%4"=="32" if /i not "%4"=="64" goto invalid
|
|
|
|
|
setlocal
|
|
|
|
|
call :env_reset post
|
2024-04-17 05:58:25 +00:00
|
|
|
|
call "{root_dir}\data\cli\env_NVM.bat" use
|
2024-04-14 23:42:06 +00:00
|
|
|
|
call "{root_dir}\data\cli\nvm.bat" use %OSP_TMP_NAME% %4
|
2024-04-07 05:14:48 +00:00
|
|
|
|
endlocal
|
|
|
|
|
goto end
|
2024-04-08 18:00:59 +00:00
|
|
|
|
:nodeurl
|
2024-04-07 04:28:39 +00:00
|
|
|
|
setlocal
|
|
|
|
|
call :env_reset post
|
2024-04-17 05:58:25 +00:00
|
|
|
|
call "{root_dir}\data\cli\env_NVM.bat" use
|
2024-04-14 23:42:06 +00:00
|
|
|
|
call "{root_dir}\data\cli\nvm.bat" %2 %3
|
2024-04-07 04:28:39 +00:00
|
|
|
|
endlocal
|
|
|
|
|
goto end
|
|
|
|
|
:nodelist
|
|
|
|
|
if /i not "%3"=="" if /i not "%3"=="available" goto invalid
|
|
|
|
|
setlocal
|
|
|
|
|
call :env_reset post
|
2024-04-17 05:58:25 +00:00
|
|
|
|
call "{root_dir}\data\cli\env_NVM.bat" use
|
2024-04-14 23:42:06 +00:00
|
|
|
|
call "{root_dir}\data\cli\nvm.bat" %2 %3
|
2024-04-07 04:28:39 +00:00
|
|
|
|
endlocal
|
|
|
|
|
goto end
|
|
|
|
|
:nodeinstall
|
|
|
|
|
if /i "%3"=="" goto invalid
|
2024-04-08 18:00:59 +00:00
|
|
|
|
set "OSP_TMP_NAME=%3"
|
|
|
|
|
set "OSP_TMP_NAME=%OSP_TMP_NAME:Node-=%"
|
2024-04-07 05:14:48 +00:00
|
|
|
|
if /i not "%4"=="" if /i not "%4"=="all" if /i not "%4"=="32" if /i not "%4"=="64" goto invalid
|
2024-04-07 04:28:39 +00:00
|
|
|
|
setlocal
|
|
|
|
|
call :env_reset post
|
2024-04-17 05:58:25 +00:00
|
|
|
|
call "{root_dir}\data\cli\env_NVM.bat" use
|
2024-04-07 04:28:39 +00:00
|
|
|
|
echo:
|
2024-04-14 14:30:34 +00:00
|
|
|
|
if /i "%2"=="uninstall" goto nodeuninstall
|
|
|
|
|
if /i "%4"=="64" goto nodeinst64
|
|
|
|
|
if /i "%4"=="" goto nodeinst64
|
|
|
|
|
:nodeinst32
|
2024-04-14 23:42:06 +00:00
|
|
|
|
call "{root_dir}\data\cli\nvm.bat" install %OSP_TMP_NAME% 32
|
|
|
|
|
call "{root_dir}\data\cli\nvm.bat" use %OSP_TMP_NAME% 32
|
2024-04-14 14:30:34 +00:00
|
|
|
|
if /i "%4"=="32" goto nodeinstallend
|
|
|
|
|
:nodeinst64
|
2024-04-14 23:42:06 +00:00
|
|
|
|
call "{root_dir}\data\cli\nvm.bat" install %OSP_TMP_NAME% 64
|
|
|
|
|
call "{root_dir}\data\cli\nvm.bat" use %OSP_TMP_NAME% 64
|
2024-04-14 14:30:34 +00:00
|
|
|
|
goto nodeinstallend
|
|
|
|
|
:nodeuninstall
|
2024-04-14 23:42:06 +00:00
|
|
|
|
call "{root_dir}\data\cli\nvm.bat" uninstall %OSP_TMP_NAME%
|
2024-04-14 14:30:34 +00:00
|
|
|
|
:nodeinstallend
|
2024-04-07 04:28:39 +00:00
|
|
|
|
endlocal
|
2024-04-14 14:30:34 +00:00
|
|
|
|
"{root_dir}\system\bin\curl.exe" -f -s {cmd_api_url}/update_node >nul 2>nul
|
2024-04-07 04:28:39 +00:00
|
|
|
|
goto end
|
2024-04-14 23:42:06 +00:00
|
|
|
|
:nodeenv
|
2024-04-17 05:58:25 +00:00
|
|
|
|
call "{root_dir}\data\cli\env_NVM.bat" %2 & call :post_env %2 Node-%OSP_TMP_NAME% %4
|
2024-04-14 23:42:06 +00:00
|
|
|
|
set "PATH={root_dir}\addons\NVM\v%OSP_TMP_NAME%;%PATH%"
|
|
|
|
|
set "NPM_CONFIG_UNICODE=true"
|
|
|
|
|
set "NPM_CONFIG_CAFILE={root_dir}\data\ssl\cacert.pem"
|
|
|
|
|
set "NPM_CONFIG_USERCONFIG={root_dir}\addons\NVM\v%OSP_TMP_NAME%\etc\user-npm.conf"
|
|
|
|
|
set "NPM_CONFIG_GLOBALCONFIG={root_dir}\addons\NVM\v%OSP_TMP_NAME%\etc\global-npm.conf"
|
|
|
|
|
set "NPM_CONFIG_CACHE={root_dir}\addons\NVM\v%OSP_TMP_NAME%\npm-cache"
|
|
|
|
|
set "NPM_CACHE_LOCATION={root_dir}\addons\NVM\v%OSP_TMP_NAME%\npm-cache"
|
|
|
|
|
goto end
|
2024-04-07 04:28:39 +00:00
|
|
|
|
:: -----------------------------------------------------------------------------------
|
2024-01-25 19:33:10 +00:00
|
|
|
|
:: SYSTEM PREPARATION TOOL
|
|
|
|
|
:: -----------------------------------------------------------------------------------
|
|
|
|
|
:sysprep
|
|
|
|
|
if /i not "%2"=="silent" if /i not "%2"=="ssd" if not "%2"=="" goto invalid
|
|
|
|
|
if /i "%2"=="silent" start "" /WAIT "{root_dir}\system\bin\syspreptool.exe" /VERYSILENT /SUPPRESSMSGBOXES /NOCANCEL
|
|
|
|
|
if /i "%2"=="ssd" start "" /WAIT "{root_dir}\system\bin\syspreptool.exe" /VERYSILENT /SUPPRESSMSGBOXES /NOCANCEL /MERGETASKS="taskSsdopts"
|
|
|
|
|
if "%2"=="" start "" "{root_dir}\system\bin\syspreptool.exe"
|
|
|
|
|
goto end
|
|
|
|
|
:: -----------------------------------------------------------------------------------
|
|
|
|
|
:: LOG VIEW
|
|
|
|
|
:: -----------------------------------------------------------------------------------
|
|
|
|
|
:log
|
2024-04-14 08:42:05 +00:00
|
|
|
|
if "%~2"=="" goto eargument
|
2024-04-14 07:04:47 +00:00
|
|
|
|
echo:
|
2024-04-17 05:58:25 +00:00
|
|
|
|
"{root_dir}\system\bin\fd.exe" -e log -a -i -p %2 "{root_dir}\logs" -x "{root_dir}\system\bin\tail.bat" {} %3
|
2024-01-25 19:33:10 +00:00
|
|
|
|
goto end
|
|
|
|
|
:: -----------------------------------------------------------------------------------
|
2024-04-14 08:42:05 +00:00
|
|
|
|
:: ADDONS/DOMAINS/MODULES/TASKS LIST
|
2024-01-25 19:33:10 +00:00
|
|
|
|
:: -----------------------------------------------------------------------------------
|
|
|
|
|
:request
|
|
|
|
|
"{root_dir}\system\bin\curl.exe" -f -s {cmd_api_url}/%1
|
|
|
|
|
if %ERRORLEVEL% gtr 0 goto error
|
|
|
|
|
goto end
|
|
|
|
|
:: -----------------------------------------------------------------------------------
|
|
|
|
|
:: INIT/ON/OFF/RESTART/STATUS
|
|
|
|
|
:: -----------------------------------------------------------------------------------
|
|
|
|
|
:mod_cmd
|
2024-04-17 08:53:49 +00:00
|
|
|
|
if "%1"=="status" if "%2"=="" "{root_dir}\system\bin\curl.exe" -f -s {cmd_api_url}/tasks
|
|
|
|
|
if "%1"=="status" if "%2"=="" if %ERRORLEVEL% gtr 0 goto error
|
|
|
|
|
if "%1"=="status" if "%2"=="" "{root_dir}\system\bin\curl.exe" -f -s {cmd_api_url}/domains
|
|
|
|
|
if "%1"=="status" if "%2"=="" if %ERRORLEVEL% gtr 0 goto error
|
|
|
|
|
if "%1"=="status" if "%2"=="" "{root_dir}\system\bin\curl.exe" -f -s {cmd_api_url}/addons
|
|
|
|
|
if "%1"=="status" if "%2"=="" if %ERRORLEVEL% gtr 0 goto error
|
|
|
|
|
if "%1"=="status" if "%2"=="" "{root_dir}\system\bin\curl.exe" -f -s {cmd_api_url}/modules
|
|
|
|
|
if "%1"=="status" if "%2"=="" if %ERRORLEVEL% gtr 0 goto error
|
|
|
|
|
if "%1"=="status" if "%2"=="" goto end
|
2024-01-25 19:33:10 +00:00
|
|
|
|
if "%2"=="" goto eargument
|
|
|
|
|
set "OSP_TMP_NAME=%2"
|
|
|
|
|
if not "%OSP_MODULES_LIST%"=="" for %%a in (%OSP_MODULES_LIST%) do (
|
|
|
|
|
if /i "%%a"=="%2" set "OSP_TMP_NAME=%%a"
|
|
|
|
|
)
|
|
|
|
|
call :strfind "%OSP_MODULES_LIST_%all:" ":%OSP_TMP_NAME%:"
|
|
|
|
|
if not defined OSP_TMPVAL goto invalid
|
|
|
|
|
set "OSP_TMPVAL=%OSP_TMP_NAME%"
|
|
|
|
|
if /i "%OSP_TMP_NAME%"=="all" set "OSP_TMPVAL=%OSP_MODULES_LIST%"
|
2024-03-27 19:07:33 +00:00
|
|
|
|
if /i "%OSP_TMP_NAME%"=="all" if /i "%1"=="on" set "OSP_TMPVAL=%OSP_MODULES_LIST%"
|
|
|
|
|
if /i "%OSP_TMP_NAME%"=="all" if /i "%1"=="off" set "OSP_TMPVAL=%OSP_MODULES_LIST%"
|
|
|
|
|
if /i "%OSP_TMP_NAME%"=="all" if /i "%1"=="restart" set "OSP_TMPVAL=%OSP_MODULES_LIST%"
|
2024-01-25 19:33:10 +00:00
|
|
|
|
if /i "%OSP_TMP_NAME%"=="all" echo: & echo {lang_cmd_to_all_warning_1} & echo {lang_cmd_to_all_warning_2}
|
|
|
|
|
if /i "%OSP_TMP_NAME%"=="all" "%SystemRoot%\System32\choice.exe" /C YN /N /M "->{lang_continue} (Y/N)?"
|
|
|
|
|
if /i "%OSP_TMP_NAME%"=="all" if not %ERRORLEVEL%==1 goto end
|
|
|
|
|
setlocal EnableDelayedExpansion
|
2024-03-30 15:31:16 +00:00
|
|
|
|
if %ERRORLEVEL%==1 set "OSP_ERR_MSG={err_failed_to_enable_ce}" & goto error
|
2024-01-25 19:33:10 +00:00
|
|
|
|
for %%a in (%OSP_TMPVAL%) do (
|
|
|
|
|
if /i "%1"=="restart" (
|
|
|
|
|
"{root_dir}\system\bin\curl.exe" -f -s {cmd_api_url}/off/%%a/%3
|
|
|
|
|
if !errorlevel! gtr 0 (
|
|
|
|
|
call :echo_error %1 %OSP_TMP_NAME% %3
|
|
|
|
|
) else (
|
|
|
|
|
"{root_dir}\system\bin\curl.exe" -f -s {cmd_api_url}/on/%%a/%3
|
|
|
|
|
if !errorlevel! gtr 0 call :echo_error %1 %OSP_TMP_NAME% %3
|
|
|
|
|
)
|
|
|
|
|
) else (
|
|
|
|
|
"{root_dir}\system\bin\curl.exe" -f -s {cmd_api_url}/%1/%%a/%3
|
|
|
|
|
if !errorlevel! gtr 0 call :echo_error %1 %OSP_TMP_NAME% %3
|
|
|
|
|
)
|
2024-03-31 19:32:19 +00:00
|
|
|
|
if !errorlevel!==0 if /i "%1"=="status" if exist "{root_dir}\logs\%%a.log" for %%S in ("{root_dir}\logs\%%a.log") do if not %%~zS==0 echo: & "{root_dir}\system\bin\tail.exe" "{root_dir}\logs\%%a.log" 15 & echo %ESC%[0m
|
2024-01-25 19:33:10 +00:00
|
|
|
|
)
|
|
|
|
|
endlocal
|
|
|
|
|
goto end
|
|
|
|
|
:: -----------------------------------------------------------------------------------
|
|
|
|
|
:: SHELL
|
|
|
|
|
:: -----------------------------------------------------------------------------------
|
|
|
|
|
:mod_shell
|
|
|
|
|
if "%2"=="" goto eargument
|
|
|
|
|
set "OSP_TMP_NAME=%2"
|
|
|
|
|
if not "%OSP_MODULES_LIST%"=="" for %%a in (%OSP_MODULES_LIST%) do (
|
|
|
|
|
if /i "%%a"=="%2" set "OSP_TMP_NAME=%%a"
|
|
|
|
|
)
|
|
|
|
|
call :strfind "%OSP_MODULES_LIST_%" ":%OSP_TMP_NAME%:"
|
|
|
|
|
if not defined OSP_TMPVAL goto invalid
|
2024-04-04 23:25:29 +00:00
|
|
|
|
if not exist "{root_dir}\data\cli\shell_%OSP_TMP_NAME%.bat" set "OSP_ERR_MSG={lang_err_no_shell_config} %OSP_TMP_NAME%" & goto error
|
2024-01-25 19:33:10 +00:00
|
|
|
|
setlocal
|
|
|
|
|
call :env_reset post
|
2024-04-04 23:25:29 +00:00
|
|
|
|
call "{root_dir}\data\cli\env_%OSP_TMP_NAME%.bat" %1 %OSP_TMP_NAME% %3 & call :post_env %1 %OSP_TMP_NAME% %3
|
2024-01-25 19:33:10 +00:00
|
|
|
|
echo:
|
|
|
|
|
TITLE %OSP_TMP_NAME% shell ^| Open Server Panel
|
2024-04-04 23:25:29 +00:00
|
|
|
|
call "{root_dir}\data\cli\shell_%OSP_TMP_NAME%.bat"
|
2024-01-25 19:33:10 +00:00
|
|
|
|
endlocal
|
|
|
|
|
chcp 65001 > nul
|
|
|
|
|
TITLE %OSP_ACTIVE_ENV% ^| Open Server Panel
|
|
|
|
|
goto end
|
|
|
|
|
:: -----------------------------------------------------------------------------------
|
|
|
|
|
:: IDN CONVERTER
|
|
|
|
|
:: -----------------------------------------------------------------------------------
|
|
|
|
|
:convert
|
|
|
|
|
if "%2"=="" goto eargument
|
|
|
|
|
"{root_dir}\system\bin\curl.exe" -f -s {cmd_api_url}/convert/%2
|
|
|
|
|
if %ERRORLEVEL% gtr 0 goto error
|
|
|
|
|
@goto end
|
|
|
|
|
:: -----------------------------------------------------------------------------------
|
|
|
|
|
:: PROJECT
|
|
|
|
|
:: -----------------------------------------------------------------------------------
|
|
|
|
|
:project
|
|
|
|
|
if "%2"=="" goto eargument
|
2024-04-04 23:25:29 +00:00
|
|
|
|
if not exist "{root_dir}\data\cli\project_%2.bat" set "OSP_ERR_MSG={lang_err_no_env_config} %2" & goto error
|
2024-01-25 19:33:10 +00:00
|
|
|
|
set "OSP_TMP_CODEPAGE=%OSP_CODEPAGE%"
|
|
|
|
|
set "OSP_TMP_ECHO_STATE=%OSP_ECHO_STATE%"
|
2024-04-08 03:58:06 +00:00
|
|
|
|
"{root_dir}\data\cli\project_%2.bat" %2 %3
|
2024-01-25 19:33:10 +00:00
|
|
|
|
@if %ERRORLEVEL% gtr 0 @set "OSP_ERR_STATE=ON"
|
|
|
|
|
@echo off
|
|
|
|
|
chcp 65001 > nul
|
|
|
|
|
if defined OSP_TMP_CODEPAGE set "OSP_CODEPAGE=%OSP_TMP_CODEPAGE%" & set "OSP_TMP_CODEPAGE="
|
|
|
|
|
if defined OSP_TMP_ECHO_STATE set "OSP_ECHO_STATE=%OSP_TMP_ECHO_STATE%" & set "OSP_TMP_ECHO_STATE="
|
|
|
|
|
if defined OSP_ERR_STATE set "OSP_ERR_STATE=" & goto error
|
|
|
|
|
goto end
|
|
|
|
|
:: -----------------------------------------------------------------------------------
|
|
|
|
|
:: MODULE ENVIRONMENT (ADD)
|
|
|
|
|
:: -----------------------------------------------------------------------------------
|
|
|
|
|
:env_add
|
|
|
|
|
if "%2"=="" goto eargument
|
2024-04-08 18:00:59 +00:00
|
|
|
|
call :strfind "%2" "Node-"
|
2024-04-08 23:35:25 +00:00
|
|
|
|
if defined OSP_TMPVAL call :nodeadd node add %2 %3 & goto end
|
2024-04-17 06:37:11 +00:00
|
|
|
|
call :strfind "%2" "Python-"
|
|
|
|
|
if defined OSP_TMPVAL call :pythonadd python add %2 %3 & goto end
|
2024-04-08 18:00:59 +00:00
|
|
|
|
set "OSP_TMPVAL="
|
2024-01-25 19:33:10 +00:00
|
|
|
|
set "OSP_TMP_NAME=%2"
|
2024-04-01 21:38:12 +00:00
|
|
|
|
if not "%OSP_ADDONS_LIST%"=="" for %%a in (%OSP_ADDONS_LIST%) do (
|
|
|
|
|
if /i "%%a"=="%2" set "OSP_TMP_NAME=%%a"
|
|
|
|
|
)
|
2024-01-25 19:33:10 +00:00
|
|
|
|
if not "%OSP_MODULES_LIST%"=="" for %%a in (%OSP_MODULES_LIST%) do (
|
|
|
|
|
if /i "%%a"=="%2" set "OSP_TMP_NAME=%%a"
|
|
|
|
|
)
|
2024-04-01 21:38:12 +00:00
|
|
|
|
call :strfind "%OSP_ADDONS_LIST_%" ":%OSP_TMP_NAME%:"
|
|
|
|
|
if not defined OSP_TMPVAL call :strfind "%OSP_MODULES_LIST_%" ":%OSP_TMP_NAME%:"
|
2024-01-25 19:33:10 +00:00
|
|
|
|
if not defined OSP_TMPVAL goto invalid
|
2024-01-27 20:28:53 +00:00
|
|
|
|
for /f "delims=-" %%i in ("%OSP_TMP_NAME%") do set "OSP_TMPVAL=%%~i"
|
|
|
|
|
call :strfind "%OSP_ACTIVE_ENV_VAL%" ":%OSP_TMPVAL%"
|
|
|
|
|
if defined OSP_TMPVAL set "OSP_ERR_MSG={lang_err_env_modules_exist}" & goto error
|
2024-01-25 19:33:10 +00:00
|
|
|
|
call :strfind "%OSP_ACTIVE_ENV_VAL%" ":%OSP_TMP_NAME%:"
|
|
|
|
|
if defined OSP_TMPVAL set "OSP_ERR_MSG={lang_err_env_already_active}" & goto error
|
2024-04-04 23:25:29 +00:00
|
|
|
|
if not exist "{root_dir}\data\cli\env_%OSP_TMP_NAME%.bat" set "OSP_ERR_MSG={lang_err_no_env_config} %OSP_TMP_NAME%" & goto error
|
|
|
|
|
call "{root_dir}\data\cli\env_%OSP_TMP_NAME%.bat" %1 %OSP_TMP_NAME% %3 & call :post_env %1 %OSP_TMP_NAME% %3
|
2024-01-25 19:33:10 +00:00
|
|
|
|
goto end
|
|
|
|
|
:: -----------------------------------------------------------------------------------
|
|
|
|
|
:: MODULE ENVIRONMENT (USE)
|
|
|
|
|
:: -----------------------------------------------------------------------------------
|
|
|
|
|
:env_set
|
|
|
|
|
if "%2"=="" goto eargument
|
2024-04-08 18:00:59 +00:00
|
|
|
|
call :strfind "%2" "Node-"
|
2024-04-08 23:35:25 +00:00
|
|
|
|
if defined OSP_TMPVAL call :nodeuse node use %2 %3 & goto end
|
2024-04-17 06:37:11 +00:00
|
|
|
|
call :strfind "%2" "Python-"
|
|
|
|
|
if defined OSP_TMPVAL call :pythonuse python use %2 %3 & goto end
|
2024-01-25 19:33:10 +00:00
|
|
|
|
set "OSP_TMP_NAME=%2"
|
2024-04-01 12:36:18 +00:00
|
|
|
|
if not "%OSP_ADDONS_LIST%"=="" for %%a in (%OSP_ADDONS_LIST%) do (
|
|
|
|
|
if /i "%%a"=="%2" set "OSP_TMP_NAME=%%a"
|
|
|
|
|
)
|
2024-01-25 19:33:10 +00:00
|
|
|
|
if not "%OSP_MODULES_LIST%"=="" for %%a in (%OSP_MODULES_LIST%) do (
|
|
|
|
|
if /i "%%a"=="%2" set "OSP_TMP_NAME=%%a"
|
|
|
|
|
)
|
2024-04-01 21:38:12 +00:00
|
|
|
|
call :strfind "%OSP_ADDONS_LIST_%" ":%OSP_TMP_NAME%:"
|
|
|
|
|
if not defined OSP_TMPVAL call :strfind "%OSP_MODULES_LIST_%" ":%OSP_TMP_NAME%:"
|
2024-01-25 19:33:10 +00:00
|
|
|
|
if not defined OSP_TMPVAL goto invalid
|
2024-04-04 23:25:29 +00:00
|
|
|
|
if not exist "{root_dir}\data\cli\env_%OSP_TMP_NAME%.bat" set "OSP_ERR_MSG={lang_err_no_env_config} %OSP_TMP_NAME%" & goto error
|
2024-01-25 19:33:10 +00:00
|
|
|
|
call :env_reset post
|
2024-04-04 23:25:29 +00:00
|
|
|
|
call "{root_dir}\data\cli\env_%OSP_TMP_NAME%.bat" %1 %OSP_TMP_NAME% %3 & call :post_env %1 %OSP_TMP_NAME% %3
|
2024-01-25 19:33:10 +00:00
|
|
|
|
goto end
|
|
|
|
|
:: -----------------------------------------------------------------------------------
|
|
|
|
|
:: DEFAULT SYSTEM ENVIRONMENT
|
|
|
|
|
:: -----------------------------------------------------------------------------------
|
|
|
|
|
:env_windows
|
|
|
|
|
call :env_reset pre
|
|
|
|
|
set "OSP_ACTIVE_ENV=System" & set "OSP_ACTIVE_ENV_VAL=:System:"
|
|
|
|
|
if /i not "{terminal_codepage}"=="" if /i "%2"=="init" set "OSP_CODEPAGE={terminal_codepage}"
|
|
|
|
|
if /i "%2"=="init" if /i not "%3"=="silent" call :logo
|
2024-04-01 00:17:40 +00:00
|
|
|
|
if /i not "%2"=="silent" if /i not "%3"=="silent" if /i not "%3"=="noprint" echo: & echo {lang_current_env}: %ESC%[36m%OSP_ACTIVE_ENV%%ESC%[0m
|
2024-01-25 19:33:10 +00:00
|
|
|
|
TITLE %OSP_ACTIVE_ENV% ^| Open Server Panel
|
|
|
|
|
goto end
|
|
|
|
|
:: -----------------------------------------------------------------------------------
|
|
|
|
|
:: RESET ENVIRONMENT
|
|
|
|
|
:: -----------------------------------------------------------------------------------
|
|
|
|
|
:env_reset
|
|
|
|
|
if /i "%1"=="pre" if not "%OSP_MODULES_LIST%"=="" for %%a in (%OSP_MODULES_LIST%) do (
|
2024-04-04 23:25:29 +00:00
|
|
|
|
if exist "{root_dir}\data\cli\env_%%a.bat" call "{root_dir}\data\cli\env_%%a.bat" resetenv
|
2024-01-25 19:33:10 +00:00
|
|
|
|
)
|
2024-04-01 21:38:12 +00:00
|
|
|
|
if /i "%1"=="pre" if not "%OSP_ADDONS_LIST%"=="" for %%a in (%OSP_ADDONS_LIST%) do (
|
2024-04-04 23:25:29 +00:00
|
|
|
|
if exist "{root_dir}\data\cli\env_%%a.bat" call "{root_dir}\data\cli\env_%%a.bat" resetenv
|
2024-04-01 21:38:12 +00:00
|
|
|
|
)
|
2024-01-25 19:33:10 +00:00
|
|
|
|
{system_environment}
|
|
|
|
|
if /i "%1"=="post" if not "%OSP_MODULES_LIST%"=="" for %%a in (%OSP_MODULES_LIST%) do (
|
2024-04-04 23:25:29 +00:00
|
|
|
|
if exist "{root_dir}\data\cli\env_%%a.bat" call "{root_dir}\data\cli\env_%%a.bat" resetenv
|
2024-01-25 19:33:10 +00:00
|
|
|
|
)
|
2024-04-01 21:38:12 +00:00
|
|
|
|
if /i "%1"=="post" if not "%OSP_ADDONS_LIST%"=="" for %%a in (%OSP_ADDONS_LIST%) do (
|
2024-04-04 23:25:29 +00:00
|
|
|
|
if exist "{root_dir}\data\cli\env_%%a.bat" call "{root_dir}\data\cli\env_%%a.bat" resetenv
|
2024-04-01 21:38:12 +00:00
|
|
|
|
)
|
2024-01-25 19:33:10 +00:00
|
|
|
|
set "ESC="
|
|
|
|
|
exit /b 0
|
|
|
|
|
:: -----------------------------------------------------------------------------------
|
|
|
|
|
:: MISCELLANEOUS FUNCTIONS
|
|
|
|
|
:: -----------------------------------------------------------------------------------
|
|
|
|
|
:invalid
|
|
|
|
|
set "OSP_ERR_MSG={lang_err_unknown_arg}" & goto error
|
|
|
|
|
:eargument
|
|
|
|
|
set "OSP_ERR_MSG={lang_err_arg_not_specified}" & goto error
|
|
|
|
|
:strfind
|
|
|
|
|
setlocal
|
|
|
|
|
set "pos="
|
|
|
|
|
set "str=%~1"
|
|
|
|
|
set "sub=%~2"
|
|
|
|
|
call set "Replaced=%%str:%sub%=%%"
|
|
|
|
|
if /i not "%str%"=="%Replaced%" set "pos=yes"
|
|
|
|
|
endlocal & set "OSP_TMPVAL=%pos%"
|
|
|
|
|
exit /b 0
|
|
|
|
|
:trim
|
|
|
|
|
@set %2=%1
|
|
|
|
|
@exit /b 0
|
|
|
|
|
:post_env
|
|
|
|
|
if /i not "%1"=="add" set "OSP_ACTIVE_ENV=%2" & set "OSP_ACTIVE_ENV_VAL=:%2:"
|
|
|
|
|
if /i "%1"=="add" set "OSP_ACTIVE_ENV=%OSP_ACTIVE_ENV% + %2" & set "OSP_ACTIVE_ENV_VAL=%OSP_ACTIVE_ENV_VAL%:%2:"
|
2024-04-01 23:54:39 +00:00
|
|
|
|
set "OSP_TMP_NAME_2=" & set "OSP_TMPVAL="
|
|
|
|
|
if not "%OSP_MODULES_LIST%"=="" for %%a in (%OSP_MODULES_LIST%) do (
|
|
|
|
|
if /i "%%a"=="%2" set "OSP_TMP_NAME_2=%%a"
|
|
|
|
|
)
|
|
|
|
|
if defined OSP_TMP_NAME_2 call :strfind "%OSP_MODULES_LIST_%" ":%OSP_TMP_NAME_2%:"
|
|
|
|
|
set "OSP_TMP_NAME_2="
|
|
|
|
|
if defined OSP_TMPVAL if not exist "{root_dir}\temp\%2.lock" echo: & echo %ESC%[93m{lang_warning}: %2 {lang_not_enabled}%ESC%[0m
|
2024-04-01 00:17:40 +00:00
|
|
|
|
if /i not "%1"=="shell" if /i not "%3"=="silent" echo: & echo {lang_current_env}: %ESC%[36m%OSP_ACTIVE_ENV%%ESC%[0m
|
2024-01-25 19:33:10 +00:00
|
|
|
|
if /i not "%1"=="shell" TITLE %OSP_ACTIVE_ENV% ^| Open Server Panel
|
|
|
|
|
@exit /b 0
|
|
|
|
|
:: -----------------------------------------------------------------------------------
|
|
|
|
|
:: EXIT
|
|
|
|
|
:: -----------------------------------------------------------------------------------
|
|
|
|
|
:before_exit
|
|
|
|
|
@if defined OSP_CODEPAGE @chcp %OSP_CODEPAGE% > nul
|
|
|
|
|
@if defined OSP_ECHO_STATE @echo %OSP_ECHO_STATE%
|
|
|
|
|
@set "OSP_CODEPAGE="
|
|
|
|
|
@set "OSP_MODULES_LIST="
|
|
|
|
|
@set "OSP_MODULES_LIST_="
|
2024-04-01 12:36:18 +00:00
|
|
|
|
@set "OSP_ADDONS_LIST="
|
|
|
|
|
@set "OSP_ADDONS_LIST_="
|
2024-01-25 19:33:10 +00:00
|
|
|
|
@set "OSP_ECHO_STATE="
|
2024-04-07 21:08:42 +00:00
|
|
|
|
@set "OSP_PROG_LIST="
|
2024-01-25 19:33:10 +00:00
|
|
|
|
@set "OSP_ERR_MSG="
|
|
|
|
|
@set "OSP_TMPVAL="
|
|
|
|
|
@set "OSP_TMP_NAME="
|
|
|
|
|
@exit /b 0
|
|
|
|
|
:notrunning
|
|
|
|
|
@echo:
|
|
|
|
|
@echo %ESC%[91m{lang_error}
|
2024-04-14 07:04:47 +00:00
|
|
|
|
@echo ────────────────────────────────────────────────────
|
2024-01-25 19:33:10 +00:00
|
|
|
|
@echo {lang_command}: osp %1 %2 %3
|
|
|
|
|
@echo {lang_message}: {lang_err_failed_exec_command}
|
|
|
|
|
@echo {lang_reason}: {lang_err_osp_must_be_started}%ESC%[0m
|
|
|
|
|
@if defined OSP_CODEPAGE @chcp %OSP_CODEPAGE% > nul
|
|
|
|
|
@set "OSP_CODEPAGE="
|
|
|
|
|
@exit /b 1
|
|
|
|
|
:end
|
|
|
|
|
@call :before_exit
|
|
|
|
|
@exit /b 0
|
|
|
|
|
:echo_error
|
|
|
|
|
@echo:
|
|
|
|
|
@echo %ESC%[91m{lang_error}
|
2024-04-14 07:04:47 +00:00
|
|
|
|
@echo ────────────────────────────────────────────────────
|
2024-01-25 19:33:10 +00:00
|
|
|
|
@echo {lang_command}: osp %1 %2 %3
|
|
|
|
|
@echo {lang_message}: {lang_err_failed_exec_command}%ESC%[0m
|
|
|
|
|
@exit /b 1
|
|
|
|
|
:error
|
|
|
|
|
@echo:
|
|
|
|
|
@echo %ESC%[91m{lang_error}
|
2024-04-14 07:04:47 +00:00
|
|
|
|
@echo ────────────────────────────────────────────────────
|
2024-01-25 19:33:10 +00:00
|
|
|
|
@echo {lang_command}: osp %1 %2 %3
|
|
|
|
|
@if not defined OSP_ERR_MSG @echo {lang_message}: {lang_err_failed_exec_command}%ESC%[0m
|
|
|
|
|
@if defined OSP_ERR_MSG @echo {lang_message}: {lang_err_failed_exec_command}
|
|
|
|
|
@if defined OSP_ERR_MSG @echo {lang_reason}: %OSP_ERR_MSG%%ESC%[0m
|
|
|
|
|
@call :before_exit
|
|
|
|
|
@exit /b 1
|