From be8bb6e1d000327a8715a794826d83afde5db8fc Mon Sep 17 00:00:00 2001 From: Jay Larson Date: Fri, 5 May 2017 11:10:41 -0500 Subject: [PATCH] First completed version. --- Makefile | 56 +++++++------------------------- SRC/iftools/Makefile | 15 +++++++++ SRC/{ => iftools}/ifup | 0 SRC/{ => iftools}/ifup.8 | 0 SRC/iftools/network.conf | 16 +++++++++ SRC/{ => iftools}/network.conf.5 | 0 SRC/iftools/network.init | 37 +++++++++++++++++++++ 7 files changed, 79 insertions(+), 45 deletions(-) create mode 100644 SRC/iftools/Makefile rename SRC/{ => iftools}/ifup (100%) rename SRC/{ => iftools}/ifup.8 (100%) create mode 100644 SRC/iftools/network.conf rename SRC/{ => iftools}/network.conf.5 (100%) create mode 100755 SRC/iftools/network.init diff --git a/Makefile b/Makefile index f24ad28..d270bd6 100644 --- a/Makefile +++ b/Makefile @@ -9,51 +9,22 @@ # GNU General Public License for more details. DEPENDS = iproute2,perl -ARCH = +ARCH = none URL = -BRIEF = -DESC = -SNAPVER = +BRIEF = Scripts for starting and stopping network interfaces +DESC = Scripts which use the iproute2 tools for automatically starting and \ +stopping network devices during startup. +SNAPVER = 0 -ARCHIVE := $(PWD)/SRC/$(shell ls SRC|egrep '(bz2|gz|tar|xz)$$'|tail -1) -TYPE := $(shell file -ib $(ARCHIVE)|cut -d';' -f1|tr -d '\n') -SRCDIR := $(shell tar -tf $(ARCHIVE)|head -1|sed 's/\/.*//') +ARCHIVE := +SRCDIR := $(PWD)/SRC/iftools PATCHDIR := $(PWD)/SRC/patches -VERSION := $(shell echo $(SRCDIR)|egrep -o '\-[0-9].*'|sed 's/^-//')-$(SNAPVER) +VERSION := $(shell grep 'VERSION\s*=>' SRC/iftools/ifup| \ + cut -d "'" -f2)-$(SNAPVER) include /usr/share/snap/Makefile.snaplinux -$(SRCDIR)/configure: $(ARCHIVE) - @if [ '$(TYPE)' == 'application/x-bzip2' ]; then \ - tar -jxf $(ARCHIVE); \ - elif [ '$(TYPE)' == 'application/x-gzip' ]; then \ - tar -zxf $(ARCHIVE); \ - elif [ '$(TYPE)' == 'application/x-tar' ]; then \ - tar -xf $(ARCHIVE); \ - elif [ '$(TYPE)' == 'application/x-xz' ]; then \ - tar -xf $(ARCHIVE); \ - else \ - echo 'Unable to determine archive type'; \ - exit 1; \ - fi - @touch $(SRCDIR)/configure - -$(SRCDIR)/config.log: $(SRCDIR)/configure - @cd $(SRCDIR) && \ - for patch in `find $(PATCHDIR) -name \*.patch|sort`; do \ - patch --verbose -Np1 -i $$patch; \ - done - @cd $(SRCDIR); \ - ./configure \ - --prefix=/usr \ - --build=x86_64-snap-linux-gnu \ - --host=x86_64-snap-linux-gnu \ - --target=x86_64-snap-linux-gnu - -$(SRCDIR)/binfile: $(SRCDIR)/config.log - @cd $(SRCDIR) && make - -$(ROOT): $(SRCDIR)/binfile +$(ROOT): $(SRCDIR)/Makefile @if [ -d $(ROOT) ]; then \ touch $(ROOT); \ else \ @@ -62,14 +33,9 @@ $(ROOT): $(SRCDIR)/binfile @cd $(SRCDIR) && make install DESTDIR=$(ROOT) -test: $(ROOT) - @cd $(SRCDIR); \ - make check - clean: @rm -rvf $(ROOT) \ $(SNAPINFO) \ $(MANIFEST) \ - $(FILES) \ - $(SRCDIR) + $(FILES) diff --git a/SRC/iftools/Makefile b/SRC/iftools/Makefile new file mode 100644 index 0000000..d79473d --- /dev/null +++ b/SRC/iftools/Makefile @@ -0,0 +1,15 @@ +dirs: + install -d -v -m 755 $(DESTDIR)/etc/init.d + install -d -v -m 755 $(DESTDIR)/etc/network.d + install -d -v -m 755 $(DESTDIR)/usr/share/iftools + install -d -v -m 755 $(DESTDIR)/usr/share/man/man{5,8} + +files: + install -v -m 755 network.init $(DESTDIR)/etc/init.d/network + install -v -m 755 network.conf \ + $(DESTDIR)/usr/share/iftools/network.conf + install -v -m 644 network.conf.5 \ + $(DESTDIR)/usr/share/man/man5/network.conf.5 + install -v -m 644 ifup.8 $(DESTDIR)/usr/share/man/man8/ifup.8 + +install: dirs files diff --git a/SRC/ifup b/SRC/iftools/ifup similarity index 100% rename from SRC/ifup rename to SRC/iftools/ifup diff --git a/SRC/ifup.8 b/SRC/iftools/ifup.8 similarity index 100% rename from SRC/ifup.8 rename to SRC/iftools/ifup.8 diff --git a/SRC/iftools/network.conf b/SRC/iftools/network.conf new file mode 100644 index 0000000..f588317 --- /dev/null +++ b/SRC/iftools/network.conf @@ -0,0 +1,16 @@ +auto lo +iface lo inet loopback + +# An example of an interface automatically started on boot with dhcp +#auto eth0 +#iface eth0 inet dhcp + +# Another example with a static IP and static route +#iface eth1 inet static +# address 192.168.0.202 +# netmask 255.255.255.0 +# gateway 192.168.0.1 +# route 192.168.3.0 via 192.168.0.100 + +# This requests that all files in /etc/network.d be appended +source-directory network.d diff --git a/SRC/network.conf.5 b/SRC/iftools/network.conf.5 similarity index 100% rename from SRC/network.conf.5 rename to SRC/iftools/network.conf.5 diff --git a/SRC/iftools/network.init b/SRC/iftools/network.init new file mode 100755 index 0000000..3ca1f3a --- /dev/null +++ b/SRC/iftools/network.init @@ -0,0 +1,37 @@ +#!/bin/sh +### BEGIN INIT INFO +# Provides: $network +# Required-Start: $local_fs swap localnet +# Required-Stop: $local_fs swap localnet +# Should-Start: $syslog +# Should-Stop: $syslog +# Default-Start: 3 4 5 +# Default-Stop: 0 1 2 6 +# Short-Description: Starts and configures network interfaces. +# Description: Starts and configures network interfaces. +### END INIT INFO + +. /lib/lsb/init-functions + +case "$1" in + start) + log_info_msg "Bringing up network interfaces" + ifup -a && log_success_msg || log_failure_msg + ;; + stop) + log_info_msg "Bringing down network interfaces" + ifdown -a && log_success_msg || log_failure_msg + ;; + + reload|restart) + log_info_msg "Restarting network interfaced" + ifreload -a && log_success_msg || log_failure_msg + ;; + + *) + echo "Usage: $0 [start|stop|reload|restart]" + exit 1 + ;; +esac + +exit 0