Login  •  Register


The time is now: Fri Feb 23, 2018 12:50 pm

Emaculation wiki  •  Delete all board cookies



Post new topic  Reply to topic Page 1 of 2 [ 33 posts ]    Go to page 1, 2  Next
Print view Previous topic  |  Next topic
Author Message
PostPosted: Wed Nov 08, 2017 12:56 am 
Offline
Apple Corer

Joined: Wed Apr 10, 2013 9:32 am
Posts: 219
[This is the continuation of http://emaculation.com/forum/viewtopic.php?f=34&p=58076#p58076]


The first "distribution" of afpfs-ng-OSX for Snow Leopard and up is ready as .pkg installer.
"Packages" made it easy to create.


Some quick information on it:

• First install Fuse for macOS from https://osxfuse.github.io/ (don't install it via Homebrew, it probably won't work for afpfs-ng-OSX).
• Then get afpfs-ng-OSX —>here<— (the 10.6 .pgk was only tested on OS X 10.6, the 10.8 .pkg was tested on OS X 10.8 and macOS 10.12). Ctrl-click on it and choose 'open'.
• Open Terminal and start Fuse for macOS and the afpfs daemon:
Code:
/Library/Filesystems/osxfuse.fs/Contents/Resources/load_osxfuse; afpfsd
• Connect to a Macintosh or emulator running Classic MacOS (should work for 7.6 through 9.2.2) by entering:
Code:
mkdir ~/mount1; mount_afp2 afp://192.168.1.95/share1 ~/mount1
where "192.168.1.95" is the IP of the machine running Classic MacOS (you could also use its name), "share1" the name of the shared folder and "mount1" (twice) the folder serving as mount point in your user folder ("~/").


AFP2 doesn't support password encryption, which is not implemented in afpfs-ng-OSX anyway.
Therefore, for connecting to AFP3 servers use the built-in functionality of macOS/OS X.

afpfs-ng-OSX does connect through AFP, but it does not actually report that to macOS/OS X. Therefore resource forks and metadata are not supported. I'm working on a workaround for critical files, but it will take some time until I get that finished.

Also, I'm working on a GUI based on AppleScript that starts Fuse for macOS, shows all AFP2 servers on the network and provides mounting by clicking on their shared volumes. It should also give the mounts sensible names like "AFP2_ServerName_VolumeName" (i.s.o. "OSXFUSE Volume 0 (afpfsd)").
I think I have most of the underlying "do shell script" commands for afpfs-ng-OSX ready.


As mentioned, afpfs-ng-OSX is tested on Snow Leopard (which actually still seems to work for AFP2 without it), Mountaion Lion, and Sierra.

Any help in testing on other macOS/OS X versions will be very much appreciated!


Last edited by mabam on Wed Nov 08, 2017 11:18 pm, edited 1 time in total.


Top
 Profile  
Reply with quote Post a reply  
PostPosted: Sat Nov 18, 2017 11:56 pm 
Offline
Apple Corer

Joined: Wed Apr 10, 2013 9:32 am
Posts: 219
I have written an AppleScript that requests AFP server information from all IP's on the network. From the responses it displays AFP2.x servers (only if not capable of AFP3.x) to select from a list:
Image
Upon choosing a server and clicking "Continue …" its shared volumes are requested which are again displayed as list to select from (unfortunately, AppleScript does not allow to combine both lists into one dialog):
Image
Upon clicking "Mount" the script creates the "mount_afp2 …" command prepended by "/usr/local/bin" as required by AppleScript. Now I think the problem is that mount_afp2 passes stuff to another binary without its location. That binary cannot be called directly. I tried having AppleScript run a LaunchAgent that executes a bash script. But that wouldn't work without the location prefix either and therefore resulted in the same problem.
I do not want to have the AppleScript execute a bash script directly as that would make a Terminal window pop up.

Does anyone know a solution for this issue?

(Support for password protected shares will follow at a later stage.)


Top
 Profile  
Reply with quote Post a reply  
PostPosted: Sun Nov 19, 2017 5:41 am 
Offline
Forum All-Star
User avatar

Joined: Fri Nov 27, 2009 5:11 am
Posts: 1985
Location: Emaculation.com
The best solution is probably to bundle mount_afp2 inside the AppleScript application in the resources folder, along with all the other components you need.

You could use lsof to trace the file chain to see what the dependencies are....


Top
 Profile  
Reply with quote Post a reply  
PostPosted: Mon Nov 20, 2017 1:07 am 
Offline
Apple Corer

Joined: Wed Apr 10, 2013 9:32 am
Posts: 219
I'm using a sub-folder of /etc where I put stuff as I also need a place for the mount points and link to them with sensible names.

For days I was looking for a solution to the problem with calling mount_afp2. It wasn't until you responded that I found Platypus which compiles a (bash) script into an app. Its documentation mentions the possibility to use bash with the -l flag making it "act as if it had been invoked as a login shell". Maybe this also would have worked with the LaunchAgent, but using Platypus is easier and the created app can run invisibly or set to display errors if needed.

Nonetheless, thanks for your tip!


Top
 Profile  
Reply with quote Post a reply  
PostPosted: Tue Nov 21, 2017 4:25 am 
Offline
Forum All-Star
User avatar

Joined: Fri Nov 27, 2009 5:11 am
Posts: 1985
Location: Emaculation.com
You're welcome :) I tend to use Platypus to create all my apps that have scripts of some sort, because it's just so easy to debug and deploy, with just a few plist and script file changes required after building.


Top
 Profile  
Reply with quote Post a reply  
PostPosted: Thu Nov 23, 2017 2:23 pm 
Offline
Apple Corer

Joined: Wed Apr 10, 2013 9:32 am
Posts: 219
After inserting some lines needed if there are errors and amending a few other things, it looks like the script is ready. Except there is one thing I can't find a solution for since a while now: In the end of the script it is supposed to launch the "mount app" I have created with Platypus.
Code:
tell application "/etc/afpfs-ng-OSX/afpfs-ng-OSX.mountcmd.app" to launch
But after every restart of the host machine the mount app won't launch at first attempt. Only at the second and after.

Is there a solution for this?

(If I have an AppleScript only containing the line to launch the mount app, it does launch at first attempt after a restart.)


Top
 Profile  
Reply with quote Post a reply  
PostPosted: Thu Nov 23, 2017 4:02 pm 
Offline
Forum All-Star

Joined: Tue Oct 14, 2008 12:12 am
Posts: 813
mabam wrote:
After inserting some lines needed if there are errors and amending a few other things, it looks like the script is ready. Except there is one thing I can't find a solution for since a while now: In the end of the script it is supposed to launch the "mount app" I have created with Platypus.
Code:
tell application "/etc/afpfs-ng-OSX/afpfs-ng-OSX.mountcmd.app" to launch
But after every restart of the host machine the mount app won't launch at first attempt. Only at the second and after.

Is there a solution for this?


I've had similar problems. I hope this message isn't time-wasting, but here are some possible alternatives that I remember using:

Code:
do shell script "open /etc/afpfs-ng-OSX/afpfs-ng-OSX.mountcmd.app"


Code:
tell application "Finder" to open file "/etc/afpfs-ng-OSX/afpfs-ng-OSX.mountcmd.app"


I'm just guessing at the syntax in both examples, but these are two ideas.


Top
 Profile  
Reply with quote Post a reply  
PostPosted: Thu Nov 23, 2017 7:36 pm 
Offline
Apple Corer

Joined: Wed Apr 10, 2013 9:32 am
Posts: 219
Thanks for your suggestions. The first one I had tried already. The second one I did just now but it didn't help either.

mabam wrote:
(If I have an AppleScript only containing the line to launch the mount app, it does launch at first attempt after a restart.)

The above means that the app might launch if I put it at the beginning of the script. That will make it the second try when the required launch at the end of the script is attempted.
I probably know a way to amend the app so it doesn't have any effect when first launched at the beginning.


Top
 Profile  
Reply with quote Post a reply  
PostPosted: Fri Nov 24, 2017 12:16 am 
Offline
Forum All-Star

Joined: Tue Oct 14, 2008 12:12 am
Posts: 813
One last idea (probably as useless as the others):

Code:
tell application "System Events" to open [etc.]


Apologies if this is just more time-wasting! I'm always annoyed at wasting time over pointless suggestions, but all these have worked in the past in other circumstances.


Top
 Profile  
Reply with quote Post a reply  
PostPosted: Fri Nov 24, 2017 1:07 am 
Offline
Apple Corer

Joined: Wed Apr 10, 2013 9:32 am
Posts: 219
I had tried that already but it doesn't work either. But that doesn't mean that you are wasting my time. Thank you for taking the time!

I have copied the script over from Mountain Lion to my Sierra VM to test. Same issue there except that the script get stopped after a while.

The script line is wrapped in an if block. Maybe that is related. I'm done for today, but that is something I'll have to look into.


Top
 Profile  
Reply with quote Post a reply  
PostPosted: Fri Nov 24, 2017 1:18 pm 
Offline
Apple Corer

Joined: Wed Apr 10, 2013 9:32 am
Posts: 219
As last action in the AppleScript (which will run as app once finished) it launches an app that has a bash script compiled into it. I have extended that bash script by a line that will kill the AppleScript app if still running (which, as discussed, is the case at first run after reboot).

This is not a beautiful solution to my problem, but a working one.
Any better suggestions are welcome!


Top
 Profile  
Reply with quote Post a reply  
PostPosted: Sun Dec 17, 2017 3:35 am 
Offline
Tinkerer
User avatar

Joined: Wed Jun 18, 2008 5:53 am
Posts: 74
This solution looks awesome. Is it still being worked on?


Top
 Profile  
Reply with quote Post a reply  
PostPosted: Sun Dec 17, 2017 8:34 am 
Offline
Apple Corer

Joined: Wed Apr 10, 2013 9:32 am
Posts: 219
I have no time right now and probably won't have the coming weeks. But I'll get back to it eventually.


Top
 Profile  
Reply with quote Post a reply  
PostPosted: Sun Jan 21, 2018 10:10 pm 
Offline
Apple Corer

Joined: Wed Apr 10, 2013 9:32 am
Posts: 219
A first version of the GUI is ready. I'm working on an updated package installer.

The GUI is controlled through the AppleScript menu in the menu bar (couldn't figure how to make it a stand-alone menu – the related online tutorials are above me). I'd like to have the package installer activate the AppleScript menu. Manually that is done by ticking the box "Show Script menu in menu bar" in the Script Editor settings. I suppose this setting is saved in some .plist file, but I couldn't find it.

Is there a way to set that option through an AppleScript or shell script?
(Well, if someone can tell me the location of the .plist file I know there is a way using a shell script.)


EDIT:
Found it: ~/Library/Preferences/com.apple.systemuiserver.plist
But it is not in plain text and can only be edited manually using XCode. So I won't be able to automate that.


Top
 Profile  
Reply with quote Post a reply  
PostPosted: Mon Jan 22, 2018 5:55 pm 
Offline
Forum All-Star
User avatar

Joined: Fri Nov 27, 2009 5:11 am
Posts: 1985
Location: Emaculation.com
mabam wrote:
Found it: ~/Library/Preferences/com.apple.systemuiserver.plist
But it is not in plain text and can only be edited manually using XCode. So I won't be able to automate that.


There's a command line tool to convert binary plists to XML for editing and then convert them back after:

Code:
plutil -convert <xml1|binary1> <file.plist>


Top
 Profile  
Reply with quote Post a reply  
PostPosted: Tue Jan 23, 2018 4:02 pm 
Offline
Apple Corer

Joined: Wed Apr 10, 2013 9:32 am
Posts: 219
Wow, that works, thank you!

The only thing is that if I do "killall SystemUIServer" the AppleScript menu doesn't always appear though it is contained in /Users/markus/Library/Preferences/com.apple.systemuiserver.plist . Is there any way to solve that?


Top
 Profile  
Reply with quote Post a reply  
PostPosted: Tue Jan 23, 2018 4:42 pm 
Offline
Forum All-Star
User avatar

Joined: Fri Nov 27, 2009 5:11 am
Posts: 1985
Location: Emaculation.com
Yes, there's another service you need to reset as well -- but for the life of me I can't remember what it is.


Top
 Profile  
Reply with quote Post a reply  
PostPosted: Tue Jan 23, 2018 7:14 pm 
Offline
Apple Corer

Joined: Wed Apr 10, 2013 9:32 am
Posts: 219
I've found a solution: After killing SystemUIServer I
Code:
open "/System/Library/CoreServices/Menu Extras/Script Menu.menu"

That makes it run for the present session. And for the next one it gets started automatically as it is registered in SystemUIServer's .plist file.


Top
 Profile  
Reply with quote Post a reply  
PostPosted: Tue Jan 23, 2018 8:27 pm 
Offline
Forum All-Star
User avatar

Joined: Fri Nov 27, 2009 5:11 am
Posts: 1985
Location: Emaculation.com
If you're doing that, you could also launch your own custom menu. There's a few frameworks out there that'll do the heavy lifting for you, and let you load in the menu items you want.


Top
 Profile  
Reply with quote Post a reply  
PostPosted: Tue Jan 23, 2018 9:18 pm 
Offline
Apple Corer

Joined: Wed Apr 10, 2013 9:32 am
Posts: 219
adespoton wrote:
If you're doing that, you could also launch your own custom menu.
Not sure it would really be a custom menu as it gets loaded into the AppleScript menu.

EDIT: You're right, it would be a separate menu. Error in reasoning on my side ...

adespoton wrote:
There's a few frameworks out there that'll do the heavy lifting for you, and let you load in the menu items you want.
If you could point me to any such framework I would be thankful as I haven't found one yet. Maybe something for a future version.


Last edited by mabam on Wed Jan 24, 2018 4:12 pm, edited 1 time in total.


Top
 Profile  
Reply with quote Post a reply  
PostPosted: Tue Jan 23, 2018 9:33 pm 
Offline
Apple Corer

Joined: Wed Apr 10, 2013 9:32 am
Posts: 219
A first version of the GUI is ready.
Find a full installer at https://github.com/mabam/afpfs-ng-OSX/releases.

• The GUI doesn't support password protected shares yet. For the time being you will have to use the command line for that.
(Through the GUI it actually connects to such shares without asking for a password. But neither does the volume show any content nor can you copy anything onto it.)
• When connected to multiple AFP2.x volumes, it is not possible to unmount a single one. afpfs-ng-OSX is only able to unmount ALL those volumes at once (even if you use the command line).
• Resource forks and meta data are NOT preserved (neither here it helps to use the command line). For a future version I'm planning a conversion mechanism for critical files. Without it macOS/OS X splits such data into "." preceded files when writing on volumes mounted through afpfs-ng-OSX. I might have an automated AppleScript remove them in future.

Please report any problems with the GUI. Not sure whether I can solve them, but I will if I can.

EDIT:
All the GUI related (uncompiled) scripts and files can be found here: https://github.com/mabam/afpfs-ng-OSX-GUI.


Top
 Profile  
Reply with quote Post a reply  
PostPosted: Wed Jan 31, 2018 6:43 pm 
Offline
Forum All-Star
User avatar

Joined: Fri Nov 27, 2009 5:11 am
Posts: 1985
Location: Emaculation.com
A request for when you get password protected shares into the GUI version... any chance you could use the keychain for management?

Code:
security unlock-keychain ~/Library/Keychains/login.keychain
<enter password>
security find-internet-password -s smtp.gmail.com -a foo@gmail.com
<dumps keychain attributes, not including password>
security find-internet-password -s smtp.gmail.com -a foo@gmail.com -g
<dumps keychain attributes, including password>


Should be doable to use the security tool to store/retrieve AFP2 password info.


Top
 Profile  
Reply with quote Post a reply  
PostPosted: Thu Feb 01, 2018 12:01 am 
Offline
Apple Corer

Joined: Wed Apr 10, 2013 9:32 am
Posts: 219
adespoton wrote:
... any chance you could use the keychain for management?

From the shell commands you posted, I don't know. I will have to dive into that once I start working on supporting password protected shares. But it would definitely make sense!


Top
 Profile  
Reply with quote Post a reply  
PostPosted: Sun Feb 11, 2018 11:53 pm 
Offline
Apple Corer

Joined: Wed Apr 10, 2013 9:32 am
Posts: 219
In order to preserve the resource fork, I'm working on a conversion mechanism using 'macbinary encode'. But if the original file contains for example an umlaut, StuffIt Expander in Classic MacOS fails on decoding it. Except for manually renaming the source file on the host, I don't have an idea for a workaround yet.

Any suggestions on how I could make this work?


Top
 Profile  
Reply with quote Post a reply  
PostPosted: Wed Feb 14, 2018 6:46 pm 
Offline
Forum All-Star
User avatar

Joined: Fri Nov 27, 2009 5:11 am
Posts: 1985
Location: Emaculation.com
I've been coming up against the same MacRoman encoding issue on a project I'm working on.

Because classic Macs don't understand UTF, but only MacRoman, 7-bit ASCII and Shift-JIS, some sort of translation will be needed prior to encoding. The source code for The Unarchiver might be useful here, as they've somehow dealt with the same issue.

The quick hack, of course, is to just throw out any characters past the 7-bit boundary and encode as ASCII. That's not very nice for any international users though.


Top
 Profile  
Reply with quote Post a reply  
Display posts from previous:  Sort by  
Post new topic  Reply to topic Page 1 of 2 [ 33 posts ]    Go to page 1, 2  Next


Who is online

Users browsing this forum: Google [Bot], LightBulbFun and 2 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
 

Search for:
Jump to:  
Powered by phpBB® Forum Software © phpBB Group