Hello! I've written a CGI script to allow the user to change the media in a BackupPC using the web GUI. There's really just two parts: shut down the server, and initialize the media. I have a shell script that works, but I would like to improve it. I have put zero effort into the HTML: I will eventually wrap the standard BackupPC look and feel around it. My biggest problem is the terrible delay while the format is taking place.
#!/bin/sh echo "Content-type: text/html" echo "" echo "<HTML><HEAD><TITLE>Resetting drive</TITLE></HEAD><BODY>" echo "<P><H1>Erasing and configuring drive</H1></P><P>" echo "Unmounting drive...<BR>" sudo /bin/umount /mnt/removable echo "<BR>Formatting drive (this may take up to 10 minutes)...<BR>" sudo /sbin/mke2fs -j -LDataDrive /dev/hdc1 > /dev/null echo "<BR>Mounting drive...<BR>" sudo /bin/mount /mnt/removable echo "<P>Drive change complete!<P>" echo "<H1><A HREF='/backuppc'>Return to Backup System</A>.</H1></P></BODY></HTML>" echo "" exit I am *very* open to suggestions on how I might implement this more cleanly. The script works, but there is a very long pause while the script does the format. If I take the "> /dev/null" out, I get lots of lines like this: 2/1222 3/1222 4/1222 5/1222 6/1222 7/1222 8/1222 9/1222 10/1222 11/1222 12/1222 13/1222 14/1222 15/1222 16/1222 17/1222 18/1222 19/1222 20/1222 21/1222 22/1222 23/1222 24/1222 25/1222 26/1222 27/1222 28/1222 29/1222 30/1222 31/1222 32/1222 33/1222 34/1222 35/1222 36/1222 37/1222 38/1222 39/1222 40/1222 41/1222 42/1222 43/1222 44/1222 45/1222 46/1222 47/1222 48/1222 49/1222 50/1222 51/1222 52/1222 53/1222 54/1222 55/1222 56/1222 57/1222 58/1222 59/1222 60/1222 61/1222 62/1222 63/1222 64/1222 65/1222 66/1222 67/1222 68/1222 69/1222 70/1222 71/1222 72/1222 73/1222 74/1222 75/1222 76/1222 77/1222 78/1222 79/1222 80/1222 81/1222 82/1222 83/1222 84/1222 85/1222 86/1222 87/1222 88/1222 89/1222 90/1222 91/1222 92/1222 Those lines repeat for hundreds of lines. What I would really like would be some way of letting the user know that progress is being made, but obviously in a slightly more attractive way! :) Does anyone have any experience on how you might be able to format a drive via a CGI script that is more attractive? Google has been no help. I have a feeling that formatting drives remotely is not exactly a common goal... :) Thank you very much for any help you might be able to provide. For completeness, I've added my script for shutting the server down below as well. "shutdown.html" is merely a BackupPC page saved as HTML and modified for my purposes. Tim Massey CGI Script: #!/bin/sh echo "Content-type: text/html" echo "" cat shutdown.html echo "" echo "" sudo /sbin/shutdown -h now exit shutdown.html: <!doctype html public "-//W3C//DTD HTML 4.01 Transitional//EN"> <html><head> <title>BackupPC: Shut Down Server</title> <link rel=stylesheet type="text/css" href="/backuppc/image/BackupPC_stnd.css" title="CSSFile"> <meta http-equiv="pragma" content="no-cache"> </head><body onLoad="document.getElementById('NavMenu').style.height=document.body.scrollHeight"> <a href="http://backuppc.sourceforge.net"><img src="/backuppc/image/logo.gif" hspace="5" vspace="7" border="0"></a><br> <div id="Content"> <div class="h1">Shut Down Server</div> <p><h2>The system is being shut down!</h2></p> <p>This will take approximately 2 minutes. Do not remove the drive before the system has powered itself off.</p> </div> <div class="NavMenu" id="NavMenu" style="height:100%"> <div class="NavTitle">Server</div> <a href="/backuppc/index.cgi">Status</a> <a href="/backuppc/index.cgi?action=summary">Host Summary</a> <a href="/backuppc/index.cgi?action=editConfig">Edit Config</a> <a href="/backuppc/index.cgi?action=editConfig&newMenu=hosts">Edit Hosts</a> <a href="/backuppc/index.cgi?action=adminOpts">Admin Options</a> <a href="/backuppc/index.cgi?action=view&type=LOG">LOG file</a> <a href="/backuppc/index.cgi?action=LOGlist">Old LOGs</a> <a href="/backuppc/index.cgi?action=emailSummary">Email summary</a> <a href="/backuppc/index.cgi?action=queue">Current queues</a> <a href="/backuppc/index.cgi?action=view&type=docs">Documentation</a> <a href="http://backuppc.sourceforge.net/faq">FAQ</a> <a href="http://www.obscorp.com">OBSCorp</a> <a href="/backuppc/shutdown.cgi">Shut Down</a> <a href="/backuppc/initmedia.cgi">Init Media</a> <br><br><br> </div> </body></html> ------------------------------------------------------------------------- Take Surveys. Earn Cash. Influence the Future of IT Join SourceForge.net's Techsay panel and you'll get the chance to share your opinions on IT & business topics through brief surveys - and earn cash http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV _______________________________________________ BackupPC-users mailing list BackupPC-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/backuppc-users http://backuppc.sourceforge.net/