Skip to content
Snippets Groups Projects
Verified Commit 81b78e7a authored by orestis.malaspin's avatar orestis.malaspin
Browse files

added creation of /home/orestis/.local/bin directory if not existing

parent 9af0a3ae
No related tags found
1 merge request!1Adds creation of $HOME/.local/bin directory if not existing
...@@ -3,13 +3,18 @@ ...@@ -3,13 +3,18 @@
# #
# Distributed under terms of the GPLv3 license. # Distributed under terms of the GPLv3 license.
{ \unalias command; \unset -f command; } >/dev/null 2>&1 {
\unalias command
\unset -f command
} >/dev/null 2>&1
tdir='' tdir=''
gitedu_release_url="https://gitedu.hesge.ch/dojo_project/projects/ui/dojocli/-/releases/Latest" gitedu_release_url="https://gitedu.hesge.ch/dojo_project/projects/ui/dojocli/-/releases/Latest"
gitedu_prealpha_url="https://gitedu.hesge.ch/dojo_project/projects/ui/dojocli/-/releases/Latest" gitedu_prealpha_url="https://gitedu.hesge.ch/dojo_project/projects/ui/dojocli/-/releases/Latest"
gitedu_url=$gitedu_release_url gitedu_url=$gitedu_release_url
cleanup_success() { cleanup_success() {
printf "The dojo is installed in %s\nMake sure %s is in your path\n" "$dest" "$dest" printf "The dojo is installed in %s\nMake sure %s is in your path\n" "$dest" "$destdir"
printf "If you are using bash you may want to append:\n"
printf "export PATH=\"\$PATH:%s\" to your .bashrc file.\n" "$destdir"
cleanup cleanup
} }
...@@ -23,8 +28,8 @@ cleanup() { ...@@ -23,8 +28,8 @@ cleanup() {
die() { die() {
cleanup cleanup
printf "\033[31m%s\033[m\n\r" "$*" > /dev/stderr; printf "\033[31m%s\033[m\n\r" "$*" >/dev/stderr
exit 1; exit 1
} }
detect_jq_tool() { detect_jq_tool() {
...@@ -37,7 +42,6 @@ detect_jq_tool() { ...@@ -37,7 +42,6 @@ detect_jq_tool() {
fi fi
} }
detect_network_tool() { detect_network_tool() {
if command -v curl 2>/dev/null >/dev/null; then if command -v curl 2>/dev/null >/dev/null; then
fetch() { fetch() {
...@@ -72,11 +76,11 @@ detect_network_tool() { ...@@ -72,11 +76,11 @@ detect_network_tool() {
fi fi
} }
detect_os() { detect_os() {
arch="" arch=""
case "$(command uname)" in case "$(command uname)" in
'Darwin') OS="macos" 'Darwin')
OS="macos"
case "$(command uname -m)" in case "$(command uname -m)" in
amd64 | x86_64) arch="x64" ;; amd64 | x86_64) arch="x64" ;;
aarch64*) arch="arm64" ;; aarch64*) arch="arm64" ;;
...@@ -95,7 +99,7 @@ detect_os() { ...@@ -95,7 +99,7 @@ detect_os() {
*) die "dojo binaries are not available for $(command uname -m) architecture. See $gitedu_url to download manually" ;; *) die "dojo binaries are not available for $(command uname -m) architecture. See $gitedu_url to download manually" ;;
esac esac
;; ;;
*) die "dojo binaries are not available for $(command uname). See $gitedu_url to download manually" *) die "dojo binaries are not available for $(command uname). See $gitedu_url to download manually" ;;
esac esac
} }
...@@ -106,23 +110,26 @@ expand_tilde() { ...@@ -106,23 +110,26 @@ expand_tilde() {
} }
parse_args() { parse_args() {
dest='~/.local/bin' destdir='~/.local/bin'
[ "$OS" = "macos" ] && dest="/usr/local/bin" [ "$OS" = "macos" ] && destdir="/usr/local/bin"
installer='' installer=''
while :; do while :; do
case "$1" in case "$1" in
dest=*) dest="${1#*=}";; destdir=*) destdir="${1#*=}" ;;
installer=*) installer="${1#*=}" ;; installer=*) installer="${1#*=}" ;;
"") break ;; "") break ;;
*) die "Unrecognized command line option: $1" ;; *) die "Unrecognized command line option: $1" ;;
esac esac
shift shift
done done
dest=$(expand_tilde "${dest}") destdir=$(expand_tilde "${destdir}")
dest="$dest/dojo" if [ ! -d "$destdir" ]; then
printf "Directory %s does not exist. Creatring %s now.\n" "$destdir" "$destdir"
mkdir -p "$destdir"
fi
dest="$destdir/dojo"
} }
get_file_url() { get_file_url() {
url="https://gitedu.hesge.ch/api/v4/projects/12972/packages/generic/dojo" url="https://gitedu.hesge.ch/api/v4/projects/12972/packages/generic/dojo"
if [ "$OS" = "macos" ]; then if [ "$OS" = "macos" ]; then
...@@ -138,7 +145,6 @@ get_release_url() { ...@@ -138,7 +145,6 @@ get_release_url() {
get_file_url "$release_version" get_file_url "$release_version"
} }
get_prealpha_url() { get_prealpha_url() {
gitedu_url=$gitedu_prealpha_url gitedu_url=$gitedu_prealpha_url
prealpha_version=$(fetch_and_get_version_quiet https://gitedu.hesge.ch/api/v4/projects/12972/releases/Pre-alpha) prealpha_version=$(fetch_and_get_version_quiet https://gitedu.hesge.ch/api/v4/projects/12972/releases/Pre-alpha)
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment