Merge pull request #264 from careyk007/setup_sh__curl_always_required
Add support for wget to setup.sh
This commit is contained in:
commit
b1bfff5b5a
2 changed files with 40 additions and 6 deletions
|
@ -75,7 +75,7 @@ bash -c "$(curl -fsSL https://zmkfirmware.dev/setup.sh)"
|
||||||
<TabItem value="wget">
|
<TabItem value="wget">
|
||||||
|
|
||||||
```
|
```
|
||||||
bash -c "$(wget https://zmkfirmware.dev/setup.sh -O -)"
|
bash -c "$(wget https://zmkfirmware.dev/setup.sh -O -)" '' --wget
|
||||||
```
|
```
|
||||||
|
|
||||||
</TabItem>
|
</TabItem>
|
||||||
|
|
40
docs/static/setup.sh
vendored
40
docs/static/setup.sh
vendored
|
@ -9,15 +9,25 @@ set -e
|
||||||
check_exists() {
|
check_exists() {
|
||||||
command_to_run=$1
|
command_to_run=$1
|
||||||
error_message=$2
|
error_message=$2
|
||||||
|
local __resultvar=$3
|
||||||
|
|
||||||
if ! eval "$command_to_run" &> /dev/null; then
|
if ! eval "$command_to_run" &> /dev/null; then
|
||||||
|
if [[ "$__resultvar" != "" ]]; then
|
||||||
|
eval $__resultvar="'false'"
|
||||||
|
else
|
||||||
printf "%s\n" "$error_message"
|
printf "%s\n" "$error_message"
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
else
|
||||||
|
if [[ "$__resultvar" != "" ]]; then
|
||||||
|
eval $__resultvar="'true'"
|
||||||
|
fi
|
||||||
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
check_exists "command -v git" "git is not installed, and is required for this script!"
|
check_exists "command -v git" "git is not installed, and is required for this script!"
|
||||||
check_exists "command -v curl" "curl is not installed, and is required for this script!"
|
check_exists "command -v curl" "curl is not installed, and is required for this script!" curl_exists
|
||||||
|
check_exists "command -v wget" "wget is not installed, and is required for this script!" wget_exists
|
||||||
|
|
||||||
check_exists "git config user.name" "Git username not set!\nRun: git config --global user.name 'My Name'"
|
check_exists "git config user.name" "Git username not set!\nRun: git config --global user.name 'My Name'"
|
||||||
check_exists "git config user.email" "Git email not set!\nRun: git config --global user.email 'example@myemail.com'"
|
check_exists "git config user.email" "Git email not set!\nRun: git config --global user.email 'example@myemail.com'"
|
||||||
|
@ -29,6 +39,30 @@ if [ ! -w `pwd` ]; then
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
# Parse all commandline options
|
||||||
|
while [[ "$#" -gt 0 ]]; do
|
||||||
|
case $1 in
|
||||||
|
-w|--wget) force_wget="true"; break;;
|
||||||
|
*) echo "Unknown parameter: $1"; exit 1;;
|
||||||
|
esac
|
||||||
|
shift
|
||||||
|
done
|
||||||
|
|
||||||
|
if [[ $curl_exists == "true" && $wget_exists == "true" ]]; then
|
||||||
|
if [[ $force_wget == "true" ]]; then
|
||||||
|
download_command="wget "
|
||||||
|
else
|
||||||
|
download_command="curl -O "
|
||||||
|
fi
|
||||||
|
elif [[ $curl_exists == "true" ]]; then
|
||||||
|
download_command="curl -O "
|
||||||
|
elif [[ $wget_exists == "true" ]]; then
|
||||||
|
download_command="wget "
|
||||||
|
else
|
||||||
|
echo 'Neither curl nor wget are installed. One of the two is required for this script!'
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
repo_path="https://github.com/zmkfirmware/zmk-config-split-template.git"
|
repo_path="https://github.com/zmkfirmware/zmk-config-split-template.git"
|
||||||
title="ZMK Config Setup:"
|
title="ZMK Config Setup:"
|
||||||
|
|
||||||
|
@ -136,10 +170,10 @@ cd ${repo_name}
|
||||||
|
|
||||||
pushd config
|
pushd config
|
||||||
|
|
||||||
curl -O "https://raw.githubusercontent.com/zmkfirmware/zmk/main/app/boards/shields/${shield}/${shield}.conf"
|
$download_command "https://raw.githubusercontent.com/zmkfirmware/zmk/main/app/boards/shields/${shield}/${shield}.conf"
|
||||||
|
|
||||||
if [ "$copy_keymap" == "yes" ]; then
|
if [ "$copy_keymap" == "yes" ]; then
|
||||||
curl -O "https://raw.githubusercontent.com/zmkfirmware/zmk/main/app/boards/shields/${shield}/${shield}.keymap"
|
$download_command "https://raw.githubusercontent.com/zmkfirmware/zmk/main/app/boards/shields/${shield}/${shield}.keymap"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
popd
|
popd
|
||||||
|
|
Loading…
Reference in a new issue