Skip to content

Commit

Permalink
[Feature-#5258][Bin] Add .bat script for all shell script. (#5445)
Browse files Browse the repository at this point in the history
  • Loading branch information
FlechazoW authored Sep 11, 2023
1 parent 8a3f261 commit ee4040b
Show file tree
Hide file tree
Showing 12 changed files with 626 additions and 2 deletions.
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -48,4 +48,5 @@ test.conf
spark-warehouse
*.flattened-pom.xml

seatunnel-examples
seatunnel-examples
/lib/*
60 changes: 60 additions & 0 deletions bin/install-plugin.cmd
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
@echo off
REM Licensed to the Apache Software Foundation (ASF) under one or more
REM contributor license agreements. See the NOTICE file distributed with
REM this work for additional information regarding copyright ownership.
REM The ASF licenses this file to You under the Apache License, Version 2.0
REM (the "License"); you may not use this file except in compliance with
REM the License. You may obtain a copy of the License at
REM
REM http://www.apache.org/licenses/LICENSE-2.0
REM
REM Unless required by applicable law or agreed to in writing, software
REM distributed under the License is distributed on an "AS IS" BASIS,
REM WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
REM See the License for the specific language governing permissions and
REM limitations under the License.

REM This script is used to download the connector plug-ins required during the running process.
REM All are downloaded by default. You can also choose what you need.
REM You only need to configure the plug-in name in config\plugin_config.txt.

REM Get seatunnel home
set "SEATUNNEL_HOME=%~dp0..\"
echo Set SEATUNNEL_HOME to [%SEATUNNEL_HOME%]

REM Connector default version is 2.3.3, you can also choose a custom version. eg: 2.1.2: install-plugin.bat 2.1.2
set "version=2.3.3"
if not "%~1"=="" set "version=%~1"
echo Install hadoop shade jar, usage version is %version%

REM Create the lib directory
if not exist "%SEATUNNEL_HOME%\lib" (
mkdir "%SEATUNNEL_HOME%\lib"
echo create lib directory
)

call "%SEATUNNEL_HOME%\mvnw.cmd" dependency:get -DgroupId="org.apache.seatunnel" -Dclassifier="optional" -DartifactId="seatunnel-hadoop3-3.1.4-uber" -Dversion="%version%" -Ddest="%SEATUNNEL_HOME%\lib"

echo Install SeaTunnel connectors plugins, usage version is %version%

REM Create the connectors directory
if not exist "%SEATUNNEL_HOME%\connectors" (
mkdir "%SEATUNNEL_HOME%\connectors"
echo create connectors directory
)

REM Create the seatunnel connectors directory (for v2)
if not exist "%SEATUNNEL_HOME%\connectors\seatunnel" (
mkdir "%SEATUNNEL_HOME%\connectors\seatunnel"
echo create seatunnel connectors directory
)

for /f "usebackq delims=" %%a in ("%SEATUNNEL_HOME%\config\plugin_config") do (
set "line=%%a"
setlocal enabledelayedexpansion
if "!line:~0,1!" neq "-" if "!line:~0,1!" neq "#" (
echo install connector : !line!
call "%SEATUNNEL_HOME%\mvnw.cmd" dependency:get -DgroupId="org.apache.seatunnel" -DartifactId="!line!" -Dversion="%version%" -Ddest="%SEATUNNEL_HOME%\connectors\seatunnel"
)
endlocal
)
21 changes: 21 additions & 0 deletions config/seatunnel-env.cmd
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
@echo off
REM Licensed to the Apache Software Foundation (ASF) under one or more
REM contributor license agreements. See the NOTICE file distributed with
REM this work for additional information regarding copyright ownership.
REM The ASF licenses this file to You under the Apache License, Version 2.0
REM (the "License"); you may not use this file except in compliance with
REM the License. You may obtain a copy of the License at
REM
REM http://www.apache.org/licenses/LICENSE-2.0
REM
REM Unless required by applicable law or agreed to in writing, software
REM distributed under the License is distributed on an "AS IS" BASIS,
REM WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
REM See the License for the specific language governing permissions and
REM limitations under the License.

REM Home directory of spark distribution.
if "%SPARK_HOME%" == "" set "SPARK_HOME=C:\Program Files\spark"

REM Home directory of flink distribution.
if "%FLINK_HOME%" == "" set "FLINK_HOME=C:\Program Files\flink"
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
@echo off
rem Licensed to the Apache Software Foundation (ASF) under one or more
rem contributor license agreements. See the NOTICE file distributed with
rem this work for additional information regarding copyright ownership.
rem The ASF licenses this file to You under the Apache License, Version 2.0
rem (the "License"); you may not use this file except in compliance with
rem the License. You may obtain a copy of the License at
rem
rem http://www.apache.org/licenses/LICENSE-2.0
rem
rem Unless required by applicable law or agreed to in writing, software
rem distributed under the License is distributed on an "AS IS" BASIS,
rem WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
rem See the License for the specific language governing permissions and
rem limitations under the License.

setlocal enabledelayedexpansion

rem resolve links - %0 may be a softlink
set "PRG=%~f0"
:resolve_loop
rem Get the parent directory of the script
set "PRG_DIR=%~dp0"
rem Change current drive and directory to %PRG_DIR% and execute the 'dir' command, which will fail if %PRG% is not a valid file.
cd /d "%PRG_DIR%" || (
echo Cannot determine the script's current directory.
exit /b 1
)

set "APP_DIR=%~dp0"
set "CONF_DIR=%APP_DIR%\config"
set "APP_JAR=%APP_DIR%\starter\seatunnel-flink-13-starter.jar"
set "APP_MAIN=org.apache.seatunnel.core.starter.flink.FlinkStarter"

if exist "%CONF_DIR%\seatunnel-env.cmd" (
call "%CONF_DIR%\seatunnel-env.cmd"
)

if "%~1"=="" (
set "args=-h"
) else (
set "args=%*"
)

set "JAVA_OPTS="
rem Log4j2 Config
if exist "%CONF_DIR%\log4j2.properties" (
set "JAVA_OPTS=!JAVA_OPTS! -Dlog4j2.configurationFile=%CONF_DIR%\log4j2.properties"
set "JAVA_OPTS=!JAVA_OPTS! -Dseatunnel.logs.path=%APP_DIR%\logs"
set "JAVA_OPTS=!JAVA_OPTS! -Dseatunnel.logs.file_name=seatunnel-flink-starter"
)

set "CLASS_PATH=%APP_DIR%\starter\logging\*;%APP_JAR%"

for /f "delims=" %%i in ('java %JAVA_OPTS% -cp %CLASS_PATH% %APP_MAIN% %args%') do (
set "CMD=%%i"
setlocal disabledelayedexpansion
if !errorlevel! equ 234 (
echo !CMD!
endlocal
exit /b 0
) else if !errorlevel! equ 0 (
echo Execute SeaTunnel Flink Job: !CMD!
endlocal
call !CMD!
) else (
echo !CMD!
endlocal
exit /b !errorlevel!
)
)
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
@echo off
rem Licensed to the Apache Software Foundation (ASF) under one or more
rem contributor license agreements. See the NOTICE file distributed with
rem this work for additional information regarding copyright ownership.
rem The ASF licenses this file to You under the Apache License, Version 2.0
rem (the "License"); you may not use this file except in compliance with
rem the License. You may obtain a copy of the License at
rem
rem http://www.apache.org/licenses/LICENSE-2.0
rem
rem Unless required by applicable law or agreed to in writing, software
rem distributed under the License is distributed on an "AS IS" BASIS,
rem WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
rem See the License for the specific language governing permissions and
rem limitations under the License.

setlocal enabledelayedexpansion

rem resolve links - %0 may be a softlink
set "PRG=%~f0"
:resolve_loop
rem Get the parent directory of the script
set "PRG_DIR=%~dp0"
rem Change current drive and directory to %PRG_DIR% and execute the 'dir' command, which will fail if %PRG% is not a valid file.
cd /d "%PRG_DIR%" || (
echo Cannot determine the script's current directory.
exit /b 1
)

set "APP_DIR=%~dp0"
set "CONF_DIR=%APP_DIR%\config"
set "APP_JAR=%APP_DIR%\starter\seatunnel-flink-15-starter.jar"
set "APP_MAIN=org.apache.seatunnel.core.starter.flink.FlinkStarter"

if exist "%CONF_DIR%\seatunnel-env.cmd" (
call "%CONF_DIR%\seatunnel-env.cmd"
)

if "%~1"=="" (
set "args=-h"
) else (
set "args=%*"
)

set "JAVA_OPTS="
rem Log4j2 Config
if exist "%CONF_DIR%\log4j2.properties" (
set "JAVA_OPTS=!JAVA_OPTS! -Dlog4j2.configurationFile=%CONF_DIR%\log4j2.properties"
set "JAVA_OPTS=!JAVA_OPTS! -Dseatunnel.logs.path=%APP_DIR%\logs"
set "JAVA_OPTS=!JAVA_OPTS! -Dseatunnel.logs.file_name=seatunnel-flink-starter"
)

set "CLASS_PATH=%APP_DIR%\starter\logging\*;%APP_JAR%"

for /f "delims=" %%i in ('java %JAVA_OPTS% -cp %CLASS_PATH% %APP_MAIN% %args%') do (
set "CMD=%%i"
setlocal disabledelayedexpansion
if !errorlevel! equ 234 (
echo !CMD!
endlocal
exit /b 0
) else if !errorlevel! equ 0 (
echo Execute SeaTunnel Flink Job: !CMD!
endlocal
call !CMD!
) else (
echo !CMD!
endlocal
exit /b !errorlevel!
)
)
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
@echo off
rem Licensed to the Apache Software Foundation (ASF) under one or more
rem contributor license agreements. See the NOTICE file distributed with
rem this work for additional information regarding copyright ownership.
rem The ASF licenses this file to You under the Apache License, Version 2.0
rem (the "License"); you may not use this file except in compliance with
rem the License. You may obtain a copy of the License at
rem
rem http://www.apache.org/licenses/LICENSE-2.0
rem
rem Unless required by applicable law or agreed to in writing, software
rem distributed under the License is distributed on an "AS IS" BASIS,
rem WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
rem See the License for the specific language governing permissions and
rem limitations under the License.

setlocal enabledelayedexpansion

rem resolve links - %0 may be a softlink
set "PRG=%~f0"
:resolve_loop
rem Get the parent directory of the script
set "PRG_DIR=%~dp0"
rem Change current drive and directory to %PRG_DIR% and execute the 'dir' command, which will fail if %PRG% is not a valid file.
cd /d "%PRG_DIR%" || (
echo Cannot determine the script's current directory.
exit /b 1
)

set "APP_DIR=%~dp0"
set "CONF_DIR=%APP_DIR%\config"
set "APP_JAR=%APP_DIR%\starter\seatunnel-spark-2-starter.jar"
set "APP_MAIN=org.apache.seatunnel.core.starter.spark.SparkStarter"

if exist "%CONF_DIR%\seatunnel-env.cmd" (
call "%CONF_DIR%\seatunnel-env.cmd"
)

if "%~1"=="" (
set "args=-h"
) else (
set "args=%*"
)

set "JAVA_OPTS="
rem Log4j2 Config
if exist "%CONF_DIR%\log4j2.properties" (
set "JAVA_OPTS=!JAVA_OPTS! -Dlog4j2.configurationFile=%CONF_DIR%\log4j2.properties"
set "JAVA_OPTS=!JAVA_OPTS! -Dseatunnel.logs.path=%APP_DIR%\logs"
set "JAVA_OPTS=!JAVA_OPTS! -Dseatunnel.logs.file_name=seatunnel-spark-starter"
)

set "CLASS_PATH=%APP_DIR%\starter\logging\*;%APP_JAR%"

for /f "delims=" %%i in ('java %JAVA_OPTS% -cp %CLASS_PATH% %APP_MAIN% %args%') do (
set "CMD=%%i"
setlocal disabledelayedexpansion
if !errorlevel! equ 234 (
echo !CMD!
endlocal
exit /b 0
) else if !errorlevel! equ 0 (
echo Execute SeaTunnel Spark Job: !CMD!
endlocal
call !CMD!
) else (
echo !CMD!
endlocal
exit /b !errorlevel!
)
)
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
@echo off
rem Licensed to the Apache Software Foundation (ASF) under one or more
rem contributor license agreements. See the NOTICE file distributed with
rem this work for additional information regarding copyright ownership.
rem The ASF licenses this file to You under the Apache License, Version 2.0
rem (the "License"); you may not use this file except in compliance with
rem the License. You may obtain a copy of the License at
rem
rem http://www.apache.org/licenses/LICENSE-2.0
rem
rem Unless required by applicable law or agreed to in writing, software
rem distributed under the License is distributed on an "AS IS" BASIS,
rem WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
rem See the License for the specific language governing permissions and
rem limitations under the License.

setlocal enabledelayedexpansion

rem resolve links - %0 may be a softlink
set "PRG=%~f0"
:resolve_loop
rem Get the parent directory of the script
set "PRG_DIR=%~dp0"
rem Change current drive and directory to %PRG_DIR% and execute the 'dir' command, which will fail if %PRG% is not a valid file.
cd /d "%PRG_DIR%" || (
echo Cannot determine the script's current directory.
exit /b 1
)

set "APP_DIR=%~dp0"
set "CONF_DIR=%APP_DIR%\config"
set "APP_JAR=%APP_DIR%\starter\seatunnel-spark-3-starter.jar"
set "APP_MAIN=org.apache.seatunnel.core.starter.spark.SparkStarter"

if exist "%CONF_DIR%\seatunnel-env.cmd" (
call "%CONF_DIR%\seatunnel-env.cmd"
)

if "%~1"=="" (
set "args=-h"
) else (
set "args=%*"
)

set "JAVA_OPTS="
rem Log4j2 Config
if exist "%CONF_DIR%\log4j2.properties" (
set "JAVA_OPTS=!JAVA_OPTS! -Dlog4j2.configurationFile=%CONF_DIR%\log4j2.properties"
set "JAVA_OPTS=!JAVA_OPTS! -Dseatunnel.logs.path=%APP_DIR%\logs"
set "JAVA_OPTS=!JAVA_OPTS! -Dseatunnel.logs.file_name=seatunnel-spark-starter"
)

set "CLASS_PATH=%APP_DIR%\starter\logging\*;%APP_JAR%"

for /f "delims=" %%i in ('java %JAVA_OPTS% -cp %CLASS_PATH% %APP_MAIN% %args%') do (
set "CMD=%%i"
setlocal disabledelayedexpansion
if !errorlevel! equ 234 (
echo !CMD!
endlocal
exit /b 0
) else if !errorlevel! equ 0 (
echo Execute SeaTunnel Spark Job: !CMD!
endlocal
call !CMD!
) else (
echo !CMD!
endlocal
exit /b !errorlevel!
)
)
Loading

0 comments on commit ee4040b

Please sign in to comment.