github.com/fnproject/cli@v0.0.0-20240508150455-e5d88bd86117/install (about) 1 #!/bin/sh 2 set -e 3 4 # Install script to install fn 5 6 version=`curl --silent https://api.github.com/repos/fnproject/cli/releases/latest | grep tag_name | cut -f 2 -d : | cut -f 2 -d '"'` 7 8 command_exists() { 9 command -v "$@" > /dev/null 2>&1 10 } 11 12 case "$(uname -m)" in 13 *64) 14 ;; 15 *) 16 echo >&2 'Error: you are not using a 64bit platform.' 17 echo >&2 'Functions CLI currently only supports 64bit platforms.' 18 exit 1 19 ;; 20 esac 21 22 user="$(id -un 2>/dev/null || true)" 23 24 sh_c='sh -c' 25 if [ "$user" != 'root' ]; then 26 if command_exists sudo; then 27 sh_c='sudo -E sh -c' 28 elif command_exists su; then 29 sh_c='su -c' 30 else 31 echo >&2 'Error: this installer needs the ability to run commands as root.' 32 echo >&2 'We are unable to find either "sudo" or "su" available to make this happen.' 33 exit 1 34 fi 35 fi 36 37 curl='' 38 if command_exists curl; then 39 curl='curl -sSL -o' 40 elif command_exists wget; then 41 curl='wget -qO' 42 elif command_exists busybox && busybox --list-modules | grep -q wget; then 43 curl='busybox wget -qO' 44 else 45 echo >&2 'Error: this installer needs the ability to run wget or curl.' 46 echo >&2 'We are unable to find either "wget" or "curl" available to make this happen.' 47 exit 1 48 fi 49 50 url='https://github.com/fnproject/cli/releases/download' 51 52 # perform some very rudimentary platform detection 53 case "$(uname)" in 54 Linux) 55 $sh_c "$curl /tmp/fn_linux $url/$version/fn_linux" 56 $sh_c "mv /tmp/fn_linux /usr/local/bin/fn" 57 $sh_c "chmod +x /usr/local/bin/fn" 58 fn --version 59 ;; 60 Darwin) 61 $sh_c "$curl /tmp/fn_mac $url/$version/fn_mac" 62 $sh_c "mv /tmp/fn_mac /usr/local/bin/fn" 63 $sh_c "chmod +x /usr/local/bin/fn" 64 fn --version 65 ;; 66 WindowsNT) 67 $sh_c "$curl $url/$version/fn.exe" 68 # TODO how to make executable? chmod? how to do tmp file and move? 69 fn.exe --version 70 ;; 71 *) 72 cat >&2 <<'EOF' 73 74 Either your platform is not easily detectable or is not supported by this 75 installer script (yet - PRs welcome! [fn/install]). 76 Please visit the following URL for more detailed installation instructions: 77 78 https://github.com/fnproject/fn 79 80 EOF 81 exit 1 82 esac 83 84 cat >&2 <<'EOF' 85 86 ______ 87 / ____/___ 88 / /_ / __ \ 89 / __/ / / / / 90 /_/ /_/ /_/` 91 92 EOF 93 exit 0