{"id":24302798,"url":"https://github.com/taigrr/systemctl","last_synced_at":"2025-08-23T06:05:51.600Z","repository":{"id":102067337,"uuid":"367483173","full_name":"taigrr/systemctl","owner":"taigrr","description":"Provides idiomatic systemctl bindings for go developers, in order to make it easier to write system tooling using golang.","archived":false,"fork":false,"pushed_at":"2025-05-23T21:48:40.000Z","size":98,"stargazers_count":59,"open_issues_count":1,"forks_count":8,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-05-23T22:34:30.186Z","etag":null,"topics":["go","golang","hacktoberfest","systemctl","systemd","wrapper-library"],"latest_commit_sha":null,"homepage":"","language":"Go","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"0bsd","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/taigrr.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":".github/FUNDING.yml","license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null},"funding":{"github":"taigrr","patreon":null,"open_collective":null,"ko_fi":null,"tidelift":null,"community_bridge":null,"liberapay":null,"issuehunt":null,"otechie":null,"custom":null}},"created_at":"2021-05-14T21:28:04.000Z","updated_at":"2025-05-23T21:48:43.000Z","dependencies_parsed_at":null,"dependency_job_id":"f834a923-2118-48a3-b88b-c6e244656719","html_url":"https://github.com/taigrr/systemctl","commit_stats":null,"previous_names":[],"tags_count":11,"template":false,"template_full_name":null,"purl":"pkg:github/taigrr/systemctl","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/taigrr%2Fsystemctl","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/taigrr%2Fsystemctl/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/taigrr%2Fsystemctl/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/taigrr%2Fsystemctl/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/taigrr","download_url":"https://codeload.github.com/taigrr/systemctl/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/taigrr%2Fsystemctl/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":271745692,"owners_count":24813516,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","status":"online","status_checked_at":"2025-08-23T02:00:09.327Z","response_time":69,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["go","golang","hacktoberfest","systemctl","systemd","wrapper-library"],"created_at":"2025-01-17T00:19:24.187Z","updated_at":"2025-08-23T06:05:51.571Z","avatar_url":"https://github.com/taigrr.png","language":"Go","readme":"[![PkgGoDev](https://pkg.go.dev/badge/github.com/taigrr/systemctl)](https://pkg.go.dev/github.com/taigrr/systemctl)\n# systemctl\n\nThis library aims at providing idiomatic `systemctl` bindings for go developers, in order to make it easier to write system tooling using golang.\nThis tool tries to take guesswork out of arbitrarily shelling out to `systemctl` by providing a structured, thoroughly-tested wrapper for the `systemctl` functions most-likely to be used in a system program.\n\nIf your system isn't running (or targeting another system running) `systemctl`, this library will be of little use to you.\n\n## What is systemctl\n\n`systemctl` is a command-line program which grants the user control over the systemd system and service manager.\n\n`systemctl` may be used to introspect and control the state of the \"systemd\" system and service manager. Please refer to `systemd(1)` for an introduction into the basic concepts and functionality this tool manages.\n\n## Supported systemctl functions\n\n- [x] `systemctl daemon-reload`\n- [x] `systemctl disable`\n- [x] `systemctl enable`\n- [x] `systemctl reenable`\n- [x] `systemctl is-active`\n- [x] `systemctl is-enabled`\n- [x] `systemctl is-failed`\n- [x] `systemctl mask`\n- [x] `systemctl restart`\n- [x] `systemctl show`\n- [x] `systemctl start`\n- [x] `systemctl status`\n- [x] `systemctl stop`\n- [x] `systemctl unmask`\n\n## Helper functionality\n\n- [x] Get start time of a service (`ExecMainStartTimestamp`) as a `Time` type\n- [x] Get current memory in bytes (`MemoryCurrent`) an an int\n- [x] Get the PID of the main process (`MainPID`) as an int\n- [x] Get the restart count of a unit (`NRestarts`) as an int\n\n\n## Useful errors\n\nAll functions return a predefined error type, and it is highly recommended these errors are handled properly.\n\n## Context support\n\nAll calls into this library support go's `context` functionality.\nTherefore, blocking calls can time out according to the caller's needs, and the returned error should be checked to see if a timeout occurred (`ErrExecTimeout`).\n\n\n## Simple example\n\n```go\npackage main\n\nimport (\n    \"context\"\n    \"fmt\"\n    \"log\"\n    \"time\"\n\n    \"github.com/taigrr/systemctl\"\n)\n\nfunc main() {\n    ctx, cancel := context.WithTimeout(context.Background(), 10*time.Second)\n    defer cancel()\n    // Equivalent to `systemctl enable nginx` with a 10 second timeout\n    opts := systemctl.Options{ UserMode: false }\n    unit := \"nginx\"\n    err := systemctl.Enable(ctx, unit, opts)\n    if err != nil {\n        log.Fatalf(\"unable to enable unit %s: %v\", \"nginx\", err)\n    }\n}\n```\n\n## License\n\nThis project is licensed under the 0BSD License, written by [Rob Landley](https://github.com/landley).\nAs such, you may use this library without restriction or attribution, but please don't pass it off as your own.\nAttribution, though not required, is appreciated.\n\nBy contributing, you agree all code submitted also falls under the License.\n\n## External resources\n\n- [Official systemctl documentation](https://www.man7.org/linux/man-pages/man1/systemctl.1.html)\n- [Inspiration for this repo](https://github.com/Ullaakut/nmap/)\n","funding_links":["https://github.com/sponsors/taigrr"],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftaigrr%2Fsystemctl","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ftaigrr%2Fsystemctl","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftaigrr%2Fsystemctl/lists"}