Better promting.
This commit is contained in:
parent
123b001312
commit
e03ba708db
@ -93,13 +93,19 @@ function run_installer()
|
|||||||
####### Setup methods
|
####### Setup methods
|
||||||
|
|
||||||
function wait_for_user() {
|
function wait_for_user() {
|
||||||
|
if [[ $( ask_user "$1" ) == false ]]; then
|
||||||
|
abort_install "${red}==>${reset} Process stopped by user. To resume the install run the one-liner command again."
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
function ask_user() {
|
||||||
while :
|
while :
|
||||||
do
|
do
|
||||||
read -p "${blue}==>${reset} $1 [Y/n] " imp
|
read -p "${blue}==>${reset} $1 [Y/n] " imp
|
||||||
case $imp in
|
case $imp in
|
||||||
[yY] ) echo; break ;;
|
[yY] ) echo true; break ;;
|
||||||
'' ) echo; break ;;
|
'' ) echo true; break ;;
|
||||||
[nN] ) abortInstall "${red}==>${reset} Process stopped by user. To resume the install run the one-liner command again." ;;
|
[nN] ) echo false; break ;;
|
||||||
* ) echo "Unrecognized option provided. Please provide either 'Y' or 'N'";
|
* ) echo "Unrecognized option provided. Please provide either 'Y' or 'N'";
|
||||||
esac
|
esac
|
||||||
done
|
done
|
||||||
@ -126,7 +132,7 @@ function run_installer()
|
|||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
function detectOS() {
|
function detect_os() {
|
||||||
if [[ "$OSTYPE" == "linux-gnu" ]]
|
if [[ "$OSTYPE" == "linux-gnu" ]]
|
||||||
then
|
then
|
||||||
OS_TYPE="linux"
|
OS_TYPE="linux"
|
||||||
@ -137,7 +143,7 @@ function run_installer()
|
|||||||
get_osx_dependencies
|
get_osx_dependencies
|
||||||
else
|
else
|
||||||
OS_TYPE="win"
|
OS_TYPE="win"
|
||||||
abortInstall "${red}==>${reset} ${b}OS not supported:${reset} Parity one-liner currently support OS X and Linux.\nFor instructions on installing parity on other platforms please visit ${u}${blue}http://ethcore.io/${reset}"
|
abort_install "${red}==>${reset} ${b}OS not supported:${reset} Parity one-liner currently support OS X and Linux.\nFor instructions on installing parity on other platforms please visit ${u}${blue}http://ethcore.io/${reset}"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
echo
|
echo
|
||||||
@ -152,11 +158,11 @@ function run_installer()
|
|||||||
elif [[ $canContinue == false && $depFound == 0 ]]
|
elif [[ $canContinue == false && $depFound == 0 ]]
|
||||||
then
|
then
|
||||||
red "All dependencies are missing and cannot be auto-installed ($depFound/$depCount)"
|
red "All dependencies are missing and cannot be auto-installed ($depFound/$depCount)"
|
||||||
abortInstall "$errorMessages";
|
abort_install "$errorMessages";
|
||||||
elif [[ $canContinue == false ]]
|
elif [[ $canContinue == false ]]
|
||||||
then
|
then
|
||||||
red "Some dependencies which cannot be auto-installed are missing ($depFound/$depCount)"
|
red "Some dependencies which cannot be auto-installed are missing ($depFound/$depCount)"
|
||||||
abortInstall "$errorMessages";
|
abort_install "$errorMessages";
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
@ -322,7 +328,7 @@ function run_installer()
|
|||||||
|
|
||||||
if [[ $isBrew == false ]]
|
if [[ $isBrew == false ]]
|
||||||
then
|
then
|
||||||
abortInstall "Couldn't install brew"
|
abort_install "Couldn't install brew"
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
@ -653,7 +659,7 @@ function run_installer()
|
|||||||
find_multirust
|
find_multirust
|
||||||
|
|
||||||
if [[ $isCurl == false || $isGit == false || $isMake == false || $isGCC == false || $isRocksDB == false || $isMultirustNightly == false ]]; then
|
if [[ $isCurl == false || $isGit == false || $isMake == false || $isGCC == false || $isRocksDB == false || $isMultirustNightly == false ]]; then
|
||||||
abortInstall
|
abort_install
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
@ -749,10 +755,10 @@ EOL
|
|||||||
cd ..
|
cd ..
|
||||||
}
|
}
|
||||||
|
|
||||||
function abortInstall()
|
function abort_install()
|
||||||
{
|
{
|
||||||
echo
|
echo
|
||||||
error "Installation failed"
|
error "Installation aborted"
|
||||||
echo -e "$1"
|
echo -e "$1"
|
||||||
echo
|
echo
|
||||||
exit 0
|
exit 0
|
||||||
@ -777,7 +783,7 @@ EOL
|
|||||||
|
|
||||||
# Check dependencies
|
# Check dependencies
|
||||||
head "Checking OS dependencies"
|
head "Checking OS dependencies"
|
||||||
detectOS
|
detect_os
|
||||||
|
|
||||||
if [[ $INSTALL_FILES != "" ]]; then
|
if [[ $INSTALL_FILES != "" ]]; then
|
||||||
echo
|
echo
|
||||||
@ -797,14 +803,14 @@ EOL
|
|||||||
|
|
||||||
if [[ ! -e parity ]]; then
|
if [[ ! -e parity ]]; then
|
||||||
# Maybe install parity
|
# Maybe install parity
|
||||||
if wait_for_user "${b}Build dependencies installed B-)!${reset} Would you like to download and build parity?"; then
|
if [[ $(ask_user "${b}Build dependencies installed B-)!${reset} Would you like to download and build parity?") == true ]]; then
|
||||||
# Do get parity.
|
# Do get parity.
|
||||||
build_parity
|
build_parity
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [[ $OS_TYPE == "linux" && $DISTRIB_ID == "Ubuntu" ]]; then
|
if [[ $OS_TYPE == "linux" && $DISTRIB_ID == "Ubuntu" ]]; then
|
||||||
if wait_for_user "${b}Netstats:${reset} Would you like to install and configure a netstats client?"; then
|
if [[ $(ask_user "${b}Netstats:${reset} Would you like to install and configure a netstats client?") == true ]]; then
|
||||||
install_netstats
|
install_netstats
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
|
Loading…
Reference in New Issue
Block a user