Skip to content

Commit

Permalink
Merge pull request #6 from LamaAni/fix_install_as_user
Browse files Browse the repository at this point in the history
Fix install as user
  • Loading branch information
LamaAni authored Oct 6, 2022
2 parents 883b01e + 4c86566 commit f42ed6b
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 17 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ Feel free to try it out :)
The following script install the latest version of the library

```shell
curl -sL https://raw.githubusercontent.com/LamaAni/zbash_config/master/install | $(which sudo || echo "") bash -s $ZBASH_CONFIG_VERSION && zbash_config install
curl -sL https://raw.githubusercontent.com/LamaAni/zbash_config/master/install | bash -s $ZBASH_CONFIG_VERSION && $HOME/.local/bin/zbash_config install
```

# Requires:
Expand Down
22 changes: 7 additions & 15 deletions install
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,10 @@ USAGE: [version]
INPUTS:
version The version to use. Defautls to latest.
ARGS:
--location Install into a specific location.
--location The filepath where to install.
"

INSTALL_LOCATION="/usr/local/bin/zbash_config"
INSTALL_LOCATION="$HOME/.local/bin/zbash_config"

while [ "$#" -gt 0 ]; do
case $1 in
Expand Down Expand Up @@ -63,18 +63,6 @@ TEMP_DOWNLOAD_PATH="$(mktemp)"
REPO_SUBPATH="LamaAni/zbash_config"

function install_lib() {
log:sep "Check install context"
log "Checking required premissions"
if [ "$(whoami)" != "root" ]; then
log "checking if sudo is available..."
type sudo >/dev/null 2>&1
if [ $? -ne 0 ]; then
warn 2 "Sudo not found. Attempting to install with user $(whoami)"
else
assert 2 "Sudo found, please rerun as root" || return $?
fi
fi

log:sep "Prepare temp files"

URL_BRANCH="$VERSION"
Expand All @@ -92,7 +80,10 @@ function install_lib() {
echo "$get_script" | bash -s "$VERSION" >|"$TEMP_DOWNLOAD_PATH"
assert $? "Failed to download zbash_config compiled script" || return $?

log:sep "Installing zbash_config as $(whoami)"
log:sep "Installing zbash_config as $(whoami) @ $INSTALL_LOCATION"

mkdir -p "$(dirname "$INSTALL_LOCATION")"
assert $? "Failed to validate install location @ $INSTALL_LOCATION"

if [ -f "$INSTALL_LOCATION" ]; then
rm -rf "$INSTALL_LOCATION"
Expand All @@ -107,6 +98,7 @@ function cleanup() {
local code=$?
rm -rf "$TEMP_DOWNLOAD_PATH"
assert "$@" || return $?
return $code
}

install_lib
Expand Down
2 changes: 1 addition & 1 deletion src/scripts/git.sh
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,6 @@ Usage: git_acp my complicated \"message text\""
;;
esac
local msg="$(echo "$@")"
: "${msg:="Auto commit @ $(date -u +"%Y-%m-%dT%H:%M:%SZ")"}"
: "${msg:="updated"}"
git add . && git commit -m "$msg" --allow-empty && git push -u origin HEAD
}

0 comments on commit f42ed6b

Please sign in to comment.