Run 3-rd paprty application at startup as root

Recently I installed an application, under SUSE 10.3.It is a java application for managing UPS unit attached to my machine on /dev/ttyS0.There is a script for starting it called start.sh.
Is there a way to automatically start this script at login in KDE,but as root, because as a user that I am using in KDE it did not work ?
I tried to use script ‘sux -c start.sh’ in Autostart folder, but with no luck. I think it is, because I have to type the password for root after ‘sux’ command, but KDE did not prompt me for this.

If you are content to do it when the computer boots, you could put this line into the file /etc/init.d/boot.local: /path_to/start.sh

I’m wondering if your script could be placed in

/etc/X11/xinit/xinitrc.d

Then it would be executed when X session starts.

(Not sure how root processes would be handled though. Someone more knowledgeable than me may be able to explain further.)

I tried to put ‘/path_to_script/start.sh’ in my /etc/init.d/boot.local, but nothing happend after login in KDE.Besides this script runs Java application in KDE and I think it has to be called in runlevel 5.
Also tried to put ‘/path_to_script/start.sh’ in /home/user/.xinitrc, but again it runs without root privileges.If I put there ‘sux -c /path_to_script/start.sh’ nothing happens.
There has to be a way to call it with root privileges at login in KDE…

I think it would need to be in /etc/X11/xinit/xinitrc.d for it to work properly.

There is aslo a possibility of putting script in ~/.kde/Autostart, but you would need to adjust sudoers file so that the relevant user has permission to run script with root privileges. I read that while googling, but beyond my current experience.

I’ve already tried that with .kde/Autostart and editing of sudoers, but again with no luck, it start with user privileges. Is there a more simple way ?

It is a java application for managing UPS unit attached to my machine on /dev/ttyS0.There is a script for starting it called start.sh.
Is there a way to automatically start this script at login in KDE,but as root, because as a user that I am using in KDE it did not work ?

I’m wondering if the reason it didn’t work as regular user is more to do with permissions concerning your serial port. Is the relevant user a member of ‘uucp’ group? Just a guess…

BTW, I found this thread, concerning a person using cron to launch a job automatically within a graphical environment. I wonder if this could work for you. Beyond my skills though…

On Sat February 21 2009 06:26 pm, terziyski wrote:

>
> I’ve already tried that with .kde/Autostart and editing of sudoers, but
> again with no luck, it start with user privileges. Is there a more
> simple way ?
>
terziyski;

Have you considered setting up a root cron tab that runs at boot. Something
like:


@reboot sleep xx;<your script>

where xx is the number of seconds after the boot to run the script. You would
just need xx long enough to be sure kde was up.

P. V.
“We’re all in this together, I’m pulling for you.” Red Green

If so, how can I check that my user has a necessary permissions for using /dev/ttyS0 ?

On Sat February 21 2009 06:46 pm, deano ferrari wrote:

>
> BTW, I found this ‘thread’
> (http://bbs.archlinux.org/viewtopic.php?pid=281421), concerning a person
> using cron to launch a job automatically within a graphical environment.
> I wonder if this could work for you. Beyond my skills though…
>
>
deano;
We seem to be on the same track (and running similar hardware) this
weekend. :wink: You just seem to type a bit faster than I do.

P. V.
“We’re all in this together, I’m pulling for you.” Red Green

As user, type

groups

You can use YaST > Security and Users > User and Group Management to Edit existing user, and add ‘uucp’ group.

@PV It would seem so, but I only wished my skills allowed for a more definitive solution. :wink:

Thank you for your quick answers guys.I tried with crontab, but again nothing happens. I could not imagine that it would be so hard to do this.

On Sat February 21 2009 08:36 pm, terziyski wrote:

>
> Thank you for your quick answers guys.I tried with crontab, but again
> nothing happens. I could not imagine that it would be so hard to do
> this.
>
>
terziyski;

What happens when you manually start this after your log in? Does it work? Do
you get any errors? If so what?

P. V.
“We’re all in this together, I’m pulling for you.” Red Green

On Sat February 21 2009 09:10 pm, PV wrote:

> On Sat February 21 2009 08:36 pm, terziyski wrote:
>
>>
>> Thank you for your quick answers guys.I tried with crontab, but again
>> nothing happens. I could not imagine that it would be so hard to do
>> this.
>>
>>
> terziyski;
>
> What happens when you manually start this after your log in? Does it work?
> Do you get any errors? If so what?
Also;
Have you tried sudo or kdesu instead of sux?

P. V.
“We’re all in this together, I’m pulling for you.” Red Green

I tried with sudo, but it does not work that way, because it is a X11 application.Also tried kdesu - still does not works, because it is not KDE application - it is a 3-rd party application and it has to be run with sux.
But finally I tried Deano’s suggestion to make my user member of uucp group. Then I putted symlink in ~.kde/Autostart to start.sh script and it worked just fine.
I think Deano was right about permissions of my user for my serial ports.
Thank you guys for your help.

But finally I tried Deano’s suggestion to make my user member of uucp group. Then I putted symlink in ~.kde/Autostart to start.sh script and it worked just fine.
I think Deano was right about permissions of my user for my serial ports.
Thank you guys for your help.

Good work. Its generally better practice if you can get an app or utility to run with user permissions than as root anyway.