Created
October 23, 2015 02:27
-
-
Save marsyang1/3ec9ff7b88f41e202b96 to your computer and use it in GitHub Desktop.
Mac startup add java policy
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?xml version="1.0" encoding="UTF-8"?> | |
<!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd"> | |
<plist version="1.0"><!-- NOTE: place this file in /Library/LaunchDaemons --> | |
<dict> | |
<key>Label</key> | |
<string>com.mars.add-java-policy</string> | |
<key>RunAtLoad</key> | |
<true/> | |
<key>Program</key> | |
<string>/opt/JavaPolicyShell/policy-shell.sh</string> | |
<key>StandardErrorPath</key> | |
<string>/opt/JavaPolicyShell/logs/launchd.error</string> | |
<key>StandardOutPath</key> | |
<string>/opt/JavaPolicyShell/logs/launchd.info</string> | |
<key>UserName</key> | |
<string>root</string><!-- MUST be root in order to run tomcat on port 80 --> | |
</dict> | |
</plist> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
if test -f com.mars.add-java-policy.plist && test -f policy-shell.sh; | |
then | |
echo "com.mars.add-java-policy.plist and policy-shell.sh exists , doing install... " | |
if test -d /opt/JavaPolicyShell/; | |
then | |
echo "remove before install" | |
launchctl unload /Library/LaunchDaemons/com.mars.add-java-policy.plist | |
rm /Library/LaunchDaemons/com.mars.add-java-policy.plist | |
rm -rf /opt/JavaPolicyShell/ | |
fi | |
if ! test -d /opt/; | |
then | |
mkdir /opt | |
chown -R root:wheel /opt | |
chmod 755 /opt | |
fi | |
mkdir /opt/JavaPolicyShell | |
mkdir /opt/JavaPolicyShell/logs | |
chown -R root:wheel /opt/JavaPolicyShell/ | |
chown root:wheel policy-shell.sh | |
chmod 754 policy-shell.sh | |
chown root:wheel com.mars.add-java-policy.plist | |
chmod 754 com.mars.add-java-policy.plist | |
mv -f com.mars.add-java-policy.plist /Library/LaunchDaemons/ | |
mv -f policy-shell.sh /opt/JavaPolicyShell/ | |
launchctl load /Library/LaunchDaemons/com.mars.add-java-policy.plist | |
echo "install completed" | |
else | |
echo "com.mars.add-java-policy.plist and policy-shell.sh is not exists" | |
fi |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
PATTERN='www.google.com' | |
if test -a /Library/Internet\ Plug-Ins/JavaAppletPlugin.plugin/Contents/Home/lib/security/java.policy; | |
then | |
if grep -q $PATTERN /Library/Internet\ Plug-Ins/JavaAppletPlugin.plugin/Contents/Home/lib/security/java.policy; | |
then | |
echo "Here are the Strings with the Pattern '$PATTERN':" | |
else | |
echo "The Pattern '$PATTERN' was NOT Found in 'java.policy'" | |
echo "start add java code base" | |
echo "grant codeBase \"http://www.google.com/-\" { Permission java.security.AllPermission; }; " >> /Library/Internet\ Plug-Ins/JavaAppletPlugin.plugin/Contents/Home/lib/security/java.policy | |
echo "end of add java code base" | |
fi | |
else | |
echo "java.policy is not exists" | |
fi |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
if test -f /Library/LaunchDaemons/net.chungyo.add-java-policy.plist; | |
then | |
launchctl unload /Library/LaunchDaemons/com.mars.add-java-policy.plist | |
rm /Library/LaunchDaemons/net.chungyo.add-java-policy.plist | |
rm -rf /opt/JavaPolicyShell/ | |
fi | |
if test -d /opt/JavaPolicyShell/; | |
then | |
rm -rf /opt/JavaPolicyShell/ | |
fi | |
echo "uninstall auto-policy complete" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment