cloudflare / cloudflared

Cloudflare Tunnel client (formerly Argo Tunnel)
https://developers.cloudflare.com/cloudflare-one/connections/connect-apps/install-and-setup/tunnel-guide
Apache License 2.0
8.49k stars 740 forks source link

Init system detection🐛 #848

Open LinuxMeow opened 1 year ago

LinuxMeow commented 1 year ago

Describe the bug

This is not an affecting issue for the functionality nor it is high priority issue or anything I just thought of adding it as suggestion here.

Installing cloudflared on Gentoo Linux works as intended and expected, especially on systemd installation.

However there is a problem with open-rc version of Gentoo Linux.

It incorrectly detects init system as SysV which causes

doas cloudflared --config ~/.cloudflared.config.yaml service install

to fail cause it is trying to execute service command instead of rc-service.

To Reproduce Steps to reproduce the behavior:

  1. Configure:
    • Gentoo Linux install with open-rc init
  2. Run:
    • doas cloudflared --config ~/.cloudflared/config.yaml service install (or sudo instead of doas)
  3. See error:
    • Detected init system SysV
    • Unable to execute service command not in $PATH

If it's an issue with Cloudflare Tunnel:

  1. Tunnel ID : Irrelevant (correctly configured)
  2. cloudflared config: Irrelevant (correctly configured)

Expected behavior

Cloudflared service install detects open-rc init

Cloudflare detects proper open-rc init system and tries to execute rc-service command accordingly instead of service.

Environment and versions

Logs and errors

Errors as described previously.

It doesn't affect the function of the tunnel itself, and it is also possible to manually install service without cloudflared command.

Additional info

Ebuild file config for compilation

Close
# Copyright 1999-2021 Gentoo Authors
# Distributed under the terms of the GNU General Public License v2

EAPI=7

EGIT_REPO_URI="https://github.com/cloudflare/${PN}.git"

inherit git-r3 go-module systemd

DESCRIPTION="Argo Tunnel client"
HOMEPAGE="https://github.com/cloudflare/cloudflared"
SRC_URI=""

LICENSE="Cloudflare"
SLOT="0"
KEYWORDS=""
RESTRICT="test" # needs net

RDEPEND="acct-user/cloudflared"

DOCS=( {CHANGES,README}.md RELEASE_NOTES )

src_unpack() {
    git-r3_src_unpack
}

src_prepare() {
    default

    DATE="$(date -u '+%Y-%m-%d-%H%M UTC')"
    sed -i  -e "s/\${VERSION}/${PV}/" \
        -e "s/\${DATE}/${DATE}/" cloudflared_man_template \
            || die "sed failed for cloudflared_man_template"
}

src_compile() {
    DATE="$(date -u '+%Y-%m-%d-%H%M UTC')"
    LDFLAGS="-X main.Version=${PV} -X \"main.BuildTime=${DATE}\""
    go build -v -mod=vendor -ldflags="${LDFLAGS}" ./cmd/cloudflared || die "build failed"
}

src_test() {
    go test -v -mod=vendor -work ./... || die "test failed"
}

src_install() {
    einstalldocs
    newman cloudflared_man_template cloudflared.1
    dobin cloudflared
    insinto /etc/cloudflared
    doins "${FILESDIR}"/config.yml
    newinitd "${FILESDIR}"/cloudflared.initd cloudflared
    newconfd "${FILESDIR}"/cloudflared.confd cloudflared
    systemd_dounit "${FILESDIR}"/cloudflared.service
}

Relevant to questioned info about version in previous step.

Package is compiled under Gentoo Linux version 9999 (or latest version).

Only relevant for documenting the package version, not relevant in the actual issue caused.

sudarshan-reddy commented 1 year ago

Thanks for this @LinuxMeow ! Unfortunately, I dont see this as something we'll be getting to anytime soon. Do you want to help with this?