-
Notifications
You must be signed in to change notification settings - Fork 92
/
coreos-installer-service
executable file
·104 lines (88 loc) · 2.93 KB
/
coreos-installer-service
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
#!/bin/bash
set -e
# Kernel networking params to persist
PERSIST_KERNEL_NET_PARAMS=("ipv6.disable" "net.ifnames" "net.naming-scheme")
# Dracut networking params to persist
# Everything other than rd.neednet.
# List from https://www.mankier.com/7/dracut.cmdline#Description-Network
PERSIST_DRACUT_NET_PARAMS=("ip" "ifname" "rd.route" "bootdev" "BOOTIF" "rd.bootif" "nameserver" "rd.peerdns" "biosdevname" "vlan" "bond" "team" "bridge" "rd.net.timeout.carrier" "coreos.no_persist_ip")
# IBM S390X params to persist
PERSIST_S390X_PARAMS=("rd.dasd" "rd.zfcp" "rd.znet" "zfcp.allow_lun_scan" "cio_ignore")
args=("install")
cmdline=( $(</proc/cmdline) )
karg() {
local name="$1" value="$2"
for arg in "${cmdline[@]}"; do
if [[ "${arg%%=*}" == "${name}" ]]; then
value="${arg#*=}"
fi
done
echo "${value}"
}
karg_bool() {
local value=$(karg "$@")
case "$value" in
""|0|no|off) return 1;;
*) return 0;;
esac
}
copy_arg() {
local arg="$1"; shift
local opt="$1"; shift
local value="$(karg "${arg}")"
if [ ! -z "${value}" ]; then
args+=("${opt}" "${value}")
fi
}
# Get install device
device="$(karg coreos.inst.install_dev)"
if [ -z "${device}" ]; then
echo "No install device specified."
exit 1
fi
if [ "${device##*/}" = "${device}" ]; then
# karg contains no slashes. Prepend "/dev/" for compatibility.
device="/dev/${device}"
fi
args+=("${device}")
# Ignition URL
ignition_url="$(karg coreos.inst.ignition_url)"
# Ignore "skip" for compatibility
if [ -n "${ignition_url}" -a "${ignition_url}" != "skip" ]; then
# Allow HTTP URLs for compatibility
args+=("--ignition-url" "${ignition_url}" "--insecure-ignition")
fi
# Forward whitelisted kernel arguments to the installed system. We have
# separate sets of whitelists for first-boot kargs and persistent kargs.
# Only pass --firstboot-kargs if additional networking options have been
# specified, since the default in coreos-assembler specifies
# `rd.neednet=1 ip=dhcp` when no options are persisted.
firstboot_args=""
for item in "${cmdline[@]}"; do
for param in "${PERSIST_KERNEL_NET_PARAMS[@]}" "${PERSIST_DRACUT_NET_PARAMS[@]}"; do
if [[ $item =~ ^$param(=.*)?$ ]]; then
firstboot_args+="${item} "
fi
done
for param in "${PERSIST_S390X_PARAMS[@]}"; do
if [[ $item =~ ^$param(=.*)?$ ]]; then
args+=("--append-karg" "${item}")
fi
done
done
if [ -n "${firstboot_args}" ]; then
args+=("--firstboot-args" "rd.neednet=1 ${firstboot_args}")
fi
# Other args that should just be copied over
copy_arg coreos.inst.image_url --image-url
copy_arg coreos.inst.platform_id --platform
copy_arg coreos.inst.stream --stream
# Insecure boolean
if karg_bool coreos.inst.insecure; then
args+=("--insecure")
fi
# Ensure device nodes have been created
udevadm settle
# Install
echo "coreos-installer ${args[@]}"
coreos-installer "${args[@]}"