Commit e489e81f authored by Jeff Bilyk's avatar Jeff Bilyk
Browse files

setup-interfaces: add an option to read custom /etc/network/interfaces from stdin

parent cd085f2e
......@@ -99,15 +99,36 @@ config_iface() {
rm $iface.noconf
}
init_tmpdir TMP
usage() {
cat <<__EOF__
usage: setup-interfaces [-h] [-i read custom /etc/network/interfaces from stdin]
cd $TMP
for i in $(detect_interfaces); do
touch $i.noconf
Setup network interfaces
options:
-h Show this help
-i Read new contents of /etc/network/interfaces from stdin
__EOF__
exit 1
}
while getopts "hi" opt; do
case $opt in
h) usage;;
i) STDINPUT=1;;
esac
done
index=1
while ls *.noconf > /dev/null 2>&1 ; do
if [ "$STDINPUT" != "1" ]; then
init_tmpdir TMP
cd $TMP
for i in $(detect_interfaces); do
touch $i.noconf
done
index=1
while ls *.noconf > /dev/null 2>&1 ; do
echon "Available interfaces are:"
for i in *.noconf; do
echon " `basename $i .noconf`"
......@@ -122,13 +143,13 @@ while ls *.noconf > /dev/null 2>&1 ; do
[ -f $iface.noconf ] || continue
config_iface $iface $(printf "%.3d~" $index)
index=$(( $index + 1 ))
done
done
echo "type=loopback" > 000~lo.conf
echo "" > interface
hostname=$(cat /etc/hostname 2>/dev/null)
echo "type=loopback" > 000~lo.conf
echo "" > interface
hostname=$(cat /etc/hostname 2>/dev/null)
for i in *.conf ; do
for i in *.conf ; do
iface=`basename $i .conf`
iface=${iface#[0-9]*~}
. ./$i
......@@ -147,21 +168,25 @@ for i in *.conf ; do
;;
esac
echo "" >> interfaces
done
done
while [ "$answer" != "yes" ] && [ "$answer" != "no" ] ; do
while [ "$answer" != "yes" ] && [ "$answer" != "no" ] ; do
echon "Do you want to do any manual network configuration? [no] "
default_read answer no
done
done
if [ "$answer" = "yes" ]; then
if [ "$answer" = "yes" ]; then
case "$EDITOR" in
nano) pkg_inst nano;;
vim) pkg_inst vim;;
esac
${EDITOR:-vi} interfaces
fi
mkdir -p $ROOT/etc/network
cp interfaces $ROOT/etc/network/
fi
mkdir -p $ROOT/etc/network
cp interfaces $ROOT/etc/network/
else
cat /dev/stdin > interfaces
mkdir -p $ROOT/etc/network
cp interfaces $ROOT/etc/network
fi
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment