Score:0

Start gnome-session as sudo with startup task

jp flag

I have a startup (task.desktop) task located in the /etc/xdg/autostart folder. It looks like this

[Desktop Entry]
Version=1.0
Name=MAAS
Comment=Metal As A Service
Exec=/home/ubuntu/initmaas.sh
Path=/home/ubuntu/
Terminal=true
Type=Application
X-GNOME-Autostart-enabled=true
Categories=Utility;Development

And it starts the initmaas.sh script which is stored in /home/ubuntu/initmaas.sh directory and looks like this:

#!/bin/bash
gnome-terminal -- sudo '/home/ubuntu/maas.sh'

Everytime I login, it asks for a prompt of the password which is fine. I give the sudo password and the task starts correctly. My question is:

How can I make the script start automaticallly by storing he password in a variable or in a text file in the initmaas.sh file. The thing is that I need to see what it does each time I or other people login because the script does a lot of things, and also I need to reinstall it on a lot of machines. The idea is to avoid to put the password each time manually. Any Ideas? Thanks a lot

David avatar
cn flag
You want full time sudo access all the time? This is generally not a good idea.
Andy McRae avatar
jp flag
hi, not full time. Just for this task. I know but Its not important. The machines are not important.
mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.