0

I’m looking to run a shell script by double-clicking it from desktop gui for my ubuntu server (v20).

I would like the shell script to run these commands in a terminal window when I double click it:

  • sudo -i (prompt for password) then under root =
  • xhost +
  • unset XAUTHORITY
  • export DISPLAY=:0
  • ssa -local

it must run in that order as I have to do this so I can run hp ssa under root

I’ve tried all sorts of ways to get it to run, but I cannot. Any help is appreciated!

Thanks

3
  • So this is a Ubuntu Core 20 server install, and not a Ubuntu 20.04 LTS Server install (the 20 is used to signify a snap only product, the 20.04 or year.month format is used for deb based products).
    – guiverc
    Nov 28, 2021 at 0:12
  • @guiverc, its just a normal 20.04 install Nov 28, 2021 at 11:31
  • Well please say so (ie. edit your question & I can remove my comment(s)), as 20 and 20.04 are different products; Ubuntu uses the year.month format for deb based products, and year format only for specialist snap only products (20 has 10 year supported life; longer than 20.04 LTS which has 5 years of standard that can be extended an extra 5 years via ESM... the products differ...)
    – guiverc
    Nov 28, 2021 at 11:33

1 Answer 1

0

For Gnome Terminal, which comes with a default Ubuntu install, that can be achieved with a custom profile. In the Preferences dialog, create a new profile, e.g. rootshell. On the "Command" tab of the new profile, specify your shell script as "Custom command". That can be exactly as you hinted to, however preferably include a shebang.

#!/bin/bash
sudo -i
xhost +
unset XAUTHORITY
export DISPLAY=:0
ssa -local

In your .desktop launcher, launch this custom terminal as:

Exec=gnome-terminal --window-with-profile=rootshell

Double-clicking the launcher will start Gnome Terminal with the custom profile. On startup, Gnome Terminal will run the script: your user password is asked to elevate priviledges to root. Subsequent commands are executed, and finally, you are dropped at a root prompt, with an environment customized through your script.

If you use a different terminal emulator, a similar approach will apply in most cases. However, details on how to configure will vary.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .