3

I have a bash script which needs root privileges. I run it by sudo ./script.sh.

I would like to create run configuration in IntelliJ IDEA, that runs this script with root privileges. It doesn't matter if it asks for password later.

Is it possible without running IDE as root or using tools like gksudo or gksu?

koto
  • 720
  • 2
  • 9
  • 29

1 Answers1

2

It was not super clear what Bash integration you use. Probably something like the plugin: BashSupport

https://plugins.jetbrains.com/plugin/4230-bashsupport

The runtime configuration window for this plugin seems not to expose permission configuration.

Hence, a simple pragmatic solution could be to actually write two scripts.

  1. You keep your script as it is
  2. Create a second one that calls your current one with sudo

sudo ./myscript.sh

enter image description here

dbalakirev
  • 1,918
  • 3
  • 20
  • 31
  • This would be sufficient for my needs, but I have one issue here. I run the wrapper script, and it asks for password. Currently the password is visible as I type it, and I would like it to be masked (or invisible). Any idea on how to deal with it? EDIT: and yes, I use this bashsupport plugin – koto Sep 26 '17 at 12:14
  • 1
    Now I have access to a different version of IDEA with probably a different version of the plugin, but this is what happens for me. If I start IDEA from an environment where tty is present (so instead of the OS menu you start using the binary command) it actually asks for the sudo password over the command line where I started idea from (process if foreground). This nicely hides the password. – dbalakirev Sep 26 '17 at 12:59
  • This is working for me as well, and it's sufficient by now. Thanks! – koto Sep 26 '17 at 13:26
  • Cool, happy to hear that :) – dbalakirev Sep 26 '17 at 14:26