Unverified Commit d581777e authored by Kroese's avatar Kroese Committed by GitHub
Browse files

feat: Podman detection (#717)

parent 23adf9a3
Loading
Loading
Loading
Loading
+8 −4
Original line number Diff line number Diff line
@@ -207,14 +207,16 @@ configureNAT() {
  fi

  if [ ! -c /dev/net/tun ]; then
    error "$tuntap" && return 1
    [[ "$PODMAN" != [Yy1]* ]] && error "$tuntap" 
    return 1
  fi

  # Check port forwarding flag
  if [[ $(< /proc/sys/net/ipv4/ip_forward) -eq 0 ]]; then
    { sysctl -w net.ipv4.ip_forward=1 > /dev/null; rc=$?; } || :
    if (( rc != 0 )) || [[ $(< /proc/sys/net/ipv4/ip_forward) -eq 0 ]]; then
      error "IP forwarding is disabled. $ADD_ERR --sysctl net.ipv4.ip_forward=1" && return 1
      [[ "$PODMAN" != [Yy1]* ]] && error "IP forwarding is disabled. $ADD_ERR --sysctl net.ipv4.ip_forward=1" 
      return 1
    fi
  fi

@@ -436,6 +438,8 @@ getInfo() {
    [ -n "$IP6" ] && IP6=$(echo "$IP6" | sed -e's/^.*inet6 \([^ ]*\)\/.*$/\1/;t;d' | head -n 1)
  fi

  [ -f "/run/.containerenv" ] && PODMAN="Y" || PODMAN="N"

  return 0
}

@@ -493,10 +497,10 @@ else
      closeBridge
      NETWORK="user"
      msg="falling back to user-mode networking!"
      if [ ! -f "/run/.containerenv" ]; then
      if [[ "$PODMAN" != [Yy1]* ]]; then
        msg="an error occured, $msg"
      else
        msg="podman rootless mode detected, $msg"
        msg="podman detected, $msg"
      fi
      warn "$msg"
      [ -z "$USER_PORTS" ] && info "Notice: port mapping will not work without \"USER_PORTS\" now."