no message
parent
4647fcd2c8
commit
041ce106ec
|
@ -1,7 +1,4 @@
|
||||||
instance-id: iid-%GUEST_NAME%;
|
instance-id: iid-%GUEST_NAME%;
|
||||||
network-interfaces: |
|
|
||||||
allow-hotplug eth0
|
|
||||||
iface eth0 inet dhcp
|
|
||||||
hostname: %GUEST_NAME%
|
hostname: %GUEST_NAME%
|
||||||
local-hostname: %GUEST_NAME%
|
local-hostname: %GUEST_NAME%
|
||||||
manage_resolv_conf: false
|
manage_resolv_conf: false
|
||||||
|
|
|
@ -0,0 +1,17 @@
|
||||||
|
## /network-config
|
||||||
|
---
|
||||||
|
version: 1
|
||||||
|
config:
|
||||||
|
- type: physical
|
||||||
|
name: eth0
|
||||||
|
subnets:
|
||||||
|
- type: static
|
||||||
|
address: %%IP_ADDRESS%%
|
||||||
|
netmask: %%NETMASK%%
|
||||||
|
routes:
|
||||||
|
- network: 0.0.0.0
|
||||||
|
netmask: 0.0.0.0
|
||||||
|
gateway: %%GATEWAY%%
|
||||||
|
- type: nameserver
|
||||||
|
address: [%%NAME_SERVER%%]
|
||||||
|
search: [%%DOMAIN%%]
|
|
@ -36,12 +36,13 @@ usage() {
|
||||||
echo -e "\t-r ram size (in megabytes) *"
|
echo -e "\t-r ram size (in megabytes) *"
|
||||||
echo -e "\t-c number of vcpus"
|
echo -e "\t-c number of vcpus"
|
||||||
echo -e "\t-b bridge to attach to *"
|
echo -e "\t-b bridge to attach to *"
|
||||||
echo -e "\t-x network info (ip:netmask:gateway)"
|
echo -e "\t-x network info"
|
||||||
|
echo -e "(type:ip:netmask:gateway - type=eni/1, ip=dhcp or address, default eni dhcp)"
|
||||||
echo -e "\t-i distribution to use (see script for supported options) - default is stretch"
|
echo -e "\t-i distribution to use (see script for supported options) - default is stretch"
|
||||||
echo -e "\t-o OS type and variant (default: generic:generic - also set by distro option when available)"
|
echo -e "\t-o OS type and variant (default: generic:generic - also set by distro option when available)"
|
||||||
}
|
}
|
||||||
|
|
||||||
while getopts "c:r:s:n:d:i:o:b:h" opt; do
|
while getopts "c:r:s:n:d:i:o:b:x:h" opt; do
|
||||||
case $opt in
|
case $opt in
|
||||||
c) cpucount=$OPTARG;;
|
c) cpucount=$OPTARG;;
|
||||||
r) ram=$OPTARG;;
|
r) ram=$OPTARG;;
|
||||||
|
@ -51,6 +52,7 @@ while getopts "c:r:s:n:d:i:o:b:h" opt; do
|
||||||
i) distro=$OPTARG;;
|
i) distro=$OPTARG;;
|
||||||
o) ostype=$OPTARG;;
|
o) ostype=$OPTARG;;
|
||||||
b) bridge=$OPTARG;;
|
b) bridge=$OPTARG;;
|
||||||
|
x) netinfo=$OPTARG;;
|
||||||
h) help="yes";;
|
h) help="yes";;
|
||||||
esac
|
esac
|
||||||
done
|
done
|
||||||
|
@ -62,6 +64,17 @@ if [[ -z $ram || -z $storage || -z $hostname || -z $domain || -z $bridge || $he
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
if [[ -f ${WORKING_DIR}/config ]]; then
|
||||||
|
source ${WORKING_DIR}/config
|
||||||
|
else
|
||||||
|
echo "Error: Missing ${WORKING_DIR}/config !"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [[ -f ${WORKING_DIR}/config.local ]]; then
|
||||||
|
source ${WORKING_DIR}/config.local
|
||||||
|
fi
|
||||||
|
|
||||||
if [[ -z $distro ]]; then
|
if [[ -z $distro ]]; then
|
||||||
distro="stretch"
|
distro="stretch"
|
||||||
fi
|
fi
|
||||||
|
@ -70,6 +83,22 @@ if [[ -z $cpucount ]]; then
|
||||||
cpucount="2"
|
cpucount="2"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
if [[ -z $netinfo ]]; then
|
||||||
|
netinfo="eni:dhcp"
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [[ ! -z $netinfo ]]; then
|
||||||
|
OIFS=${IFS}
|
||||||
|
IFS=:
|
||||||
|
read -ra $netinfo_config <<< "$netinfo"
|
||||||
|
virt_netinfo_type=${netinfo_config[0]}
|
||||||
|
virt_netinfo_address=${netinfo_config[1]}
|
||||||
|
virt_netinfo_netmask=${netinfo_config[2]}
|
||||||
|
virt_netinfo_gateway=${netinfo_config[3]}
|
||||||
|
IFS=${OIFS}
|
||||||
|
fi
|
||||||
|
|
||||||
|
|
||||||
if [[ ! -z $ostype ]]; then
|
if [[ ! -z $ostype ]]; then
|
||||||
OIFS=${IFS}
|
OIFS=${IFS}
|
||||||
IFS=:
|
IFS=:
|
||||||
|
@ -86,21 +115,25 @@ arch="amd64"
|
||||||
|
|
||||||
source distros
|
source distros
|
||||||
|
|
||||||
if [[ -f ${WORKING_DIR}/config ]]; then
|
sed -e "s/%GUEST_NAME%/${hostname}/" ${WORKING_DIR}/meta-data > ${WORKING_DIR}/output/meta-data
|
||||||
source ${WORKING_DIR}/config
|
sed -e "s/%FQDN%/${hostname}.${domain}/" ${WORKING_DIR}/user-data > ${WORKING_DIR}/output/user-data
|
||||||
|
|
||||||
|
if [[ ${virt_netinfo_type} == "eni" ]]; then
|
||||||
|
cat ${WORK_DIR}/network/legacy-eni >> ${WORK_DIR}/output/meta-data
|
||||||
|
if [[ ${virt_netinfo_address} == "dhcp" ]]; then
|
||||||
|
echo " iface eth0 inet dhcp" >> ${WORK_DIR}/output/meta-data
|
||||||
else
|
else
|
||||||
echo "Error: Missing ${WORKING_DIR}/config !"
|
echo " iface eth0 inet static" >> ${WORK_DIR}/output/meta-data
|
||||||
exit 1
|
echo " address ${virt_netinfo_address}" >> ${WORK_DIR}/output/meta-data
|
||||||
|
echo " netmask ${virt_netinfo_netmask}" >> ${WORK_DIR}/output/meta-data
|
||||||
|
echo " gateway ${virt_netinfo_gateway}" >> ${WORK_DIR}/output/meta-data
|
||||||
fi
|
fi
|
||||||
|
elif [[ $virt_netinfo_type == "1" ]]; then
|
||||||
if [[ -f config.local ]]; then
|
echo "Not implemented yet!"
|
||||||
source config.local
|
elif [[ $virt_netinfo_type == "2" ]]; then
|
||||||
|
echo "Not implemented yet!"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
sed -e "s/%GUEST_NAME%/${hostname}/" meta-data > output/meta-data
|
|
||||||
sed -e "s/%FQDN%/${hostname}.${domain}/" user-data > output/user-data
|
|
||||||
|
|
||||||
|
|
||||||
if [[ ! -f images/${IMG_NAME} ]]; then
|
if [[ ! -f images/${IMG_NAME} ]]; then
|
||||||
echo "Downloading image ${IMG_NAME}..."
|
echo "Downloading image ${IMG_NAME}..."
|
||||||
wget ${IMG_URL}/${IMG_NAME} -O images/${IMG_NAME}
|
wget ${IMG_URL}/${IMG_NAME} -O images/${IMG_NAME}
|
||||||
|
|
Loading…
Reference in New Issue