Skip to content

Commit

Permalink
install.sh: use case
Browse files Browse the repository at this point in the history
  • Loading branch information
ken-matsui committed Nov 18, 2024
1 parent 95aecba commit cc2c83c
Showing 1 changed file with 29 additions and 23 deletions.
52 changes: 29 additions & 23 deletions install.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,31 +4,37 @@ set -eu
cd $HOME
echo 'Installing dotfiles ...'

if [ "$(uname)" == Darwin ]; then
# Ask for the administrator password upfront
printf 'Password for your PC [\e[32m?\e[m] ' && sudo -v
# Keep-alive: update existing `sudo` time stamp until this script has finished
while true; do sudo -n true; sleep 60; kill -0 "$$" || exit; done 2>/dev/null &
echo ''

echo 'Installing Xcode command line tools ...'
check="$(xcode-select --install 2>&1)"
str='xcode-select: note: install requested for command line developer tools'
while [ "$check" == "$str" ]; do
case "$(uname)" in
Darwin)
# Ask for the administrator password upfront
printf 'Password for your PC [\e[32m?\e[m] ' && sudo -v
# Keep-alive: update existing `sudo` time stamp until this script has finished
while true; do sudo -n true; sleep 60; kill -0 "$$" || exit; done 2>/dev/null &
echo ''

echo 'Installing Xcode command line tools ...'
check="$(xcode-select --install 2>&1)"
sleep 1
done
elif [ "$(uname)" == Linux ]; then
# https://askubuntu.com/a/459425
local _distrotype="$(awk -F= '/^NAME/{print $2}' /etc/os-release)"
if [ "$_distrotype" != '"Manjaro Linux"' ]; then
echo "$_distrotype is not supported."
str='xcode-select: note: install requested for command line developer tools'
while [ "$check" == "$str" ]; do
check="$(xcode-select --install 2>&1)"
sleep 1
done
;;

Linux)
# https://askubuntu.com/a/459425
local _distrotype="$(awk -F= '/^NAME/{print $2}' /etc/os-release)"
if [ "$_distrotype" != '"Manjaro Linux"' ]; then
echo "$_distrotype is not supported."
exit 1
fi
;;

*)
echo "'$(uname)' is not supported."
exit 1
fi
else
echo "'$(uname)' is not supported."
exit 1
fi
;;
esac

echo 'Downloading ken-matsui/dotfiles ...'
git clone https://github.com/ken-matsui/dotfiles.git
Expand Down

0 comments on commit cc2c83c

Please sign in to comment.