mas-cli / mas

:package: Mac App Store command line interface
MIT License
10.79k stars 272 forks source link

Suggestion - changes to improve automation #70

Open edrozenberg opened 7 years ago

edrozenberg commented 7 years ago

I'm running mas over ssh to several machines to automate install of mas apps. Different machines may be signed into different mas accounts, and the apps each one has purchased may be different.

Currently attempting to install an app that's not "purchased" blocks the mas tool. Also not being logged in blocks the tool. Blocks in the sense a dialog would normally pop up when running locally on the machine, but remotely over ssh there is no way to interact with dialog boxes popped up by the Apple MAS app.

The following, which may or may not be possible, would make proper automation possible:

rodionovd commented 7 years ago

Thanks for your suggestions Eduard! I'll take a look whether it's possible to avoid blocking in these situations.

edrozenberg commented 7 years ago

@rodionovd Thanks!

Another block scenario I ran into - for some apps (maybe all apps?), when the app is open/running, the Mac App Store GUI pops up a dialog to ask whether it's ok to close to app to be able to update it.

rodionovd commented 7 years ago

Oh nice one! Will look into this too

allansan commented 7 years ago

Observation: Running mas signin as root (only done for testing purposes on a VM!) seems to enable mas to run over SSH connections.

I was doing some testing using a launchd item to call a script locally to make things run, however I'd forgotten for a second that I'd put the launchd item in /Library/LaunchDaemons and therefore it wouldn't run as root. Just for a laugh I signed in as root and now mas is running over SSH..

[EDIT] I have now tested this again having signed out of mas as root and moved the launchd item to the users local homeDir (~/Library/LaunchDaemons/) and re-run the script and I can confirm that this is also working. I'll have to reset the VM to test it continues to work without signing in as root.

rodionovd commented 7 years ago

@allansan great insight, thanks! Will take that into account

geerlingguy commented 7 years ago

Another thing—could you maybe add some sort of signin status command that would return 0/success if signed in, or 1/error if not signed in? That way it could be used as a flag to let the automating software know whether or not to pop a prompt for login...

I'm using mas to finish the last piece of install automation via Ansible with my mac-dev-playbook project—see https://github.com/geerlingguy/mac-dev-playbook/issues/11. Thanks so much for building/maintaining this!

rodionovd commented 7 years ago

Another thing—could you maybe add some sort of signin status command that would return 0/success if signed in, or 1/error if not signed in? That way it could be used as a flag to let the automating software know whether or not to pop a prompt for login...

@geerlingguy such a great idea! Would be awesome if you create a PR for this ⭐️(else I'll implement it myself at the weekend anyway)

rodionovd commented 7 years ago

@geerlingguy I just realized you can actually use mas account command to figure out whether you're signed in or not: it will exit with1 if you're not currently signed in and with 0 if you are.

geerlingguy commented 7 years ago

@rodionovd - You're quite correct!

 21:24:00 ~ $ mas account
user@example.com
 21:24:04 ~ $ echo $?
0

 21:24:14 ~ $ mas account
Not signed in
Error: Not signed in

 21:24:18 ~ $ echo $?
1

It's adequate for my needs. Thanks!

yustein commented 7 years ago
screenshot 2017-04-11 20 57 04

What do you guys recommend to interact with the GUI errors the app store gives? They can easily be bypassed by clicking a button but how do we do that in a script so that the app updates continue?

use case:

If you have an app purchased from another app store, the app store app will give an error but the error can be bypassed by simply clicking OK and the updates do continue.

One possibility is to mute the errors and another one is to use some advanced scripting to interact with the GUI prompts.

aquintiliano commented 6 years ago

@allansan I am not sure on what you did, but I am unable to run mas over SSH even using sudo mas signin... does it really work?