Skip to content

Commit

Permalink
Updated setup script to follow XGD standard (#23)
Browse files Browse the repository at this point in the history
Joinked from wd-41 PR: baalimago/wd-41#5
  • Loading branch information
baalimago authored Sep 9, 2024
1 parent acb0d26 commit f4bc29e
Showing 1 changed file with 12 additions and 4 deletions.
16 changes: 12 additions & 4 deletions setup.sh
Original file line number Diff line number Diff line change
Expand Up @@ -78,10 +78,18 @@ if ! chmod +x "$tmp_file"; then
fi
printf "OK!\n"

# Move the binary to /usr/local/bin and handle permission errors
if ! mv "$tmp_file" /usr/local/bin/clai; then
echo "Failed to move the binary to /usr/local/bin/clai, see error above. Try running the script with sudo, or run 'mv $tmp_file <desired-position>'."
# Move the binary to standard XDG location and handle permission errors
INSTALL_DIR=$HOME/.local/bin
# If run as 'sudo', install to /usr/local/bin for systemwide use
if [ -x /usr/bin/id ]; then
if [ `/usr/bin/id -u` -eq 0 ]; then
INSTALL_DIR=/usr/local/bin
fi
fi

if ! mv "$tmp_file" $INSTALL_DIR/clai; then
echo "Failed to move the binary to $INSTALL_DIR/clai, see error above. Try making sure you have write permission there, or run 'mv $tmp_file <desired-position>'."
exit 1
fi

echo "clai installed successfully in /usr/local/bin, try it out with 'clai h'"
echo "clai installed successfully in $INSTALL_DIR, try it out with 'clai h'"

0 comments on commit f4bc29e

Please sign in to comment.