File tree 1 file changed +15
-2
lines changed
1 file changed +15
-2
lines changed Original file line number Diff line number Diff line change @@ -123,14 +123,24 @@ export function isActive(unitName: string, unit?: Unit) {
123
123
const type = getType ( unitName , unit ) ;
124
124
const name = getName ( unitName ) ;
125
125
126
- return execSync ( `systemctl is-active ${ name } .${ type } ` ) . toString ( ) . trim ( ) === "active" ;
126
+ try {
127
+ return execSync ( `systemctl is-active ${ name } .${ type } ` ) . toString ( ) . trim ( ) === "active" ;
128
+ }
129
+ catch {
130
+ return false ;
131
+ }
127
132
}
128
133
129
134
export function isEnabled ( unitName : string , unit ?: Unit ) {
130
135
const type = getType ( unitName , unit ) ;
131
136
const name = getName ( unitName ) ;
132
137
133
- return execSync ( `systemctl is-enabled ${ name } .${ type } ` ) . toString ( ) . trim ( ) === "enabled" ;
138
+ try {
139
+ return execSync ( `systemctl is-enabled ${ name } .${ type } ` ) . toString ( ) . trim ( ) === "enabled" ;
140
+ }
141
+ catch {
142
+ return false ;
143
+ }
134
144
}
135
145
136
146
export function daemonReload ( ) {
@@ -171,6 +181,9 @@ export class Ctl {
171
181
}
172
182
}
173
183
184
+ /**
185
+ * Enabled Unit will be started on next boot
186
+ */
174
187
public enable ( ) {
175
188
execSync ( `systemctl enable ${ this . name } .${ this . type } ` ) ;
176
189
}
You can’t perform that action at this time.
0 commit comments