On Sun, Nov 1, 2009 at 3:23 PM, ronen <
nar...@gmail.com> wrote:
> Another issue that Iv stumbled upon relates to gpg keys:
>
> sh 'gpg --keyserver hkp://
keyserver.ubuntu.com:11371 --recv-key
> 881574DE && gpg -a --export 881574DE | sudo apt-key add'
>
> Under Ubuntu this works when running automateIt with the current user,
> the following recipe require sudo user (iv ommited the sources.list
> edit & the apt update):
>
> sh 'gpg --keyserver hkp://
keyserver.ubuntu.com:11371 --recv-key
> 881574DE && gpg -a --export 881574DE | sudo apt-key add'
>
> package_manager.install('some_package')
>
> Running it with sudo permission (sudo automateIt) will make gpg
> unhappy (something with current user not owner of ~/.gnupg/gnu.conf),
> the only solution that I can think of is some how enable different
> parts of the recipe run with different users.
This seems to be an issue with how gpg behaves under sudo, and not automateit.
My guess is that sudo imports some of your non-root user's environment
variables, like HOME, and gpg is then trying to use these
unsuccessfully. I recommend trying to figure out what environmental
variables gpg is trying to use and set them in your sudo'ed shell. If
you can figure out how to trick it into working, please post the
solution.
On my system, I was able to import the key by doing one of these:
1. Create an AutomateIt recipe like this, note the "-- -" at the end
of "apt-key" instructions which my system required:
881574DE && gpg -a --export 881574DE | apt-key add -- -"
Execute the recipe with a command that sets the HOME variable for the
initial sudo:
HOME=/root sudo automateit myrecipe.rb
2. Or set the HOME variable inside the "sh" command:
sh "export HOME=/root; gpg --keyserver
--export 881574DE | apt-key add -- -"
And executing it like:
sudo automateit myrecipe.rb
> Id like to thank you for a cool & useful framework!
> Looking forward to learn more about it
Thanks!
-igal