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() { ...@@ -99,15 +99,36 @@ config_iface() {
rm $iface.noconf rm $iface.noconf
} }
init_tmpdir TMP usage() {
cat <<__EOF__
usage: setup-interfaces [-h] [-i read custom /etc/network/interfaces from stdin]
cd $TMP Setup network interfaces
for i in $(detect_interfaces); do
touch $i.noconf 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 done
index=1 if [ "$STDINPUT" != "1" ]; then
while ls *.noconf > /dev/null 2>&1 ; do 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:" echon "Available interfaces are:"
for i in *.noconf; do for i in *.noconf; do
echon " `basename $i .noconf`" echon " `basename $i .noconf`"
...@@ -122,13 +143,13 @@ while ls *.noconf > /dev/null 2>&1 ; do ...@@ -122,13 +143,13 @@ while ls *.noconf > /dev/null 2>&1 ; do
[ -f $iface.noconf ] || continue [ -f $iface.noconf ] || continue
config_iface $iface $(printf "%.3d~" $index) config_iface $iface $(printf "%.3d~" $index)
index=$(( $index + 1 )) index=$(( $index + 1 ))
done done
echo "type=loopback" > 000~lo.conf echo "type=loopback" > 000~lo.conf
echo "" > interface echo "" > interface
hostname=$(cat /etc/hostname 2>/dev/null) hostname=$(cat /etc/hostname 2>/dev/null)
for i in *.conf ; do for i in *.conf ; do
iface=`basename $i .conf` iface=`basename $i .conf`
iface=${iface#[0-9]*~} iface=${iface#[0-9]*~}
. ./$i . ./$i
...@@ -147,21 +168,25 @@ for i in *.conf ; do ...@@ -147,21 +168,25 @@ for i in *.conf ; do
;; ;;
esac esac
echo "" >> interfaces 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] " echon "Do you want to do any manual network configuration? [no] "
default_read answer no default_read answer no
done done
if [ "$answer" = "yes" ]; then if [ "$answer" = "yes" ]; then
case "$EDITOR" in case "$EDITOR" in
nano) pkg_inst nano;; nano) pkg_inst nano;;
vim) pkg_inst vim;; vim) pkg_inst vim;;
esac esac
${EDITOR:-vi} interfaces ${EDITOR:-vi} interfaces
fi fi
mkdir -p $ROOT/etc/network
cp interfaces $ROOT/etc/network/
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