Skip to main content
Solved

Help with a script


Forum|alt.badge.img+4

So we're trying to set things up to use Google Drive as an automagic backup solution here. I've used MacDropAny to set up my proof of concept, but I feel like that'll be too time consuming to set up on all our users' machines. I'm trying to write a script and deploy it via self service once the user's account is created, Google Drive is installed, and signed in. I've got the commands down to move the contents of the Home folder to Google Drive, then create symlinks back in the Home folder, but I'm having trouble getting it to run as local admin, as there's a few sudo's in the script and the account I'd be running it from would not have admin rights. I'm leaning towards ssh-ing into admin@localhost to get admin rights, but am stumbling on feeding the password to the script. Any help would be greatly appreciated!

Best answer by ShaunRMiller83

How are you planning to run your script? If you are running the script using a LaunchDaemon you could have it run as root or run for all users so that shouldn't be an issue. Alternatively you could setup a Casper policy and set it to make available for offline use. Which would functionally be similar.

Also note if you decide to run it thru Casper since the script would run as root technically you won't need the sudo commands since you're already root. Depending on your security & logging that may be a concern or maybe not.

I should have added to my initial post if you do go the LaunchDaemon route you may want to check out Lingon X.

View original
Did this topic help you find an answer to your question?

3 replies

Forum|alt.badge.img+11
  • Valued Contributor
  • 142 replies
  • Answer
  • March 10, 2016

How are you planning to run your script? If you are running the script using a LaunchDaemon you could have it run as root or run for all users so that shouldn't be an issue. Alternatively you could setup a Casper policy and set it to make available for offline use. Which would functionally be similar.

Also note if you decide to run it thru Casper since the script would run as root technically you won't need the sudo commands since you're already root. Depending on your security & logging that may be a concern or maybe not.

I should have added to my initial post if you do go the LaunchDaemon route you may want to check out Lingon X.


Forum|alt.badge.img+15
  • Contributor
  • 67 replies
  • March 10, 2016

Like @ShaunM9483 said, run the script from Casper or as a LaunchDaemon and it will run with root privileges. If you need the script to execute a portion as the user you can use:

sudo -u <username> -i 'command arguments'

So,

sudo -u brad -i 'whoami'

Returns: brad

or:

sudo -u brad -i 'cd ~/Desktop;pwd'

Returns /Users/brad/Desktop

Happy backing up and scripting!
-Brad


Forum|alt.badge.img+4
  • Author
  • New Contributor
  • 6 replies
  • March 10, 2016

Thanks for the help! I was totally overthinking it and just trying to execute the script on my test case rather than deploying via Casper.


Reply


Cookie policy

We use cookies to enhance and personalize your experience. If you accept you agree to our full cookie policy. Learn more about our cookies.

 
Cookie settings