42 lines
1.1 KiB
Bash
Executable File
42 lines
1.1 KiB
Bash
Executable File
#!/bin/sh
|
|
set -eu
|
|
|
|
exec >>/var/log/monok8s/boot.log 2>&1
|
|
|
|
export PATH="/usr/local/bin:/usr/local/sbin:$PATH"
|
|
|
|
MIGRATIONS_LIB=/usr/lib/monok8s/lib/migrations.sh
|
|
CONFIG_DIR=/opt/monok8s/config
|
|
BOOT_STATE=/run/monok8s/boot-state.env
|
|
BOOTPART_FILE="$CONFIG_DIR/.bootpart"
|
|
MIGRATION_STATE_DIR="$CONFIG_DIR/migration-state"
|
|
|
|
mkdir -p /dev/hugepages
|
|
mountpoint -q /dev/hugepages || mount -t hugetlbfs none /dev/hugepages
|
|
echo 256 > /proc/sys/vm/nr_hugepages
|
|
|
|
CUR=$(grep '^BOOT_PART=' "$BOOT_STATE" | cut -d= -f2-)
|
|
LAST=$(cat "$BOOTPART_FILE" 2>/dev/null || true)
|
|
|
|
slot_changed=0
|
|
if [ "$CUR" != "$LAST" ]; then
|
|
slot_changed=1
|
|
echo "Slot changed ($LAST -> $CUR)"
|
|
fi
|
|
|
|
# shellcheck source=/dev/null
|
|
. "$MIGRATIONS_LIB"
|
|
|
|
if [ "$slot_changed" -eq 1 ]; then
|
|
monok8s_cleanup_runtime_state
|
|
fi
|
|
|
|
K8S_MINOR="$(monok8s_detect_k8s_minor || true)"
|
|
if [ -n "$K8S_MINOR" ]; then
|
|
monok8s_run_migration_dir \
|
|
"/usr/lib/monok8s/migrations.d/k8s/$K8S_MINOR" \
|
|
"$MIGRATION_STATE_DIR/k8s/$K8S_MINOR"
|
|
fi
|
|
|
|
/usr/local/bin/ctl init --env-file "$CONFIG_DIR/cluster.env" >>/var/log/monok8s/bootstrap.log 2>&1 &
|