mirror of
https://github.com/novitechie/jetbra
synced 2024-12-22 06:15:45 +00:00
init
This commit is contained in:
parent
e060f1c114
commit
f1a2ce1395
3
.gitignore
vendored
Normal file
3
.gitignore
vendored
Normal file
@ -0,0 +1,3 @@
|
||||
*.iml
|
||||
.idea/
|
||||
target/
|
@ -47,6 +47,7 @@
|
||||
<Can-Retransform-Classes>true</Can-Retransform-Classes>
|
||||
</manifestEntries>
|
||||
</archive>
|
||||
<finalName>jetbra-agent</finalName>
|
||||
</configuration>
|
||||
<executions>
|
||||
<execution>
|
||||
|
@ -13,7 +13,7 @@ public class AgentMain {
|
||||
AgentBuilder agentBuilder = newAgentBuilder();
|
||||
agentBuilder.type(ElementMatchers.named("java.security.cert.PKIXBuilderParameters"))
|
||||
.transform((builder, typeDescription, classLoader, module, protectionDomain) -> builder
|
||||
.visit(Advice.to(PKIXBuilderParameters.class)
|
||||
.visit(Advice.to(PKIXBuilderParametersAdvice.class)
|
||||
.on(ElementMatchers.isConstructor().and(ElementMatchers.takesArgument(0, Set.class)))))
|
||||
.asTerminalTransformation()
|
||||
.type(ElementMatchers.named("sun.net.www.http.HttpClient"))
|
||||
|
@ -2,13 +2,12 @@ package win.novice.li;
|
||||
|
||||
import net.bytebuddy.asm.Advice;
|
||||
|
||||
import java.lang.reflect.Field;
|
||||
import java.lang.reflect.Method;
|
||||
import java.security.cert.TrustAnchor;
|
||||
import java.util.HashSet;
|
||||
import java.util.Set;
|
||||
|
||||
public class PKIXBuilderParameters {
|
||||
public class PKIXBuilderParametersAdvice {
|
||||
|
||||
|
||||
@Advice.OnMethodEnter
|
73
script/install-all-users.vbs
Normal file
73
script/install-all-users.vbs
Normal file
@ -0,0 +1,73 @@
|
||||
If Not WScript.Arguments.Named.Exists("elevate") Then
|
||||
CreateObject("Shell.Application").ShellExecute WScript.FullName, """" & WScript.ScriptFullName & """ /elevate", "", "runas", 10
|
||||
WScript.Quit
|
||||
End If
|
||||
|
||||
Set oShell = CreateObject("WScript.Shell")
|
||||
Set oEnvSystem = oShell.Environment("SYSTEM")
|
||||
Set oFS = CreateObject("Scripting.FileSystemObject")
|
||||
|
||||
Dim sBasePath, sJarFile
|
||||
sBasePath = oFS.GetParentFolderName(oFS.GetParentFolderName(WScript.ScriptFullName))
|
||||
sJarFile = sBasePath & "\jetbra-agent.jar"
|
||||
|
||||
If Not oFS.FileExists(sJarFile) Then
|
||||
MsgBox "jetbra-agent.jar not found", vbOKOnly Or vbCritical
|
||||
WScript.Quit -1
|
||||
End If
|
||||
|
||||
MsgBox "It may take a few seconds to execute this script." & vbCrLf & vbCrLf & "Click 'OK' button and wait for the prompt of 'Done.' to pop up!"
|
||||
|
||||
Dim sEnvKey, sEnvVal, aJBProducts
|
||||
aJBProducts = Array("idea", "clion", "phpstorm", "goland", "pycharm", "webstorm", "webide", "rider", "datagrip", "rubymine", "appcode", "dataspell", "gateway", "jetbrains_client", "jetbrainsclient", "studio", "devecostudio")
|
||||
|
||||
Set re = New RegExp
|
||||
re.Global = True
|
||||
re.IgnoreCase = True
|
||||
re.Pattern = "^\-javaagent:.*[\/\\]jetbra\-agent\.jar.*"
|
||||
|
||||
Sub RemoveEnv(env)
|
||||
On Error Resume Next
|
||||
|
||||
For Each sPrd in aJBProducts
|
||||
sEnvKey = UCase(sPrd) & "_VM_OPTIONS"
|
||||
sEnvVal = oShell.ExpandEnvironmentStrings("%" & sEnvKey & "%")
|
||||
If sEnvVal <> ("%" & sEnvKey & "%") Then
|
||||
env.Remove(sEnvKey)
|
||||
End If
|
||||
Next
|
||||
End Sub
|
||||
|
||||
RemoveEnv oShell.Environment("USER")
|
||||
|
||||
Dim sVmOptionsFile
|
||||
For Each sPrd in aJBProducts
|
||||
sEnvKey = UCase(sPrd) & "_VM_OPTIONS"
|
||||
sVmOptionsFile = sBasePath & "\vmoptions\" & sPrd & ".vmoptions"
|
||||
If oFS.FileExists(sVmOptionsFile) Then
|
||||
ProcessVmOptions sVmOptionsFile
|
||||
oEnvSystem(sEnvKey) = sVmOptionsFile
|
||||
End If
|
||||
Next
|
||||
|
||||
Sub ProcessVmOptions(ByVal file)
|
||||
Dim sLine, sNewContent, bMatch
|
||||
Set oFile = oFS.OpenTextFile(file, 1, 0)
|
||||
|
||||
sNewContent = ""
|
||||
Do Until oFile.AtEndOfStream
|
||||
sLine = oFile.ReadLine
|
||||
bMatch = re.Test(sLine)
|
||||
If Not bMatch Then
|
||||
sNewContent = sNewContent & sLine & vbLf
|
||||
End If
|
||||
Loop
|
||||
oFile.Close
|
||||
|
||||
sNewContent = sNewContent & "-javaagent:" & sJarFile & "=jetbrains"
|
||||
Set oFile = oFS.OpenTextFile(file, 2, 0)
|
||||
oFile.Write sNewContent
|
||||
oFile.Close
|
||||
End Sub
|
||||
|
||||
MsgBox "Done."
|
54
script/install-current-user.vbs
Normal file
54
script/install-current-user.vbs
Normal file
@ -0,0 +1,54 @@
|
||||
Set oShell = CreateObject("WScript.Shell")
|
||||
Set oEnv = oShell.Environment("USER")
|
||||
Set oFS = CreateObject("Scripting.FileSystemObject")
|
||||
|
||||
Dim sEnvKey, sEnvVal, aJBProducts
|
||||
aJBProducts = Array("idea", "clion", "phpstorm", "goland", "pycharm", "webstorm", "webide", "rider", "datagrip", "rubymine", "appcode", "dataspell", "gateway", "jetbrains_client", "jetbrainsclient", "studio", "devecostudio")
|
||||
|
||||
Set re = New RegExp
|
||||
re.Global = True
|
||||
re.IgnoreCase = True
|
||||
re.Pattern = "^\-javaagent:.*[\/\\]jetbra\-agent\.jar.*"
|
||||
|
||||
Dim sBasePath, sJarFile
|
||||
sBasePath = oFS.GetParentFolderName(oShell.CurrentDirectory)
|
||||
sJarFile = sBasePath & "\jetbra-agent.jar"
|
||||
|
||||
If Not oFS.FileExists(sJarFile) Then
|
||||
MsgBox "jetbra-agent.jar not found", vbOKOnly Or vbCritical
|
||||
WScript.Quit -1
|
||||
End If
|
||||
|
||||
MsgBox "It may take a few seconds to execute this script." & vbCrLf & vbCrLf & "Click 'OK' button and wait for the prompt of 'Done.' to pop up!"
|
||||
|
||||
Dim sVmOptionsFile
|
||||
For Each sPrd in aJBProducts
|
||||
sEnvKey = UCase(sPrd) & "_VM_OPTIONS"
|
||||
sVmOptionsFile = sBasePath & "\vmoptions\" & sPrd & ".vmoptions"
|
||||
If oFS.FileExists(sVmOptionsFile) Then
|
||||
ProcessVmOptions sVmOptionsFile
|
||||
oEnv(sEnvKey) = sVmOptionsFile
|
||||
End If
|
||||
Next
|
||||
|
||||
Sub ProcessVmOptions(ByVal file)
|
||||
Dim sLine, sNewContent, bMatch
|
||||
Set oFile = oFS.OpenTextFile(file, 1, 0)
|
||||
|
||||
sNewContent = ""
|
||||
Do Until oFile.AtEndOfStream
|
||||
sLine = oFile.ReadLine
|
||||
bMatch = re.Test(sLine)
|
||||
If Not bMatch Then
|
||||
sNewContent = sNewContent & sLine & vbLf
|
||||
End If
|
||||
Loop
|
||||
oFile.Close
|
||||
|
||||
sNewContent = sNewContent & "-javaagent:" & sJarFile & "=jetbrains"
|
||||
Set oFile = oFS.OpenTextFile(file, 2, 0)
|
||||
oFile.Write sNewContent
|
||||
oFile.Close
|
||||
End Sub
|
||||
|
||||
MsgBox "Done."
|
91
script/install.sh
Executable file
91
script/install.sh
Executable file
@ -0,0 +1,91 @@
|
||||
#!/bin/sh
|
||||
|
||||
set -e
|
||||
|
||||
OS_NAME=$(uname -s)
|
||||
JB_PRODUCTS="idea clion phpstorm goland pycharm webstorm webide rider datagrip rubymine appcode dataspell gateway jetbrains_client jetbrainsclient studio devecostudio"
|
||||
|
||||
BASE_PATH=$(dirname $(
|
||||
cd $(dirname "$0")
|
||||
pwd
|
||||
))
|
||||
|
||||
JAR_FILE_PATH="${BASE_PATH}/jetbra-agent.jar"
|
||||
|
||||
if [ ! -f "${JAR_FILE_PATH}" ]; then
|
||||
echo 'jetbra-agent.jar not found'
|
||||
exit -1
|
||||
fi
|
||||
|
||||
KDE_ENV_DIR="${HOME}/.config/plasma-workspace/env"
|
||||
LAUNCH_AGENTS_DIR="${HOME}/Library/LaunchAgents"
|
||||
|
||||
PROFILE_PATH="${HOME}/.profile"
|
||||
ZSH_PROFILE_PATH="${HOME}/.zshrc"
|
||||
PLIST_PATH="${LAUNCH_AGENTS_DIR}/jetbrains.vmoptions.plist"
|
||||
|
||||
if [ $OS_NAME = "Darwin" ]; then
|
||||
BASH_PROFILE_PATH="${HOME}/.bash_profile"
|
||||
|
||||
mkdir -p "${LAUNCH_AGENTS_DIR}"
|
||||
echo '<?xml version="1.0" encoding="UTF-8"?><!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd"><plist version="1.0"><dict><key>Label</key><string>jetbrains.vmoptions</string><key>ProgramArguments</key><array><string>sh</string><string>-c</string><string>' >"${PLIST_PATH}"
|
||||
else
|
||||
BASH_PROFILE_PATH="${HOME}/.bashrc"
|
||||
mkdir -p "${KDE_ENV_DIR}"
|
||||
fi
|
||||
|
||||
touch "${PROFILE_PATH}"
|
||||
touch "${BASH_PROFILE_PATH}"
|
||||
touch "${ZSH_PROFILE_PATH}"
|
||||
|
||||
MY_VMOPTIONS_SHELL_NAME="jetbrains.vmoptions.sh"
|
||||
MY_VMOPTIONS_SHELL_FILE="${HOME}/.${MY_VMOPTIONS_SHELL_NAME}"
|
||||
echo '#!/bin/sh' >"${MY_VMOPTIONS_SHELL_FILE}"
|
||||
|
||||
EXEC_LINE='___MY_VMOPTIONS_SHELL_FILE="${HOME}/.jetbrains.vmoptions.sh"; if [ -f "${___MY_VMOPTIONS_SHELL_FILE}" ]; then . "${___MY_VMOPTIONS_SHELL_FILE}"; fi'
|
||||
|
||||
for PRD in $JB_PRODUCTS; do
|
||||
VM_FILE_PATH="${BASE_PATH}/vmoptions/${PRD}.vmoptions"
|
||||
if [ ! -f "${VM_FILE_PATH}" ]; then
|
||||
continue
|
||||
fi
|
||||
|
||||
if [ $OS_NAME = "Darwin" ]; then
|
||||
sed -i '' '/^\-javaagent:.*[\/\\]jetbra\-agent\.jar.*/d' "${VM_FILE_PATH}"
|
||||
else
|
||||
sed -i '/^\-javaagent:.*[\/\\]jetbra\-agent\.jar.*/d' "${VM_FILE_PATH}"
|
||||
fi
|
||||
|
||||
echo "-javaagent:${JAR_FILE_PATH}=jetbrains" >>"${VM_FILE_PATH}"
|
||||
|
||||
ENV_NAME=$(echo $PRD | tr '[a-z]' '[A-Z]')"_VM_OPTIONS"
|
||||
echo "export ${ENV_NAME}=\"${VM_FILE_PATH}\"" >>"${MY_VMOPTIONS_SHELL_FILE}"
|
||||
|
||||
if [ $OS_NAME = "Darwin" ]; then
|
||||
launchctl setenv "${ENV_NAME}" "${VM_FILE_PATH}"
|
||||
echo "launchctl setenv \"${ENV_NAME}\" \"${VM_FILE_PATH}\"" >>"${PLIST_PATH}"
|
||||
fi
|
||||
done
|
||||
|
||||
if [ $OS_NAME = "Darwin" ]; then
|
||||
sed -i '' '/___MY_VMOPTIONS_SHELL_FILE="${HOME}\/\.jetbrains\.vmoptions\.sh"; if /d' "${PROFILE_PATH}" >/dev/null 2>&1
|
||||
sed -i '' '/___MY_VMOPTIONS_SHELL_FILE="${HOME}\/\.jetbrains\.vmoptions\.sh"; if /d' "${BASH_PROFILE_PATH}" >/dev/null 2>&1
|
||||
sed -i '' '/___MY_VMOPTIONS_SHELL_FILE="${HOME}\/\.jetbrains\.vmoptions\.sh"; if /d' "${ZSH_PROFILE_PATH}" >/dev/null 2>&1
|
||||
|
||||
echo '</string></array><key>RunAtLoad</key><true/></dict></plist>' >>"${PLIST_PATH}"
|
||||
else
|
||||
sed -i '/___MY_VMOPTIONS_SHELL_FILE="${HOME}\/\.jetbrains\.vmoptions\.sh"; if /d' "${PROFILE_PATH}" >/dev/null 2>&1
|
||||
sed -i '/___MY_VMOPTIONS_SHELL_FILE="${HOME}\/\.jetbrains\.vmoptions\.sh"; if /d' "${BASH_PROFILE_PATH}" >/dev/null 2>&1
|
||||
sed -i '/___MY_VMOPTIONS_SHELL_FILE="${HOME}\/\.jetbrains\.vmoptions\.sh"; if /d' "${ZSH_PROFILE_PATH}" >/dev/null 2>&1
|
||||
fi
|
||||
|
||||
echo "${EXEC_LINE}" >>"${PROFILE_PATH}"
|
||||
echo "${EXEC_LINE}" >>"${BASH_PROFILE_PATH}"
|
||||
echo "${EXEC_LINE}" >>"${ZSH_PROFILE_PATH}"
|
||||
|
||||
if [ $OS_NAME = "Darwin" ]; then
|
||||
echo 'done. the "kill Dock" command can fix the crash issue.'
|
||||
else
|
||||
ln -sf "${MY_VMOPTIONS_SHELL_FILE}" "${KDE_ENV_DIR}/${MY_VMOPTIONS_SHELL_NAME}"
|
||||
echo "done. you'd better log off first!"
|
||||
fi
|
28
script/uninstall-all-users.vbs
Normal file
28
script/uninstall-all-users.vbs
Normal file
@ -0,0 +1,28 @@
|
||||
If Not WScript.Arguments.Named.Exists("elevate") Then
|
||||
CreateObject("Shell.Application").ShellExecute WScript.FullName, """" & WScript.ScriptFullName & """ /elevate", "", "runas", 10
|
||||
WScript.Quit
|
||||
End If
|
||||
|
||||
MsgBox "It may take a few seconds to execute this script." & vbCrLf & vbCrLf & "Click 'OK' button and wait for the prompt of 'Done.' to pop up!"
|
||||
|
||||
Sub RemoveEnv(env)
|
||||
On Error Resume Next
|
||||
|
||||
Dim sEnvKey, sEnvVal, aJBProducts
|
||||
aJBProducts = Array("idea", "clion", "phpstorm", "goland", "pycharm", "webstorm", "webide", "rider", "datagrip", "rubymine", "appcode", "dataspell", "gateway", "jetbrains_client", "jetbrainsclient", "studio", "devecostudio")
|
||||
|
||||
For Each sPrd in aJBProducts
|
||||
sEnvKey = UCase(sPrd) & "_VM_OPTIONS"
|
||||
sEnvVal = oShell.ExpandEnvironmentStrings("%" & sEnvKey & "%")
|
||||
If sEnvVal <> ("%" & sEnvKey & "%") Then
|
||||
env.Remove(sEnvKey)
|
||||
End If
|
||||
Next
|
||||
End Sub
|
||||
|
||||
Set oShell = CreateObject("WScript.Shell")
|
||||
|
||||
RemoveEnv oShell.Environment("USER")
|
||||
RemoveEnv oShell.Environment("SYSTEM")
|
||||
|
||||
MsgBox "Done."
|
17
script/uninstall-current-user.vbs
Normal file
17
script/uninstall-current-user.vbs
Normal file
@ -0,0 +1,17 @@
|
||||
Set oShell = CreateObject("WScript.Shell")
|
||||
Set oEnv = oShell.Environment("USER")
|
||||
|
||||
Dim sEnvKey, sEnvVal, aJBProducts
|
||||
aJBProducts = Array("idea", "clion", "phpstorm", "goland", "pycharm", "webstorm", "webide", "rider", "datagrip", "rubymine", "appcode", "dataspell", "gateway", "jetbrains_client", "jetbrainsclient", "studio", "devecostudio")
|
||||
|
||||
MsgBox "It may take a few seconds to execute this script." & vbCrLf & vbCrLf & "Click 'OK' button and wait for the prompt of 'Done.' to pop up!"
|
||||
|
||||
For Each sPrd in aJBProducts
|
||||
sEnvKey = UCase(sPrd) & "_VM_OPTIONS"
|
||||
sEnvVal = oShell.ExpandEnvironmentStrings("%" & sEnvKey & "%")
|
||||
If sEnvVal <> ("%" & sEnvKey & "%") Then
|
||||
oEnv.Remove(sEnvKey)
|
||||
End If
|
||||
Next
|
||||
|
||||
MsgBox "Done."
|
50
script/uninstall.sh
Executable file
50
script/uninstall.sh
Executable file
@ -0,0 +1,50 @@
|
||||
#!/bin/sh
|
||||
|
||||
set -e
|
||||
|
||||
OS_NAME=$(uname -s)
|
||||
JB_PRODUCTS="idea clion phpstorm goland pycharm webstorm webide rider datagrip rubymine appcode dataspell gateway jetbrains_client jetbrainsclient studio devecostudio"
|
||||
|
||||
KDE_ENV_DIR="${HOME}/.config/plasma-workspace/env"
|
||||
|
||||
PROFILE_PATH="${HOME}/.profile"
|
||||
ZSH_PROFILE_PATH="${HOME}/.zshrc"
|
||||
PLIST_PATH="${HOME}/Library/LaunchAgents/jetbrains.vmoptions.plist"
|
||||
|
||||
if [ $OS_NAME = "Darwin" ]; then
|
||||
BASH_PROFILE_PATH="${HOME}/.bash_profile"
|
||||
else
|
||||
BASH_PROFILE_PATH="${HOME}/.bashrc"
|
||||
fi
|
||||
|
||||
touch "${PROFILE_PATH}"
|
||||
touch "${BASH_PROFILE_PATH}"
|
||||
touch "${ZSH_PROFILE_PATH}"
|
||||
|
||||
MY_VMOPTIONS_SHELL_NAME="jetbrains.vmoptions.sh"
|
||||
MY_VMOPTIONS_SHELL_FILE="${HOME}/.${MY_VMOPTIONS_SHELL_NAME}"
|
||||
|
||||
rm -rf "${MY_VMOPTIONS_SHELL_FILE}"
|
||||
|
||||
if [ $OS_NAME = "Darwin" ]; then
|
||||
for PRD in $JB_PRODUCTS; do
|
||||
ENV_NAME=$(echo $PRD | tr '[a-z]' '[A-Z]')"_VM_OPTIONS"
|
||||
|
||||
launchctl unsetenv "${ENV_NAME}"
|
||||
done
|
||||
|
||||
rm -rf "${PLIST_PATH}"
|
||||
|
||||
sed -i '' '/___MY_VMOPTIONS_SHELL_FILE="${HOME}\/\.jetbrains\.vmoptions\.sh"; if /d' "${PROFILE_PATH}" >/dev/null 2>&1
|
||||
sed -i '' '/___MY_VMOPTIONS_SHELL_FILE="${HOME}\/\.jetbrains\.vmoptions\.sh"; if /d' "${BASH_PROFILE_PATH}" >/dev/null 2>&1
|
||||
sed -i '' '/___MY_VMOPTIONS_SHELL_FILE="${HOME}\/\.jetbrains\.vmoptions\.sh"; if /d' "${ZSH_PROFILE_PATH}" >/dev/null 2>&1
|
||||
|
||||
echo 'done.'
|
||||
else
|
||||
sed -i '/___MY_VMOPTIONS_SHELL_FILE="${HOME}\/\.jetbrains\.vmoptions\.sh"; if /d' "${PROFILE_PATH}" >/dev/null 2>&1
|
||||
sed -i '/___MY_VMOPTIONS_SHELL_FILE="${HOME}\/\.jetbrains\.vmoptions\.sh"; if /d' "${BASH_PROFILE_PATH}" >/dev/null 2>&1
|
||||
sed -i '/___MY_VMOPTIONS_SHELL_FILE="${HOME}\/\.jetbrains\.vmoptions\.sh"; if /d' "${ZSH_PROFILE_PATH}" >/dev/null 2>&1
|
||||
|
||||
rm -rf "${KDE_ENV_DIR}/${MY_VMOPTIONS_SHELL_NAME}"
|
||||
echo "done. you'd better log off first!"
|
||||
fi
|
Loading…
Reference in New Issue
Block a user