$qossettings{'ENABLED'} = 'on';
&General::writehash("${General::swroot}/qos/settings", \%qossettings);
system("/usr/local/bin/qosctrl generate >/dev/null 2>&1");
- system("/usr/bin/touch /var/ipfire/qos/enable");
system("/usr/local/bin/qosctrl start >/dev/null 2>&1");
system("logger -t ipfire 'QoS started'");
}
elsif ($qossettings{'ACTION'} eq $Lang::tr{'stop'})
{
- system("/usr/local/bin/qosctrl stop >/dev/null 2>&1");
- unlink "/var/ipfire/qos/bin/qos.sh";
- unlink "/var/ipfire/qos/enable";
- system("logger -t ipfire 'QoS stopped'");
$qossettings{'ENABLED'} = 'off';
&General::writehash("${General::swroot}/qos/settings", \%qossettings);
+ system("/usr/local/bin/qosctrl stop >/dev/null 2>&1");
+ system("/usr/local/bin/qosctrl generate >/dev/null 2>&1");
+ system("logger -t ipfire 'QoS stopped'");
}
elsif ($qossettings{'ACTION'} eq $Lang::tr{'restart'})
{
$qossettings{'ENABLED'} = 'on';
&General::writehash("${General::swroot}/qos/settings", \%qossettings);
system("/usr/local/bin/qosctrl generate >/dev/null 2>&1");
- system("/usr/bin/touch /var/ipfire/qos/enable");
system("/usr/local/bin/qosctrl start >/dev/null 2>&1");
system("logger -t ipfire 'QoS started'");
} else {
#include <sys/types.h>
#include <fcntl.h>
#include "setuid.h"
+#include "libsmooth.h"
#define QOS_SH "/var/ipfire/qos/bin/qos.sh"
int main(int argc, char *argv[]) {
-
+ struct keyvalue* kv = NULL;
int fd = -1;
+ int r = 0;
if (!(initsetuid()))
exit(1);
}
if (strcmp(argv[1], "generate") == 0) {
- safe_system("/usr/bin/perl /var/ipfire/qos/bin/makeqosscripts.pl > " QOS_SH);
+ kv = initkeyvalues();
+ if (!readkeyvalues(kv, CONFIG_ROOT "/qos/settings")) {
+ fprintf(stderr, "Cannot read QoS settings\n");
+ r = 1;
+ goto END;
+ }
+
+ char enabled[STRING_SIZE];
+ if (!findkey(kv, "ENABLED", enabled))
+ strcpy(enabled, "off");
+
+ if (strcmp(enabled, "on") == 0)
+ safe_system("/usr/bin/perl /var/ipfire/qos/bin/makeqosscripts.pl > " QOS_SH);
+ else
+ unlink(QOS_SH);
}
if ((fd = open(QOS_SH, O_RDONLY)) != -1) {
close(fd);
} else {
// If there is no qos.sh do nothing.
- exit(0);
+ goto END;
}
safe_system("chmod 755 " QOS_SH " &>/dev/null");
exit(1);
}
- return 0;
+END:
+ if (kv)
+ freekeyvalues(kv);
+
+ return r;
}