Skip to content

Commit 54c8d00

Browse files
committed
Set hostname to sdc:hostname. Fixes #6.
1 parent 12250a8 commit 54c8d00

File tree

2 files changed

+25
-0
lines changed

2 files changed

+25
-0
lines changed

src/lib/smartdc/mdata-fetch

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,24 @@ if [[ ! -d /var/db ]]; then
1717
mkdir -p /var/db
1818
fi
1919

20+
smartdc_info "Retrieving metadata sdc:hostname"
21+
22+
$MDATA_GET sdc:hostname >/etc/hostname.new
23+
case $? in
24+
0)
25+
smartdc_info "Metadata sdc:hostname successfuly retrieved."
26+
mv /etc/hostname{.new,}
27+
smartdc_info "Setting hostname"
28+
hostname $(cat /etc/hostname)
29+
;;
30+
1)
31+
smartdc_info "Metadata sdc:hostname not defined."
32+
rm -f /etc/hostname.new
33+
;;
34+
*)
35+
smartdc_fatal "Metadata couldn't be retrieved."
36+
;;
37+
esac
2038

2139
smartdc_info "Retrieving metadata user-data"
2240

src/lib/smartdc/redhat

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,3 +6,10 @@
66

77
# load common functions and vars
88
. /lib/smartdc/common.lib
9+
10+
11+
# Set hostname to value set in /etc/hostname
12+
# Ensures we get the hostname from meta data sdc:hostname if it was set.
13+
NEWHOSTNAME=$(cat /etc/hostname)
14+
15+
sed -i '/HOSTNAME=/HOSTNAME=${NEWHOSTNAME}/g' /etc/sysconfig/network

0 commit comments

Comments
 (0)