Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

packetfix-hander: don't hardcode Wireshark.app installation path into the apple script #19

Open
maslovalex opened this issue Apr 3, 2024 · 5 comments
Labels
enhancement New feature or request

Comments

@maslovalex
Copy link

Current packetfix-handler expects Wireshark to be installed under /Applications/ which is not always the case, e.g. macports installs it under the /Applications/MacPorts/

Couldn't find the sources of AppleScript to make a PR :) so, here are the changes to make it a bit better than it is:

do shell script "/Applications/Wireshark.app/Contents/MacOS/Wireshark -k -i packetflix -o gui.window_title:\"" & title & "\" -o extcap.packetflix.url:\"" & thisURL & "\""

to something like

set wiresharkBundleId to id of application "Wireshark"
set theWorkspace to current application's NSWorkspace's sharedWorkspace()
set wiresharkPath to ((theWorkspace's URLForApplicationWithBundleIdentifier:wiresharkBundleId)'s |path|()) as text
	
do shell script wiresharkPath & "/Contents/MacOS/Wireshark -k -i packetflix -o gui.window_title:\"" & title & "\" -o extcap.packetflix.url:\"" & thisURL & "\""

This is not my solution, btw, just found a nice one from https://www.macscripter.net/t/determining-path-to-application-without-using-path-to-command/73645/5

@thediveo
Copy link
Collaborator

thediveo commented Apr 3, 2024

Thank you very much for your report and information on how to fix it, highly appreciated!

With my current limited understanding of these macos corners, the Apple script "sources" are inside https://github.com/siemens/cshargextcap/tree/main/packaging/macos/packetflix-handler: this "exploded" bundle can be loaded into Apple's Script Editor. Yes, that's very inconvenient, not something that fits into modern CI/CD, but Apple doesn't seem to recognize this as outdated. If there is actually a way to build from proper source in a Github action runner, I would be thankful for pointers.

I'll look into this.

@maslovalex
Copy link
Author

Unfortunately I am like on the same boat: not that familiar with AppleScriptEditor and especially would it be possible to actually create app in GitHub action.

If macOS runner is available than maybe something like osacompile -o packetflix-handler.app MyScript.applescript would do the trick. MyScript.applescript would be a plain text.
Maybe also -x as man has https://ss64.com/mac/osacompile.html

@hellt
Copy link
Contributor

hellt commented Apr 23, 2024

Hi @maslovalex
while the apple script knocks me off everytime I see its syntax, the snippet you provided seems to be correct (who tf someone came up with this syntax I have no idea)

It is actually quite easy to modify the script, you open the app Script Editor and with it open up the .app bundle.

Anyways, I added the snippet you provided and zipped it:

packetflix-handler.zip

It worked on my system where the app is installed natively (no macports), give it a try and hopefully it "just works"

@maslovalex
Copy link
Author

Yes, it works for me also as I have modified it manually in my system same way you described 👍

@thediveo
Copy link
Collaborator

nota bene: we should consider using nohup in order to be able to finish the script immediately after start. This would allow starting multiple Wireshark-Edgeshark sessions in parallel from the web UI. Beware of quoting...

do shell script "nohup open -a " & quoted form of appPath & " --args " & quoted form of arguments & " > /dev/null 2>&1 &" 

@thediveo thediveo added the enhancement New feature or request label Sep 27, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

3 participants