#!/bin/sh
|
|
echo '***************************************************************************'
|
echo '* *'
|
echo '* BeiJing VCI-TECH jar batch signer process *'
|
echo '* *'
|
echo '* *'
|
echo '* Http://www.vci-tech.com *'
|
echo '* *'
|
echo '***************************************************************************'
|
|
## back to jre bin
|
cd ../../jre/bin
|
##
|
##
|
export TOOL_HOME=`pwd`
|
cd ../..
|
## Project path
|
export PROJECT_HOME=`pwd`
|
|
cd _SIGNER
|
export _SIGNER=`pwd`
|
export folder_origned=$_SIGNER/folder-lib-signed
|
export folder_origned_lib=$folder_origned/lib
|
export folder_origned_modules=$folder_origned/modules
|
|
export folder_signed=$folder_origned/_signed
|
export folder_signed_lib=$folder_signed/lib
|
export folder_signed_modules=$folder_signed/modules
|
|
export conf_file=properties/conf.properties
|
export conf_file_full=$_SIGNER/$conf_file
|
export rmip_system_common_jar_origned=$folder_origned/lib/rmip-system-common.jar
|
export rmip_system_common_jar_signed=$folder_signed/lib/rmip-system-common.jar
|
|
export key=vcivci
|
export keyFile=$PROJECT_HOME/_SIGNER/vcikeystore
|
export keyAlias=vci
|
|
export APP_HOME=$PROJECT_HOME
|
export LOGS_PATH=$APP_HOME/logs
|
export SIGN_LOG=$LOGS_PATH/sign_log.txt
|
export APP_HOME_LIBS=$APP_HOME/libs
|
export APP_HOME_LIBS_LIB=$APP_HOME_LIBS/lib
|
export APP_HOME_LIBS_MODULES=$APP_HOME_LIBs/modules
|
export APP_HOME_WEB_INF=$APP_HOME/WEB-INF
|
export APP_HOME_WEB_INF_LIB=$APP_HOME_WEB_INF/lib
|
export APP_HOME_PROPERTIES=$APP_HOME/properties
|
export TOMCAT_HOME=$APP_HOME/tomcat
|
export CALICATE_HOME=$TOMCAT_HOME
|
export TOMCAT_LIB=$TOMCAT_HOME/lib
|
export TOMCAT_BIN=$TOMCAT_HOME/bin
|
export TOMCAT_WEBAPPS=$TOMCAT_HOME/webapps
|
|
export WEB_APP_NAME=web
|
export WEB_APP_WEB_INF=$TOMCAT_WEBAPPS/$WEB_APP_NAME/WEB-INF
|
export WEB_APP_WEB_INF_LIB=$WEB_APP_WEB_INF/lib
|
|
|
export fileSignerCount=0
|
function folder_signer(){
|
for file in `ls $1`
|
do
|
if [ -d "$1"/"$file" ]; then
|
folder_signer "$1/$file"
|
else
|
file_signer "$1"/"$file"
|
fi
|
done
|
}
|
|
function file_signer(){
|
filename=$(basename "$1")
|
extenstion="${filename##*.}"
|
filename="${filename%.*}"
|
if [ "$extenstion" = "jar" ]; then
|
echo ''
|
echo 'signering' $1 ' [BEGIN]'
|
$TOOL_HOME/jarsigner -storepass $key -keystore $keyFile $1 $keyAlias
|
echo 'signering' $1 ' [DONE]'
|
fileSignerCount=$(($fileSignerCount+1))
|
else
|
echo 'signering' $1 ' [BAD! IS NOT .jar FILE]'
|
fi
|
}
|
|
if [ ! -d "$APP_HOME_LIBS" ]; then
|
mkdir -p $APP_HOME_LIBS
|
mkdir -p $APP_HOME_LIBS_LIB
|
mkdir -p $APP_HOME_LIBS_MODULES
|
else
|
if [ ! -d "$APP_HOME_LIBS_LIB" ]; then
|
mkdir -p $APP_HOME_LIBS_LIB
|
fi
|
|
if [ ! -d "$APP_HOME_LIBS_MODULES" ]; then
|
mkdir -p $APP_HOME_LIBS_MODULES
|
fi
|
fi
|
|
if [ ! -d "APP_HOME_WEB_INF" ]; then
|
mkdir -p $APP_HOME_WEB_INF
|
mkdir -p $APP_HOME_WEB_INF_LIB
|
else
|
if [ ! -d "$APP_HOME_WEB_INF_LIB" ]; then
|
mkdir -p $APP_HOME_WEB_INF_LIB
|
fi
|
fi
|
|
|
echo ''
|
echo '0. All [BEGIN]'
|
echo ''
|
echo ''
|
|
echo ''
|
echo '1. delete exists key file'
|
#rm -rf $keyFile
|
echo '1. delete exists key file [DONE]'
|
echo ''
|
|
echo '2. regen key file'
|
#$TOOL_HOME/keytool -genkey -keystore $keyFile -alias $keyAlias -dname "CN=VCI Technology Co.Ltd,OU=test.com,O=bj,L=bj,ST=bj, C=cn" -keypass $key -storepass $key -validity 7200
|
echo '2. regen key file [DONE]'
|
echo ''
|
|
echo '3. copy need signer' $folder_origned'/lib & modules(directory and child directory) to presigner directory('$folder_signed')'
|
if [ -d "$folder_signed" ]; then
|
echo 'delete' $folder_signed'(directory)'
|
rm -rf $folder_signed
|
echo 'delete' $folder_signed'(directory) [DONE]'
|
echo ''
|
fi
|
echo 'mkdir' $folder_signed'(directory)'
|
mkdir -p $folder_signed
|
echo 'mkdir' $folder_signed'(directory) [DONE]'
|
echo ''
|
|
if [ -d "$folder_origned_lib" ]; then
|
echo 'copy' $folder_origned_lib'(directory) to' $folder_signed
|
cp -rf $folder_origned_lib $folder_signed
|
#find $folder_signed_lib/ -name '*.sh' | xargs rm -rf
|
echo 'copy' $folder_origned_lib'(directory) to' $folder_signed ' [DONE]'
|
echo ''
|
fi
|
|
if [ -d "$folder_origned_modules" ]; then
|
echo 'copy' $folder_origned_modules'(directory) to' $folder_signed
|
cp -rf $folder_origned_modules $folder_signed
|
echo 'copy' $folder_origned_modules'(directory) to' $folder_signed ' [DONE]'
|
echo ''
|
fi
|
echo '3. copy need signer' $folder_origned'/lib & modules(directory and child directory) to presigner directory('$folder_signed') [DONE]'
|
echo ''
|
|
if [ -f "$conf_file_full" -a -f "$rmip_system_common_jar_signed" ]; then
|
echo '4. rewrite' $conf_file_full'(file) content to' $rmip_system_common_jar_signed
|
$TOOL_HOME/jar -uf $rmip_system_common_jar_signed $conf_file
|
echo '4. rewrite' $conf_file_full'(file) content to' $rmip_system_common_jar_signed ' [DONE]'
|
echo ''
|
fi
|
|
if [ -f "$conf_file_full" -a -f "$rmip_system_common_jar_signed" ]; then
|
echo '5. copy' $conf_file_full'(file) to' $APP_HOME_PROPERTIES ')'
|
cp -rf $conf_file_full $APP_HOME_PROPERTIES
|
echo '5. copy' $conf_file_full'(file) to' $APP_HOME_PROPERTIES ') [DONE]'
|
echo ''
|
fi
|
|
echo '6. jarsigner('$folder_signed'/**/**/*.jar)'
|
fileSignerCount=0
|
if [ -d $folder_signed_lib ]; then
|
echo ''
|
folder_signer $folder_signed_lib
|
fi
|
|
if [ -d $folder_signed_modules ]; then
|
echo ''
|
folder_signer $folder_signed_modules
|
fi
|
echo ''
|
echo 'signer total:' $fileSignerCount
|
echo '6. jarsigner('$folder_signed'/**/**/*.jar) [DONE]'
|
echo ''
|
|
if [ -d "$folder_signed_lib" ]; then
|
echo '7. copy' $folder_signed_lib'(directory) to' $APP_HOME_LIBS
|
cp -rf $folder_signed_lib $APP_HOME_LIBS
|
echo '7. copy' $folder_signed_lib'(directory) to' $APP_HOME_LIBS ' [DONE]'
|
echo ''
|
fi
|
|
if [ -d "$folder_signed_modules" ]; then
|
echo '7.1 copy' $folder_signed_modules'(directory) to' $APP_HOME_LIBS
|
cp -rf $folder_signed_modules $APP_HOME_LIBS
|
echo '7.1 copy' $folder_signed_modules'(directory) to' $APP_HOME_LIBS ' [DONE]'
|
echo ''
|
fi
|
|
if [ -d "$folder_signed" ]; then
|
echo '7.2 copy' $folder_signed'/**/**/*.jar(files) to' $APP_HOME_WEB_INF_LI
|
find $folder_signed -name "*.jar" -type f -exec cp -rf {} $APP_HOME_WEB_INF_LIB \;
|
echo '7.2 copy' $folder_signed'/**/**/*.jar(files) to' $APP_HOME_WEB_INF_LIB ' [DONE]'
|
echo ''
|
fi
|
|
|
if [ -d "$TOMCAT_WEBAPPS"/"$WEB_APP_NAME" ]; then
|
if [ -f "$rmip_system_common_jar_origned" ]; then
|
echo '8. copy' $rmip_system_common_jar_origned'(file) to' $WEB_APP_WEB_INF_LIB
|
if [ ! -d "$WEB_APP_WEB_INF" ]; then
|
mkdir -p $WEB_APP_WEB_INF
|
mkdir -p $WEB_APP_WEB_INF_LIB
|
else
|
mkdir -p $WEB_APP_WEB_INF_LIB
|
fi
|
cp -rf $rmip_system_common_jar_origned $WEB_APP_WEB_INF_LIB
|
echo '8. copy' $rmip_system_common_jar_origned'(file) to' $WEB_APP_WEB_INF_LIB ' [DONE]'
|
echo ''
|
fi
|
fi
|
|
|
echo ''
|
echo '9. All [END]'
|
echo ''
|
echo ''
|