From 34b3e1e4ca1a4d26db91e51c82921463e085dfc2 Mon Sep 17 00:00:00 2001 From: Kolan Sh Date: Sun, 20 May 2012 13:52:39 +0400 Subject: [PATCH] Initial commit --- Makefile | 8 +++ .../gentoo/app-admin/network-profile/Manifest | 1 + .../network-profile-9999.ebuild | 45 +++++++++++++ sbin/network-profile.sh | 63 +++++++++++++++++++ 4 files changed, 117 insertions(+) create mode 100644 Makefile create mode 100644 pkgs/gentoo/app-admin/network-profile/Manifest create mode 100644 pkgs/gentoo/app-admin/network-profile/network-profile-9999.ebuild create mode 100755 sbin/network-profile.sh diff --git a/Makefile b/Makefile new file mode 100644 index 0000000..1d65628 --- /dev/null +++ b/Makefile @@ -0,0 +1,8 @@ +SHELL = /bin/sh +PREFIX = /usr + +all: + +install: + install -d ${DESTDIR}/usr/sbin + install --mode=755 sbin/*.sh ${DESTDIR}/usr/sbin diff --git a/pkgs/gentoo/app-admin/network-profile/Manifest b/pkgs/gentoo/app-admin/network-profile/Manifest new file mode 100644 index 0000000..226e1b7 --- /dev/null +++ b/pkgs/gentoo/app-admin/network-profile/Manifest @@ -0,0 +1 @@ +EBUILD network-profile-9999.ebuild 828 RMD160 80d563a6c5d57803cebeebbad3ec137f380ff6c8 SHA1 d9aef51030ebde6a23e2b95751b35aff13e4398f SHA256 252b9901609736ba33e4cb0068b68c507e46a9987f9d8751543489d341aefd3f diff --git a/pkgs/gentoo/app-admin/network-profile/network-profile-9999.ebuild b/pkgs/gentoo/app-admin/network-profile/network-profile-9999.ebuild new file mode 100644 index 0000000..8049f81 --- /dev/null +++ b/pkgs/gentoo/app-admin/network-profile/network-profile-9999.ebuild @@ -0,0 +1,45 @@ +# Copyright 1999-2011 Gentoo Foundation +# Distributed under the terms of the GNU General Public License v2 +# $Header: $ + +EAPI=4 + +inherit eutils + +if [[ ${PV} == "9999" ]] ; then + EGIT_REPO_URI=${EGIT_REPO_URI:-"git://github.com/backbone/network-profile.git"} + inherit git-2 + KEYWORDS="" +else + SRC_URI="ftp://backbone.ws/projects/network-profile/${P}.tar.bz2" + KEYWORDS="-* ~x86 ~amd64" +fi + +DESCRIPTION="Automated Gentoo upgrading" + +HOMEPAGE="https://chili.backbone.ws/projects/network-profile" + +SLOT="0" + +LICENSE="GPL-3" + +IUSE="" + +DEPEND="" + +RDEPEND="${DEPEND}" + +src_prepare() { + if [[ ${PV} == "9999" ]] ; then + # Allow user patches to be applied without modifying the ebuild + epatch_user + fi +} + +src_install() { + if [[ ${PV} == "9999" ]] ; then + emake install DESTDIR="${D}" + else + emake install DESTDIR="${D}" || die + fi +} diff --git a/sbin/network-profile.sh b/sbin/network-profile.sh new file mode 100755 index 0000000..f00babc --- /dev/null +++ b/sbin/network-profile.sh @@ -0,0 +1,63 @@ +#!/bin/bash + +__net_restart () +{ + interfaces="`grep [0-9]=\\" /etc/conf.d/net | grep -v ^# | sed 's~.*_\([A-Za-z]*[0-9]\)=.*~\1~' | sort -u`" + irestart= + for i in $interfaces; do + irestart="$irestart net.$i" + done + sudo eselect rc restart $irestart +} + +if [[ "$1" == "" ]]; then + echo "Usage:" + echo " net \$profile: selects network \$profile" + echo " net new \$base \$profile: creates new \$profile based on \$base" + echo " net edit: edit current active network profile" + echo " net edit \$profile: edit network \$profile" + echo " net view: view current active network profile" + echo " net view \$profile: view network \$profile" + echo " net rm \$profile: removes network \$profile" + echo " net restart: restarts the network" + echo + echo "Profiles (*active):" + active=`readlink /etc/conf.d/net | sed 's~^net\.~~'` + for f in /etc/conf.d/net.*; do + fn=`echo $f | sed 's~^/etc/conf.d/net\.~~'` + [[ "$fn" == "$active" ]] && echo "* $fn" || echo " $fn" + done + +elif [[ "$1" == "restart" ]]; then + __net_restart + +elif [[ "$1" == "edit" && "$2" == "" ]]; then + sudo $EDITOR /etc/conf.d/net + +elif [[ "$1" == "edit" && "$2" != "" ]]; then + sudo $EDITOR /etc/conf.d/net.$2 + +elif [[ "$1" == "rm" && "$2" != "" ]]; then + sudo rm -f /etc/conf.d/net.$2 + +elif [[ "$1" == "view" && "$2" == "" ]]; then + $PAGER /etc/conf.d/net + +elif [[ "$1" == "view" && "$2" != "" ]]; then + $PAGER /etc/conf.d/net.$2 + +elif [[ "$1" == "rm" && "$2" != "" ]]; then + sudo rm -f /etc/conf.d/net.$2 + +elif [[ "$1" == "new" && "$2" != "" && "$3" != "" ]]; then + sudo cp -f /etc/conf.d/net.$2 /etc/conf.d/net.$3 && sudo $EDITOR /etc/conf.d/net.$3 + sudo rm -f /etc/conf.d/net && sudo ln -s net.$3 /etc/conf.d/net + __net_restart + +else + sudo rm -f /etc/conf.d/net && sudo ln -s net.$1 /etc/conf.d/net + __net_restart +fi + +exit 0 +