Skip to content

Commit 748c689

Browse files
committed
Rename script
1 parent fe2ca3e commit 748c689

File tree

3 files changed

+4
-4
lines changed

3 files changed

+4
-4
lines changed

scripts/cloud_init/update_timesyncd.sh scripts/cloud_init/install_chrony.sh

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
set -euo pipefail
44

55
systemctl disable --now systemd-timesyncd
6-
apt install -y chrony
6+
apt-get install -y chrony
77

88
cat >/etc/chrony/chrony.conf <<EOF
99
pool time.aws.com iburst

src/cloud_init_scripts.json

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"override_k3s_service.sh": "#!/usr/bin/env bash\n\nset -euo pipefail\n\nmkdir -p /etc/systemd/system/k3s.service.d\nmkdir -p /etc/systemd/system/k3s-agent.service.d\n\ncat >/etc/systemd/system/k3s.service.d/override.conf <<EOF\n[Service]\nKillSignal=SIGTERM\nTimeoutStopSec=10\nEOF\n\ncat >/etc/systemd/system/k3s-agent.service.d/override.conf <<EOF\n[Service]\nKillSignal=SIGTERM\nTimeoutStopSec=10\nEOF",
33
"pin_ip_addresses.sh": "#!/usr/bin/env bash\n\nset -euo pipefail\n\narch=\"amd64\"\n\nif [[ \"$(uname -m)\" == \"aarch64\" ]]; then\n arch=\"arm64\"\nfi\n\nwget -qO /usr/bin/yq https://github.com/mikefarah/yq/releases/download/v4.35.2/yq_linux_\"${arch}\"\n\nchmod +x /usr/bin/yq\n\nreadarray ifaces < <(yq -o=j -I=0 '.network.ethernets | to_entries | .[]' /etc/netplan/50-cloud-init.yaml)\n\ndeclare -p ifaces\n\nmkdir -p /etc/netplan\n\ncat >/etc/netplan/99-netcfg-static.yaml <<EOF\nnetwork:\n version: 2\n ethernets:\nEOF\n\nchmod 0700 /etc/netplan/*\n\nlastIp=\"\"\nlastIface=\"\"\nlastName=\"\"\n\nfor iface in \"${ifaces[@]}\"; do\n lastName=$(echo \"$iface\" | yq '.key' -) || exit $?\n mac=$(echo \"$iface\" | yq '.value.match.macaddress' -) || exit $?\n lastIface=$(ip -br link | awk -v mac=\"$mac\" '$3 ~ mac { print $1 }') || exit $?\n lastIp=$(wait_for_interface.sh \"$lastIface\") || exit $?\n\n {\n echo \" ${lastName}:\"\n echo \" addresses:\"\n echo \" - ${lastIp}\"\n } >>/etc/netplan/99-netcfg-static.yaml\ndone\n\necho \"$lastIface\" >/etc/node-external-iface\necho \"$lastIp\" | awk -F/ '{print $1}' >/etc/node-external-ip\ncat /etc/netplan/99-netcfg-static.yaml\nnetplan apply\n\necho \"Waiting for network to come back up...\"\n\nwhile ! ping -c 1 -W 1 8.8.8.8; do\n sleep 1\n echo \"Still waiting for network to come back up...\"\ndone\n",
4-
"update_timesyncd.sh": "#!/usr/bin/env bash\n\nset -euo pipefail\n\nsystemctl disable --now systemd-timesyncd\napt install -y chrony\n\ncat >/etc/chrony/chrony.conf <<EOF\npool time.aws.com iburst\n\n# Use time sources from DHCP.\nsourcedir /run/chrony-dhcp\n\n# This directive specify the location of the file containing ID/key pairs for\n# NTP authentication.\nkeyfile /etc/chrony/chrony.keys\n\n# This directive specify the file into which chronyd will store the rate\n# information.\ndriftfile /var/lib/chrony/chrony.drift\n\n# Save NTS keys and cookies.\nntsdumpdir /var/lib/chrony\n\n# Uncomment the following line to turn logging on.\n#log tracking measurements statistics\n\n# Log files location.\nlogdir /var/log/chrony\n\n# Stop bad estimates upsetting machine clock.\nmaxupdateskew 100.0\n\n# This directive enables kernel synchronisation (every 11 minutes) of the\n# real-time clock. Note that it can’t be used along with the 'rtcfile' directive.\nrtcsync\n\n# Step the system clock instead of slewing it if the adjustment is larger than\n# one second, but only in the first three clock updates.\nmakestep 1 3\n\n# Get TAI-UTC offset and leap seconds from the system tz database.\n# This directive must be commented out when using time sources serving\n# leap-smeared time.\nleapsectz right/UTC\nEOF\n\nservice chrony force-reload\nchronyc tracking",
5-
"wait_for_interface.sh": "#!/usr/bin/env bash\n\nset -euo pipefail\n\ninterface=${1:?\"Interface name is required\"}\n\nmaxAttempts=15\n\nattempts=0\n\nwhile ! ip addr show \"$interface\" | grep 'inet ' 1>&2; do\n if [[ $attempts -ge $maxAttempts ]]; then\n echo >&2 \"Timed out waiting for $interface to be up.\"\n exit 1\n fi\n\n echo >&2 \"Waiting for $interface to be up...\"\n sleep 1\n attempts=$((attempts + 1))\ndone\n\nip addr show \"$interface\" | grep 'inet ' | awk '{print $2}'\n"
4+
"wait_for_interface.sh": "#!/usr/bin/env bash\n\nset -euo pipefail\n\ninterface=${1:?\"Interface name is required\"}\n\nmaxAttempts=15\n\nattempts=0\n\nwhile ! ip addr show \"$interface\" | grep 'inet ' 1>&2; do\n if [[ $attempts -ge $maxAttempts ]]; then\n echo >&2 \"Timed out waiting for $interface to be up.\"\n exit 1\n fi\n\n echo >&2 \"Waiting for $interface to be up...\"\n sleep 1\n attempts=$((attempts + 1))\ndone\n\nip addr show \"$interface\" | grep 'inet ' | awk '{print $2}'\n",
5+
"install_chrony.sh": "#!/usr/bin/env bash\n\nset -euo pipefail\n\nsystemctl disable --now systemd-timesyncd\napt-get install -y chrony\n\ncat >/etc/chrony/chrony.conf <<EOF\npool time.aws.com iburst\n\n# Use time sources from DHCP.\nsourcedir /run/chrony-dhcp\n\n# This directive specify the location of the file containing ID/key pairs for\n# NTP authentication.\nkeyfile /etc/chrony/chrony.keys\n\n# This directive specify the file into which chronyd will store the rate\n# information.\ndriftfile /var/lib/chrony/chrony.drift\n\n# Save NTS keys and cookies.\nntsdumpdir /var/lib/chrony\n\n# Uncomment the following line to turn logging on.\n#log tracking measurements statistics\n\n# Log files location.\nlogdir /var/log/chrony\n\n# Stop bad estimates upsetting machine clock.\nmaxupdateskew 100.0\n\n# This directive enables kernel synchronisation (every 11 minutes) of the\n# real-time clock. Note that it can’t be used along with the 'rtcfile' directive.\nrtcsync\n\n# Step the system clock instead of slewing it if the adjustment is larger than\n# one second, but only in the first three clock updates.\nmakestep 1 3\n\n# Get TAI-UTC offset and leap seconds from the system tz database.\n# This directive must be commented out when using time sources serving\n# leap-smeared time.\nleapsectz right/UTC\nEOF\n\nservice chrony force-reload\nchronyc tracking"
66
}

src/utils.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -309,7 +309,7 @@ export async function createCloudInitConfig(
309309
],
310310
runcmd: [
311311
"sysctl -p /etc/sysctl.d/98-inotify.conf",
312-
"/usr/bin//update_timesyncd.sh",
312+
"/usr/bin/install_chrony.sh",
313313
"/usr/bin/pin_ip_addresses.sh",
314314
"/usr/bin/override_k3s_service.sh",
315315
...(instance.role === "server" && instance.keepalived ? ["/usr/bin/setup_keepalived.sh"] : []),

0 commit comments

Comments
 (0)