Commit 235c5a35 authored by jinliang's avatar jinliang

update userdata for windows

parent 972d4f23
...@@ -47,26 +47,28 @@ public class AliEcsRemoteClient { ...@@ -47,26 +47,28 @@ public class AliEcsRemoteClient {
// PowerShell UserData for Windows ECS // PowerShell UserData for Windows ECS
private static String getUserData() { private static String getUserData() {
return "$script = @\"\n" return "[bat] \n"
+ "Set-ExecutionPolicy Bypass -Scope Process -Force;\n" + "rem Set Execution Policy (Note: Batch doesn't directly support this) \n"
+ "$ErrorActionPreference = 'Stop';\n" + "rem Set-ExecutionPolicy Bypass -Scope Process -Force; \n"
+ "# Configure 3proxy\n" + "rem The above line is not needed in batch since it can be controlled from the PowerShell session itself \n"
+ "$configContent = @\"\n"
+ "users %s:CL:%s\n" + "rem Set error action preference \n"
+ "allow %s *\n" + "set ErrorActionPreference=Stop \n"
+ "auth strong\n"
+ "proxy -p8880\n" + "rem Configure 3proxy settings \n"
+ "proxy -p8881 -a\n" + "echo users %s:CL:%s > C:\\3proxy-0.9.4-x64\\bin64\\3proxy.cfg \n"
+ "socks -p8882\n" + "echo allow %s * >> C:\\3proxy-0.9.4-x64\\bin64\\3proxy.cfg \n"
+ "flush\n" + "echo auth strong >> C:\\3proxy-0.9.4-x64\\bin64\\3proxy.cfg \n"
+ "\";\n" + "echo proxy -p8880 >> C:\\3proxy-0.9.4-x64\\bin64\\3proxy.cfg \n"
+ "Set-Content -Path 'C:\\3proxy-0.9.4-x64\\bin64\\3proxy.cfg' -Value $configContent -Force;\n" + "echo proxy -p8881 -a >> C:\\3proxy-0.9.4-x64\\bin64\\3proxy.cfg \n"
+ "\n" + "echo socks -p8882 >> C:\\3proxy-0.9.4-x64\\bin64\\3proxy.cfg \n"
+ "# Start 3proxy service\n" + "echo flush >> C:\\3proxy-0.9.4-x64\\bin64\\3proxy.cfg \n"
+ "Start-Process 'net' -ArgumentList 'start 3proxy' -NoNewWindow -Wait;\n"
+ "\"@;\n" + "rem Start the 3proxy service \n"
+ "$script | Out-File -FilePath 'C:\\Windows\\Temp\\userdata.ps1' -Force;\n" + "net start 3proxy \n"
+ "Start-Process PowerShell -ArgumentList 'C:\\Windows\\Temp\\userdata.ps1' -NoNewWindow -Wait;";
+ "rem End script \n"
+ "exit \n";
} }
/* /*
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment