Fixed redirector schedules - This fixes bug #0000685
[people/pmueller/ipfire-2.x.git] / src / misc-progs / updxlratorctrl.c
1 #include <stdio.h>
2 #include <string.h>
3 #include <unistd.h>
4 #include <stdlib.h>
5 #include <sys/types.h>
6 #include <fcntl.h>
7 #include "setuid.h"
8
9 int main(int argc, char *argv[]){
10 if ( argc < 2 ){
11 printf("invalid parameter(s)\n");
12 return(1);
13 }
14
15 if (!(initsetuid()))
16 exit(1);
17
18 if (strcmp(argv[1], "cron") == 0){
19 safe_system("rm /etc/fcron.*/updxlrator 2&>/dev/null");
20
21 if (strcmp(argv[2], "daily") == 0){
22 safe_system("ln -s /var/ipfire/updatexlrator/bin/checkup /etc/fcron.daily/updxlrator");
23 } else if (strcmp(argv[2], "weekly") == 0){
24 safe_system("ln -s /var/ipfire/updatexlrator/bin/checkup /etc/fcron.weekly/updxlrator");
25 } else if (strcmp(argv[2], "monthly") == 0){
26 safe_system("ln -s /var/ipfire/updatexlrator/bin/checkup /etc/fcron.monthly/updxlrator");
27 }else{
28 printf("invalid parameter(s)\n");
29 return(1);
30 }
31 }
32 return 0;
33 }