Initial commit

This commit is contained in:
Kolan Sh 2012-05-20 13:52:39 +04:00
commit 34b3e1e4ca
4 changed files with 117 additions and 0 deletions

8
Makefile Normal file
View File

@ -0,0 +1,8 @@
SHELL = /bin/sh
PREFIX = /usr
all:
install:
install -d ${DESTDIR}/usr/sbin
install --mode=755 sbin/*.sh ${DESTDIR}/usr/sbin

View File

@ -0,0 +1 @@
EBUILD network-profile-9999.ebuild 828 RMD160 80d563a6c5d57803cebeebbad3ec137f380ff6c8 SHA1 d9aef51030ebde6a23e2b95751b35aff13e4398f SHA256 252b9901609736ba33e4cb0068b68c507e46a9987f9d8751543489d341aefd3f

View File

@ -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
}

63
sbin/network-profile.sh Executable file
View File

@ -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