Created
May 27, 2015 16:53
-
-
Save kawanet/cf7bb8363733007c4d9c to your computer and use it in GitHub Desktop.
root 権限で実行されていたら特定ユーザに su してシェルスクリプトを起動し直す
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/bin/sh | |
| # re-launch itself with a specified user when launched with root user | |
| [ "$(id -u)" -eq 0 ] && exec su - "someuser" -c "$0 $*" | |
| # do something | |
| whoami |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment