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
9107a682
Commit
9107a682
authored
Aug 05, 2011
by
Jeff Bilyk
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
setup-hostname: add an option to specify hostname
parent
0aeb9386
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
29 additions
and
3 deletions
+29
-3
setup-hostname.in
setup-hostname.in
+29
-3
No files found.
setup-hostname.in
View file @
9107a682
...
...
@@ -5,6 +5,20 @@ PREFIX=
.
$PREFIX
/lib/libalpine.sh
usage
()
{
cat
<<
__EOF__
usage: setup-hostname [-h] [-n hostname]
Sets the system hostname.
options:
-h Show this help
-n Specify the hostname to set
__EOF__
exit
1
}
# http://en.wikipedia.org/wiki/Hostname#Restrictions_on_valid_host_names
valid_hostname
()
{
# check length
...
...
@@ -24,10 +38,22 @@ valid_hostname() {
return
0
}
while
getopts
"hn:"
opt
;
do
case
$opt
in
h
)
usage
;;
n
)
HOSTNAME
=
"
$OPTARG
"
;;
esac
done
while
true
;
do
HOST
=
`
hostname
`
echon
"Enter system hostname (short form, e.g. 'foo') [
$HOST
]: "
default_read HOST
`
hostname
`
if
[
-n
"
$HOSTNAME
"
]
;
then
HOST
=
"
$HOSTNAME
"
else
HOST
=
`
hostname
`
echon
"Enter system hostname (short form, e.g. 'foo') [
$HOST
]: "
default_read HOST
`
hostname
`
fi
if
valid_hostname
"
$HOST
"
;
then
break
fi
...
...
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