{"action":"created","issue":{"url":"https://api.github.com/repos/saltstack/salt-bootstrap/issues/611","labels_url":"https://api.github.com/repos/saltstack/salt-bootstrap/issues/611/labels{/name}","comments_url":"https://api.github.com/repos/saltstack/salt-bootstrap/issues/611/comments","events_url":"https://api.github.com/repos/saltstack/salt-bootstrap/issues/611/events","html_url":"https://github.com/saltstack/salt-bootstrap/issues/611","id":90527962,"number":611,"title":"SmartOS doesn't detect missing git, fails install","user":{"login":"BretFisher","id":792287,"avatar_url":"https://avatars.githubusercontent.com/u/792287?v=3","gravatar_id":"","url":"https://api.github.com/users/BretFisher","html_url":"https://github.com/BretFisher","followers_url":"https://api.github.com/users/BretFisher/followers","following_url":"https://api.github.com/users/BretFisher/following{/other_user}","gists_url":"https://api.github.com/users/BretFisher/gists{/gist_id}","starred_url":"https://api.github.com/users/BretFisher/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/BretFisher/subscriptions","organizations_url":"https://api.github.com/users/BretFisher/orgs","repos_url":"https://api.github.com/users/BretFisher/repos","events_url":"https://api.github.com/users/BretFisher/events{/privacy}","received_events_url":"https://api.github.com/users/BretFisher/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":9,"created_at":"2015-06-24T00:43:36Z","updated_at":"2015-07-10T17:34:40Z","closed_at":null,"body":"On a fresh SmartOS machine, install fails due to not having `git` installed, but script thinks it is.\r\n\r\nIn `bootstrap-salt.sh` on SmartOS, the `which` binary doesn't work as it does on Linux and returns a string rather then `null`. This trips the script into thinking `git` is installed, even though it isn't. Current bootstrap-salt.sh:\r\n```bash\r\ninstall_smartos_git_deps() {\r\n    install_smartos_deps || return 1\r\n    if [ \"$(which git)\" = \"\" ]; then\r\n        pkgin -y install scmgit || return 1\r\n    fi\r\n```\r\nhttps://github.com/saltstack/salt-bootstrap/blob/develop/bootstrap-salt.sh#L4172\r\n\r\nI'm not sure how to fix it using the return string compare as used throughout the script. Here's what SmartOS `which` returns:\r\n\r\n`which git`\r\n`no git in /usr/local/sbin /usr/local/bin /opt/local/sbin /opt/local/bin /usr/sbin /usr/bin /sbin`\r\n\r\nAnd here are alternatives to using `which` to determine if a binary exists.\r\nhttp://stackoverflow.com/questions/592620/check-if-a-program-exists-from-a-bash-script\r\n\r\nI'm happy to submit patch but first what to see which way team is leaning on the solution. This is a working replacement in my testing:\r\n\r\n```bash\r\ncommand -v git >/dev/null 2>&1 || { pkgin -y install git; }\r\n```"},"comment":{"url":"https://api.github.com/repos/saltstack/salt-bootstrap/issues/comments/120470350","html_url":"https://github.com/saltstack/salt-bootstrap/issues/611#issuecomment-120470350","issue_url":"https://api.github.com/repos/saltstack/salt-bootstrap/issues/611","id":120470350,"user":{"login":"s0undt3ch","id":300048,"avatar_url":"https://avatars.githubusercontent.com/u/300048?v=3","gravatar_id":"","url":"https://api.github.com/users/s0undt3ch","html_url":"https://github.com/s0undt3ch","followers_url":"https://api.github.com/users/s0undt3ch/followers","following_url":"https://api.github.com/users/s0undt3ch/following{/other_user}","gists_url":"https://api.github.com/users/s0undt3ch/gists{/gist_id}","starred_url":"https://api.github.com/users/s0undt3ch/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/s0undt3ch/subscriptions","organizations_url":"https://api.github.com/users/s0undt3ch/orgs","repos_url":"https://api.github.com/users/s0undt3ch/repos","events_url":"https://api.github.com/users/s0undt3ch/events{/privacy}","received_events_url":"https://api.github.com/users/s0undt3ch/received_events","type":"User","site_admin":false},"created_at":"2015-07-10T17:34:40Z","updated_at":"2015-07-10T17:34:40Z","body":"The correct sh would be something like:\r\n\r\n```\r\n    if [ $(which git) -eq 1 ]; then\r\n        pkgin -y install git || return 1\r\n    fi\r\n```\r\n\r\nAnd I'm cool with it if it also works for SmartOS..."}}