Koozali.org: home of the SME Server

Help ! Contribs Development : Display Bash Progression

Offline beckynet

  • *
  • 107
  • +0/-0
    • http://www.beckynet.be
Help ! Contribs Development : Display Bash Progression
« on: August 10, 2010, 08:52:45 AM »
Hello World,

I need help to develop a contribution.

I would like to display the progress of a bash script in the control panel.

It's a script that stops services, do a backup and then restarts the services.

This script may take several minutes to run.

Is it possible to do this? And how?

Thank you in advance.

Olivier Beeckmans
----------------------------------------------------
Beeckmans Olivier
Belgian Army ICT Technician
I discovered E-Smith with version 4.12
----------------------------------------------------

Offline Stefano

  • *
  • 10,894
  • +3/-0
Re: Help ! Contribs Development : Display Bash Progression
« Reply #1 on: August 10, 2010, 09:39:14 AM »
Hi..

Code: [Select]
man pv
will help you ;-)

Offline beckynet

  • *
  • 107
  • +0/-0
    • http://www.beckynet.be
Re: Help ! Contribs Development : Display Bash Progression
« Reply #2 on: August 10, 2010, 09:50:51 AM »
Thanks for your respons stefano,

But I don't want to see a progress bar or percentage.

I would like to see in the server-manager control panel, after pressing a start button, the same as I can see when I launch the script from the console line by line.

I'm not a King of perl  :?

Thanks

Olivier Beeckmans
----------------------------------------------------
Beeckmans Olivier
Belgian Army ICT Technician
I discovered E-Smith with version 4.12
----------------------------------------------------

Offline Stefano

  • *
  • 10,894
  • +3/-0
Re: Help ! Contribs Development : Display Bash Progression
« Reply #3 on: August 10, 2010, 10:07:18 AM »
in a html page? mmmhh... I have no idea atm, sorry..

Offline cactus

  • *
  • 4,880
  • +3/-0
    • http://www.snetram.nl
Re: Help ! Contribs Development : Display Bash Progression
« Reply #4 on: August 10, 2010, 10:17:29 AM »
Thanks for your respons stefano,

But I don't want to see a progress bar or percentage.

I would like to see in the server-manager control panel, after pressing a start button, the same as I can see when I launch the script from the console line by line.

I'm not a King of perl  :?

Thanks

Olivier Beeckmans
Perhaps the software update panel might be off help. IIRC it shows the output of the yum command. The backup and restore panel seems to do this as well as it would echo the filenames restored to the browser IIRC.

I am curious to know why you need such a custom backup solution. Can you elaborate a bit on this topic? Does the normal backup routine not suit your needs?
Be careful whose advice you buy, but be patient with those who supply it. Advice is a form of nostalgia, dispensing it is a way of fishing the past from the disposal, wiping it off, painting over the ugly parts and recycling it for more than its worth ~ Baz Luhrmann - Everybody's Free (To Wear Sunscreen)

Offline beckynet

  • *
  • 107
  • +0/-0
    • http://www.beckynet.be
Re: Help ! Contribs Development : Display Bash Progression
« Reply #5 on: August 10, 2010, 11:41:56 AM »
My project is not a Full SME Backup.

It's a daily disaster backup for Zarafa DB, for up to seven days.

It contain three panels one to config daily backup (for this panel no return is needed, this panel is ready), one for a backup now and one for restore one of the 7 backup (those panels need script return).

Thanks for your respons

Olivier Beeckmans
----------------------------------------------------
Beeckmans Olivier
Belgian Army ICT Technician
I discovered E-Smith with version 4.12
----------------------------------------------------

Offline beckynet

  • *
  • 107
  • +0/-0
    • http://www.beckynet.be
Re: Help ! Contribs Development : Display Bash Progression
« Reply #6 on: August 12, 2010, 08:02:46 PM »
Thank you Cactus

I found the solution in the panel YUM.

Three days of analysis and testing :shock:, now it works! And I can continue my project.  8)

Thank you all

Olivier Beeckmans
----------------------------------------------------
Beeckmans Olivier
Belgian Army ICT Technician
I discovered E-Smith with version 4.12
----------------------------------------------------

Offline Stefano

  • *
  • 10,894
  • +3/-0
Re: Help ! Contribs Development : Display Bash Progression
« Reply #7 on: August 12, 2010, 08:04:35 PM »
will you share it?

Offline cactus

  • *
  • 4,880
  • +3/-0
    • http://www.snetram.nl
Re: Help ! Contribs Development : Display Bash Progression
« Reply #8 on: August 12, 2010, 08:05:07 PM »
Thank you Cactus

I found the solution in the panel YUM.
You're welcome. Any change you will be maintaining this package in the SME Contribs CVS? For details see: http://wiki.contribs.org/Package_Modification
Be careful whose advice you buy, but be patient with those who supply it. Advice is a form of nostalgia, dispensing it is a way of fishing the past from the disposal, wiping it off, painting over the ugly parts and recycling it for more than its worth ~ Baz Luhrmann - Everybody's Free (To Wear Sunscreen)

Offline beckynet

  • *
  • 107
  • +0/-0
    • http://www.beckynet.be
Re: Help ! Contribs Development : Display Bash Progression
« Reply #9 on: August 12, 2010, 08:48:59 PM »
will you share it?

Yes, once the project is fully completed.

Thank you for your interest.

Olivier Beeckmans
----------------------------------------------------
Beeckmans Olivier
Belgian Army ICT Technician
I discovered E-Smith with version 4.12
----------------------------------------------------

Offline CharlieBrady

  • *
  • 6,918
  • +3/-0
Re: Help ! Contribs Development : Display Bash Progression
« Reply #10 on: August 13, 2010, 05:11:42 PM »
Yes, once the project is fully completed.

No project is ever fully completed.

Linux would not be what it is today without the policy of "release early - release often". Neither would SME server.

Anyway, what you are planning to do is non-trivial, because of the way that http works. There's not way for a server-manager panel process to callback to your browser and make changes in what is displayed whenever something interesting has happened. Your browser has to ask what the current state is, and then display something as a result. You need to do some background reading on subjects such as "Web 2.0" and AJAX.

If you have a script which only takes a few minutes to run, you might be able to "fake it" by progressively showing new text line by line as your backend script runs, but you have little control over what buffering happens between that script and the viewer, so you cannot control how interactive the display appears to be.

If your script take longer than a few minutes, you will almost certainly have the browser report a timeout.

Offline beckynet

  • *
  • 107
  • +0/-0
    • http://www.beckynet.be
Re: Help ! Contribs Development : Display Bash Progression
« Reply #11 on: August 14, 2010, 01:02:41 PM »
No project is ever fully completed.

I mean completely finished, when I reached the goal of my project.

If your script take longer than a few minutes, you will almost certainly have the browser report a timeout.

In fact it is not necessary to display line by line what happens.
The script takes several minutes, which is important for the user is to know where he is in the running of backup. And especially when the backup is finished.

I found the solution in the panel yum (thank you to cactus).

Basically I run the backup script in the background from my panel
I initiate a key in the db as a flag. (with this flag you can leave the panel for another)
I call a page with autorefresh of 10 seconds. (with this no timout occure)
The script complete a report with his progress.
The autorefresh page displays the report every 10 seconds.
When the script is finished, It remove the flag.
Autorefresh page gives way to the homepage of my panel with a message of success.

This part of the project is completed.

It now remains for me to do the restore.

Thanks for your interest

Olivier Beeckmans
----------------------------------------------------
Beeckmans Olivier
Belgian Army ICT Technician
I discovered E-Smith with version 4.12
----------------------------------------------------