Revision 6161ab06

b/rename
49 49

  
50 50
mount_disk0 $TARGET $root_dev $boot_dev
51 51

  
52
HNAME="$TARGET/etc/hostname"
53
MNAME="$TARGET/etc/mailname"
52
get_os_type
53

  
54
case "${OS_TYPE}" in
55
    debian)
56
        HNAME="${TARGET}/etc/hostname"
57
        OLD_HNAME="$(cat $HNAME)"
58
        ;;
59
    redhat)
60
        HNAME="${TARGET}/etc/sysconfig/network"
61
        OLD_HNAME="$(grep HOSTNAME ${HNAME} | \
62
            sed -e 's/HOSTNAME=//' | cut -d \".\" -f 1)"
63
        ;;
64
    gentoo)
65
        HNAME="${TARGET}/etc/conf.d/hostname"
66
        OLD_HNAME="$(grep HOSTNAME ${HNAME} | \
67
            sed -e 's/HOSTNAME=//' | cut -d \".\" -f 1)"
68
        ;;
69
    suse)
70
        HNAME="${TARGET}/etc/HOSTNAME"
71
        OLD_HNAME="$(cat $HNAME)"
72
        ;;
73
esac
54 74

  
55
# for hostname, we raise and error if the old hostname is not what we
56
# expect
57
OLD_HNAME="`cat $HNAME`"
58 75
if [ "$OLD_HNAME" = "$old_name" ]; then
59
	echo $instance > $HNAME
76
    case "${OS_TYPE}" in
77
        debian|suse)
78
            echo $instance > $HNAME
79
            ;;
80
        redhat|gentoo)
81
            sed -ei "s/HOSTNAME=${OLD_HNAME}/HOSTNAME=${instance}/" $HNAME
82
            ;;
83
    esac
60 84
else
61
	log_error "Cannot rename from $old_name to $instance:"
62
	log_error "Instance has a different hostname ($OLD_HNAME)"
63
	exit 1
64
fi
65

  
66
# for mailname, we rename only if it has the old name, otherwise we
67
# ignore it (and assumme that it's a customized name)
68
if [ "`cat $MNAME`" = "$old_name" ]; then
69
	echo $instance > $MNAME
85
    log_error "Cannot rename from $old_name to $instance:"
86
    log_error "Instance has a different hostname ($OLD_HNAME)"
87
    exit 1
70 88
fi
71 89

  
72 90
# execute cleanups

Also available in: Unified diff