Author Topic: adding script to system startup  (Read 214 times)

Offline shimonl

  • Full Member
  • ***
  • Posts: 155
adding script to system startup
« on: February 11, 2013, 04:22:16 PM »
Hi,
I recently bought a U.P.S. for my computer, after too many
power outages during stormy weather. It connects to the
PC via USB, and comes with a script that will monitor the
power supply. In case of a power outage, it can shut down
cleanly, before the electricity to the computer fails.
(BTW - I was impressed that it came with Linux support!
I had serious fears that it would say something like
"fully supported - when running Redmond software")

What I would like to ask is: How do I get this script to run
automatically at every startup of the computer? So far
I have been opening a terminal, doing su to root, and running
it manually. Obviously I would prefer that when the system
boots, that it be run as root without manual intervention.

Thanks!
Shimon

Offline Just17

  • PCLinuxOS Tester
  • Super Villain
  • *******
  • Posts: 10648
  • MLUs Forever!
Re: adding script to system startup
« Reply #1 on: February 11, 2013, 04:41:42 PM »
A question first .......  have you tried setting up your UPS in Configure your computer - Hardware - Set up UPS?

MLUs rule the roost!

Linux XPS 3.4.38-pclos1.bfs  64 bit
Intel Core2 Quad CPU Q9450 @ 2.66GHz
4 GB RAM
MCP51 High Def Audio
GeForce GTX 550 Ti
PHILIPS  ‎DVD+-RW DVD8701
‎Logitech ‎BT Mini-Receiver
Afatech DTT

Offline shimonl

  • Full Member
  • ***
  • Posts: 155
Re: adding script to system startup
« Reply #2 on: February 11, 2013, 04:50:37 PM »
Yes, I tried that. It failed to recognize the ups.
What came with it worked fine, so I am happy with that! :)
Can you tell me how to make it run at every boot?
My method requires
a) that I remember!! ;-)
b) it leaves an open terminal on my screen for the duration of the session
c) I am afraid to log off, because I need that script to be on to catch a power outage.

Thanks!

Online muungwana

  • Hero Member
  • *****
  • Posts: 6237
Re: adding script to system startup
« Reply #3 on: February 11, 2013, 04:57:10 PM »

exactly,what command are you running on the terminal to start the script up?
.. 3 things are certain in life : death, taxes and software bloat ..
.. tell me something i don't know, something i can use as i struggle to reason with the world around me ..

Offline YouCanToo

  • PCLinuxOS Tester
  • Hero Member
  • *******
  • Posts: 5331
  • Location: Lebanon, OR., USA
    • Spreading the word.......
Re: adding script to system startup
« Reply #4 on: February 11, 2013, 07:34:48 PM »
Hi,
I recently bought a U.P.S. for my computer, after too many
power outages during stormy weather. It connects to the
PC via USB, and comes with a script that will monitor the
power supply. In case of a power outage, it can shut down
cleanly, before the electricity to the computer fails.
(BTW - I was impressed that it came with Linux support!
I had serious fears that it would say something like
"fully supported - when running Redmond software")

What I would like to ask is: How do I get this script to run
automatically at every startup of the computer? So far
I have been opening a terminal, doing su to root, and running
it manually. Obviously I would prefer that when the system
boots, that it be run as root without manual intervention.

Thanks!
Shimon



This would make a good edition to the Knowledge Base. How about adding it ?
http://pclinuxoshelp.com/index.php/PCLinuxOS_Hardware_Database#Other_hardware




Be sure to visit the NEW Knowledge Base


Linux is user-friendly- it's just picky who its friends are!

Offline ternor

  • Hero Member
  • *****
  • Posts: 1797
Re: adding script to system startup
« Reply #5 on: February 11, 2013, 08:06:42 PM »
I believe I followed the advice in this video when attempting to get the Firestarter gui running automatically on log in.  When the script ran it generated an error message (something about 'dbus') so I put the task on the back burner.  YMMV.

Offline sling-shot

  • PCLinuxOS Tester
  • Hero Member
  • *******
  • Posts: 1730
  • Satyameva Jayate | Truth Alone Triumphs.
