summaryrefslogtreecommitdiffstats
path: root/watchfrr/watchfrr.c
diff options
context:
space:
mode:
authorDavid Lamparter <equinox@opensourcerouting.org>2017-08-02 10:46:01 +0200
committerDavid Lamparter <equinox@opensourcerouting.org>2017-08-09 11:30:58 +0200
commit64a249ad9e25a4613d6c7994e94e5616c1e10288 (patch)
tree52990fbeddb769fa5af13725ad06ffe2e188aeb3 /watchfrr/watchfrr.c
parentlib: don't mkdir state paths in watchfrr (diff)
downloadfrr-64a249ad9e25a4613d6c7994e94e5616c1e10288.tar.xz
frr-64a249ad9e25a4613d6c7994e94e5616c1e10288.zip
watchfrr: remove STATEDIR preprocessor define
use frr_vtydir from libfrr instead. Signed-off-by: David Lamparter <equinox@opensourcerouting.org>
Diffstat (limited to 'watchfrr/watchfrr.c')
-rw-r--r--watchfrr/watchfrr.c22
1 files changed, 8 insertions, 14 deletions
diff --git a/watchfrr/watchfrr.c b/watchfrr/watchfrr.c
index 692615455..37f6fb53d 100644
--- a/watchfrr/watchfrr.c
+++ b/watchfrr/watchfrr.c
@@ -50,21 +50,12 @@
#define DEFAULT_LOGLEVEL LOG_INFO
#define DEFAULT_MIN_RESTART 60
#define DEFAULT_MAX_RESTART 600
-#ifdef PATH_WATCHFRR_PID
-#define DEFAULT_PIDFILE PATH_WATCHFRR_PID
-#else
-#define DEFAULT_PIDFILE STATEDIR "/watchfrr.pid"
-#endif
-#ifdef DAEMON_VTY_DIR
-#define VTYDIR DAEMON_VTY_DIR
-#else
-#define VTYDIR STATEDIR
-#endif
#define PING_TOKEN "PING"
/* Needs to be global, referenced somewhere inside libfrr. */
struct thread_master *master;
+static char pidfile_default[256];
static bool watch_only = false;
@@ -118,7 +109,7 @@ static struct global_state {
int numdown; /* # of daemons that are not UP or UNRESPONSIVE */
} gs = {
.phase = PHASE_NONE,
- .vtydir = VTYDIR,
+ .vtydir = frr_vtydir,
.period = 1000 * DEFAULT_PERIOD,
.timeout = DEFAULT_TIMEOUT,
.restart_timeout = DEFAULT_RESTART_TIMEOUT,
@@ -245,9 +236,9 @@ Otherwise, the interval is doubled (but capped at the -M value).\n\n",
passing command-line arguments with embedded spaces.\n\
-v, --version Print program version\n\
-h, --help Display this help and exit\n",
- VTYDIR, DEFAULT_LOGLEVEL, LOG_EMERG, LOG_DEBUG, LOG_DEBUG,
+ frr_vtydir, DEFAULT_LOGLEVEL, LOG_EMERG, LOG_DEBUG, LOG_DEBUG,
DEFAULT_MIN_RESTART, DEFAULT_MAX_RESTART, DEFAULT_PERIOD,
- DEFAULT_TIMEOUT, DEFAULT_RESTART_TIMEOUT, DEFAULT_PIDFILE);
+ DEFAULT_TIMEOUT, DEFAULT_RESTART_TIMEOUT, pidfile_default);
}
static pid_t run_background(char *shell_cmd)
@@ -976,10 +967,13 @@ FRR_DAEMON_INFO(watchfrr, WATCHFRR,
int main(int argc, char **argv)
{
int opt;
- const char *pidfile = DEFAULT_PIDFILE;
+ const char *pidfile = pidfile_default;
const char *special = "zebra";
const char *blankstr = NULL;
+ snprintf(pidfile_default, sizeof(pidfile_default), "%s/watchfrr.pid",
+ frr_vtydir);
+
frr_preinit(&watchfrr_di, argc, argv);
progname = watchfrr_di.progname;