Skip to content

Commit

Permalink
Merge pull request #5 from hazcod/feat/runuser
Browse files Browse the repository at this point in the history
feat(maclaunch): add simple runs as user feature
  • Loading branch information
hazcod authored Dec 27, 2019
2 parents 204bfc8 + 280fd2f commit ad96d30
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 1 deletion.
2 changes: 1 addition & 1 deletion .github/workflows/shellcheck.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,4 @@ jobs:
uses: reviewdog/action-shellcheck@v1
with:
github_token: ${{ secrets.github_token }}
reporter: CI/CD
reporter: github-pr-review
24 changes: 24 additions & 0 deletions maclaunch.sh
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,22 @@ function isSystem {
[[ $1 == /System/* ]]
}

function getScriptUser {
local scriptPath="$1"

if echo "$scriptPath" | grep -q "LaunchAgent"; then
whoami
return
fi

if ! grep -q '<key>UserName</key>' "$scriptPath"; then
echo "root"
return
fi

echo "custom"
}

function listItems {
itemDirectories=("${startup_dirs[@]}")

Expand Down Expand Up @@ -127,8 +143,16 @@ function listItems {
startup_type=" (core)"
fi

runAsUser="$(getScriptUser "$f")"
if [ "$runAsUser" = "root" ]; then
runAsUser="${RED}root${NC}"
elif [ "$runAsUser" = "custom" ]; then
runAsUser="${YELLOW}custom${NC}"
fi

echo -e "${BOLD}> ${startup_name}${NC}${startup_type}"
echo " Type : ${type}"
echo -e " User : ${runAsUser}"
echo -e " Launch: ${load_str}${NC}"
echo " File : $f"

Expand Down

0 comments on commit ad96d30

Please sign in to comment.