Reinstate dropbear 0.54 update
[tomato.git] / release / src / router / rc / snmp.c
blob953e496c7f58e54b3c6eeb0467f327e352114251
1 /*
2 * snmp.c
4 * Copyright (C) 2011 shibby
6 */
7 #include <rc.h>
8 #include <sys/stat.h>
10 void start_snmp(void)
12 FILE *fp;
14 // only if enable...
15 if( nvram_match( "snmp_enable", "1" ) )
18 // writing data to file
19 if( !( fp = fopen( "/etc/snmpd.conf", "w" ) ) )
21 perror( "/etc/snmpd.conf" );
22 return;
24 fprintf(fp, "syslocation %s\n", nvram_safe_get( "snmp_location" ) );
25 fprintf(fp, "syscontact %s <%s>\n", nvram_safe_get( "snmp_contact" ),nvram_safe_get( "snmp_contact" ) );
26 fprintf(fp, "rocommunity %s\n", nvram_safe_get( "snmp_ro" ) );
28 fclose( fp );
29 chmod( "/etc/snmpd.conf", 0644 );
31 xstart( "snmpd", "-c", "/etc/snmpd.conf" );
34 return;
37 void stop_snmp(void)
39 killall("snmpd", SIGTERM);
40 return;