cloudflare / cloudflare/cloudflared
Init system detection🐛
- Dominant language
- Go
- Stars
- 15.6k
- Forks
- 1.4k
- PR merge metrics
- No merged PRs in 30d
Description
## 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
```console
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:
4. Tunnel ID : `Irrelevant (correctly configured)`
5. 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**
- OS: [Gentoo Linux (open-rc init)]
- Architecture: [amd64 (x86_64)]
- Version: [2022.12.13 (latest git pull as of the time of install)]
## 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.
- Importance: Very low
- Affected functionality: Only automatic service install
## Additional info
### Ebuild file config for compilation
```bash
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.
Contributor guide
Assessment
This issue has not been assessed yet.