田源
2025-01-16 cfd8d4c470cc6db6f6689ebf01eae07e47a46990
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
#!/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 ''