{"id":18607004,"url":"https://github.com/gwbres/systemctl","last_synced_at":"2025-04-05T11:08:11.230Z","repository":{"id":41383289,"uuid":"480746487","full_name":"gwbres/systemctl","owner":"gwbres","description":":penguin: Small rust crate to interact with systemd","archived":false,"fork":false,"pushed_at":"2024-10-24T09:27:54.000Z","size":76,"stargazers_count":25,"open_issues_count":15,"forks_count":16,"subscribers_count":1,"default_branch":"main","last_synced_at":"2024-10-25T06:59:12.391Z","etag":null,"topics":["rust","rust-library","systemd","systemd-service"],"latest_commit_sha":null,"homepage":"","language":"Rust","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/gwbres.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE-APACHE","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}},"created_at":"2022-04-12T09:46:55.000Z","updated_at":"2024-10-24T09:27:58.000Z","dependencies_parsed_at":"2023-02-18T02:31:02.274Z","dependency_job_id":"d314f095-7a1a-4434-99f9-2712cbd6ff55","html_url":"https://github.com/gwbres/systemctl","commit_stats":{"total_commits":59,"total_committers":2,"mean_commits":29.5,"dds":"0.016949152542372836","last_synced_commit":"74b7bbfeabd9e807eb181b5a7703e3ddda79cd0c"},"previous_names":[],"tags_count":12,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/gwbres%2Fsystemctl","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/gwbres%2Fsystemctl/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/gwbres%2Fsystemctl/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/gwbres%2Fsystemctl/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/gwbres","download_url":"https://codeload.github.com/gwbres/systemctl/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247325693,"owners_count":20920714,"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","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":["rust","rust-library","systemd","systemd-service"],"created_at":"2024-11-07T02:27:58.789Z","updated_at":"2025-04-05T11:08:11.209Z","avatar_url":"https://github.com/gwbres.png","language":"Rust","funding_links":[],"categories":[],"sub_categories":[],"readme":"# systemctl\n\nSmall rust crate to interact with systemd units through `systemctl`.\n\nAt the time I needed those features, I was not aware of `zbus-systemd`, which is now available and should be prefered.  \nThis crate uses `systemctl` interaction directly, which is far from ideal for applications.\n`zbus-systemd` should therefore be prefered.\n\n[![crates.io](https://img.shields.io/crates/v/systemctl.svg)](https://crates.io/crates/systemctl)\n[![License](https://img.shields.io/badge/license-Apache%202.0-blue?style=flat-square)](https://github.com/gwbres/systemctl/blob/main/LICENSE-APACHE)\n[![License](https://img.shields.io/badge/license-MIT-blue?style=flat-square)](https://github.com/gwbres/systemctl/blob/main/LICENSE-MIT)\n[![crates.io](https://img.shields.io/crates/d/systemctl.svg)](https://crates.io/crates/systemctl)  \n[![Rust](https://github.com/gwbres/systemctl/actions/workflows/rust.yml/badge.svg?branch=main)](https://github.com/gwbres/systemctl/actions/workflows/rust.yml)\n[![crates.io](https://docs.rs/systemctl/badge.svg)](https://docs.rs/systemctl/badge.svg)\n\n## Features\n\n* serde: Enable to make structs in this crate De-/Serializable\n\n## Limitations\n\nCurrently, systemd Version \u003c245 are not supported as unit-file-list changed from two column to three column setup. See: [systemd Changelog](https://github.com/systemd/systemd/blob/16bfb12c8f815a468021b6e20871061d20b50f57/NEWS#L6073)\n\n## Unit / service operation\n\nNominal service operations:\n\n```rust\nlet systemctl = systemctl::SystemCtl::default();\nsystemctl.stop(\"systemd-journald.service\")\n    .unwrap();\nsystemctl.restart(\"systemd-journald.service\")\n    .unwrap();\n\nif let Ok(true) = systemctl.exists(\"ntpd\") {\n    let is_active = systemctl.is_active(\"ntpd\")\n        .unwrap();\n}\n```\n\n## Service enumeration\n\n```rust\nlet systemctl = systemctl::SystemCtl::default();\n// list all units\nsystemctl.list_units(None, None, None);\n\n// list all services \n// by adding a --type filter\nsystemctl.list_units(Some(\"service\"), None, None);\n\n// list all services currently `enabled` \n// by adding a --state filter\nsystemctl.list_units(Some(\"service\"), Some(\"enabled\"), None);\n\n// list all services starting with cron\nsystemctl.list_units(Some(\"service\"), None, Some(\"cron*\"));\n```\n\n## Unit structure\n\nUse the unit structure for more information\n\n```rust\nlet systemctl = systemctl::SystemCtl::default();\nlet unit = systemctl.create_unit(\"ssh.service\")\n    .unwrap();\nsystemctl.restart(\u0026unit.name).unwrap();\nprintln!(\"active: {}\", unit.active);\nprintln!(\"preset: {}\", unit.preset);\n\nif let Some(docs) = unit.docs { // doc pages available\n    for doc in docs {\n        if let Some(page) = doc.as_man() {\n            // `man` page exists \n        }\n        if let Some(url) = doc.as_url() {\n            // `url` is indicated\n        }\n    }\n}\n\nprintln!(\"auto_start (enabled): {:?}\", unit.auto_start);\nprintln!(\"config script : {}\", unit.script);\nprintln!(\"pid: {:?}\", unit.pid);\nprintln!(\"Running task(s): {:?}\", unit.tasks);\nprintln!(\"Memory consumption: {:?}\", unit.memory);\n```\n\n## TODO\n\n* [ ] parse all known attributes in `from_systemctl`\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fgwbres%2Fsystemctl","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fgwbres%2Fsystemctl","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fgwbres%2Fsystemctl/lists"}