diff --git a/compile/Makefile b/compile/Makefile index a1a24a6..59ead6d 100644 --- a/compile/Makefile +++ b/compile/Makefile @@ -1,4 +1,4 @@ -PROGS = ip-screen cpu-screen +PROGS = cpu-screen #ifndef CFLAGS CFLAGS = -O2 -Wall -s @@ -14,9 +14,6 @@ CC = gcc all: $(PROGS) -ip-screen: ip-screen.c - diet $(CC) $(CFLAGS) -o $@ $^ - cpu-screen: cpu-screen.c diet $(CC) $(CFLAGS) -o $@ $^ diff --git a/compile/ip-screen.c b/compile/ip-screen.c deleted file mode 100644 index 7c46a47..0000000 --- a/compile/ip-screen.c +++ /dev/null @@ -1,87 +0,0 @@ -/* - * Filename: ip-screen.c - * Purpose: print ip address of configured network interfaces - * Authors: grml-team (grml.org), (c) Michael Gebetsroither - * Bug-Reports: see http://grml.org/bugs/ - * License: This file is licensed under the GPL v2. - *********************************************************************************/ - -#include -#include -#include - -#include -#include -#include -#include -#include -#include - -#define MAX_IFS 32 -#define WRITE(x) write(1, x, strlen(x)) - -// USER CONFIG -#define ERR_MSG "[running ip-screen failed]\n" -#define NO_IFACE_MSG "[ network n/a ]\n" - -void die(int errcode) -{ - WRITE(ERR_MSG); - exit(errcode); -} - -int main() -{ - int sockfd; - int total, remaining, current; - struct ifconf ifc; - struct ifreq *ifrp; - struct sockaddr_in *addr; - struct in_addr *tmp = NULL; - char buf[sizeof(struct ifreq)*MAX_IFS]; - char *ctmp = NULL; - - sockfd = socket(PF_INET,SOCK_DGRAM,0); - if(-1 == sockfd) - die(1); - - ifc.ifc_buf = buf; - ifc.ifc_len = sizeof(buf); - if (-1 == ioctl(sockfd, SIOCGIFCONF, &ifc)) - die(2); - - remaining = total = ifc.ifc_len; - ifrp = ifc.ifc_req; - while(remaining) { - if( ifrp->ifr_addr.sa_family == AF_INET ) { - if (-1 == ioctl(sockfd, SIOCGIFFLAGS, ifrp)) { - die(3); - } - addr = (struct sockaddr_in *)&(ifrp->ifr_addr); - if(!(ifrp->ifr_flags & IFF_LOOPBACK)) { - if(tmp) { - ctmp = inet_ntoa(*tmp); - WRITE(ctmp); - WRITE(" | "); - } - tmp = &addr->sin_addr; - } - } - - current = sizeof(struct ifreq); - ifrp = (struct ifreq *)( ((char *)ifrp)+current ); - remaining -= current; - } - - if(tmp){ - ctmp = inet_ntoa(*tmp); - WRITE(ctmp); - WRITE("\n"); - } else { - WRITE(NO_IFACE_MSG); - } - - return 0; -} - -/** END OF FILE *****************************************************************/ diff --git a/debian/control b/debian/control index 0ee6328..89ede35 100644 --- a/debian/control +++ b/debian/control @@ -18,6 +18,7 @@ Depends: dash, grml-etc-core, less, + libio-interface-perl, lockfile-progs, perl, screen, diff --git a/debian/grml-scripts-core.install b/debian/grml-scripts-core.install index 6e41592..19d4318 100644 --- a/debian/grml-scripts-core.install +++ b/debian/grml-scripts-core.install @@ -1,3 +1,2 @@ compile/cpu-screen usr/bin/ -compile/ip-screen usr/bin/ usr_bin/* usr/bin/ diff --git a/debian/grml-scripts-core.lintian-overrides b/debian/grml-scripts-core.lintian-overrides index 05ad2f5..3d438ec 100644 --- a/debian/grml-scripts-core.lintian-overrides +++ b/debian/grml-scripts-core.lintian-overrides @@ -1,4 +1,3 @@ grml-scripts-core: statically-linked-binary [usr/bin/cpu-screen] -grml-scripts-core: statically-linked-binary [usr/bin/ip-screen] grml-scripts-core: bugs-field-does-not-refer-to-debian-infrastructure mailto:bugs@grml.org grml-scripts-core: script-with-language-extension [usr/bin/lesspipe.sh] diff --git a/usr_bin/ip-screen b/usr_bin/ip-screen new file mode 100755 index 0000000..4cbd89a --- /dev/null +++ b/usr_bin/ip-screen @@ -0,0 +1,15 @@ +#!/usr/bin/perl +use strict; +use IO::Interface::Simple; + +my @interfaces = IO::Interface::Simple->interfaces; +my $found = 0; +for my $if (@interfaces) { + next if $if->is_loopback; + print " | " if $found; + print $if->address; + $found = 1; +} +print "[ network n/a ]" unless $found; +print "\n"; +