Diff for /freem/src/fmadm.c between versions 1.37 and 1.39

version 1.37, 2025/04/14 19:20:20 version 1.39, 2025/04/15 16:49:36
Line 24 Line 24
  *   along with FreeM.  If not, see <https://www.gnu.org/licenses/>.   *   along with FreeM.  If not, see <https://www.gnu.org/licenses/>.
  *   *
  *   $Log$   *   $Log$
    *   Revision 1.39  2025/04/15 16:49:36  snw
    *   Make use of logprintf throughout codebase
    *
    *   Revision 1.38  2025/04/15 02:24:43  snw
    *   Improve FreeM logging capabilities
    *
  *   Revision 1.37  2025/04/14 19:20:20  snw   *   Revision 1.37  2025/04/14 19:20:20  snw
  *   Create LOCALSTATEDIR during fmadm configure if needed   *   Create LOCALSTATEDIR during fmadm configure if needed
  *   *
Line 141 Line 147
 #include "transact.h"  #include "transact.h"
 #include "namespace.h"  #include "namespace.h"
 #include "fs.h"  #include "fs.h"
   #include "log.h"
   
 #ifdef HAVE_LIBREADLINE  #ifdef HAVE_LIBREADLINE
 #  if defined(HAVE_READLINE_READLINE_H)  #  if defined(HAVE_READLINE_READLINE_H)
Line 388  int main (int argc, char **argv) Line 395  int main (int argc, char **argv)
     printf ("action = '%s' object = '%s' environment = '%s' namespace = '%s' config_file = '%s' base_arg = '%d' next argument = '%s'\n", action, obj_str, fma_environment, fma_namespace, config_file, base_arg, argv[base_arg]);      printf ("action = '%s' object = '%s' environment = '%s' namespace = '%s' config_file = '%s' base_arg = '%d' next argument = '%s'\n", action, obj_str, fma_environment, fma_namespace, config_file, base_arg, argv[base_arg]);
     exit(1);      exit(1);
 */  */
       init_log ();
           
     /* override for fmadm configure and daemon stuff */      /* override for fmadm configure and daemon stuff */
     if (got_action) {      if (got_action) {
Line 1537  void fm_configure (void) Line 1545  void fm_configure (void)
     char jnlhostid[4096];          char jnlhostid[4096];    
     char jnlcut[4096];      char jnlcut[4096];
     char hostid[4096];      char hostid[4096];
       char logdir[4096];
       
     char confbase[4096];      char confbase[4096];
     char envbase[4096];      char envbase[4096];
   
Line 1577  void fm_configure (void) Line 1586  void fm_configure (void)
     }      }
 #endif      #endif    
   
       snprintf (logdir, sizeof (logdir) - 1, "/var/log/freem");
     snprintf (vardir, sizeof (vardir) - 1, "%s", LOCALSTATEDIR);      snprintf (vardir, sizeof (vardir) - 1, "%s", LOCALSTATEDIR);
     snprintf (varbase, sizeof (varbase) - 1, "%s/freem", LOCALSTATEDIR);      snprintf (varbase, sizeof (varbase) - 1, "%s/freem", LOCALSTATEDIR);
     snprintf (rundir, sizeof (rundir) - 1, "%s/freem/run", LOCALSTATEDIR);      snprintf (rundir, sizeof (rundir) - 1, "%s/freem/run", LOCALSTATEDIR);
Line 1644  void fm_configure (void) Line 1654  void fm_configure (void)
     }      }
           
     /* check for existence of needed directories */      /* check for existence of needed directories */
       if (stat (logdir, &etcstat) == -1) {
           fprintf (stderr, "fmadm:  creating %s [logdir]\n", logdir);
           mkdir (logdir, 0775);
           set_permissions (logdir, username, groupname, 0775);
       }
   
     if (stat (SYSCONFDIR, &etcstat) == -1) {      if (stat (SYSCONFDIR, &etcstat) == -1) {
         fprintf (stderr, "fmadm:  creating %s [SYSCONFDIR]\n", SYSCONFDIR);          fprintf (stderr, "fmadm:  creating %s [SYSCONFDIR]\n", SYSCONFDIR);
         mkdir (SYSCONFDIR, 0775);          mkdir (SYSCONFDIR, 0775);
Line 1785  void fm_configure (void) Line 1801  void fm_configure (void)
                   
         snprintf (buf, sizeof (buf) - 1, "env_path=%s/freem/%s", LOCALSTATEDIR, fma_environment);          snprintf (buf, sizeof (buf) - 1, "env_path=%s/freem/%s", LOCALSTATEDIR, fma_environment);
         fm_write (fp, buf);          fm_write (fp, buf);
   
           snprintf (buf, sizeof (buf) - 1, "log_threshold_file=info");
           fm_write (fp, buf);
           
           snprintf (buf, sizeof (buf) - 1, "log_threshold_syslog=info");
           fm_write (fp, buf);
   
           snprintf (buf, sizeof (buf) - 1, "log_threshold_stderr=warning");
           fm_write (fp, buf);
                   
         fclose (fp);          fclose (fp);
         fprintf (stderr, "[OK]\n");          fprintf (stderr, "[OK]\n");
Line 1795  void fm_configure (void) Line 1820  void fm_configure (void)
         update_conf (env_config_file, fma_environment, "user", env_user);          update_conf (env_config_file, fma_environment, "user", env_user);
         update_conf (env_config_file, fma_environment, "group", env_group);          update_conf (env_config_file, fma_environment, "group", env_group);
         update_conf (env_config_file, fma_environment, "enabled", env_enabled);          update_conf (env_config_file, fma_environment, "enabled", env_enabled);
           update_conf (env_config_file, fma_environment, "log_threshold_file", "info");
           update_conf (env_config_file, fma_environment, "log_threshold_syslog", "info");
           update_conf (env_config_file, fma_environment, "log_threshold_stderr", "warning");        
     }      }
   
     if (reconfigure == FALSE) {      if (reconfigure == FALSE) {

Removed from v.1.37  
changed lines
  Added in v.1.39


FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>