Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
35 changes: 30 additions & 5 deletions install.sh
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,34 @@ verify_system() {
fatal 'Can not find systemd or openrc to use as a process supervisor for k3s'
}

# --- use sudo if we are not already root ---
set_sudo_cmd() {
SUDO=sudo
if [ $(id -u) -eq 0 ]; then
SUDO=
fi
}

# --- check for a running firewall and warn ---
warn_if_firewall_running() {
set_sudo_cmd
# --- suse/rhel ---
if [ -x /usr/bin/firewall-cmd ]; then
$SUDO firewall-cmd --state > /dev/null 2>&1 && rc=$? || rc=$?
# --- 252 = NOT_RUNNING ---
if [ $rc -ne "252" ]; then
warn 'Using firewalld with K3s is not recommended. See https://docs.k3s.io/installation/requirements'
fi
fi
# --- debian/ubuntu ---
if [ -x /usr/sbin/ufw ]; then
$SUDO /usr/bin/ufw | grep -qw active && rc=$? || rc=$?
if [ $rc -eq "0" ]; then
warn 'Using ufw with K3s is not recommended. See https://docs.k3s.io/installation/requirements'
fi
fi
}

# --- add quotes to command arguments ---
quote() {
for arg in "$@"; do
Expand Down Expand Up @@ -212,11 +240,7 @@ setup_env() {
${invalid_chars}"
fi

# --- use sudo if we are not already root ---
SUDO=sudo
if [ $(id -u) -eq 0 ]; then
SUDO=
fi
set_sudo_cmd

# --- use systemd type if defined or create default ---
if [ -n "${INSTALL_K3S_TYPE}" ]; then
Expand Down Expand Up @@ -1147,6 +1171,7 @@ eval set -- $(escape "${INSTALL_K3S_EXEC}") $(quote "$@")
# --- run the install process --
{
verify_system
warn_if_firewall_running
setup_env "$@"
download_and_verify
setup_selinux
Expand Down
2 changes: 1 addition & 1 deletion install.sh.sha256sum
Original file line number Diff line number Diff line change
@@ -1 +1 @@
48fe6ec10517263cc69e1c924cf6b283c59a2b942b9b46186fc7c8d29e6f243a install.sh
8b4a2fdc02e053c13705012b69f44a9bdb19c4fe656f783d95ee01a08e39c1e3 install.sh
Loading