Changeset 5345ae3 in freewrt for package/fwwif/extra/mgmt.ecpp


Ignore:
Timestamp:
Jul 3, 2007, 6:18:07 PM (18 years ago)
Author:
Thorsten Glaser <tg@…>
Children:
cb6d2db
Parents:
0040a26
Message:

turn commit into some kind of management console

git-svn-id: svn://www.freewrt.org/trunk/freewrt@3109 afb5a338-a214-0410-bd46-81f09a774fd1

File:
1 moved

Legend:

Unmodified
Added
Removed
  • package/fwwif/extra/mgmt.ecpp

    r0040a26 r5345ae3  
    3232really;
    3333ck;
     34op;
    3435</%args>
    3536<%application>
    3637unsigned checkpoint;
    3738</%application>
    38 %       runComp2(header, title, "commit to fwcf (flash)");
    39 %       unsigned ick;
    40 %       ick = strtoul(ck.c_str(), NULL, 0);
    41 %       if (really == "yes" && ick && ick == checkpoint) {
    42 <h1>Committing to flash…</h1>
     39<%cpp>
     40        bool okay = false;
     41        std::string pageheader = "management";
     42        std::string pagetitle_run, pagetitle_wrong, pagetitle_ok, utilname;
     43        std::string text_wrong, text_ok;        /* HTML ok in these */
     44        if (op == "commit") {
     45                pageheader = "commit to fwcf (flash)";
     46                pagetitle_run = "Committing to flash";
     47                pagetitle_wrong = "Commit failed";
     48                text_wrong = "Committing to flash failed.";
     49                pagetitle_ok = "Committed successfully";
     50                text_ok = "The changes to <tt>/etc</tt> were ";
     51                text_ok += "successfully committed to flash using the ";
     52                text_ok += "FreeWRT Configuration Filesystem.";
     53                utilname = "fwcf commit";
     54                okay = true;
     55        }
     56        runComp2(header, title, pageheader);
     57        unsigned ick;
     58        ick = strtoul(ck.c_str(), NULL, 0);
     59        if (!okay) {
     60</%cpp>
     61<h1>Management functions</h1>
     62<p>Please choose one of the following management functions.</p><ul>
     63 <li><a href="mgmt?op=commit">Commit changes to flash (FWCF)</a></li>
     64 <li><a href="version">FWWIF Version Information</a></li>
     65</ul>
     66%       } else if (really == "yes" && ick && ick == checkpoint) {
     67<h1><$pagetitle_run$>…</h1>
    4368<p>Please wait…</p>
    4469<%cpp>
    4570                int i = 0;
    46                 const char *s = "fwcf commit";
     71                const char *s;
    4772                char *text;
     73
     74                if (op == "commit") {
     75                        s = "fwcf commit";
     76                }
    4877
    4978                reply.setDirectMode(); // flush output
     
    5281                text = c_exec(s, &i);
    5382                if (i) {
     83                        reply.out() << "<h1>";
     84                        reply.sout() << text_wrong;
     85                        reply.out() << "!</h1>\n<p>" << text_wrong << "</p>\n";
     86                } else {
     87                        reply.out() << "<h1>";
     88                        reply.sout() << text_ok;
     89                        reply.out() << ".</h1>\n<p>" << text_ok << "</p>\n";
     90                }
    5491</%cpp>
    55 <h1>Commit failed!</h1>
    56 <p>Committing to flash failed.</p>
    57 %               } else {
    58 <h1>Committed successfully.</h1>
    59 <p>The changes to <tt>/etc</tt> were successfully committed
    60  to flash using the FreeWRT Configuration Filesystem.</p>
    61 %               }
    62 <p class="blkbeg">The “fwcf commit” utility returned the following output:</p>
     92<p class="blkbeg">The “<$utilname$>” utility returned the following output:</p>
    6393<pre class="blkmid">
    6494%               reply.sout() << text ? (*text ? text : "(no output)") : "(null)";
    6595</pre><p class="blkend">The exit code was <$ WEXITSTATUS(i) $>.</p>
    6696<p>Go <a href="javascript:back();">back</a> or to the <a href="/">index</a>.</p>
    67 %       } else {
    68 %               int i;
    69 %               char *changes;
    70 %
    71 %               do {
    72 %                       checkpoint = arc4random();      /* authorisation */
    73 %               } while (!checkpoint);
    74 %               changes = c_exec("/sbin/fwcf status", &i);
    75 %               if (changes) {
     97<%cpp>
     98        } else {
     99                do {
     100                        checkpoint = arc4random();      /* authorisation */
     101                } while (!checkpoint);
     102
     103                if (op == "commit") {
     104                        int i;
     105                        char *changes;
     106
     107                        changes = c_exec("/sbin/fwcf status", &i);
     108                        if (changes) {
     109</%cpp>
    76110<p class="blkbeg">The following files have been modified:</p>
    77111<pre class="blkmid"><$ *changes ? changes : "No files modified." $></pre>
    78112<p class="blkend">Do you really want to commit all these changes
    79 %                       free(changes);
    80 %               } else {
     113%                               free(changes);
     114%                       } else {
    81115<h1>Commit to flash</h1>
    82116<p>Do you really want to commit all changes to <tt>/etc</tt>
    83 %               }
     117%                       }
    84118 into flash to retain them over system reboots?</p>
    85119<table width="100%">
     
    87121  <td>&nbsp;</td>
    88122  <td style="background-color:#00FF00;width:60px;height:32px;font-size:big;text-align:center;"><a
    89    href="commit?really=yes&amp;ck=<$checkpoint$>">Yes</a></td>
     123   href="commit?op=commit&amp;really=yes&amp;ck=<$checkpoint$>">Yes</a></td>
    90124  <td style="background-color:#FF0000;width:60px;height:32px;font-size:big;text-align:center;"><a
    91125   href="/">No</a></td>
     
    93127 </tr>
    94128</table>
     129%               }
    95130%       }
    96131<& footer>
Note: See TracChangeset for help on using the changeset viewer.