summaryrefslogtreecommitdiff
path: root/emulators/vmware3/scripts/configure
blob: 4b00cb17e72e9132d1f2b61c2aabac2c8ce018d1 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
#!/bin/sh

[ "_$VMNET_HOST_IP" = _ ] && VMNET_HOST_IP="192.168.254.1"
[ "_$VMNET_NETMASK" = _ ] && VMNET_NETMASK="255.255.255.0"

host_ip=$VMNET_HOST_IP
netmask=$VMNET_NETMASK
title="VMware network options"

get_network_settings() {
    bridged="NO"
    /usr/bin/dialog --title "$title" --clear --yesno \
"\n"\
"Do you want to use netgraph bridging?\n"\
    10 50
    if [ $? -eq 0 ]; then
	bridged="YES"
	result=`/usr/bin/dialog --title "$title" --clear --inputbox \
"\n"\
"To which interface would you\n"\
"like to tie the bridge?:"\
	10 50 "" \
	2>&1 > /dev/tty`
	case $? in
	0)
	    if [ -z "$result" ]; then
		return 1
	    fi
	    bdg_interface=$result
	    ;;
        1)
	    return 1
	    ;;
	esac
	host_ip=192.168.0.1
	netmask=255.255.255.0
    else

    result=`/usr/bin/dialog --title "$title" --clear --inputbox \
"\n"\
"What will be the IP address of your host\n"\
"on your private network?:"\
    10 50 $host_ip \
    2>&1 >/dev/tty `

    case $? in
    0)
	if [ -z "$result" ]; then
	    return 1
	fi
	host_ip=$result
	;;
    1)	
	return 1
	;;
    esac

    result=`/usr/bin/dialog --title "$title" --clear --inputbox \
"\n"\
"What will be the netmask of your private\n"\
"network?:"\
    10 50 $netmask \
    2>&1 >/dev/tty `

    case $? in
    0)
	if [ -z "$result" ]; then
	    return 1
	fi
	netmask=$result
	;;
    1)	
	return 1
	;;
    esac
    return 0;
    fi
}

do_network() {
    while true; do
	get_network_settings

	if [ "X$bridged" != "XYES" ]; then
	/usr/bin/dialog --title "Confirmation" --clear --yesno \
"\n"\
"Are the following options correct?\n\n"\
"Configuration: host only\n"\
"IP address:    $host_ip\n"\
"Netmask:       $netmask\n"\
	10 50
	[ $? -eq 0 ] && return 0
	else
		/usr/bin/dialog --title "Confirmation" --clear --yesno \
"\n"\
"Are the following options correct?\n\n"\
"Configuration: bridged\n"\
"Interface:     $bdg_interface\n"\
		10 50
		[ $? -eq 0 ] && return 0
	fi

	/usr/bin/dialog --title "Confirmation" --clear --yesno \
"\n"\
"Do you want to edit network options again?\n"\
	10 50
	[ $? -eq 0 ] && continue

	/usr/bin/dialog --title "Confirmation" --clear --yesno \
"\n"\
"Do you want to continue without networking?\n"\
	10 50
	[ $? -eq 0 ] && return 1

	host_ip=$VMNET_HOST_IP
	netmask=$VMNET_NETMASK

	return 0;
    done
}

networking=0
if [ _$BATCH = _ ]; then
    do_network

    if [ $? -eq 0 ]; then
	networking=1
	if [ X$bridged = XYES ]; then
	    /usr/bin/dialog --title "$title" --infobox \
"\n"\
"The following options will be used.\n\n"\
"Configuration: bridged\n"\
"Interface:     $bdg_interface\n"\
	    10 50
	else
	/usr/bin/dialog --title "$title" --infobox \
"\n"\
"The following options will be used.\n\n"\
"Configuration: host only\n"\
"IP address:    $host_ip\n"\
"Netmask:       $netmask\n"\
	10 50
	fi
    fi
else #BATCH
    [ -f ${WRKDIR}/Makefile.inc.net ] && exit 0
fi #BATCH

(
exec > ${WRKDIR}/Makefile.inc.net

echo '#' `date`
echo VMNET_BRIDGED=$bridged
echo VMNET_BRIDGED_INTERFACE=$bdg_interface
echo VMNET_HOST_IP=$host_ip
echo VMNET_NETMASK=$netmask
echo VMNET_NETWORKING=$networking
)

exit 0