#加固
root=${1}
jar_path=${2}
account='15902141504'
pwd='qwqw10010'
key_path="${root}/jks/"

java -jar ${jar_path} -login ${account} ${pwd}
java -jar ${jar_path} -importsign ../../${project_name}/app/${signing_certificate} ${signging_certificatePassword} ${signing_keyAlias} ${signging_storePassword}
#java -jar jiagu.jar -showsign
java -jar ${jar_path} -config -update -nocert
java -jar ${jar_path} -jiagu ../../${project_name}/resGuardApks/${project_name}_release.apk ../../${project_name}/resGuardApks -autosigns

cd ../../${project_name}
jiagu_apk=""
for file in resGuardApks/*; do
    if [[ ${file} == *jiagu.apk ]]
    then
        jiagu_apk=${file}
    fi
    done

# V1 签名
jarsigner -verbose -digestalg SHA1 -sigalg MD5withRSA \
-keystore app/${signing_certificate} \
-storepass ${signging_storePassword} \
-keypass ${signging_certificatePassword} \
-signedjar resGuardApks/${project_name}_release_jg.apk ${jiagu_apk} \
${signing_keyAlias}

#copy到指定目录
now_time=$(date "+%Y-%m-%d %H_%M_%S")
cp "resGuardApks/${project_name}_release_jg.apk" "/Users/connor/Documents/apks/${project_name}_jg_${now_time}.apk"
