diff --git a/docs/index.md b/docs/index.md index a7398ca..05c071a 100644 --- a/docs/index.md +++ b/docs/index.md @@ -43,3 +43,4 @@ * [kickstart.user.exec](kickstart/user/exec) * [kickstart.user.is_on_group](kickstart/user/is_on_group) * [kickstart.user.remove_group](kickstart/user/remove_group) +* [kickstart.user.root?](kickstart/user/root?) diff --git a/docs/kickstart/user/root?.md b/docs/kickstart/user/root?.md new file mode 100644 index 0000000..a16e657 --- /dev/null +++ b/docs/kickstart/user/root?.md @@ -0,0 +1,13 @@ +# kickstart.user.root? + +Return 0 if the user running is root and 1 if not. + + +### Example + +```bash +$ whoami +root +$ kickstart.user.root? && echo yup +yup +``` diff --git a/kickstart/recipes/kickstart/user.sh b/kickstart/recipes/kickstart/user.sh index bcf3239..7c51e8b 100644 --- a/kickstart/recipes/kickstart/user.sh +++ b/kickstart/recipes/kickstart/user.sh @@ -47,3 +47,7 @@ kickstart.user.exec() { kickstart.info Running \'"$@"\' as $user su $user - bash -c "$command" } + +kickstart.user.root?() { + [ `whoami` == root ] +}