Re: adding script to system startup
« Reply #6 on: February 11, 2013, 08:45:14 PM »
It could be run from rc.local inside /etc/rc.d I guess, but you may not get a visible terminal. NOT SURE about the second point though.
Packaging well will cure headaches of many :) But learning to package will cause headaches in many :(

AMD AthlonX2 3600+/ASUS M2NPV-VM/ATi HD4670/Onboard sound/3.5GB DDR2-533 RAM/SEAGATE 160+320GB HDD/DELL S2240L FullHD/Creative SBS370 2.1/PCLinuxOS2013/KDE4
Samsung NP305U1-A06IN | Nokia E6

Offline rich2005

  • Sr. Member
  • ****
  • Posts: 257
Re: adding script to system startup
« Reply #7 on: February 12, 2013, 01:48:21 AM »
Does the script have to run as root?
Could it go in ~/.kde4/Autostart/

Offline Just17

  • PCLinuxOS Tester
  • Super Villain
  • *******
  • Posts: 10648
  • MLUs Forever!
Re: adding script to system startup
« Reply #8 on: February 12, 2013, 03:46:52 AM »
Yes, I tried that. It failed to recognize the ups.
What came with it worked fine, so I am happy with that! :)
Can you tell me how to make it run at every boot?
My method requires
a) that I remember!! ;-)
b) it leaves an open terminal on my screen for the duration of the session
c) I am afraid to log off, because I need that script to be on to catch a power outage.

Thanks!


You can add the script to  ~/.kde4/Autostart ....  most easily done through the KDE CC (Configure your Desktop) - System Admin - Startup & Shutdown.

IF your script prompts for root password when run, then you will be met with that prompt at login.

It can serve as both a reminder and as a means to NOT run the script if you so choose.

If you want the script to run more like an OS service then a different scheme can be used.

MLUs rule the roost!

Linux XPS 3.4.38-pclos1.bfs  64 bit
Intel Core2 Quad CPU Q9450 @ 2.66GHz
4 GB RAM
MCP51 High Def Audio
GeForce GTX 550 Ti
PHILIPS  ‎DVD+-RW DVD8701
‎Logitech ‎BT Mini-Receiver
Afatech DTT

Offline shimonl

  • Full Member
  • ***
  • Posts: 155
Re: adding script to system startup
« Reply #9 on: February 12, 2013, 03:24:03 PM »
OK, first the good news: My UPS software is working,
starts up at boot, and shuts down my system in an
orderly manner after a power outage. :-)

Now, the explanations.
The UPS itself is called PRV900Pro and is sold in Israel by
http://www.advicepower.com/
(Sorry, I could not find an English URL for the device, I
bought it from BUG at http://www.bug.co.il/fpage.asp?brand=0&ser=%E0%EC+%F4%F1%F7)

It came with a software CD that had a Linux directory.
In that directory was one .bin file, which I ran to unzip
a set of files, including the script I mentioned before, "ViewPower".
Running that script as root (after su) would add an icon to the system tray,
and the icon's menu would cause a browser tab to open at localhost:nnnnn,
(I forget the port #) to monitor the UPS and control its functions.

After watching the video suggested by ternor, I added "ViewPower &"
to rc.local, but this did not help. I did not get the tray icon, and the
browser did not show anything. I also tried running it from my own
user, so that I could add it to my startup, but that failed completely.

Then I found that on the web page of the ViewPower package
http://www.power-software-download.com/viewpower.html
there is a text mode package, and I decided to try that.
I got another .bin file (http://www.power-software-download.com/viewpower/installViewPower_Linux_text_i386.tar.gz)
and went through the same steps as with the first package,
but this time it added the line to rc.local by itself, and it works!

So, I am very happy to no longer have to be afraid of storms :-)
Shimon

Main screen:


Offline Just17

  • PCLinuxOS Tester
  • Super Villain
  • *******
  • Posts: 10648
  • MLUs Forever!
Re: adding script to system startup
« Reply #10 on: February 13, 2013, 02:38:43 AM »
Great!
Glad you got everything working to your satisfaction  ;)

MLUs rule the roost!

Linux XPS 3.4.38-pclos1.bfs  64 bit
Intel Core2 Quad CPU Q9450 @ 2.66GHz
4 GB RAM
MCP51 High Def Audio
GeForce GTX 550 Ti
PHILIPS  ‎DVD+-RW DVD8701
‎Logitech ‎BT Mini-Receiver
Afatech DTT