diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..8b25c8a --- /dev/null +++ b/.gitignore @@ -0,0 +1 @@ +/jre diff --git a/README.md b/README.md index 9d2f3e5..9b65638 100644 --- a/README.md +++ b/README.md @@ -1,30 +1,12 @@ -# Java Service Wrapper +# Java Service Wrapper For Single ## 项目介绍 -java service wrapper 3.5.40 +java service wrapper 3.5.43 > - support windows x86-32 and x86-64 > - support linux x86-32 and x86-64 > - include apr-1.7.0, apr-util-1.6.1, crypto-1.1, expat-1.6.0, ssl-1.1, z-1.2.11, tcnative-1.2.23 -## 编译说明 - -### build for wrapper-single: - - - `cd ./wrapper` - - `cp ./conf/wrapper.single.temp ./conf/wrapper.conf` - - `cp ./conf/wrapper-property.single.temp ./conf/wrapper-property.conf` - - `cp ./conf/wrapper-additional.single.temp ./conf/wrapper-additional.conf` - - `rm -rf ./conf/*.temp` - -### build for wrapper-tomcat: - - - `cd ./wrapper` - - `cp ./conf/wrapper.tomcat.temp ./conf/wrapper.conf` - - `cp ./conf/wrapper-property.tomcat.temp ./conf/wrapper-property.conf` - - `cp ./conf/wrapper-additional.tomcat.temp ./conf/wrapper-additional.conf` - - `rm -rf ./conf/*.temp` - ## 安装说明 ### install for windows: @@ -51,5 +33,6 @@ java service wrapper 3.5.40 - conf/wrapper-property.conf这个文件里设置服务名称 - conf/wrapper-additional.conf这个文件里设置内存、端口、其他-D参数 + - conf/wrapper-additional.conf这个文件里的参数如果包含空格,需要使用双引号引起来 - \#号是注释 - 配置文件里不能有中文字符,编辑的时候建议用notepad++ diff --git a/bin/keytool.bat b/bin/keytool.bat new file mode 100644 index 0000000..472cc62 --- /dev/null +++ b/bin/keytool.bat @@ -0,0 +1,440 @@ +@echo off + +rem ====================================================================================== +rem set window properties +rem buffer size : 9999*150=0x270f0096 +rem window size : 40*150=0x00280096 +set CONSOLE_CURR="HKCU\Console\%%SystemRoot%%_system32_cmd.exe" +reg add %CONSOLE_CURR% /t REG_SZ /v "FaceName" /d "Lucida Console" /f 2>nul>nul +reg add %CONSOLE_CURR% /t REG_DWORD /v "FontSize" /d 0x00100008 /f 2>nul>nul +reg add %CONSOLE_CURR% /t REG_DWORD /v "ScreenBufferSize" /d 0x270f0096 /f 2>nul>nul +reg add %CONSOLE_CURR% /t REG_DWORD /v "ScreenColors" /d 0x0000000a /f 2>nul>nul +reg add %CONSOLE_CURR% /t REG_DWORD /v "WindowSize" /d 0x00280096 /f 2>nul>nul +rem ====================================================================================== + +cd /d %~dp0 +set "WORK_DIR=%CD%" +cd .. +set "BASE_DIR=%CD%" +cd %WORK_DIR% +SET PATH=.;%WORK_DIR%;%BASE_DIR%\jre\bin;%PATH% +rem echo %WORK_DIR% + +rem restart console +rem if not defined x (set x=0&start cmd /c %0&exit) + +setlocal EnableDelayedExpansion +setlocal EnableExtensions + +rem 版权信息 +set "PROG_NAME=keytool" +set "COPY_RIGHT=www.cdjdgm.com" + +rem 步骤计数 +set "step=1" + +rem 当前日期和时间 +set "DATE=%DATE: =0%" +set "YYYY=%DATE:~,4%" +set "MM=%DATE:~5,2%" +set "DD=%DATE:~8,2%" +set "YYYYMMDD=%YYYY%%MM%%DD%" +set "TIME=%TIME: =0%" +set "HH=%TIME:~0,2%" +set "MI=%TIME:~3,2%" +set "SS=%TIME:~6,2%" +set "HHMISS=%HH%%MI%%SS%" +set "YYYYMMDDHHMISS=%YYYY%-%MM%-%DD% %HH%:%MI%:%SS%" + +rem 命令行参数 +set arg_subcmd= +set arg_alias= +set arg_file= + +rem 设置标题 +title %PROG_NAME% ^| %COPY_RIGHT% + +rem 程序开始 +rem ====================================================================================== + +rem 打印基本信息 +echo. +rem echo start... +rem echo CopyRight %COPY_RIGHT% +rem echo current time : %YYYYMMDDHHMISS% +echo. + +rem 读取命令行参数 +call :read_parameters %* +rem 读取配置信息 +call :read_config +rem 执行命令 +call :execute_command + +rem echo end... +echo. +pause +rem pause>nul +goto :eof + +rem 程序结束 +rem ====================================================================================== + + +rem init,list,import,export,delete,alias,file +rem 读取命令行参数 +:read_parameters +rem echo [Step %step%]: read command line parameters +rem set /a step+=1 + +rem no param +if "%1x" == "x" goto :no_param + +rem read param +:loop_read_param +if "%1x" == "x" goto :end_read_param +rem echo [%1] +if "%1x" == "--helpx" ( + if "!arg_subcmd!x" == "x" ( set "arg_subcmd=help" ) + shift + goto :loop_read_param +) +if "%1x" == "-helpx" ( + if "!arg_subcmd!x" == "x" ( set "arg_subcmd=help" ) + shift + goto :loop_read_param +) +if "%1x" == "--hx" ( + if "!arg_subcmd!x" == "x" ( set "arg_subcmd=help" ) + shift + goto :loop_read_param +) +if "%1x" == "-hx" ( + if "!arg_subcmd!x" == "x" ( set "arg_subcmd=help" ) + shift + goto :loop_read_param +) +if "%1x" == "--initx" ( + if "!arg_subcmd!x" == "x" ( set "arg_subcmd=init" ) + shift + goto :loop_read_param +) +if "%1x" == "-initx" ( + if "!arg_subcmd!x" == "x" ( set "arg_subcmd=init" ) + shift + goto :loop_read_param +) +if "%1x" == "--listx" ( + if "!arg_subcmd!x" == "x" ( set "arg_subcmd=list" ) + shift + goto :loop_read_param +) +if "%1x" == "-listx" ( + if "!arg_subcmd!x" == "x" ( set "arg_subcmd=list" ) + shift + goto :loop_read_param +) +if "%1x" == "--importx" ( + if "!arg_subcmd!x" == "x" ( set "arg_subcmd=import" ) + shift + goto :loop_read_param +) +if "%1x" == "-importx" ( + if "!arg_subcmd!x" == "x" ( set "arg_subcmd=import" ) + shift + goto :loop_read_param +) +if "%1x" == "--exportx" ( + if "!arg_subcmd!x" == "x" ( set "arg_subcmd=export" ) + shift + goto :loop_read_param +) +if "%1x" == "-exportx" ( + if "!arg_subcmd!x" == "x" ( set "arg_subcmd=export" ) + shift + goto :loop_read_param +) +if "%1x" == "--deletex" ( + if "!arg_subcmd!x" == "x" ( set "arg_subcmd=delete" ) + shift + goto :loop_read_param +) +if "%1x" == "-deletex" ( + if "!arg_subcmd!x" == "x" ( set "arg_subcmd=delete" ) + shift + goto :loop_read_param +) +if "%1x" == "--aliasx" ( + if "!arg_alias!x" == "x" ( set "arg_alias=%~2" ) + shift + shift + goto :loop_read_param +) +if "%1x" == "-aliasx" ( + if "!arg_alias!x" == "x" ( set "arg_alias=%~2" ) + shift + shift + goto :loop_read_param +) +if "%1x" == "--filex" ( + if "!arg_file!x" == "x" ( set "arg_file=%~2" ) + shift + shift + goto :loop_read_param +) +if "%1x" == "-filex" ( + if "!arg_file!x" == "x" ( set "arg_file=%~2" ) + shift + shift + goto :loop_read_param +) +echo [unsupport command : %1] +shift +goto :loop_read_param +:end_read_param + +rem echo arg_subcmd=%arg_subcmd% +rem echo arg_alias=%arg_alias% +rem echo arg_file=%arg_file% +rem echo. +goto :eof + +:no_param +rem echo. +goto :eof + +rem read config info from keytool.env +:read_config +rem echo [Step %step%]: read config info from keytool.env +rem set /a step+=1 +if exist "%WORK_DIR%\keytool.env" ( + for /f "eol=# delims=" %%i in ('type "%WORK_DIR%\keytool.env"^| find /i "="') do ( + set _temp=%%i + rem set !_temp! + rem echo !_temp! + for /f "tokens=1,* delims==" %%a in ("!_temp!") do ( + set "key=%%~a" + set "value=%%~b" + rem echo key=!key!,value=!value! + if "!value!x" neq "x" ( + set "!key!=!value:/=\!" + rem echo !key!=!value:/=\! + ) else ( + set "!key!=" + ) + ) + ) +) else ( + echo %WORK_DIR%\keytool.env does not exist. + echo please make sure keytool.env exists. + goto :eof +) +rem echo. +goto :eof + +rem call command +:execute_command +if [%arg_subcmd%]==[] ( + call :show_menu +) else if [%arg_subcmd%]==[help] ( + call :show_help +) else if [%arg_subcmd%]==[init] ( + call :execute_init_command +) else if [%arg_subcmd%]==[list] ( + call :execute_list_command +) else if [%arg_subcmd%]==[import] ( + call :execute_import_command +) else if [%arg_subcmd%]==[export] ( + call :execute_export_command +) else if [%arg_subcmd%]==[delete] ( + call :execute_delete_command +) +if not errorlevel 1 goto :eof +echo. +goto :eof + +rem show menu +:show_menu +cls +echo. +echo Enter the number 1-5 to execute the command +echo================================================== +echo. +echo [1] : Initialize Cacerts +echo [2] : List Certs +echo [3] : Import Certs +echo [4] : Export Certs +echo [5] : Delete Certs +echo. +echo [q] : Exit Menu +echo. +echo================================================== +echo. +set /p menu_input=enter the number : +if "%menu_input%x" equ "1x" call :execute_init_command +if "%menu_input%x" equ "2x" call :execute_list_command +if "%menu_input%x" equ "3x" call :execute_import_command +if "%menu_input%x" equ "4x" call :execute_export_command +if "%menu_input%x" equ "5x" call :execute_delete_command +if "%menu_input%x" equ "qx" goto :eof +set "menu_input=" +set "step=1" +pause +goto show_menu + +echo. +goto :eof + +rem show help +:show_help +echo [Step %step%]: show help info +set /a step+=1 + +echo keytool.bat [--init] ^| [--list] ^| [--import] ^| [--export] ^| [--delete] ^| [--alias test] ^| [--file xxx.crt] +echo --init execute init command. +echo. +echo --list execute list command. +echo --alias test +echo. +echo --import execute import command. +echo --alias test +echo --file xxx.crt +echo. +echo --export execute export command. +echo --alias test +echo --file xxx.crt +echo. +echo --delete execute delete command. +echo --alias test + +echo. +goto :eof + +rem execute init command +:execute_init_command +echo [Step %step%]: execute init command +set /a step+=1 + +echo copy %BASE_DIR%\jre\lib\security\cacerts to %BASE_DIR%\%trustfile% +echo f | xcopy "%BASE_DIR%\jre\lib\security\cacerts" "%BASE_DIR%\%trustfile%" /s/e/i/y +echo change storepasswd to %newstorepass% +"%BASE_DIR%\jre\bin\keytool" -storepasswd -v -keystore "%BASE_DIR%\%trustfile%" -storepass "%oldstorepass%" -new "%newstorepass%" +echo successfully executed init command. + +echo. +goto :eof + +rem execute list command +:execute_list_command +echo [Step %step%]: execute list command +set /a step+=1 + +if "%arg_alias%x" == "x" ( + echo list all entries in the keystore + "%BASE_DIR%\jre\bin\keytool" -list -keystore "%BASE_DIR%\%trustfile%" -storepass "%newstorepass%" + echo successfully executed list command. +) else ( + echo list the specified entries in the keystore : [%arg_alias%] + "%BASE_DIR%\jre\bin\keytool" -list -v -keystore "%BASE_DIR%\%trustfile%" -alias "%arg_alias%" -storepass "%newstorepass%" + echo successfully executed list command. +) + +echo. +goto :eof + +rem execute import command +:execute_import_command +echo [Step %step%]: execute import command +set /a step+=1 + +if "%arg_alias%x" == "x" ( + if "%arg_file%x" == "x" ( + rem import certificate from %BASE_DIR%\%certspath% + echo import certificate from %BASE_DIR%\%certspath%\*.crt + for /f "delims=" %%a in ('dir /b "%BASE_DIR%\%certspath%" ^| findstr .crt') do ( + rem echo %%a + set file=%%a + set alias=!file:~0,-4! + rem echo !alias! + rem echo !file! + rem echo check if alias [!alias!] exists + rem "%BASE_DIR%\jre\bin\keytool" -list -keystore "%BASE_DIR%\%trustfile%" -alias "!alias!" -storepass "%newstorepass%" + echo delete alias [!alias!]... + "%BASE_DIR%\jre\bin\keytool" -delete -keystore "%BASE_DIR%\%trustfile%" -alias "!alias!" -storepass "%newstorepass%" + echo import certificate, alias : [!alias!], file : [!file!] + "%BASE_DIR%\jre\bin\keytool" -importcert -noprompt -keystore "%BASE_DIR%\%trustfile%" -alias "!alias!" -file "%BASE_DIR%\%certspath%\!file!" -storepass "%newstorepass%" + ) + echo import certificate from %BASE_DIR%\%certspath%\*.cer + for /f "delims=" %%a in ('dir /b "%BASE_DIR%\%certspath%" ^| findstr .cer') do ( + rem echo %%a + set file=%%a + set alias=!file:~0,-4! + rem echo !alias! + rem echo !file! + rem echo check if alias [!alias!] exists + rem "%BASE_DIR%\jre\bin\keytool" -list -keystore "%BASE_DIR%\%trustfile%" -alias "!alias!" -storepass "%newstorepass%" + echo delete alias [!alias!]... + "%BASE_DIR%\jre\bin\keytool" -delete -keystore "%BASE_DIR%\%trustfile%" -alias "!alias!" -storepass "%newstorepass%" + echo import certificate, alias : [!alias!], file : [!file!] + "%BASE_DIR%\jre\bin\keytool" -importcert -noprompt -keystore "%BASE_DIR%\%trustfile%" -alias "!alias!" -file "%BASE_DIR%\%certspath%\!file!" -storepass "%newstorepass%" + ) + echo successfully executed import command. + ) else ( + echo alias cannot be empty + ) +) else ( + if "%arg_file%x" == "x" ( + echo file cannot be empty + ) else ( + if not exist "%arg_file%" ( + echo the file [%arg_file%] does not exist + ) else ( + echo import certificate, alias : [%arg_alias%], file : [%arg_file%] + "%BASE_DIR%\jre\bin\keytool" -importcert -noprompt -keystore "%BASE_DIR%\%trustfile%" -alias "%arg_alias%" -file "%arg_file%" -storepass "%newstorepass%" + echo successfully executed import command. + ) + ) +) + +echo. +goto :eof + +rem execute export command +:execute_export_command +echo [Step %step%]: execute export command +set /a step+=1 + +if "%arg_alias%x" == "x" ( + echo alias cannot be empty + goto :eof +) +if "%arg_file%x" == "x" ( + echo file cannot be empty + goto :eof +) +if exist "%arg_file%" ( + echo the file [%arg_file%] already exists + goto :eof +) +echo export certificate, alias : [%arg_alias%], file : [%arg_file%] +"%BASE_DIR%\jre\bin\keytool" -exportcert -rfc -keystore "%BASE_DIR%\%trustfile%" -alias "%arg_alias%" -file "%arg_file%" -storepass "%newstorepass%" +echo successfully executed export command. + +echo. +goto :eof + +rem execute delete command +:execute_delete_command +echo [Step %step%]: execute delete command +set /a step+=1 + +if "%arg_alias%x" == "x" ( + echo alias cannot be empty + goto :eof +) +echo delete certificate, alias : [%arg_alias%] +"%BASE_DIR%\jre\bin\keytool" -delete -v -keystore "%BASE_DIR%\%trustfile%" -alias "%arg_alias%" -storepass "%newstorepass%" +echo successfully executed delete command. + +echo. +goto :eof diff --git a/bin/keytool.env b/bin/keytool.env new file mode 100644 index 0000000..b950814 --- /dev/null +++ b/bin/keytool.env @@ -0,0 +1,5 @@ +# keytool.env +trustfile="conf/certs/.truststore" +certspath="conf/certs" +oldstorepass="changeit" +newstorepass="123456" diff --git a/bin/keytool.sh b/bin/keytool.sh new file mode 100644 index 0000000..ad0e970 --- /dev/null +++ b/bin/keytool.sh @@ -0,0 +1,420 @@ +#!/bin/bash + +########################################################################## +# keytool.sh +# for centos 7.x +# author : yong.ran@cdjdgm.com +########################################################################## + +# local variable +keytoolcmd="jre/bin/keytool" #keytoolcmd +step=1 + +set -e +set -o noglob + +# save old work path +pwd_old=`pwd` + +# set author info +date1=`date "+%Y-%m-%d %H:%M:%S"` +date2=`date "+%Y%m%d%H%M%S"` +author="yong.ran@cdjdgm.com" + +# init font and color +if [ "${TERM}" == "xterm" ]; then + bold=$(tput bold); underline=$(tput sgr 0 1); reset=$(tput sgr0); + red=$(tput setaf 1); green=$(tput setaf 2); yellow=$(tput setaf 3); blue=$(tput setaf 4); white=$(tput setaf 7); +else + bold=""; underline=""; reset=""; + red=""; green=""; yellow=""; blue=""; white=""; +fi + +# header and logging +header() { printf "\n${underline}${bold}${blue}■ %s${reset}\n" "$@"; } +header2() { printf "\n${underline}${bold}${blue}❏ %s${reset}\n" "$@"; } +header3() { printf "\n${underline}${bold}${blue}❏ %s${reset}\n" "$@"; } +info() { printf "${white}➜ %s${reset}\n" "$@"; } +warn() { printf "${yellow}➜ %s${reset}\n" "$@"; } +error() { printf "${red}✖ %s${reset}\n" "$@"; } +success() { printf "${green}✔ %s${reset}\n" "$@"; } +usage() { printf "\n${underline}${bold}${blue}Usage:${reset} ${blue}%s${reset}\n" "$@"; } +timestamp() { printf "➜ current time : $(date +%Y-%m-%d' '%H:%M:%S.%N | cut -b 1-23)\n"; } + +# get real path +getRealPath() { if [[ "$1" =~ ^\/.* ]]; then temp_path="$1"; else temp_path="${pwd_old}/$1"; fi; printf "$(readlink -f ${temp_path})"; } + +# trap signal +trap "error '******* ERROR: Something went wrong.*******'; exit 1" sigterm +trap "error '******* Caught sigint signal. Stopping...*******'; exit 2" sigint + +set +o noglob + +# entry base dir +base_name=`basename $0 .sh` +base_dir="${pwd_old}" +source_name="$0" +while [ -h "${source_name}" ]; do + base_dir="$( cd -P "$( dirname "${source_name}" )" && pwd )" + source_name="$(readlink "${source_name}")" + [[ ${source_name} != /* ]] && source_name="${base_dir}/${source_name}" +done +base_dir="$( cd -P "$( dirname "${source_name}" )" && pwd )" +cd "${base_dir}" + +# envirionment + +# args flag +arg_subcmd= +arg_alias= +arg_file= + +# 解析参数 +# echo $@ +# 定义选项, -o 表示短选项 -a 表示支持长选项的简单模式(以 - 开头) -l 表示长选项 +# a 后没有冒号,表示没有参数 +# b 后跟一个冒号,表示有一个必要参数 +# c 后跟两个冒号,表示有一个可选参数(可选参数必须紧贴选项) +# -n 出错时的信息 +# -- 也是一个选项,比如 要创建一个名字为 -f 的目录,会使用 mkdir -- -f , +# 在这里用做表示最后一个选项(用以判定 while 的结束) +# $@ 从命令行取出参数列表(不能用用 $* 代替,因为 $* 将所有的参数解释成一个字符串 +# 而 $@ 是一个参数数组) +# args=`getopt -o ab:c:: -a -l apple,banana:,cherry:: -n "${source_name}" -- "$@"` +args=`getopt -o h -a -l help,init,list,import,export,delete,alias:,file: -n "${source_name}" -- "$@"` +# 判定 getopt 的执行时候有错,错误信息输出到 STDERR +if [ $? != 0 ]; then + error "Terminating..." >&2 + exit 1 +fi + +# show start time +timestamp; + +# show parameter options +header "[Step ${step}]: show parameter options."; let step+=1 + +# echo ${args} +# 重新排列参数的顺序 +# 使用eval 的目的是为了防止参数中有shell命令,被错误的扩展。 +eval set -- "${args}" +# 处理具体的选项 +while true +do + case "$1" in + -h | --help | -help) + info "option -h|--help" + arg_subcmd=help + shift + ;; + --init | -init) + info "option --init" + arg_subcmd=init + shift + ;; + --list | -list) + info "option --list" + arg_subcmd=list + shift + ;; + --import | -import) + info "option --import" + arg_subcmd=import + shift + ;; + --export | -export) + info "option --export" + arg_subcmd=export + shift + ;; + --delete | -delete) + info "option --delete" + arg_subcmd=delete + shift + ;; + --alias | -alias) + info "option --alias argument : $2" + arg_alias=$2 + shift 2 + ;; + --file | -file) + info "option --file argument : $2" + arg_file=$(getRealPath "$2") + shift 2 + ;; + --) + shift + break + ;; + *) + error "Internal error!" + exit 1 + ;; + esac +done +#显示除选项外的参数(不包含选项的参数都会排到最后) +# arg 是 getopt 内置的变量 , 里面的值,就是处理过之后的 $@(命令行传入的参数) +for arg do + warn "$arg"; +done + +# define usage +usage=$"`basename $0` [-h|--help] [--init] [--list] [--import] [--export] [--delete] [--alias=xxx] [--file=xxx.crt] + [-h|--help]................show help info. + [--init]...................execute init command. + [--list]...................execute list command. + [--import].................execute import command. + [--export].................execute export command. + [--delete].................execute delete command. + [--alias=xxx]..............alias of the entry. + [--file=xxx.crt]...........the name of the certificate. +" + +# show usage +fun_show_usage() { + usage "$usage"; + exit 1 +} + +########################################################################## + +# read environment variables from .env file +fun_read_envfile() { + header "[Step ${step}]: read environment variables from ${base_name}.env file."; let step+=1 + while read line; + do + # echo ${line}; + trim=$(echo ${line} | sed 's/^[ ]*//g' | sed 's/[ ]*$//g') + if [ "x$trim" == "x" ]; then + # ignore empty line + continue; + fi + rem=$(echo ${trim:0:1}) + if [ "x$rem" == "x#" ]; then + # ignore rem line + continue; + fi + key=$(echo ${trim%%=*} | sed 's/^[ ]*//g' | sed 's/[ ]*$//g') + value=$(echo ${trim#*=} | sed 's/^[ ]*//g' | sed 's/[ ]*$//g') + last=$(echo ${key##*_}) + if [ "x$last" == "xPASS" ]; then + info "${key}=***" + else + info "${key}=${value}" + fi + eval "${key}=${value}" + done < "${base_dir}/${base_name}.env" + success "successfully readed environment variables." + return 0 +} + +# execute init command +fun_execute_init_command() { + header "[Step ${step}]: execute init command."; let step+=1 + set +e + + info "copy ${base_dir}/../jre/lib/security/cacerts to ${base_dir}/../${trustfile}" + \cp -rf "${base_dir}/../jre/lib/security/cacerts" "${base_dir}/../${trustfile}" + info "change storepasswd to ${newstorepass}" + "${base_dir}"/../${keytoolcmd} -storepasswd -v -keystore "${base_dir}/../${trustfile}" -storepass "${oldstorepass}" -new "${newstorepass}" + + success "successfully executed init command." + set -e + return 0 +} + +# execute list command +fun_execute_list_command() { + header "[Step ${step}]: execute list command."; let step+=1 + set +e + + if [ "x${arg_alias}" == "x" ]; then + info "list all entries in the keystore" + "${base_dir}"/../${keytoolcmd} -list -keystore "${base_dir}/../${trustfile}" -storepass "${newstorepass}" + ret=$? + if [ ${ret} == 0 ]; then + success "successfully executed list command." + else + error "failed to execute list command." + fi + else + info "list the specified entries in the keystore : [${arg_alias}]" + "${base_dir}"/../${keytoolcmd} -list -v -keystore "${base_dir}/../${trustfile}" -alias "${arg_alias}" -storepass "${newstorepass}" + ret=$? + if [ ${ret} == 0 ]; then + success "successfully executed list command." + else + error "failed to execute list command." + fi + fi + + set -e + return 0 +} + +# execute import command +fun_execute_import_command() { + header "[Step ${step}]: execute import command."; let step+=1 + set +e + + if [ "x${arg_alias}" == "x" -a "x${arg_file}" == "x" ]; then + # import certificate from ${base_dir}/../${certspath} + info "import certificate from ${base_dir}/../${certspath}" + i=0 + for file in $(find "${base_dir}/../${certspath}" -name "*.crt" -o -name "*.cer"); do + _file="${file##*/}" + alias="${_file%.*}" + #suffix="${_file##*.}" + # list + info "check if alias [${alias}] exists" + "${base_dir}"/../${keytoolcmd} -list -keystore "${base_dir}/../${trustfile}" -alias "${alias}" -storepass "${newstorepass}" + ret1=$? + if [ ${ret1} == 0 ]; then + info "alias [${alias}] already exists." + echo "" + # delete + info "delete alias [${alias}]..." + "${base_dir}"/../${keytoolcmd} -delete -keystore "${base_dir}/../${trustfile}" -alias "${alias}" -storepass "${newstorepass}" + ret2=$? + if [ ${ret2} == 0 ]; then + info "successfully deleted alias [${alias}]." + else + info "failed to delete alias [${alias}]." + fi + else + info "alias [${alias}] does not exist." + fi + echo "" + # import + info "import certificate, alias : [${alias}], file : [${file}]" + "${base_dir}"/../${keytoolcmd} -importcert -noprompt -keystore "${base_dir}/../${trustfile}" -alias "${alias}" -file "${file}" -storepass "${newstorepass}" + ret3=$? + if [ ${ret3} == 0 ]; then + info "successfully deleted alias [${alias}]." + else + info "failed to delete alias [${alias}]." + fi + echo "" + done + success "successfully executed import command." + set -e + return 0 + else + # import certificate from specified file + info "import certificate from specified file" + if [ "x${arg_alias}" == "x" ]; then + error "alias cannot be empty" + usage "$usage" + set -e + return 1 + fi + if [ "x${arg_file}" == "x" ]; then + error "file cannot be empty" + usage "$usage" + set -e + return 1 + fi + if [ ! -f "${arg_file}" ]; then + error "the file [${arg_file}] does not exist" + usage "$usage" + set -e + return 1 + fi + info "import certificate, alias : [${arg_alias}], file : [${arg_file}]" + "${base_dir}"/../${keytoolcmd} -importcert -noprompt -keystore "${base_dir}/../${trustfile}" -alias "${arg_alias}" -file "${arg_file}" -storepass "${newstorepass}" + success "successfully executed import command." + set -e + return 0 + fi +} + +# execute export command +fun_execute_export_command() { + header "[Step ${step}]: execute export command."; let step+=1 + set +e + + if [ "x${arg_alias}" == "x" -o "x${arg_file}" == "x" ]; then + error "alias and file cannot be empty" + usage "$usage" + return 1 + fi + if [ -f "${arg_file}" ]; then + error "the file [${arg_file}] already exists" + usage "$usage" + return 1 + fi + info "export certificate, alias : [${arg_alias}], file : [${arg_file}]" + "${base_dir}"/../${keytoolcmd} -exportcert -rfc -keystore "${base_dir}/../${trustfile}" -alias "${arg_alias}" -file "${arg_file}" -storepass "${newstorepass}" + + success "successfully executed export command." + set -e + return 0 +} + +# execute delete command +fun_execute_delete_command() { + header "[Step ${step}]: execute delete command."; let step+=1 + set +e + + if [ "x${arg_alias}" == "x" ]; then + error "alias cannot be empty" + usage "$usage" + return 1 + fi + info "delete certificate, alias : [${arg_alias}]" + "${base_dir}"/../${keytoolcmd} -delete -v -keystore "${base_dir}/../${trustfile}" -alias "${arg_alias}" -storepass "${newstorepass}" + + success "successfully executed delete command." + set -e + return 0 +} + +########################################################################## + +# execute subcommand +case "${arg_subcmd}" in + help) + # show usage + fun_show_usage + ;; + init) + # read environment variables from .env file + fun_read_envfile; + # execute init command + fun_execute_init_command; + ;; + list) + # read environment variables from .env file + fun_read_envfile; + # execute list command + fun_execute_list_command; + ;; + import) + # read environment variables from .env file + fun_read_envfile; + # execute import command + fun_execute_import_command; + ;; + export) + # read environment variables from .env file + fun_read_envfile; + # execute export command + fun_execute_export_command; + ;; + delete) + # read environment variables from .env file + fun_read_envfile; + # execute delete command + fun_execute_delete_command; + ;; + *) + # show usage + fun_show_usage + ;; +esac + +# show end time +timestamp; +echo "" + +exit $? diff --git a/bin/wrapper-3.5.41.jar b/bin/wrapper-3.5.43.jar similarity index 56% rename from bin/wrapper-3.5.41.jar rename to bin/wrapper-3.5.43.jar index 5207f28..1af8444 100644 Binary files a/bin/wrapper-3.5.41.jar and b/bin/wrapper-3.5.43.jar differ diff --git a/bin/wrapper-console-start.sh b/bin/wrapper-console-start.sh index ef6e247..543ae14 100644 --- a/bin/wrapper-console-start.sh +++ b/bin/wrapper-console-start.sh @@ -17,7 +17,7 @@ base_dir="$( cd -P "$( dirname "$source" )" && pwd )" cd "${base_dir}" if [ -x "${base_dir}/wrapper-create-linkfile.sh" ]; then - "${base_dir}/wrapper-create-linkfile.sh" + "${base_dir}/wrapper-create-linkfile.sh" >/dev/null 2>&1 fi if [ -x "${base_dir}/wrapper.sh" ]; then diff --git a/bin/wrapper-linux-x86-32 b/bin/wrapper-linux-x86-32 index 7aa0852..979d13f 100644 Binary files a/bin/wrapper-linux-x86-32 and b/bin/wrapper-linux-x86-32 differ diff --git a/bin/wrapper-linux-x86-64 b/bin/wrapper-linux-x86-64 index b9e3152..c74248a 100644 Binary files a/bin/wrapper-linux-x86-64 and b/bin/wrapper-linux-x86-64 differ diff --git a/bin/wrapper-service-install.sh b/bin/wrapper-service-install.sh index 1265287..22b1b0d 100644 --- a/bin/wrapper-service-install.sh +++ b/bin/wrapper-service-install.sh @@ -17,7 +17,7 @@ base_dir="$( cd -P "$( dirname "$source" )" && pwd )" cd "${base_dir}" if [ -x "${base_dir}/wrapper-create-linkfile.sh" ]; then - "${base_dir}/wrapper-create-linkfile.sh" + "${base_dir}/wrapper-create-linkfile.sh" >/dev/null 2>&1 fi if [ -x "${base_dir}/wrapper.sh" ]; then diff --git a/bin/wrapper-service-start.sh b/bin/wrapper-service-start.sh index 595e8bd..e7280cc 100644 --- a/bin/wrapper-service-start.sh +++ b/bin/wrapper-service-start.sh @@ -17,7 +17,7 @@ base_dir="$( cd -P "$( dirname "$source" )" && pwd )" cd "${base_dir}" if [ -x "${base_dir}/wrapper-create-linkfile.sh" ]; then - "${base_dir}/wrapper-create-linkfile.sh" + "${base_dir}/wrapper-create-linkfile.sh" >/dev/null 2>&1 fi if [ -x "${base_dir}/wrapper.sh" ]; then diff --git a/bin/wrapper-service-stop.sh b/bin/wrapper-service-stop.sh index 16b9b38..804a574 100644 --- a/bin/wrapper-service-stop.sh +++ b/bin/wrapper-service-stop.sh @@ -17,7 +17,7 @@ base_dir="$( cd -P "$( dirname "$source" )" && pwd )" cd "${base_dir}" if [ -x "${base_dir}/wrapper-create-linkfile.sh" ]; then - "${base_dir}/wrapper-create-linkfile.sh" + "${base_dir}/wrapper-create-linkfile.sh" >/dev/null 2>&1 fi if [ -x "${base_dir}/wrapper.sh" ]; then diff --git a/bin/wrapper-service-uninstall.sh b/bin/wrapper-service-uninstall.sh index 1922a87..1c639d5 100644 --- a/bin/wrapper-service-uninstall.sh +++ b/bin/wrapper-service-uninstall.sh @@ -17,7 +17,7 @@ base_dir="$( cd -P "$( dirname "$source" )" && pwd )" cd "${base_dir}" if [ -x "${base_dir}/wrapper-create-linkfile.sh" ]; then - "${base_dir}/wrapper-create-linkfile.sh" + "${base_dir}/wrapper-create-linkfile.sh" >/dev/null 2>&1 fi if [ -x "${base_dir}/wrapper.sh" ]; then diff --git a/bin/wrapper-windows-x86-32.exe b/bin/wrapper-windows-x86-32.exe index 8526200..e32a292 100644 Binary files a/bin/wrapper-windows-x86-32.exe and b/bin/wrapper-windows-x86-32.exe differ diff --git a/bin/wrapper-windows-x86-64.exe b/bin/wrapper-windows-x86-64.exe index 95289cc..ec3c9b2 100644 Binary files a/bin/wrapper-windows-x86-64.exe and b/bin/wrapper-windows-x86-64.exe differ diff --git a/bin/wrapper.bat b/bin/wrapper.bat index ed0d2c1..ff89021 100644 --- a/bin/wrapper.bat +++ b/bin/wrapper.bat @@ -23,7 +23,7 @@ rem echo RUN_AS_USER=%RUN_AS_USER% rem ####################################################################################### rem -rem Copyright (c) 1999, 2019 Tanuki Software, Ltd. +rem Copyright (c) 1999, 2020 Tanuki Software, Ltd. rem http://www.tanukisoftware.com rem All rights reserved. rem @@ -37,7 +37,7 @@ rem rem ----------------------------------------------------------------------------- rem These settings can be modified to fit the needs of your application -rem Optimized for use with version 3.5.41 of the Wrapper. +rem Optimized for use with version 3.5.43 of the Wrapper. rem The base name for the Wrapper binary. set _WRAPPER_BASE=wrapper diff --git a/bin/wrapper.sh b/bin/wrapper.sh index b3ece43..1581fa1 100644 --- a/bin/wrapper.sh +++ b/bin/wrapper.sh @@ -31,7 +31,7 @@ fi ####################################################################################### # -# Copyright (c) 1999, 2019 Tanuki Software, Ltd. +# Copyright (c) 1999, 2020 Tanuki Software, Ltd. # http://www.tanukisoftware.com # All rights reserved. # @@ -42,11 +42,11 @@ fi # # Java Service Wrapper sh script. Suitable for starting and stopping # wrapped Java applications on UNIX platforms. +# Optimized for use with version 3.5.43 of the Wrapper. # #----------------------------------------------------------------------------- # These settings can be modified to fit the needs of your application -# Optimized for use with version 3.5.41 of the Wrapper. # IMPORTANT - Please always stop and uninstall an application before making # any changes to this file. Failure to do so could remove the @@ -255,23 +255,59 @@ gettext() { fi } -resolveIdLocation() { - if [ "X$ID_BIN" = "X" ] ; then - # On Solaris, the version in /usr/xpg4/bin should be used. - ID_BIN="/usr/xpg4/bin/id" - if [ ! -x "$ID_BIN" ] ; then - ID_BIN="id" - result=`command -v id 2>/dev/null` - if [ $? -ne 0 ] ; then - ID_BIN="/usr/bin/id" - if [ ! -x "$ID_BIN" ] ; then - eval echo `gettext 'Unable to locate "id".'` - eval echo `gettext 'Please report this message along with the location of the command on your system.'` - exit 1 +## +# Resolves the location of a system command. +# +# $1: the name of the variable to set (without the $) +# $2: the name of the command +# $3: an ordered and semicolon-separated list of paths where the command should +# be searched. The list should contain an empty value for the command to be +# searched using the PATH environment variable. +# $4: 1 to be strict (the script will stop with an error), 0 otherwise. +resolveLocation() { + eval "CMD_TEMP=\$$1" + if [ "X$CMD_TEMP" = "X" ] ; then + found=0 + + OIFS=$IFS + IFS=';' + for CMD_PATH in $3 + do + if [ -z "$CMD_PATH" ] ; then + # empty path + CMD_TEMP="$2" + ret=`command -v $CMD_TEMP 2>/dev/null` + if [ $? -eq 0 ] ; then + found=1 + break + fi + else + CMD_TEMP="${CMD_PATH}/$2" + if [ -x "$CMD_TEMP" ] ; then + found=1 + break fi fi + done + IFS=$OIFS + + if [ $found -eq 1 ] ; then + eval "$1=$CMD_TEMP" + elif [ $4 -eq 1 ] ; then + eval echo `gettext 'Unable to locate "$2".'` + eval echo `gettext 'Please report this message along with the location of the command on your system.'` + exit 1 + else + # return the error + return 1 fi fi + return 0 +} + +resolveIdLocation() { + # On Solaris, the version in /usr/xpg4/bin should be used in priority. + resolveLocation ID_BIN id "/usr/xpg4/bin/id;;/usr/bin/id" 1 } resolveCurrentUser() { @@ -281,24 +317,6 @@ resolveCurrentUser() { fi } -resolvePidofLocation() { - if [ "X$PIDOF_BIN" = "X" ] ; then - PIDOF_BIN="pidof" - result=`command -v pidof 2>/dev/null` - if [ $? -ne 0 ] ; then - PIDOF_BIN="/bin/pidof" - if [ ! -x "$PIDOF_BIN" ] ; then - PIDOF_BIN="/usr/sbin/pidof" - if [ ! -x "$PIDOF_BIN" ] ; then - eval echo `gettext 'Unable to locate "pidof".'` - eval echo `gettext 'Please report this message along with the location of the command on your system.'` - exit 1 - fi - fi - fi - fi -} - # check if we are running under Cygwin terminal. # Note: on some OS's (for example Solaris, MacOS), -o is not a valid parameter # and it shows an error message. We redirect stderr to null so the error message @@ -514,34 +532,10 @@ LOCKDIR="/var/lock/subsys" LOCKFILE="$LOCKDIR/$APP_NAME" pid="" -# Resolve the location of the 'ps' command -PS_BIN="/usr/ucb/ps" -if [ ! -x "$PS_BIN" ] -then - PS_BIN="/usr/bin/ps" - if [ ! -x "$PS_BIN" ] - then - PS_BIN="/bin/ps" - if [ ! -x "$PS_BIN" ] - then - eval echo `gettext 'Unable to locate "ps".'` - eval echo `gettext 'Please report this message along with the location of the command on your system.'` - exit 1 - fi - fi -fi +# Resolve the location of the 'ps' & 'tr' command +resolveLocation PS_BIN ps "/usr/ucb;/usr/bin;/bin" 1 +resolveLocation TR_BIN tr "/usr/bin;/bin" 1 -TR_BIN="/usr/bin/tr" -if [ ! -x "$TR_BIN" ] -then - TR_BIN="/bin/tr" - if [ ! -x "$TR_BIN" ] - then - eval echo `gettext 'Unable to locate "tr".'` - eval echo `gettext 'Please report this message along with the location of the command on your system.'` - exit 1 - fi -fi # Resolve the os DIST_OS=`uname -s | $TR_BIN "[A-Z]" "[a-z]" | $TR_BIN -d ' '` case "$DIST_OS" in @@ -552,7 +546,7 @@ case "$DIST_OS" in # HP-UX needs the XPG4 version of ps (for -o args) DIST_OS="hpux" UNIX95="" - export UNIX95 + export UNIX95 ;; 'darwin') DIST_OS="macosx" @@ -564,23 +558,7 @@ case "$DIST_OS" in DIST_OS="zos" ;; 'linux') - if [ -f /etc/fedora-release -o -f /etc/redhat-release -o -f /etc/redhat_version ] ; then - if [ "X`command -v /sbin/chkconfig`" != "X" ] ; then - DIST_LINUX_FAMILY="Red Hat" - fi - elif [ -f /etc/SuSE-release ] ; then - if [ "X`command -v insserv`" != "X" ] ; then - DIST_LINUX_FAMILY="SUSE" - fi - elif [ -f /etc/lsb-release -o -f /etc/debian_version -o -f /etc/debian_release ] ; then - if [ "X`command -v update-rc.d`" != "X" ] ; then - DIST_LINUX_FAMILY="Debian" - fi - fi - DIST_LINUX_NAME=`grep "^NAME=" /etc/os-release 2>/dev/null | cut -d= -f 2 | sed 's/\"//g'` - if [ "$DIST_LINUX_NAME" = "Amazon Linux" ] && [ "X`command -v /sbin/chkconfig`" != "X" ] ; then - DIST_LINUX_FAMILY="Red Hat" - fi + DIST_OS="linux" ;; esac @@ -1374,7 +1352,7 @@ launchinternal() { if [ "X$pid" = "X" ] then # The string passed to eval must handles spaces in paths correctly. - COMMAND_LINE="$CMDNICE \"$WRAPPER_CMD\" \"$WRAPPER_CONF\" wrapper.syslog.ident=\"$APP_NAME\" wrapper.pidfile=\"$PIDFILE\" wrapper.daemonize=TRUE $APPNAMEPROP $ANCHORPROP $IGNOREPROP $STATUSPROP $COMMANDPROP $LOCKPROP wrapper.script.version=3.5.41 $ADDITIONAL_PARA" + COMMAND_LINE="$CMDNICE \"$WRAPPER_CMD\" \"$WRAPPER_CONF\" wrapper.syslog.ident=\"$APP_NAME\" wrapper.pidfile=\"$PIDFILE\" wrapper.daemonize=TRUE $APPNAMEPROP $ANCHORPROP $IGNOREPROP $STATUSPROP $COMMANDPROP $LOCKPROP wrapper.script.version=3.5.43 $ADDITIONAL_PARA" eval $COMMAND_LINE else eval echo `gettext '$APP_LONG_NAME is already running.'` @@ -1397,7 +1375,7 @@ console() { prepAdditionalParams "$@" # The string passed to eval must handles spaces in paths correctly. - COMMAND_LINE="$CMDNICE \"$WRAPPER_CMD\" \"$WRAPPER_CONF\" wrapper.syslog.ident=\"$APP_NAME\" wrapper.pidfile=\"$PIDFILE\" $APPNAMEPROP $ANCHORPROP $STATUSPROP $COMMANDPROP $LOCKPROP wrapper.script.version=3.5.41 $ADDITIONAL_PARA" + COMMAND_LINE="$CMDNICE \"$WRAPPER_CMD\" \"$WRAPPER_CONF\" wrapper.syslog.ident=\"$APP_NAME\" wrapper.pidfile=\"$PIDFILE\" $APPNAMEPROP $ANCHORPROP $STATUSPROP $COMMANDPROP $LOCKPROP wrapper.script.version=3.5.43 $ADDITIONAL_PARA" eval $COMMAND_LINE COMMAND_EXIT_CODE=$? if [ $COMMAND_EXIT_CODE -ne 0 ] ; then @@ -1597,7 +1575,7 @@ upstartInstall() { return 1 fi - eval echo `gettext ' Installing the $APP_LONG_NAME daemon using upstart...'` + eval echo `gettext ' Installing the $APP_LONG_NAME daemon with upstart...'` if [ -f "${REALDIR}/${APP_NAME}.install" ] ; then eval echo `gettext ' a custom upstart conf file ${APP_NAME}.install found'` cp "${REALDIR}/${APP_NAME}.install" "/etc/init/${APP_NAME}.conf" @@ -1655,7 +1633,7 @@ upstartRestart() { upstartRemove() { stopit "0" - eval echo `gettext ' Removing $APP_LONG_NAME daemon from upstart...'` + eval echo `gettext ' Removing the $APP_LONG_NAME daemon from upstart...'` rm "/etc/init/${APP_NAME}.conf" } @@ -1666,7 +1644,7 @@ systemdDetection() { return 1 fi - resolvePidofLocation + resolveLocation PIDOF_BIN pidof ";/bin;/usr/sbin" 1 result=`$PIDOF_BIN systemd` return $? } @@ -1679,7 +1657,7 @@ systemdInstall() { return 1 fi - eval echo `gettext ' Installing the $APP_LONG_NAME daemon using systemd...'` + eval echo `gettext ' Installing the $APP_LONG_NAME daemon with systemd...'` if [ -f "${REALDIR}/${APP_NAME}.service" ] ; then eval echo `gettext ' a custom service file ${APP_NAME}.service found'` cp "${REALDIR}/${APP_NAME}.service" "${SYSTEMD_SERVICE_FILE}" @@ -1735,7 +1713,7 @@ systemdStart() { systemctl start $APP_NAME if [ $? -ne 0 ] ; then - eval echo `gettext 'Failed to start service $APP_NAME'` + eval echo `gettext 'Failed to start $APP_LONG_NAME.'` exit 1 fi @@ -1751,7 +1729,7 @@ systemdStop() { systemctl stop $APP_NAME if [ $? -ne 0 ] ; then - eval echo `gettext 'Failed to stop service $APP_NAME'` + eval echo `gettext 'Failed to stop $APP_LONG_NAME.'` exit 1 fi } @@ -1773,7 +1751,7 @@ systemdRestart() { systemdRemove() { stopit "0" - eval echo `gettext ' Removing $APP_LONG_NAME daemon from systemd...'` + eval echo `gettext ' Removing the $APP_LONG_NAME daemon from systemd...'` systemctl disable $APP_NAME rm "/etc/systemd/system/${APP_NAME}.service" systemctl daemon-reload @@ -1819,7 +1797,7 @@ srcStart() { startsrc -s "${APP_NAME}" if [ $? -ne 0 ] ; then - eval echo `gettext 'Failed to start service $APP_NAME'` + eval echo `gettext 'Failed to start $APP_LONG_NAME.'` exit 1 fi @@ -1835,7 +1813,7 @@ srcStop() { stopsrc -s "${APP_NAME}" if [ $? -ne 0 ] ; then - eval echo `gettext 'Failed to stop service $APP_NAME'` + eval echo `gettext 'Failed to stop $APP_LONG_NAME.'` exit 1 fi } @@ -1861,7 +1839,7 @@ start() { prepAdditionalParams "$@" # The string passed to eval must handles spaces in paths correctly. - COMMAND_LINE="$CMDNICE \"$WRAPPER_CMD\" \"$WRAPPER_CONF\" wrapper.syslog.ident=\"$APP_NAME\" wrapper.pidfile=\"$PIDFILE\" wrapper.daemonize=TRUE $APPNAMEPROP $ANCHORPROP $IGNOREPROP $STATUSPROP $COMMANDPROP $LOCKPROP wrapper.script.version=3.5.41 $ADDITIONAL_PARA" + COMMAND_LINE="$CMDNICE \"$WRAPPER_CMD\" \"$WRAPPER_CONF\" wrapper.syslog.ident=\"$APP_NAME\" wrapper.pidfile=\"$PIDFILE\" wrapper.daemonize=TRUE $APPNAMEPROP $ANCHORPROP $IGNOREPROP $STATUSPROP $COMMANDPROP $LOCKPROP wrapper.script.version=3.5.43 $ADDITIONAL_PARA" eval $COMMAND_LINE startwait @@ -2012,67 +1990,24 @@ checkInstalled() { installedStatus=$SERVICE_INSTALLED_DEFAULT fi elif [ "$DIST_OS" = "linux" ] ; then - case "$DIST_LINUX_FAMILY" in - 'Red Hat') - if [ "X$1" != "Xstrict" -o \( -z "$USE_SYSTEMD" -a -z "$USE_UPSTART" \) ] ; then - if [ -f "/etc/init.d/$APP_NAME" -o -L "/etc/init.d/$APP_NAME" ] ; then - installedStatus=$SERVICE_INSTALLED_DEFAULT - installedWith="init.d" - fi - fi - if [ "X$1" != "Xstrict" -o -n "$USE_SYSTEMD" ] ; then - if [ -f "${SYSTEMD_SERVICE_FILE}" ] ; then - installedStatus=`expr $installedStatus + $SERVICE_INSTALLED_SYSTEMD` - installedWith="${installedWith}${installedWith:+, }systemd" - fi - fi - if [ "X$1" != "Xstrict" -o -n "$USE_UPSTART" ] ; then - if [ -f "/etc/init/${APP_NAME}.conf" ] ; then - installedStatus=`expr $installedStatus + $SERVICE_INSTALLED_UPSTART` - installedWith="${installedWith}${installedWith:+, }upstart" - fi - fi - ;; - 'SUSE') - if [ "X$1" != "Xstrict" -o \( -z "$USE_SYSTEMD" -a -z "$USE_UPSTART" \) ] ; then - if [ -f "/etc/init.d/$APP_NAME" -o -L "/etc/init.d/$APP_NAME" ] ; then - installedStatus=$SERVICE_INSTALLED_DEFAULT - installedWith="init.d" - fi - fi - if [ "X$1" != "Xstrict" -o -n "$USE_SYSTEMD" ] ; then - if [ -f "${SYSTEMD_SERVICE_FILE}" ] ; then - installedStatus=`expr $installedStatus + $SERVICE_INSTALLED_SYSTEMD` - installedWith="${installedWith}${installedWith:+, }systemd" - fi - fi - ;; - 'Debian') - if [ "X$1" != "Xstrict" -o \( -z "$USE_SYSTEMD" -a -z "$USE_UPSTART" \) ] ; then - if [ -f "/etc/init.d/$APP_NAME" -o -L "/etc/init.d/$APP_NAME" ] ; then - installedStatus=$SERVICE_INSTALLED_DEFAULT - installedWith="init.d" - fi - fi - if [ "X$1" != "Xstrict" -o -n "$USE_SYSTEMD" ] ; then - if [ -f "${SYSTEMD_SERVICE_FILE}" ] ; then - installedStatus=`expr $installedStatus + $SERVICE_INSTALLED_SYSTEMD` - installedWith="${installedWith}${installedWith:+, }systemd" - fi - fi - if [ "X$1" != "Xstrict" -o -n "$USE_UPSTART" ] ; then - if [ -f "/etc/init/${APP_NAME}.conf" ] ; then - installedStatus=`expr $installedStatus + $SERVICE_INSTALLED_UPSTART` - installedWith="${installedWith}${installedWith:+, }upstart" - fi - fi - ;; - *) + if [ "X$1" != "Xstrict" -o \( -z "$USE_SYSTEMD" -a -z "$USE_UPSTART" \) ] ; then if [ -f "/etc/init.d/$APP_NAME" -o -L "/etc/init.d/$APP_NAME" ] ; then installedStatus=$SERVICE_INSTALLED_DEFAULT + installedWith="init.d" fi - ;; - esac + fi + if [ "X$1" != "Xstrict" -o -n "$USE_SYSTEMD" ] ; then + if [ -f "${SYSTEMD_SERVICE_FILE}" ] ; then + installedStatus=`expr $installedStatus + $SERVICE_INSTALLED_SYSTEMD` + installedWith="${installedWith}${installedWith:+, }systemd" + fi + fi + if [ "X$1" != "Xstrict" -o -n "$USE_UPSTART" ] ; then + if [ -f "/etc/init/${APP_NAME}.conf" ] ; then + installedStatus=`expr $installedStatus + $SERVICE_INSTALLED_UPSTART` + installedWith="${installedWith}${installedWith:+, }upstart" + fi + fi elif [ "$DIST_OS" = "hpux" ] ; then if [ -f "/sbin/init.d/$APP_NAME" -o -L "/sbin/init.d/$APP_NAME" ] ; then installedStatus=$SERVICE_INSTALLED_DEFAULT @@ -2166,11 +2101,30 @@ validateAppNameLength() { fi } -printDetectedDistro() { - if [ "X$DIST_LINUX_NAME" != "X" ] ; then - eval echo `gettext 'Detected $DIST_LINUX_NAME \($DIST_LINUX_FAMILY family\):'` +resolveInitdCommand() { + # NOTE: update-rc.d & chkconfig are the recommended interfaces for managing + # init scripts. insserv is a low level tool used by these interfaces. + # chkconfig was available on old versions Ubuntu, but update-rc.d is + # preferred. chkconfig is used on RHEL based Linux. + + # update-rc.d is used on distros such as Debian/Ubuntu + resolveLocation INITD_COMMAND "update-rc.d" ";/usr/sbin" 0 + if [ $? -eq 0 ] ; then + USE_UPDATE_RC=1 else - eval echo `gettext 'Detected $DIST_LINUX_FAMILY or one of its derivatives:'` + # chkconfig is used on distros such as RHEL or Amazon Linux + resolveLocation INITD_COMMAND chkconfig ";/sbin" 0 + if [ $? -eq 0 ] ; then + USE_CHKCONFIG=1 + else + # if neither chkconfig nor update-rc.d are present, try insserv + resolveLocation INITD_COMMAND insserv ";/sbin" 0 + if [ $? -eq 0 ] ; then + USE_INSSERV=1 + else + INITD_COMMAND="" + fi + fi fi } @@ -2194,54 +2148,30 @@ installdaemon() { ln -s "/etc/init.d/$APP_NAME" "/etc/rc3.d/S${APP_RUN_LEVEL_S}$APP_NAME_LOWER" fi elif [ "$DIST_OS" = "linux" ] ; then - case "$DIST_LINUX_FAMILY" in - 'Red Hat') - printDetectedDistro - if [ $installedStatus -ne $SERVICE_NOT_INSTALLED ] ; then - eval echo `gettext ' The $APP_LONG_NAME daemon is already installed with $installedWith.'` - elif [ -n "$USE_SYSTEMD" ] ; then - systemdInstall - elif [ -n "$USE_UPSTART" ] ; then - upstartInstall - else - eval echo `gettext ' Installing the $APP_LONG_NAME daemon...'` + eval echo `gettext 'Detected Linux:'` + if [ $installedStatus -ne $SERVICE_NOT_INSTALLED ] ; then + eval echo `gettext ' The $APP_LONG_NAME daemon is already installed with $installedWith.'` + elif [ -n "$USE_SYSTEMD" ] ; then + systemdInstall + elif [ -n "$USE_UPSTART" ] ; then + upstartInstall + else + resolveInitdCommand + if [ -n "$USE_CHKCONFIG" ] ; then + eval echo `gettext ' Installing the $APP_LONG_NAME daemon with init.d \($INITD_COMMAND\)...'` ln -s "$REALPATH" "/etc/init.d/$APP_NAME" - /sbin/chkconfig --add "$APP_NAME" - /sbin/chkconfig "$APP_NAME" on - fi - ;; - 'SUSE') - printDetectedDistro - if [ $installedStatus -ne $SERVICE_NOT_INSTALLED ] ; then - eval echo `gettext ' The $APP_LONG_NAME daemon is already installed with $installedWith.'` - elif [ -n "$USE_SYSTEMD" ] ; then - systemdInstall - else - eval echo `gettext ' Installing the $APP_LONG_NAME daemon...'` + $INITD_COMMAND --add "$APP_NAME" + $INITD_COMMAND "$APP_NAME" on + elif [ "$USE_INSSERV" ] ; then + eval echo `gettext ' Installing the $APP_LONG_NAME daemon with init.d \($INITD_COMMAND\)...'` ln -s "$REALPATH" "/etc/init.d/$APP_NAME" - insserv "/etc/init.d/$APP_NAME" - fi - ;; - 'Debian') - printDetectedDistro - if [ $installedStatus -ne $SERVICE_NOT_INSTALLED ] ; then - eval echo `gettext ' The $APP_LONG_NAME daemon is already installed with $installedWith.'` - elif [ -n "$USE_SYSTEMD" ] ; then - systemdInstall - elif [ -n "$USE_UPSTART" ] ; then - upstartInstall - else - eval echo `gettext ' Installing the $APP_LONG_NAME daemon using init.d...'` + $INITD_COMMAND "/etc/init.d/$APP_NAME" + elif [ "$USE_UPDATE_RC" ] ; then + eval echo `gettext ' Installing the $APP_LONG_NAME daemon with init.d \($INITD_COMMAND\)...'` ln -s "$REALPATH" "/etc/init.d/$APP_NAME" - update-rc.d "$APP_NAME" defaults - fi - ;; - *) - eval echo `gettext 'Detected Linux:'` - if [ $installedStatus -ne $SERVICE_NOT_INSTALLED ] ; then - eval echo `gettext ' The $APP_LONG_NAME daemon is already installed.'` + $INITD_COMMAND "$APP_NAME" defaults else - eval echo `gettext ' Installing the $APP_LONG_NAME daemon...'` + eval echo `gettext ' Installing the $APP_LONG_NAME daemon with init.d...'` ln -s "$REALPATH" /etc/init.d/$APP_NAME for i in `ls "/etc/rc3.d/K"??"$APP_NAME_LOWER" "/etc/rc5.d/K"??"$APP_NAME_LOWER" "/etc/rc3.d/S"??"$APP_NAME_LOWER" "/etc/rc5.d/S"??"$APP_NAME_LOWER" 2>/dev/null` ; do eval echo `gettext ' Removing unexpected file before proceeding: $i'` @@ -2252,8 +2182,7 @@ installdaemon() { ln -s "/etc/init.d/$APP_NAME" "/etc/rc5.d/S${APP_RUN_LEVEL_S}$APP_NAME_LOWER" ln -s "/etc/init.d/$APP_NAME" "/etc/rc5.d/K${APP_RUN_LEVEL_K}$APP_NAME_LOWER" fi - ;; - esac + fi elif [ "$DIST_OS" = "hpux" ] ; then eval echo `gettext 'Detected HP-UX:'` if [ $installedStatus -ne $SERVICE_NOT_INSTALLED ] ; then @@ -2467,7 +2396,7 @@ removedaemon() { isBitSet $installedStatus $SERVICE_INSTALLED_DEFAULT if [ $? -eq 1 ] ; then stopit "0" - eval echo `gettext ' Removing $APP_LONG_NAME daemon...'` + eval echo `gettext ' Removing the $APP_LONG_NAME daemon...'` for i in `ls "/etc/rc3.d/K"??"$APP_NAME_LOWER" "/etc/rc3.d/S"??"$APP_NAME_LOWER" "/etc/init.d/$APP_NAME" 2>/dev/null` ; do rm -f $i done @@ -2476,50 +2405,7 @@ removedaemon() { exit 1 fi elif [ "$DIST_OS" = "linux" ] ; then - case "$DIST_LINUX_FAMILY" in - 'Red Hat') - printDetectedDistro - isBitSet $installedStatus $SERVICE_INSTALLED_DEFAULT - if [ $? -eq 1 ] ; then - stopit "0" - eval echo `gettext ' Removing $APP_LONG_NAME daemon...'` - /sbin/chkconfig "$APP_NAME" off - /sbin/chkconfig --del "$APP_NAME" - rm -f "/etc/init.d/$APP_NAME" - fi - ;; - 'SUSE') - printDetectedDistro - isBitSet $installedStatus $SERVICE_INSTALLED_DEFAULT - if [ $? -eq 1 ] ; then - stopit "0" - eval echo `gettext ' Removing $APP_LONG_NAME daemon from init.d...'` - insserv -r "/etc/init.d/$APP_NAME" - rm -f "/etc/init.d/$APP_NAME" - fi - ;; - 'Debian') - printDetectedDistro - isBitSet $installedStatus $SERVICE_INSTALLED_DEFAULT - if [ $? -eq 1 ] ; then - stopit "0" - eval echo `gettext ' Removing $APP_LONG_NAME daemon from init.d...'` - update-rc.d -f "$APP_NAME" remove - rm -f "/etc/init.d/$APP_NAME" - fi - ;; - *) - eval echo `gettext 'Detected Linux:'` - isBitSet $installedStatus $SERVICE_INSTALLED_DEFAULT - if [ $? -eq 1 ] ; then - stopit "0" - eval echo `gettext ' Removing $APP_LONG_NAME daemon...'` - for i in `ls "/etc/rc3.d/K"??"$APP_NAME_LOWER" "/etc/rc5.d/K"??"$APP_NAME_LOWER" "/etc/rc3.d/S"??"$APP_NAME_LOWER" "/etc/rc5.d/S"??"$APP_NAME_LOWER" "/etc/init.d/$APP_NAME" 2>/dev/null` ; do - rm -f $i - done - fi - ;; - esac + eval echo `gettext 'Detected Linux:'` isBitSet $installedStatus $SERVICE_INSTALLED_SYSTEMD if [ $? -eq 1 ] ; then systemdRemove @@ -2528,6 +2414,27 @@ removedaemon() { if [ $? -eq 1 ] ; then upstartRemove fi + isBitSet $installedStatus $SERVICE_INSTALLED_DEFAULT + if [ $? -eq 1 ] ; then + stopit "0" + eval echo `gettext ' Removing the $APP_LONG_NAME daemon from init.d...'` + resolveInitdCommand + if [ -n "$USE_CHKCONFIG" ] ; then + $INITD_COMMAND "$APP_NAME" off + $INITD_COMMAND --del "$APP_NAME" + rm -f "/etc/init.d/$APP_NAME" + elif [ "$USE_INSSERV" ] ; then + $INITD_COMMAND -r "/etc/init.d/$APP_NAME" + rm -f "/etc/init.d/$APP_NAME" + elif [ "$USE_UPDATE_RC" ] ; then + $INITD_COMMAND -f "$APP_NAME" remove + rm -f "/etc/init.d/$APP_NAME" + else + for i in `ls "/etc/rc3.d/K"??"$APP_NAME_LOWER" "/etc/rc5.d/K"??"$APP_NAME_LOWER" "/etc/rc3.d/S"??"$APP_NAME_LOWER" "/etc/rc5.d/S"??"$APP_NAME_LOWER" "/etc/init.d/$APP_NAME" 2>/dev/null` ; do + rm -f $i + done + fi + fi if [ $installedStatus -eq $SERVICE_NOT_INSTALLED ] ; then eval echo `gettext ' The $APP_LONG_NAME daemon is not currently installed.'` exit 1 @@ -2537,7 +2444,7 @@ removedaemon() { isBitSet $installedStatus $SERVICE_INSTALLED_DEFAULT if [ $? -eq 1 ] ; then stopit "0" - eval echo `gettext ' Removing $APP_LONG_NAME daemon...'` + eval echo `gettext ' Removing the $APP_LONG_NAME daemon...'` for i in `ls "/sbin/rc3.d/K"??"$APP_NAME_LOWER" "/sbin/rc3.d/S"??"$APP_NAME_LOWER" "/sbin/init.d/$APP_NAME" 2>/dev/null` ; do rm -f $i done @@ -2549,7 +2456,7 @@ removedaemon() { eval echo `gettext 'Detected AIX:'` if [ $installedStatus -ne $SERVICE_NOT_INSTALLED ] ; then stopit "0" - eval echo `gettext ' Removing $APP_LONG_NAME daemon...'` + eval echo `gettext ' Removing the $APP_LONG_NAME daemon...'` isBitSet $installedStatus $SERVICE_INSTALLED_DEFAULT if [ $? -eq 1 ] ; then for i in `ls "/etc/rc.d/rc2.d/K"??"$APP_NAME_LOWER" "/etc/rc.d/rc2.d/S"??"$APP_NAME_LOWER" "/etc/rc.d/init.d/$APP_NAME" 2>/dev/null` ; do @@ -2573,7 +2480,7 @@ removedaemon() { eval echo `gettext 'Detected FreeBSD:'` if [ -f "/etc/rc.d/$APP_NAME" -o -L "/etc/rc.d/$APP_NAME" ] ; then stopit "0" - eval echo `gettext ' Removing $APP_LONG_NAME daemon...'` + eval echo `gettext ' Removing the $APP_LONG_NAME daemon...'` for i in "/etc/rc.d/$APP_NAME" do rm -f $i @@ -2587,7 +2494,7 @@ removedaemon() { eval echo `gettext 'Detected Mac OSX:'` if [ -f "/Library/LaunchDaemons/${APP_PLIST}" -o -L "/Library/LaunchDaemons/${APP_PLIST}" ] ; then stopit "0" - eval echo `gettext ' Removing $APP_LONG_NAME daemon...'` + eval echo `gettext ' Removing the $APP_LONG_NAME daemon...'` # Make sure the plist is installed LOADED_PLIST=`launchctl list | grep ${APP_PLIST_BASE}` if [ "X${LOADED_PLIST}" != "X" ] ; then @@ -2602,7 +2509,7 @@ removedaemon() { eval echo `gettext 'Detected z/OS:'` if [ -f /etc/rc.bak ] ; then stopit "0" - eval echo `gettext ' Removing $APP_LONG_NAME daemon...'` + eval echo `gettext ' Removing the $APP_LONG_NAME daemon...'` cp /etc/rc /etc/rc.bak sed "s/_BPX_JOBNAME=\'APP_NAME\'.*//g" /etc/rc.bak > /etc/rc rm /etc/rc.bak diff --git a/conf/certs/.keep b/conf/certs/.keep new file mode 100644 index 0000000..e69de29 diff --git a/conf/subconf/.keep b/conf/subconf/.keep new file mode 100644 index 0000000..e69de29 diff --git a/conf/wrapper-additional.default b/conf/wrapper-additional.conf similarity index 83% rename from conf/wrapper-additional.default rename to conf/wrapper-additional.conf index de9ad3f..4f9b0d6 100644 --- a/conf/wrapper-additional.default +++ b/conf/wrapper-additional.conf @@ -3,7 +3,6 @@ #******************************************************************** # Java Additional Parameters #******************************************************************** --javaagent:"%WRAPPER_BASE_DIR%/exporter/jmx_prometheus_javaagent-0.12.0.jar=9404:%WRAPPER_BASE_DIR%/exporter/jmx_exporter.yml" -server -showversion -XX:+PrintGCDetails @@ -15,9 +14,12 @@ -Xmx4096M -Xss1M -XX:MetaspaceSize=128M --XX:MaxMetaspaceSize=1024M +-XX:MaxMetaspaceSize=256M +-XX:MaxDirectMemorySize=4096M -Djava.security.egd=file:/dev/urandom -Djava.awt.headless=true +-Djava.net.preferIPv4Stack=true +-Djava.net.preferIPv6Addresses=false -Dfile.encoding=UTF-8 -Dsun.jnu.encoding=UTF-8 -Dsun.stdout.encoding=UTF-8 diff --git a/conf/wrapper-additional.tmpl b/conf/wrapper-additional.tmpl index b298067..acca822 100644 --- a/conf/wrapper-additional.tmpl +++ b/conf/wrapper-additional.tmpl @@ -3,58 +3,63 @@ #******************************************************************** # Java Additional Parameters #******************************************************************** -{{- if eq .JmxExporter.Enabled "true"}} --javaagent:"%WRAPPER_BASE_DIR%/exporter/jmx_prometheus_javaagent-0.12.0.jar={{.JmxExporter.Port}}:%WRAPPER_BASE_DIR%/exporter/jmx_exporter.yml" +{{- if eq .Jvm.JmxExporter.Enabled "true"}} +-javaagent:"%WRAPPER_BASE_DIR%/exporter/jmx_prometheus_javaagent-0.12.0.jar={{.Jvm.JmxExporter.Port}}:%WRAPPER_BASE_DIR%/exporter/jmx_exporter.yml" {{- end}} -server -showversion -{{- if eq .HeapDumpEnabled "true"}} +{{- if eq .Jvm.HeapDumpEnabled "true"}} -XX:+HeapDumpOnOutOfMemoryError -XX:HeapDumpPath=../temp/ {{- end}} -{{- if eq .PrintGcEnabled "true"}} +{{- if eq .Jvm.PrintGcEnabled "true"}} -XX:+PrintGCDetails -XX:+PrintGCDateStamps -XX:+PrintGCTimeStamps -XX:+PrintHeapAtGC {{- end}} -Xloggc:../logs/jvmgc.log --Xms{{.Xms}} --Xmx{{.Xmx}} --Xss{{.Xss}} --XX:MetaspaceSize={{.MetaspaceSize}} --XX:MaxMetaspaceSize={{.MaxMetaspaceSize}} -{{- if eq .RemoteDebug.Enabled "true"}} +-Xms{{.Jvm.Xms}} +-Xmx{{.Jvm.Xmx}} +-Xss{{.Jvm.Xss}} +-XX:MetaspaceSize={{.Jvm.MetaspaceSize}} +-XX:MaxMetaspaceSize={{.Jvm.MaxMetaspaceSize}} +-XX:MaxDirectMemorySize={{.Jvm.MaxDirectMemorySize}} +{{- if eq .Jvm.RemoteDebug.Enabled "true"}} -Xint -Xdebug -Xnoagent -Djava.compiler=NONE --Xrunjdwp:transport=dt_socket,server=y,suspend={{.RemoteDebug.Suspend}},address={{.RemoteDebug.Port}} +-Xrunjdwp:transport=dt_socket,server=y,suspend={{.Jvm.RemoteDebug.Suspend}},address={{.Jvm.RemoteDebug.Port}} {{- end}} -Djava.security.egd=file:/dev/urandom -Djava.awt.headless=true +-Djava.net.preferIPv4Stack=true +-Djava.net.preferIPv6Addresses=false -Dfile.encoding=UTF-8 -Dsun.jnu.encoding=UTF-8 -Dsun.stdout.encoding=UTF-8 -Dsun.stderr.encoding=UTF-8 -Duser.timezone=GMT+8 -{{- if eq .JmxRemote.Enabled "true"}} +{{- if eq .Jvm.JmxRemote.Enabled "true"}} -Dcom.sun.management.jmxremote --Dcom.sun.management.jmxremote.ssl={{.JmxRemote.Ssl}} +-Dcom.sun.management.jmxremote.ssl={{.Jvm.JmxRemote.Ssl}} -Dcom.sun.management.jmxremote.local.only=false --Dcom.sun.management.jmxremote.authenticate={{.JmxRemote.Auth}} +-Dcom.sun.management.jmxremote.authenticate={{.Jvm.JmxRemote.Auth}} -Dcom.sun.management.jmxremote.access.file=../conf/jmxremote.access -Dcom.sun.management.jmxremote.password.file=../conf/jmxremote.password --Djava.rmi.server.hostname={{.JmxRemote.RmiServerHostname}} --Drmi.registry.port.platform={{.JmxRemote.RmiRegistryPort}} --Drmi.server.port.platform={{.JmxRemote.RmiServerPort}} +-Djava.rmi.server.hostname={{.Jvm.JmxRemote.RmiServerHostname}} +-Drmi.registry.port.platform={{.Jvm.JmxRemote.RmiRegistryPort}} +-Drmi.server.port.platform={{.Jvm.JmxRemote.RmiServerPort}} {{- end}} --Dhttp.listen.port={{.HttpListenPort}} --Dshutdown.port={{.ShutdownPort}} +-Dhttp.listen.port={{.Jvm.HttpListenPort}} +-Dshutdown.port={{.Jvm.ShutdownPort}} #******************************************************************** # Other Parameters #******************************************************************** -{{- range .OtherParameters}} +{{- range .Jvm.OtherParameters}} +{{- if .}} -D{{.}} {{- end}} +{{- end}} diff --git a/conf/wrapper-environment.tmpl b/conf/wrapper-environment.tmpl deleted file mode 100644 index 2a8e176..0000000 --- a/conf/wrapper-environment.tmpl +++ /dev/null @@ -1,31 +0,0 @@ -{ - "JmxExporter": { - "Enabled": "${WRAPPER_JMX_EXPORTER_ENABLED}", - "Port": "${WRAPPER_JMX_EXPORTER_PORT}" - }, - "HeapDumpEnabled": "${WRAPPER_HEAP_DUMP_ENABLED}", - "PrintGcEnabled": "${WRAPPER_PRINT_GC_ENABLED}", - "Xms": "${WRAPPER_XMS}", - "Xmx": "${WRAPPER_XMX}", - "Xss": "${WRAPPER_XSS}", - "MetaspaceSize": "${WRAPPER_METASPACE_SIZE}", - "MaxMetaspaceSize": "${WRAPPER_MAX_METASPACE_SIZE}", - "RemoteDebug": { - "Enabled": "${WRAPPER_REMOTE_DEBUG_ENABLED}", - "Suspend": "${WRAPPER_REMOTE_DEBUG_SUSPEND}", - "Port": "${WRAPPER_REMOTE_DEBUG_PORT}" - }, - "JmxRemote": { - "Enabled": "${WRAPPER_JMX_REMOTE_ENABLED}", - "Ssl": "${WRAPPER_JMX_REMOTE_SSL}", - "Auth": "${WRAPPER_JMX_REMOTE_AUTH}", - "RmiServerHostname": "${WRAPPER_JMX_REMOTE_RMI_SERVER_HOSTNAME}", - "RmiRegistryPort": "${WRAPPER_JMX_REMOTE_RMI_REGISTRY_PORT}", - "RmiServerPort": "${WRAPPER_JMX_REMOTE_RMI_SERVER_PORT}" - }, - "HttpListenPort": "${WRAPPER_HTTP_LISTEN_PORT}", - "ShutdownPort": "${WRAPPER_SHUTDOWN_PORT}", - "OtherParameters": [ - ${WRAPPER_OTHER_PARAMETERS} - ] -} \ No newline at end of file diff --git a/conf/wrapper-property.single b/conf/wrapper-property.conf similarity index 94% rename from conf/wrapper-property.single rename to conf/wrapper-property.conf index c0e723c..5b630e4 100644 --- a/conf/wrapper-property.single +++ b/conf/wrapper-property.conf @@ -7,4 +7,4 @@ set.APP_NAME=myapp set.APP_LONG_NAME=myapp set.APP_DESC=myapp set.APP_LAUNCHER=org.springframework.boot.loader.JarLauncher -set.RUN_AS_USER= \ No newline at end of file +set.RUN_AS_USER= diff --git a/conf/wrapper-property.tomcat b/conf/wrapper-property.tmpl similarity index 50% rename from conf/wrapper-property.tomcat rename to conf/wrapper-property.tmpl index 187c7ae..65a7c8d 100644 --- a/conf/wrapper-property.tomcat +++ b/conf/wrapper-property.tmpl @@ -3,7 +3,8 @@ #******************************************************************** # Wrapper App Properties #******************************************************************** -set.APP_NAME=myapp -set.APP_LONG_NAME=myapp -set.APP_DESC=myapp -set.RUN_AS_USER= \ No newline at end of file +set.APP_NAME={{.Prop.AppName}} +set.APP_LONG_NAME={{.Prop.AppLongName}} +set.APP_DESC={{.Prop.AppDesc}} +set.APP_LAUNCHER={{.Prop.AppLauncher}} +set.RUN_AS_USER={{.Prop.RunAsUser}} diff --git a/conf/wrapper.single b/conf/wrapper.conf similarity index 97% rename from conf/wrapper.single rename to conf/wrapper.conf index 1d78838..de8e46e 100644 --- a/conf/wrapper.single +++ b/conf/wrapper.conf @@ -151,7 +151,7 @@ wrapper.syslog.loglevel=NONE wrapper.ignore_sequence_gaps=TRUE # Do not start if the pid file already exists. -wrapper.pidfile.strict=TRUE +wrapper.pidfile.strict=FALSE # Title to use when running as a console wrapper.console.title=%APP_NAME% @@ -270,3 +270,12 @@ wrapper.java.detect_debug_jvm=FALSE # print java version wrapper.java.version.output=TRUE wrapper.java.version.timeout=60 + +# wrapper's pid and status +wrapper.pidfile=./%APP_NAME%.pid +wrapper.statusfile=./%APP_NAME%.status + +# java's pid, id, status +wrapper.java.pidfile=./%APP_NAME%.java.pid +wrapper.java.idfile=./%APP_NAME%.java.id +wrapper.java.statusfile=./%APP_NAME%.java.status diff --git a/conf/wrapper.tomcat b/conf/wrapper.tomcat deleted file mode 100644 index 6ca2c46..0000000 --- a/conf/wrapper.tomcat +++ /dev/null @@ -1,276 +0,0 @@ -#encoding=UTF-8 -# Configuration files must begin with a line specifying the encoding -# of the the file. - -#******************************************************************** -# Wrapper License Properties (Ignored by Community Edition) -#******************************************************************** -# Professional and Standard Editions of the Wrapper require a valid -# License Key to start. Licenses can be purchased or a trial license -# requested on the following pages: -# http://wrapper.tanukisoftware.com/purchase -# http://wrapper.tanukisoftware.com/trial - -# Include file problems can be debugged by leaving only one '#' -# at the beginning of the following line: -##include.debug - -# The Wrapper will look for either of the following optional files for a -# valid License Key. License Key properties can optionally be included -# directly in this configuration file. -#include ../conf/wrapper-license.conf -#include ../conf/wrapper-license-%WRAPPER_HOST_NAME%.conf -#include ../conf/wrapper-property.conf - -# The following property will output information about which License Key(s) -# are being found, and can aid in resolving any licensing problems. -#wrapper.license.debug=TRUE - -#******************************************************************** -# Wrapper Localization -#******************************************************************** -# Specify the language and locale which the Wrapper should use. -#wrapper.lang=en_US # en_US or ja_JP - -# Specify the location of the language resource files (*.mo). -wrapper.lang.folder=../lang - -#******************************************************************** -# Wrapper App Properties -#******************************************************************** -set.MALLOC_ARENA_MAX=1 -set.WRAPPER_BASE_DIR=%WRAPPER_BIN_DIR%/.. -set.LD_LIBRARY_PATH=.:%WRAPPER_BASE_DIR%/libcore:%WRAPPER_BASE_DIR%/libextend:/usr/lib:/usr/lib64:/usr/local/lib:/usr/local/lib64 -set.JAVA_HOME=%WRAPPER_BASE_DIR%/jre -set.CLASSPATH=.:%JAVA_HOME%/lib - -#******************************************************************** -# Wrapper Java Properties -#******************************************************************** -# Java Application -# Locate the java binary on the system PATH: -#wrapper.java.command=java -# Specify a specific java binary: -wrapper.java.command=%JAVA_HOME%/bin/java - -# Tell the Wrapper to log the full generated Java command line. -wrapper.java.command.loglevel=INFO - -# Java Main class. This class must implement the WrapperListener interface -# or guarantee that the WrapperManager class is initialized. Helper -# classes are provided to do this for you. -# See the following page for details: -# http://wrapper.tanukisoftware.com/doc/english/integrate.html -wrapper.java.mainclass=org.tanukisoftware.wrapper.WrapperStartStopApp - -# Java Classpath (include wrapper.jar) Add class path elements as -# needed starting from 1 -wrapper.java.classpath.1=%WRAPPER_BASE_DIR%/bin/wrapper-*.jar -wrapper.java.classpath.2=%WRAPPER_BASE_DIR%/bin/*.jar - -# Java Library Path (location of Wrapper.DLL or libwrapper.so) -wrapper.java.library.path.1=%WRAPPER_BASE_DIR%/libcore -wrapper.java.library.path.2=%WRAPPER_BASE_DIR%/libextend -wrapper.java.library.path.3=/usr/lib -wrapper.java.library.path.4=/usr/lib64 -wrapper.java.library.path.5=/usr/local/lib -wrapper.java.library.path.6=/usr/local/lib64 - -# Java Bits. On applicable platforms, tells the JVM to run in 32 or 64-bit mode. -wrapper.java.additional.auto_bits=TRUE - -# Java Additional Parameters -wrapper.java.additional.default.stripquotes=TRUE -wrapper.java.additional.1=-Dcatalina.home="%WRAPPER_BASE_DIR%" -wrapper.java.additional.2=-Dcatalina.base="%WRAPPER_BASE_DIR%" -wrapper.java.additional.3=-Djava.io.tmpdir="%WRAPPER_BASE_DIR%/temp" -wrapper.java.additional.4=-Djdk.tls.ephemeralDHKeySize=2048 -wrapper.java.additional.5=-Djava.protocol.handler.pkgs=org.apache.catalina.webresources - -# wrapper.java.additional_file -wrapper.java.additional_file.stripquotes=TRUE -wrapper.java.additional_file=%WRAPPER_BASE_DIR%/conf/wrapper-additional.conf - -# Initial Java Heap Size (in MB) -#wrapper.java.initmemory=3 - -# Maximum Java Heap Size (in MB) -#wrapper.java.maxmemory=64 - -# Application parameters. Add parameters as needed starting from 1 -wrapper.app.parameter.default.stripquotes=TRUE -wrapper.app.parameter.1=org.apache.catalina.startup.Bootstrap -wrapper.app.parameter.2=1 -wrapper.app.parameter.3=start -wrapper.app.parameter.4=org.apache.catalina.startup.Bootstrap -wrapper.app.parameter.5=TRUE -wrapper.app.parameter.6=1 -wrapper.app.parameter.7=stop - -# wrapper.app.parameter_file -wrapper.app.parameter_file.stripquotes=TRUE - -#******************************************************************** -# Wrapper Logging Properties -#******************************************************************** -# Enables Debug output from the Wrapper. -# wrapper.debug=TRUE - -# Format of output for the console. (See docs for formats) -wrapper.console.format=LPTM - -# Log Level for console output. (See docs for log levels) -wrapper.console.loglevel=INFO - -# Log file to use for wrapper output logging. -wrapper.logfile=%WRAPPER_BASE_DIR%/logs/console_ROLLNUM.log - -wrapper.logfile.purge.pattern=%WRAPPER_BASE_DIR%/logs/console_*.log -wrapper.logfile.purge.sort=TIMES -wrapper.logfile.rollmode=SIZE - -# Format of output for the log file. (See docs for formats) -wrapper.logfile.format=LPTM - -# Log Level for log file output. (See docs for log levels) -wrapper.logfile.loglevel=INFO - -# Maximum size that the log file will be allowed to grow to before -# the log is rolled. Size is specified in bytes. The default value -# of 0, disables log rolling. May abbreviate with the 'k' (kb) or -# 'm' (mb) suffix. For example: 10m = 10 megabytes. -wrapper.logfile.maxsize=10m - -# Maximum number of rolled log files which will be allowed before old -# files are deleted. The default value of 0 implies no limit. -wrapper.logfile.maxfiles=50 - -# Log Level for sys/event log output. (See docs for log levels) -wrapper.syslog.loglevel=NONE - -#******************************************************************** -# Wrapper General Properties -#******************************************************************** -# Allow for the use of non-contiguous numbered properties -wrapper.ignore_sequence_gaps=TRUE - -# Do not start if the pid file already exists. -wrapper.pidfile.strict=TRUE - -# Title to use when running as a console -wrapper.console.title=%APP_NAME% - -#******************************************************************** -# Wrapper JVM Checks -#******************************************************************** -# Detect DeadLocked Threads in the JVM. (Requires Standard Edition) -wrapper.check.deadlock=TRUE -wrapper.check.deadlock.interval=60 -wrapper.check.deadlock.action=RESTART -wrapper.check.deadlock.output=FULL - -# Out Of Memory detection. -# (Ignore output from dumping the configuration to the console. This is only needed by the TestWrapper sample application.) -wrapper.filter.trigger.999=wrapper.filter.trigger.*java.lang.OutOfMemoryError -wrapper.filter.allow_wildcards.999=TRUE -wrapper.filter.action.999=NONE -# Ignore -verbose:class output to avoid false positives. -wrapper.filter.trigger.1000=[Loaded java.lang.OutOfMemoryError -wrapper.filter.action.1000=NONE - -# Ignore java.lang.OutOfMemoryError without wildcards enabled -wrapper.filter.trigger.1001=Exception in thread "*" java.lang.OutOfMemoryError -wrapper.filter.action.1001=NONE -# Only match Exception in thread "*" java.lang.OutOfMemoryError with wildcards enabled -wrapper.filter.trigger.1002=Exception in thread "*" java.lang.OutOfMemoryError -wrapper.filter.allow_wildcards.1002=TRUE -wrapper.filter.action.1002=DUMP,RESTART -wrapper.filter.message.1002=The JVM has run out of memory. - -# Ignore java.lang.StackOverflowError without wildcards enabled -wrapper.filter.trigger.1003=Exception in thread "*" java.lang.StackOverflowError -wrapper.filter.action.1003=NONE -# Only match Exception in thread "*" java.lang.StackOverflowError with wildcards enabled -wrapper.filter.trigger.1004=Exception in thread "*" java.lang.StackOverflowError -wrapper.filter.allow_wildcards.1004=TRUE -wrapper.filter.action.1004=DUMP,RESTART -wrapper.filter.message.1004=The JVM has run stack over flow. - -#******************************************************************** -# Wrapper Email Notifications. (Requires Professional Edition) -#******************************************************************** -# Common Event Email settings. -#wrapper.event.default.email.debug=TRUE -#wrapper.event.default.email.smtp.host= -#wrapper.event.default.email.smtp.port=25 -#wrapper.event.default.email.subject=[%WRAPPER_HOSTNAME%:%WRAPPER_NAME%:%WRAPPER_EVENT_NAME%] Event Notification -#wrapper.event.default.email.sender= -#wrapper.event.default.email.recipient= - -# Configure the log attached to event emails. -#wrapper.event.default.email.maillog=ATTACHMENT -#wrapper.event.default.email.maillog.lines=50 -#wrapper.event.default.email.maillog.format=LPTM -#wrapper.event.default.email.maillog.loglevel=INFO - -# Enable specific event emails. -#wrapper.event.wrapper_start.email=TRUE -#wrapper.event.jvm_prelaunch.email=TRUE -#wrapper.event.jvm_start.email=TRUE -#wrapper.event.jvm_started.email=TRUE -#wrapper.event.jvm_deadlock.email=TRUE -#wrapper.event.jvm_stop.email=TRUE -#wrapper.event.jvm_stopped.email=TRUE -#wrapper.event.jvm_restart.email=TRUE -#wrapper.event.jvm_failed_invocation.email=TRUE -#wrapper.event.jvm_max_failed_invocations.email=TRUE -#wrapper.event.jvm_kill.email=TRUE -#wrapper.event.jvm_killed.email=TRUE -#wrapper.event.jvm_unexpected_exit.email=TRUE -#wrapper.event.wrapper_stop.email=TRUE - -# Specify custom mail content -wrapper.event.jvm_restart.email.body=The JVM was restarted.\n\nPlease check on its status.\n - -#******************************************************************** -# Wrapper Windows Service Properties -#******************************************************************** -# WARNING - Do not modify any of these properties when an application -# using this configuration file has been installed as a service. -# Please uninstall the service before modifying this section. The -# service can then be reinstalled. - -# Name of the service -wrapper.name=%APP_NAME% - -# Display name of the service -wrapper.displayname=%APP_LONG_NAME% - -# Description of the service -wrapper.description=%APP_DESC% - -# Service dependencies. Add dependencies as needed starting from 1 -wrapper.ntservice.dependency.1= - -# Mode in which the service is installed. AUTO_START, DELAY_START or DEMAND_START -wrapper.ntservice.starttype=AUTO_START - -# Allow the service to interact with the desktop (Windows NT/2000/XP only). -wrapper.ntservice.interactive=FALSE - -# dump environment -wrapper.environment.dump=TRUE - -# startup timeout 10m(impl WrapperListener) -wrapper.startup.timeout=600 - -# ping -wrapper.ping.timeout=60 -wrapper.ping.interval=10 - -# enable or disable this debugging check -wrapper.java.detect_debug_jvm=FALSE - -# print java version -wrapper.java.version.output=TRUE -wrapper.java.version.timeout=60 diff --git a/libcore/libwrapper-linux-x86-32.so b/libcore/libwrapper-linux-x86-32.so index f691921..a7f01de 100644 Binary files a/libcore/libwrapper-linux-x86-32.so and b/libcore/libwrapper-linux-x86-32.so differ diff --git a/libcore/libwrapper-linux-x86-64.so b/libcore/libwrapper-linux-x86-64.so index 0fe5cb5..e90a3a8 100644 Binary files a/libcore/libwrapper-linux-x86-64.so and b/libcore/libwrapper-linux-x86-64.so differ diff --git a/libcore/wrapper-windows-x86-32.dll b/libcore/wrapper-windows-x86-32.dll index 9ef1176..729441a 100644 Binary files a/libcore/wrapper-windows-x86-32.dll and b/libcore/wrapper-windows-x86-32.dll differ diff --git a/libcore/wrapper-windows-x86-64.dll b/libcore/wrapper-windows-x86-64.dll index 6417ab2..9c1d489 100644 Binary files a/libcore/wrapper-windows-x86-64.dll and b/libcore/wrapper-windows-x86-64.dll differ