Skip to content

Commit 664e8d3

Browse files
committed
feat(ctl): added isEnabled
1 parent f80118f commit 664e8d3

File tree

2 files changed

+13
-0
lines changed

2 files changed

+13
-0
lines changed

packages/ctl/src/ctl.ts

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -126,6 +126,13 @@ export function isActive(unitName: string, unit?: Unit) {
126126
return execSync(`systemctl is-active ${name}.${type}`).toString().trim() === "active";
127127
}
128128

129+
export function isEnabled(unitName: string, unit?: Unit) {
130+
const type = getType(unitName, unit);
131+
const name = getName(unitName);
132+
133+
return execSync(`systemctl is-enabled ${name}.${type}`).toString().trim() === "enabled";
134+
}
135+
129136
export class Ctl {
130137
private readonly type: string;
131138
private readonly name: string;
@@ -190,4 +197,8 @@ export class Ctl {
190197
public isActive() {
191198
return isActive(this.name, this.unit);
192199
}
200+
201+
public isEnabled() {
202+
return isEnabled(this.name, this.unit);
203+
}
193204
}

packages/ctl/src/index.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,4 +8,6 @@ export {
88
start,
99
stop,
1010
restart,
11+
isActive,
12+
isEnabled,
1113
} from "./ctl.js";

0 commit comments

Comments
 (0)