7676
7777# configuration things at the top for QOL
7878LANDO_DEFAULT_MV=" 3"
79+ LANDO_BINDIR=" $HOME /.lando/bin"
80+ LANDO_DATADIR=" ${XDG_DATA_HOME:- $HOME / .data} /lando"
7981LANDO_TMPDIR=${TMPDIR:-/ tmp}
8082MACOS_OLDEST_SUPPORTED=" 12.0"
8183REQUIRED_CURL_VERSION=" 7.41.0"
@@ -164,12 +166,15 @@ get_installer_os
164166# @TODO: dest based on lmv
165167ARCH=" ${LANDO_INSTALLER_ARCH:- " $INSTALLER_ARCH " } "
166168DEBUG=" ${LANDO_INSTALLER_DEBUG:- ${RUNNER_DEBUG:- } } "
167- DEST=" ${LANDO_INSTALLER_DEST:-/ usr / local / bin} "
169+ DEST=" ${LANDO_INSTALLER_DEST:- $HOME / .lando / bin} "
168170FAT=" ${LANDO_INSTALLER_FAT:- 0} "
169171OS=" ${LANDO_INSTALLER_OS:- " $INSTALLER_OS " } "
170172SUDO=" ${LANDO_INSTALLER_SUDO:- 1} "
171173SETUP=" ${LANDO_INSTALLER_SETUP:- 1} "
174+ SYMLINKER=" ${LANDO_BINDIR} /lando"
172175VERSION=" ${LANDO_VERSION:- ${LANDO_INSTALLER_VERSION:- stable} } "
176+
177+ # preserve originals OPTZ
173178ORIGOPTS=" $* "
174179
175180usage () {
@@ -268,7 +273,6 @@ if [[ "$DEBUG" == "1" ]]; then
268273 LANDO_DEBUG=" --debug"
269274fi ;
270275
271-
272276# redefine this one
273277abort () {
274278 printf " ${tty_red} ERROR${tty_reset} : %s\n" " $( chomp " $1 " ) " >&2
803807# LANDO
804808LANDO=" ${DEST} /lando"
805809LANDO_TMPFILE=" ${LANDO_TMPDIR} /${RANDOM} "
810+ HIDDEN_LANDO=" ${LANDO_DATADIR} /${VERSION} /lando"
806811
807812# Create directories if we need to
808813if [[ ! -d " $DEST " ]]; then auto_exec mkdir -p " $DEST " ; fi
809814if [[ ! -d " $LANDO_TMPDIR " ]]; then auto_exec mkdir -p " $LANDO_TMPDIR " ; fi
815+ if [[ ! -d " $LANDO_BINDIR " ]]; then execute mkdir -p " $LANDO_BINDIR " ; fi
810816
811817# download lando
812818log " ${tty_magenta} downloading${tty_reset} ${tty_bold}${URL}${tty_reset} to ${tty_bold}${LANDO}${tty_reset} "
@@ -821,17 +827,20 @@ auto_exec curl \
821827auto_exec chmod +x " ${LANDO_TMPFILE} "
822828execute " ${LANDO_TMPFILE} " version > /dev/null
823829
824- # if we get here we should be good to move it to its final destination
830+ # if dest = symlinker then we need to actually mv 2 LANDO_DATADIR
825831# NOTE: we use mv here instead of cp because of https://developer.apple.com/forums/thread/130313
826- auto_exec mv -f " ${LANDO_TMPFILE} " " ${LANDO} "
832+ if [[ " $LANDO " == " $SYMLINKER " ]]; then
833+ execute mkdir -p " ${LANDO_DATADIR} /${VERSION} "
834+ execute mv -f " $LANDO_TMPFILE " " $HIDDEN_LANDO "
835+ execute ln -sf " $HIDDEN_LANDO " " $SYMLINKER "
836+ else
837+ auto_exec mv -f " $LANDO_TMPFILE " " $LANDO "
838+ auto_exec ln -sf " $LANDO " " $SYMLINKER "
839+ fi
827840
828841# if lando 3 then we need to do some other cleanup things
829842# @TODO: is there an equivalent on lando 4?
830843if [[ $LMV == ' 3' ]]; then
831- # ensure dirz
832- execute mkdir -p " $HOME /.lando/bin"
833- # force symlink landobin to ensure PATH primacy as best we can
834- execute ln -sf " ${LANDO} " " $HOME /.lando/bin/lando"
835844 # remove preexisting lando core so this one can also assert primacy
836845 execute rm -rf " $HOME /.lando/plugins/@lando/core"
837846 # clean
@@ -851,11 +860,18 @@ if [[ "$SETUP" == "1" ]]; then
851860fi
852861
853862# shell env
854- log " ${tty_blue} adding${tty_reset} ${tty_bold}${DEST}${tty_reset} to ${tty_bold} PATH${tty_reset} "
855- execute " ${LANDO} " shellenv --add " ${LANDO_DEBUG-} "
863+ execute " ${LANDO} " shellenv --add " ${LANDO_DEBUG-} " > /dev/null
856864
857- # TODO: print better messages for different situations eg ensure setup
858- log " ${tty_green} success!${tty_reset} ${tty_bold} lando${tty_reset} is now installed!"
865+ # sucess message here
866+ log " ${tty_green} success!${tty_reset} ${tty_magenta} lando${tty_reset} is now installed!"
867+
868+ # if we cannot invoke lando then print shellenv message
869+ if \
870+ ! execute lando version > /dev/null \
871+ || [[ " $( readlink -f $( which lando) ) " != " $LANDO " && " $( readlink -f $( which lando) ) " != " $HIDDEN_LANDO " ]]; then
872+ log
873+ log " ${tty_magenta} Start a new terminal session${tty_reset} or run ${tty_magenta} eval \"\$ (${LANDO} shellenv)\" ${tty_reset} to use lando"
874+ fi
859875
860876# FIN!
861877exit 0
0 commit comments