allow coexistance of N build and AC build.
[tomato.git] / release / src / router / rc / ups.c
blobaa300b7517ae46c9c762f72dca7461a800fde480
1 /*
2 * ups.c
4 * Copyright (C) 2011 shibby
6 */
7 #include <rc.h>
8 #include <sys/stat.h>
10 void start_ups(void)
12 FILE *fpm;
13 FILE *fpc;
15 // always copy and try start service if USB support is enable
16 // if service will not find apc ups, then will turn off automaticaly
17 // if( nvram_match( "ups_enable", "1" ) )
18 // {
20 eval("cp", "/www/apcupsd/tomatodata.cgi", "/www/ext/cgi-bin/tomatodata.cgi");
21 eval("cp", "/www/apcupsd/tomatoups.cgi", "/www/ext/cgi-bin/tomatoups.cgi");
23 // writing data to file
25 /* turn off at the moment. We will use this in the future.
26 if( !( fpc = fopen( "/etc/apcupsd.conf", "w" ) ) )
28 perror( "/etc/apcupsdd.conf" );
29 return;
31 fprintf( fpc, "USBCABLE usb \n");
32 fprintf( fpc, "UPSTYPE usb \n");
33 fprintf( fpc, "DEVICE \n");
34 fprintf( fpc, "EVENTSFILE /var/log/apcupsd.events \n");
36 fclose( fpc );
37 chmod( "/etc/apcupsd.conf", 0644 );
39 if( !( fpm = fopen( "/etc/apcemail.conf", "w" ) ) )
41 perror( "/etc/apcemail.conf" );
42 return;
44 fprintf( fpm, "SYSADMIN=myemail@domain.com \n");
45 fprintf( fpm, "APCUPSD_MAIL=\"sendmail -S server.home -f root\" \n");
47 fclose(fpm);
48 chmod( "/etc/apcemail.conf", 0644 );
50 xstart( "apcupsd" );
51 // }
53 return;
56 void stop_ups(void)
58 killall("apcupsd", SIGTERM);
59 // eval("rm", "/etc/apcupsd.conf");
60 // eval("rm", "/etc/apcemail.conf");
61 // eval("rm", "/www/ext/cgi-bin/tomatodata.cgi");
62 // eval("rm", "/www/ext/cgi-bin/tomatoups.cgi");
63 return;