Revision: 7890
          http://sourceforge.net/p/ipcop/svn/7890
Author:   owes
Date:     2015-02-15 17:01:39 +0000 (Sun, 15 Feb 2015)
Log Message:
-----------
Add --status to be able to fetch server status from CGI even when the file has 
600 access right.

Modified Paths:
--------------
    ipcop/trunk/src/progs/restartopenvpn.c

Modified: ipcop/trunk/src/progs/restartopenvpn.c
===================================================================
--- ipcop/trunk/src/progs/restartopenvpn.c      2015-02-13 22:14:46 UTC (rev 
7889)
+++ ipcop/trunk/src/progs/restartopenvpn.c      2015-02-15 17:01:39 UTC (rev 
7890)
@@ -14,6 +14,8 @@
  * You should have received a copy of the GNU General Public License
  * along with IPCop.  If not, see <http://www.gnu.org/licenses/>.
  *
+ * (c) 2009-2015 The IPCop Team
+ *
  * $Id$
  *
  */
@@ -31,6 +33,7 @@
 static int flag_start = 0;
 static int flag_stop = 0;
 static int flag_restart = 0;
+static int flag_status = 0;
 static int enabled_count;
 
 
@@ -63,6 +66,22 @@
 }
 
 
+/*
+    Fetch server status from /var/log/openvpnserver.log
+*/
+void status()
+{
+    if (access("/var/log/openvpnserver.log", F_OK) == -1) {
+        /* Does not exist? Server not yet started or something else */
+        verbose_printf(1, "openvpnserver.log does not exist\n");
+    }
+    else {
+        safe_system("cat /var/log/openvpnserver.log");
+    }
+    exit(0);
+}
+
+
 int main(int argc, char *argv[])
 {
     int i, j;
@@ -75,6 +94,7 @@
         { "stop",    no_argument, &flag_stop, 1 },
         { "restart", no_argument, &flag_restart, 1 },
         { "config", no_argument, 0, 'c' },
+        { "status", no_argument, &flag_status, 1 },
         { "verbose", no_argument, 0, 'v' },
         { "help",    no_argument, 0, 'h' },
         { 0, 0, 0, 0}
@@ -99,7 +119,7 @@
         }
     }
     
-    if (!flag_start && !flag_stop && !flag_restart) {
+    if (!flag_start && !flag_stop && !flag_restart && !flag_status) {
         /* need at least one of start, stop, restart */
         usage(argv[0], 1);
     }
@@ -107,6 +127,11 @@
     if ( !(initsetuid()) )
         exit(1);
 
+    if (flag_status) {
+        status();
+        /* no return */
+    }
+
     /* Terminate running OpenVPN server */
     if (access("/var/run/openvpn.pid", 0) != -1) {
         verbose_printf(2, "Stopping OpenVPN server ... \n");

This was sent by the SourceForge.net collaborative development platform, the 
world's largest Open Source development site.


------------------------------------------------------------------------------
Dive into the World of Parallel Programming. The Go Parallel Website,
sponsored by Intel and developed in partnership with Slashdot Media, is your
hub for all things parallel software development, from weekly thought
leadership blogs to news, videos, case studies, tutorials and more. Take a
look and join the conversation now. http://goparallel.sourceforge.net/
_______________________________________________
Ipcop-svn mailing list
Ipcop-svn@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/ipcop-svn

Reply via email to