troglobit / finit

Fast init for Linux. Cookies included
https://troglobit.com/projects/finit/
MIT License
632 stars 63 forks source link

Read specific condition on/off from external script #255

Closed troglobit closed 2 years ago

troglobit commented 2 years ago

Discussed in https://github.com/troglobit/finit/discussions/251

Originally posted by **hongkongkiwi** April 28, 2022 I have a need to read signal status from a bash script. e.g I have lte_connected and wifi_connected is there a similar command to initctl -a status "service" but for conditions to know if they are set? Right now I'm using: ``` initctl -b -p cond dump | awk '{ print $4 }' | grep -q '^' ``` This method is a bit awkward and involves two additional tools.
troglobit commented 2 years ago
root@zero:~# initctl cond get foo
root@zero:~# initctl -v cond get foo
off
root@zero:~# initctl -v cond set foo
root@zero:~# initctl -v cond get foo
on
root@zero:~# echo $?
0
root@zero:~# initctl -v cond clr foo
root@zero:~# initctl -v cond get foo
off
root@zero:~# echo $?
1