updated on Thu Jan 26 16:09:46 UTC 2012
[aur-mirror.git] / java-jce_ustrength / install_java_jce_ustrength
blob44e0d9eedd185dd41321b64d4bfd6eef2954c074
1 #!/bin/bash
3 # The affected files:
4 # b94923af60a5b4659a8df2847fe1ab6d US_export_policy.jar
5 # 53e2a50065ac6ea39cb2aa7d3975284b local_policy.jar
7 # Internal variables
8 md5_this_uspolicy=b94923af60a5b4659a8df2847fe1ab6d
9 md5_this_localpolicy=53e2a50065ac6ea39cb2aa7d3975284b
10 jcedir=/usr/share/java/java-jce_ustrength
11 jresecuritydir=/opt/java/jre/lib/security
12 _ext=java-jce_ustrength.backup
14 # 1 = Root
15 # 0 = other ID
16 check_root(){
17 if [ ${UID} -eq 0 ]; then
18 return 1
20 return 0
23 # 0 = Unlimited Strength JCE Policy already installed
24 # 1 = Original JCE Policy installed
25 # 2 = Destination files don't exist
26 check_destinationfiles(){
27 if [ ! -e "${jresecuritydir}/US_export_policy.jar" -o ! -e "${jresecuritydir}/local_policy.jar" ];
28 then
29 return 2
31 md5_uspolicy=$(md5sum ${jresecuritydir}/US_export_policy.jar | cut -d " " -f 1)
32 md5_localpolicy=$(md5sum ${jresecuritydir}/local_policy.jar | cut -d " " -f 1)
33 if [ "${md5_uspolicy}" == "${md5_this_uspolicy}" -a \
34 "${md5_localpolicy}" == "${md5_this_localpolicy}" ]; then
35 return 0
37 return 1
40 install(){
41 check_destinationfiles
42 not_installed=$?
43 if [ "${not_installed}" -eq "1" ]; then
44 check_root
45 isroot=$?
46 if [ "${isroot}" -eq "0" ]; then
47 echo "You must be root for doing this operation."
48 exit 1
50 echo -n "Installing Unlimited Strength JCE files..."
51 cp ${jresecuritydir}/US_export_policy.jar ${jresecuritydir}/US_export_policy.jar.${_ext} || return 1
52 cp ${jresecuritydir}/local_policy.jar ${jresecuritydir}/local_policy.jar.${_ext} || return 1
53 cp ${jcedir}/US_export_policy.jar ${jresecuritydir}/ || return 1
54 cp ${jcedir}/local_policy.jar ${jresecuritydir}/ || return 1
55 echo " installed."
56 else
57 echo "Unlimited Strength JCE files already installed."
61 uninstall(){
62 check_destinationfiles
63 not_installed=$?
64 if [ "$not_installed" -eq "0" ]; then
65 check_root
66 isroot=$?
67 if [ "${isroot}" -eq "0" ]; then
68 echo "You must be root for doing this operation."
69 exit 0
71 echo -n "Uninstalling Unlimited Strength JCE files..."
72 if [ ! -e "${jresecuritydir}/US_export_policy.jar.${_ext}" -a \
73 ! -e "${jresecuritydir}/local_policy.jar.${_ext}" ]; then
74 echo "Previous backup of the files doesn't exist!"
75 echo "For uninstall, reinstall the jre package."
76 exit 0
79 mv ${jresecuritydir}/US_export_policy.jar.${_ext} ${jresecuritydir}/US_export_policy.jar || return 1
80 mv ${jresecuritydir}/local_policy.jar.${_ext} ${jresecuritydir}/local_policy.jar || return 1
81 echo " uninstalled."
82 else
83 if [ -e "${jresecuritydir}/US_export_policy.jar.${_ext}" -a \
84 -e "${jresecuritydir}/local_policy.jar.${_ext}" ]; then
85 check_root
86 isroot=$?
87 if [ "${isroot}" -eq "0" ]; then
88 echo "You must be root for doing this operation."
89 exit 1
91 echo -n "Deleting old regular JCE files backup..."
92 rm ${jresecuritydir}/US_export_policy.jar.${_ext} || return 1
93 rm ${jresecuritydir}/local_policy.jar.${_ext} || return 1
94 echo " deleted."
97 if [ "${not_installed}" -eq "1" ]; then
98 echo "Regular JCE files already installed."
103 case "$1" in
104 install) install
106 uninstall) uninstall
108 *) echo "Usage $0: {install|uninstall}"
110 esac
111 exit 0