From a79906a4c5cd871dd8d615c73ff40a7ecb6cb905 Mon Sep 17 00:00:00 2001 From: ms Date: Fri, 26 May 2006 12:19:48 +0000 Subject: [PATCH] =?utf8?q?Ge=C3=A4ndert:=20=20=20*=20IPCop=20->=20IPFire?= =?utf8?q?=20bei=20den=20misc-progs=20=20=20*=20Startscripte=20verschoben?= =?utf8?q?=20und=20Symlink=20nach=20/usr/local/bin/rc*=20Gel=C3=B6scht:=20?= =?utf8?q?=20=20*=20Restartshaping=20in=20den=20Misc-Progs,=20weil=20es=20?= =?utf8?q?durch=20QoS=20ersetzt=20wird.?= MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit git-svn-id: http://svn.ipfire.org/svn/ipfire/trunk@145 ea5c0bd1-69bd-2848-81d8-4f18e57aeed8 --- lfs/startscripts | 5 +- src/init.d/{rcapplejuice => applejuice} | 0 src/init.d/{rcasterisk => asterisk} | 0 src/init.d/{rcgnump3d => gnump3d} | 0 src/init.d/{rcsamba => samba} | 0 src/misc-progs/Makefile | 23 +- .../{ipcopbackup.c => ipfirebackup.c} | 0 .../{ipcopbkcfg.c => ipfirebkcfg.c} | 0 .../{ipcopdeath.c => ipfiredeath.c} | 0 .../{ipcoprebirth.c => ipfirerebirth.c} | 0 .../{ipcopreboot.c => ipfirereboot.c} | 0 .../{ipcoprscfg.c => ipfirerscfg.c} | 0 src/misc-progs/restartapplejuice.c | 26 ++ src/misc-progs/restartshaping.c | 234 ------------------ 14 files changed, 39 insertions(+), 249 deletions(-) rename src/init.d/{rcapplejuice => applejuice} (100%) rename src/init.d/{rcasterisk => asterisk} (100%) rename src/init.d/{rcgnump3d => gnump3d} (100%) rename src/init.d/{rcsamba => samba} (100%) rename src/misc-progs/{ipcopbackup.c => ipfirebackup.c} (100%) rename src/misc-progs/{ipcopbkcfg.c => ipfirebkcfg.c} (100%) rename src/misc-progs/{ipcopdeath.c => ipfiredeath.c} (100%) rename src/misc-progs/{ipcoprebirth.c => ipfirerebirth.c} (100%) rename src/misc-progs/{ipcopreboot.c => ipfirereboot.c} (100%) rename src/misc-progs/{ipcoprscfg.c => ipfirerscfg.c} (100%) create mode 100644 src/misc-progs/restartapplejuice.c delete mode 100644 src/misc-progs/restartshaping.c diff --git a/lfs/startscripts b/lfs/startscripts index e9dc12d51..4612e03d1 100644 --- a/lfs/startscripts +++ b/lfs/startscripts @@ -48,8 +48,9 @@ md5 : $(TARGET) : $(patsubst %,$(DIR_DL)/%,$(objects)) @$(PREBUILD) - mkdir /etc/init.d - cd $(DIR_SRC)/src/init.d && cp -v * /etc/init.d + test -d /etc/init.d || mkdir /etc/init.d + cd $(DIR_SRC)/src/init.d && cp -fv * /etc/init.d chown root.root /etc/init.d/* chmod 755 /etc/init.d/* + for i in `ls /etc/init.d`; do ln -vfs /etc/init.d/$i /usr/local/bin/rc$i; done @$(POSTBUILD) \ No newline at end of file diff --git a/src/init.d/rcapplejuice b/src/init.d/applejuice similarity index 100% rename from src/init.d/rcapplejuice rename to src/init.d/applejuice diff --git a/src/init.d/rcasterisk b/src/init.d/asterisk similarity index 100% rename from src/init.d/rcasterisk rename to src/init.d/asterisk diff --git a/src/init.d/rcgnump3d b/src/init.d/gnump3d similarity index 100% rename from src/init.d/rcgnump3d rename to src/init.d/gnump3d diff --git a/src/init.d/rcsamba b/src/init.d/samba similarity index 100% rename from src/init.d/rcsamba rename to src/init.d/samba diff --git a/src/misc-progs/Makefile b/src/misc-progs/Makefile index 566d33442..ffcd4ddd4 100644 --- a/src/misc-progs/Makefile +++ b/src/misc-progs/Makefile @@ -1,7 +1,3 @@ -# -# $Id: Makefile,v 1.5.2.7 2005/11/20 23:20:13 franck78 Exp $ -# - CC=gcc CFLAGS=-O2 -Wall @@ -9,11 +5,12 @@ COMPILE=$(CC) $(CFLAGS) PROGS = iowrap SUID_PROGS = setdmzholes setportfw setfilters setxtaccess restartdhcp restartsnort \ - restartsquid restartssh ipcopreboot \ - ipcopbkcfg ipcoprscfg installpackage installfcdsl ipsecctrl \ - setaliases ipcopbackup restartshaping restartntpd \ - restartwireless setdate rebuildhosts \ + restartsquid restartssh ipfirereboot \ + ipfirebkcfg ipfirerscfg installpackage installfcdsl ipsecctrl \ + setaliases ipfirebackup restartntpd \ + restartapplejuice setdate rebuildhosts \ restartsyslogd logwatch + # restartwireless install : all install -m 755 $(PROGS) /usr/local/bin @@ -54,12 +51,12 @@ setfilters: setfilters.c setuid.o ../install+setup/libsmooth/varval.o rebuildhosts: rebuildhosts.c setuid.o ../install+setup/libsmooth/varval.o $(COMPILE) -I../install+setup/libsmooth/ rebuildhosts.c setuid.o ../install+setup/libsmooth/varval.o -o $@ +restartapplejuice: restartapplejuice.c setuid.o ../install+setup/libsmooth/varval.o + $(COMPILE) -I../install+setup/libsmooth/ restartapplejuice.c setuid.o ../install+setup/libsmooth/varval.o -o $@ + restartdhcp: restartdhcp.c setuid.o ../install+setup/libsmooth/varval.o $(COMPILE) -I../install+setup/libsmooth/ restartdhcp.c setuid.o ../install+setup/libsmooth/varval.o -o $@ -restartshaping: restartshaping.c setuid.o ../install+setup/libsmooth/varval.o - $(COMPILE) -I../install+setup/libsmooth/ restartshaping.c setuid.o ../install+setup/libsmooth/varval.o -o $@ - restartssh: restartssh.c setuid.o ../install+setup/libsmooth/varval.o $(COMPILE) -I../install+setup/libsmooth/ restartssh.c setuid.o ../install+setup/libsmooth/varval.o -o $@ @@ -78,5 +75,5 @@ restartwireless: restartwireless.c setuid.o ../install+setup/libsmooth/varval.o ipsecctrl: ipsecctrl.c setuid.o ../install+setup/libsmooth/varval.o $(COMPILE) -I../install+setup/libsmooth/ ipsecctrl.c setuid.o ../install+setup/libsmooth/varval.o -o $@ -ipcopbackup: ipcopbackup.c setuid.o - $(COMPILE) -lcrypt ipcopbackup.c setuid.o -o $@ +ipfirebackup: ipfirebackup.c setuid.o + $(COMPILE) -lcrypt ipfirebackup.c setuid.o -o $@ diff --git a/src/misc-progs/ipcopbackup.c b/src/misc-progs/ipfirebackup.c similarity index 100% rename from src/misc-progs/ipcopbackup.c rename to src/misc-progs/ipfirebackup.c diff --git a/src/misc-progs/ipcopbkcfg.c b/src/misc-progs/ipfirebkcfg.c similarity index 100% rename from src/misc-progs/ipcopbkcfg.c rename to src/misc-progs/ipfirebkcfg.c diff --git a/src/misc-progs/ipcopdeath.c b/src/misc-progs/ipfiredeath.c similarity index 100% rename from src/misc-progs/ipcopdeath.c rename to src/misc-progs/ipfiredeath.c diff --git a/src/misc-progs/ipcoprebirth.c b/src/misc-progs/ipfirerebirth.c similarity index 100% rename from src/misc-progs/ipcoprebirth.c rename to src/misc-progs/ipfirerebirth.c diff --git a/src/misc-progs/ipcopreboot.c b/src/misc-progs/ipfirereboot.c similarity index 100% rename from src/misc-progs/ipcopreboot.c rename to src/misc-progs/ipfirereboot.c diff --git a/src/misc-progs/ipcoprscfg.c b/src/misc-progs/ipfirerscfg.c similarity index 100% rename from src/misc-progs/ipcoprscfg.c rename to src/misc-progs/ipfirerscfg.c diff --git a/src/misc-progs/restartapplejuice.c b/src/misc-progs/restartapplejuice.c new file mode 100644 index 000000000..c1a985078 --- /dev/null +++ b/src/misc-progs/restartapplejuice.c @@ -0,0 +1,26 @@ +/* IFire helper program - restartapplejuice + * + * Starts or stops the applejuice core + * + */ + +#include +#include +#include +#include +#include +#include +#include "setuid.h" + + +int main(void) +{ + if (!(initsetuid())) + exit(1); + + safe_system("/etc/init.d/applejuice stop"); + sleep(3); + safe_system("/etc/init.d/applejuice start"); + + return 0; +} diff --git a/src/misc-progs/restartshaping.c b/src/misc-progs/restartshaping.c deleted file mode 100644 index 9ce0b1e98..000000000 --- a/src/misc-progs/restartshaping.c +++ /dev/null @@ -1,234 +0,0 @@ -/* IPCop helper program - restartshaping - * - * This program is distributed under the terms of the GNU General Public - * Licence. See the file COPYING for details. - * - * Copyright (C) 2002-04-09 Mark Wormgoor - * - * $Id: restartshaping.c,v 1.2.2.5 2005/01/28 13:11:40 riddles Exp $ - * - */ - -#include "libsmooth.h" -#include "setuid.h" -#include -#include -#include -#include -#include -#include - -int main(int argc, char *argv[]) -{ - FILE *file = NULL, *ifacefile = NULL; - struct keyvalue *kv = NULL; - int uplink, downlink, count = 0, r2q = 10; - char command[STRING_SIZE]; - char iface[STRING_SIZE] = ""; - char s[STRING_SIZE]; - char *result; - char proto[STRING_SIZE]; - char *protocol; - char *port; - char *prio; - char *enabled; - - if (!(initsetuid())) { - fprintf(stderr, "Cannot run setuid\n"); - exit(1); - } - - /* Init the keyvalue structure */ - kv=initkeyvalues(); - - /* Read in the current values */ - if (!readkeyvalues(kv, CONFIG_ROOT "/shaping/settings")) - { - fprintf(stderr, "Cannot read shaping settings\n"); - goto EXIT; - } - - /* See what interface there is */ - if ((ifacefile = fopen(CONFIG_ROOT "/red/iface", "r"))) - { - fgets(iface, STRING_SIZE, ifacefile); - if (iface[strlen(iface) - 1] == '\n') - iface[strlen(iface) - 1] = '\0'; - fclose (ifacefile); - } else { - fprintf(stderr, "Couldn't open iface file\n"); - return(1); - } - - if (strspn(iface, LETTERS_NUMBERS) != strlen(iface)) - { - fprintf(stderr, "Bad iface: %s\n", iface); - goto EXIT; - } - - /* Find the VALID value */ - if (!findkey(kv, "VALID", s)) - { - fprintf(stderr, "Cannot read VALID\n"); - goto EXIT; - } - - /* Check if config is VALID */ - if (! strcmp(s, "yes")==0) - goto EXIT; - - snprintf(command, STRING_SIZE-1, "/sbin/tc qdisc del dev %s root", iface); - safe_system(command); - snprintf(command, STRING_SIZE-1, "/sbin/tc qdisc del dev %s ingress", iface); - safe_system(command); - - /* Find the ENABLE value */ - if (!findkey(kv, "ENABLE", s)) - { - fprintf(stderr, "Cannot read ENABLE\n"); - goto EXIT; - } - - /* Check if shaping is ENABLED */ - if (! strcmp(s, "on")==0) - goto EXIT; - - /* Find the UPLINK value */ - if (!findkey(kv, "UPLINK", s)) - { - fprintf(stderr, "Cannot read UPLINK\n"); - goto EXIT; - } - uplink = atoi(s); - if (! uplink > 0) { - fprintf(stderr, "Invalid value for UPLINK\n"); - goto EXIT; - } - /* In some limited testing, it was shown that - r2q = ( uplink * 1024 / 1500 ); - * produced error messages from the kernel saying r2q needed to be - * changed. 1500 is taken as the MTU, but it seems that 16384 works - * better. -Alan. - */ - r2q = ( uplink * 1024 / 16384 ); - uplink = (uplink * 100) / 101; - - /* Find the DOWNLINK value */ - if (!findkey(kv, "DOWNLINK", s)) - { - fprintf(stderr, "Cannot read DOWNLINK\n"); - goto EXIT; - } - downlink = atoi(s); - if (! downlink > 0) { - fprintf(stderr, "Invalid value for DOWNLINK\n"); - goto EXIT; - } - downlink = (downlink * 200) / 201; - - /* Uplink classes */ - snprintf(command, STRING_SIZE-1, "/sbin/tc qdisc add dev %s root handle 1: htb default 20 r2q %d", iface, r2q); - safe_system(command); - snprintf(command, STRING_SIZE-1, "/sbin/tc class add dev %s parent 1: classid 1:1 htb rate %dkbit", iface, uplink); - safe_system(command); - snprintf(command, STRING_SIZE-1, "/sbin/tc class add dev %s parent 1:1 classid 1:10 htb rate %dkbit ceil %dkbit prio 1", iface, (8 * uplink) / 10, uplink); - safe_system(command); - snprintf(command, STRING_SIZE-1, "/sbin/tc class add dev %s parent 1:1 classid 1:20 htb rate %dkbit ceil %dkbit prio 2", iface, (6 * uplink) / 10, uplink); - safe_system(command); - snprintf(command, STRING_SIZE-1, "/sbin/tc class add dev %s parent 1:1 classid 1:30 htb rate %dkbit ceil %dkbit prio 3", iface, (4 * uplink) / 10, uplink); - safe_system(command); - - /* Uplink Stochastic fairness queue */ - snprintf(command, STRING_SIZE-1, "/sbin/tc qdisc add dev %s parent 1:10 handle 10: sfq perturb 10", iface); - safe_system(command); - snprintf(command, STRING_SIZE-1, "/sbin/tc qdisc add dev %s parent 1:20 handle 20: sfq perturb 10", iface); - safe_system(command); - snprintf(command, STRING_SIZE-1, "/sbin/tc qdisc add dev %s parent 1:30 handle 30: sfq perturb 10", iface); - safe_system(command); - - /* TOS Minimum Delay and ICMP traffic for high priority queue */ - snprintf(command, STRING_SIZE-1, "/sbin/tc filter add dev %s parent 1:0 protocol ip prio 10 u32 match ip tos 0x10 0xff flowid 1:10", iface); - safe_system(command); - snprintf(command, STRING_SIZE-1, "/sbin/tc filter add dev %s parent 1:0 protocol ip prio 10 u32 match ip protocol 1 0xff flowid 1:10", iface); - safe_system(command); - - /* ACK packets for high priority queue (to speed up downloads) */ - snprintf(command, STRING_SIZE-1, "/sbin/tc filter add dev %s parent 1: protocol ip prio 10 u32 match ip protocol 6 0xff match u8 0x05 0x0f at 0 match u16 0x0000 0xffc0 at 2 match u8 0x10 0xff at 33 flowid 1:10", iface); - safe_system(command); - - file = fopen(CONFIG_ROOT "/shaping/config", "r"); - if (file) - { - while (fgets(s, STRING_SIZE, file) != NULL) - { - if (s[strlen(s) - 1] == '\n') - s[strlen(s) - 1] = '\0'; - result = strtok(s, ","); - - count = 0; - protocol = NULL; - port = NULL; - prio = NULL; - enabled = NULL; - while (result) - { - if (count == 0) - protocol = result; - else if (count == 1) - port = result; - else if (count == 2) - prio = result; - else if (count == 3) - enabled = result; - count++; - result = strtok(NULL, ","); - } - if (!(protocol && port && prio && enabled)) - break; - if (strcmp(protocol, "tcp") == 0) { - strcpy(proto, "6"); - } else if (strcmp(protocol, "udp") == 0) { - strcpy(proto, "17"); - } else { - fprintf(stderr, "Bad protocol: %s\n", protocol); - goto EXIT; - } - if (strspn(port, PORT_NUMBERS) != strlen(port)) - { - fprintf(stderr, "Bad port: %s\n", port); - goto EXIT; - } - if (strspn(prio, NUMBERS) != strlen(prio)) - { - fprintf(stderr, "Bad priority: %s\n", prio); - goto EXIT; - } - - if (strcmp(enabled, "on") == 0) - { - snprintf(command, STRING_SIZE-1, "/sbin/tc filter add dev %s parent 1: protocol ip prio 14 u32 match ip protocol %s 0xff match ip dport %s 0xffff flowid 1:%s", iface, proto, port, prio); - - safe_system(command); - - snprintf(command, STRING_SIZE-1, "/sbin/tc filter add dev %s parent 1: protocol ip prio 15 u32 match ip protocol %s 0xff match ip sport %s 0xffff flowid 1:%s", iface, proto, port, prio); - - safe_system(command); - } - } - } - - /* Setting everything else to the default queue */ - snprintf(command, STRING_SIZE-1, "/sbin/tc filter add dev %s parent 1: protocol ip prio 18 u32 match ip dst 0.0.0.0/0 flowid 1:20", iface); - safe_system(command); - - /* Downlink Section */ - snprintf(command, STRING_SIZE-1, "/sbin/tc qdisc add dev %s handle ffff: ingress", iface); - safe_system(command); - snprintf(command, STRING_SIZE-1, "/sbin/tc filter add dev %s parent ffff: protocol ip prio 50 u32 match ip src 0.0.0.0/0 police rate %dkbit burst 10k drop flowid :1", iface, downlink); - safe_system(command); - -EXIT: - if (kv) freekeyvalues(kv); - if (file) fclose(file); - return 0; -} -- 2.39.5