]>
git.ipfire.org Git - people/teissler/ipfire-2.x.git/blob - src/misc-progs/addonctrl.c
1 /* This file is part of the IPFire Firewall.
3 * This program is distributed under the terms of the GNU General Public
4 * Licence. See the file COPYING for details.
12 #include <sys/types.h>
16 #define BUFFER_SIZE 1024
18 char command
[BUFFER_SIZE
];
20 int main(int argc
, char *argv
[]) {
26 fprintf(stderr
, "\nMissing arguments.\n\naddonctrl addon (start|stop|restart|reload|enable|disable)\n\n");
30 if ( strlen(argv
[1])>32 ) {
31 fprintf(stderr
, "\nString to large.\n\naddonctrl addon (start|stop|restart|reload|enable|disable)\n\n");
35 if ( strchr(argv
[1],'/') || strchr(argv
[1],'$') || strchr(argv
[1],'[') || strchr(argv
[1],'{') ) {
36 fprintf(stderr
, "\nIllegal Char found.\n\naddonctrl addon (start|stop|restart|reload|enable|disable)\n\n");
40 sprintf(command
, "/opt/pakfire/db/installed/meta-%s", argv
[1]);
41 FILE *fp
= fopen(command
,"r");
45 fprintf(stderr
, "\nAddon '%s' not found.\n\naddonctrl addon (start|stop|restart|reload|status|enable|disable)\n\n", argv
[1]);
49 if (strcmp(argv
[2], "start") == 0) {
50 sprintf(command
,"/etc/rc.d/init.d/%s start", argv
[1]);
52 } else if (strcmp(argv
[2], "stop") == 0) {
53 sprintf(command
,"/etc/rc.d/init.d/%s stop", argv
[1]);
55 } else if (strcmp(argv
[2], "restart") == 0) {
56 sprintf(command
,"/etc/rc.d/init.d/%s restart", argv
[1]);
58 } else if (strcmp(argv
[2], "reload") == 0) {
59 sprintf(command
,"/etc/rc.d/init.d/%s reload", argv
[1]);
61 } else if (strcmp(argv
[2], "status") == 0) {
62 sprintf(command
,"/etc/rc.d/init.d/%s status", argv
[1]);
64 } else if (strcmp(argv
[2], "enable") == 0) {
65 sprintf(command
,"mv -f /etc/rc.d/rc3.d/off/S??%s /etc/rc.d/rc3.d" , argv
[1]);
67 } else if (strcmp(argv
[2], "disable") == 0) {
68 sprintf(command
,"mkdir -p /etc/rc.d/rc3.d/off");
70 sprintf(command
,"mv -f /etc/rc.d/rc3.d/S??%s /etc/rc.d/rc3.d/off" , argv
[1]);
73 fprintf(stderr
, "\nBad argument given.\n\naddonctrl addon (start|stop|restart|reload|enable|disable)\n\n");