Skip to content

Commit 4d687ad

Browse files
author
Chris Maunder
committed
Merge branch 'v2.9.0' of https://github.com/codeproject/CodeProject.AI-Server into v2.9.0
2 parents 21b8de2 + ff29b4a commit 4d687ad

File tree

1 file changed

+30
-14
lines changed

1 file changed

+30
-14
lines changed

src/scripts/utils.sh

Lines changed: 30 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -718,12 +718,21 @@ function setupDotNet () {
718718
return 6 # unable to download required asset
719719
fi
720720

721+
if [ "$architecture" = 'arm64' ]; then
722+
dotnet_path="/opt/dotnet"
723+
elif [ "$os" = "linux" ]; then
724+
dotnet_path="/usr/lib/dotnet/"
725+
else
726+
# dotnet_path="/usr/lib/dotnet/"
727+
# dotnet_path="~/.dotnet/"
728+
dotnet_path="/usr/local/share/dotnet/"
729+
fi
730+
721731
# output a warning message if no admin rights and instruct user on manual steps
722732
if [ "$architecture" = 'arm64' ]; then
723-
# installs in /opt/dotnet
724733
install_instructions="sudo bash '${installScriptsDirPath}/dotnet-install-arm.sh' $requestedNetMajorMinorVersion $requestedType"
725734
else
726-
install_instructions="sudo bash '${installScriptsDirPath}/dotnet-install.sh' --install-dir '/usr/lib/dotnet/' --channel $requestedNetMajorMinorVersion --runtime $requestedType"
735+
install_instructions="sudo bash '${installScriptsDirPath}/dotnet-install.sh' --install-dir '${dotnet_path}' --channel $requestedNetMajorMinorVersion --runtime $requestedType"
727736
fi
728737
checkForAdminAndWarn "$install_instructions"
729738

@@ -752,21 +761,21 @@ function setupDotNet () {
752761
fi
753762
else
754763
if [ $verbosity = "quiet" ]; then
755-
sudo bash "${installScriptsDirPath}/dotnet-install.sh" --install-dir "/usr/lib/dotnet/" --channel "$requestedNetMajorMinorVersion" --runtime "$requestedType" "--quiet"
764+
sudo bash "${installScriptsDirPath}/dotnet-install.sh" --install-dir "$dotnet_path" --channel "$requestedNetMajorMinorVersion" --runtime "$requestedType" "--quiet"
756765
elif [ $verbosity = "loud" ]; then
757-
sudo bash "${installScriptsDirPath}/dotnet-install.sh" --install-dir "/usr/lib/dotnet/" --channel "$requestedNetMajorMinorVersion" --runtime "$requestedType" "--verbose"
766+
sudo bash "${installScriptsDirPath}/dotnet-install.sh" --install-dir "$dotnet_path" --channel "$requestedNetMajorMinorVersion" --runtime "$requestedType" "--verbose"
758767
else
759-
sudo bash "${installScriptsDirPath}/dotnet-install.sh" --install-dir "/usr/lib/dotnet/" --channel "$requestedNetMajorMinorVersion" --runtime "$requestedType"
768+
sudo bash "${installScriptsDirPath}/dotnet-install.sh" --install-dir "$dotnet_path" --channel "$requestedNetMajorMinorVersion" --runtime "$requestedType"
760769
fi
761770
fi
762771
fi
763772
else
764773
if [ $verbosity = "quiet" ]; then
765-
sudo bash "${installScriptsDirPath}/dotnet-install.sh" --install-dir "/usr/lib/dotnet/" --channel "$requestedNetMajorMinorVersion" --runtime "$requestedType" "--quiet"
774+
sudo bash "${installScriptsDirPath}/dotnet-install.sh" --install-dir "${dotnet_path}" --channel "$requestedNetMajorMinorVersion" --runtime "$requestedType" "--quiet"
766775
elif [ $verbosity = "loud" ]; then
767-
sudo bash "${installScriptsDirPath}/dotnet-install.sh" --install-dir "/usr/lib/dotnet/" --channel "$requestedNetMajorMinorVersion" --runtime "$requestedType" "--verbose"
776+
sudo bash "${installScriptsDirPath}/dotnet-install.sh" --install-dir "${dotnet_path}" --channel "$requestedNetMajorMinorVersion" --runtime "$requestedType" "--verbose"
768777
else
769-
sudo bash "${installScriptsDirPath}/dotnet-install.sh" --install-dir "/usr/lib/dotnet/" --channel "$requestedNetMajorMinorVersion" --runtime "$requestedType"
778+
sudo bash "${installScriptsDirPath}/dotnet-install.sh" --install-dir "${dotnet_path}" --channel "$requestedNetMajorMinorVersion" --runtime "$requestedType"
770779
fi
771780
fi
772781
fi
@@ -795,17 +804,24 @@ function setupDotNet () {
795804
if [ "$os" == "macos" ]; then
796805
# The install script is for CI/CD and doesn't actually register .NET. So add
797806
# link and env variable
798-
export DOTNET_ROOT=~/.dotnet
807+
export DOTNET_ROOT=${dotnet_path}
799808
export PATH=${DOTNET_ROOT}${PATH:+:${PATH}}
800809

801810
if [ ! -e /usr/local/bin/dotnet ]; then
802-
ln -fs ~/.dotnet/dotnet /usr/local/bin/dotnet
811+
ln -fs "${dotnet_path}dotnet" "/usr/local/bin/dotnet"
803812
fi
804813

805-
if grep -q 'export DOTNET_ROOT=' ~/.bashrc; then
806-
echo 'export DOTNET_ROOT=~/.dotnet' >> ~/.bashrc
807-
echo "export PATH=${DOTNET_ROOT}${PATH:+:${PATH}}" >> ~/.bashrc
808-
fi
814+
# if [ -f ~/.bashrc ]; then
815+
if [ ! -f ~/.bashrc ] || [ $(grep -q 'export DOTNET_ROOT=' ~/.bashrc) ]; then
816+
sudo echo "export DOTNET_ROOT=${dotnet_path}" >> ~/.bashrc
817+
sudo echo "export PATH=${dotnet_path}${PATH:+:${PATH}}" >> ~/.bashrc
818+
fi
819+
# elif [ -f ~/.bash_profile ]; then
820+
# if grep -q 'export DOTNET_ROOT=' ~/.bash_profile; then
821+
# echo 'export DOTNET_ROOT=${dotnet_path}' >> ~/.bash_profile
822+
# echo "export PATH=${dotnet_path}${PATH:+:${PATH}}" >> ~/.bash_profile
823+
# fi
824+
# fi
809825
fi
810826
fi
811827

0 commit comments

Comments
 (0)