Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
alpine-conf
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
18
Issues
18
List
Boards
Labels
Service Desk
Milestones
Merge Requests
3
Merge Requests
3
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Operations
Operations
Incidents
Environments
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
alpine
alpine-conf
Commits
e489e81f
Commit
e489e81f
authored
Aug 07, 2011
by
Jeff Bilyk
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
setup-interfaces: add an option to read custom /etc/network/interfaces from stdin
parent
cd085f2e
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
84 additions
and
59 deletions
+84
-59
setup-interfaces.in
setup-interfaces.in
+84
-59
No files found.
setup-interfaces.in
View file @
e489e81f
...
...
@@ -99,69 +99,94 @@ 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
done
index
=
1
while
ls
*
.noconf
>
/dev/null 2>&1
;
do
echon
"Available interfaces are:"
for
i
in
*
.noconf
;
do
echon
"
`
basename
$i
.noconf
`
"
done
echo
"."
Setup network interfaces
firstif
=
`
get_first_unconfigured
`
echon
"Which one do you want to initialize? (or 'done') [
$firstif
] "
default_read iface
"
$firstif
"
[
"
$iface
"
=
"done"
]
&&
break
[
-f
$iface
.noconf
]
||
continue
config_iface
$iface
$(
printf
"%.3d~"
$index
)
index
=
$((
$index
+
1
))
done
options:
-h Show this help
-i Read new contents of /etc/network/interfaces from stdin
__EOF__
exit
1
}
echo
"type=loopback"
>
000~lo.conf
echo
""
>
interface
hostname
=
$(
cat
/etc/hostname 2>/dev/null
)
for
i
in
*
.conf
;
do
iface
=
`
basename
$i
.conf
`
iface
=
${
iface
#[0-9]*~
}
.
./
$i
echo
"auto
$iface
"
>>
interfaces
echo
"iface
$iface
inet
$type
"
>>
interfaces
case
$type
in
dhcp
)
[
-n
"
$hostname
"
]
\
&&
echo
-e
"
\t
hostname
$hostname
"
>>
interfaces
;;
static
)
echo
-e
"
\t
address
$address
"
>>
interfaces
echo
-e
"
\t
netmask
$netmask
"
>>
interfaces
[
"
$gateway
"
]
\
&&
echo
-e
"
\t
gateway
$gateway
"
>>
interfaces
;;
esac
echo
""
>>
interfaces
while
getopts
"hi"
opt
;
do
case
$opt
in
h
)
usage
;;
i
)
STDINPUT
=
1
;;
esac
done
while
[
"
$answer
"
!=
"yes"
]
&&
[
"
$answer
"
!=
"no"
]
;
do
echon
"Do you want to do any manual network configuration? [no] "
default_read answer no
done
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
`
"
done
echo
"."
firstif
=
`
get_first_unconfigured
`
echon
"Which one do you want to initialize? (or 'done') [
$firstif
] "
default_read iface
"
$firstif
"
[
"
$iface
"
=
"done"
]
&&
break
[
-f
$iface
.noconf
]
||
continue
config_iface
$iface
$(
printf
"%.3d~"
$index
)
index
=
$((
$index
+
1
))
done
echo
"type=loopback"
>
000~lo.conf
echo
""
>
interface
hostname
=
$(
cat
/etc/hostname 2>/dev/null
)
for
i
in
*
.conf
;
do
iface
=
`
basename
$i
.conf
`
iface
=
${
iface
#[0-9]*~
}
.
./
$i
echo
"auto
$iface
"
>>
interfaces
echo
"iface
$iface
inet
$type
"
>>
interfaces
case
$type
in
dhcp
)
[
-n
"
$hostname
"
]
\
&&
echo
-e
"
\t
hostname
$hostname
"
>>
interfaces
;;
static
)
echo
-e
"
\t
address
$address
"
>>
interfaces
echo
-e
"
\t
netmask
$netmask
"
>>
interfaces
[
"
$gateway
"
]
\
&&
echo
-e
"
\t
gateway
$gateway
"
>>
interfaces
;;
esac
echo
""
>>
interfaces
done
while
[
"
$answer
"
!=
"yes"
]
&&
[
"
$answer
"
!=
"no"
]
;
do
echon
"Do you want to do any manual network configuration? [no] "
default_read answer no
done
if
[
"
$answer
"
=
"yes"
]
;
then
case
"
$EDITOR
"
in
nano
)
pkg_inst nano
;;
vim
)
pkg_inst vim
;;
esac
${
EDITOR
:-
vi
}
interfaces
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/
else
cat
/dev/stdin
>
interfaces
mkdir
-p
$ROOT
/etc/network
cp
interfaces
$ROOT
/etc/network
fi
mkdir
-p
$ROOT
/etc/network
cp
interfaces
$ROOT
/etc/network/
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment