Browse Source

space indent code

tor-relay
nicolas.dorier 6 years ago
parent
commit
dbcd9972c3
No known key found for this signature in database GPG Key ID: 6618763EF09186FE
  1. 138
      btcpay-setup.sh

138
btcpay-setup.sh

@ -8,24 +8,24 @@ if [[ "$0" = "$BASH_SOURCE" ]]; then
fi fi
if [[ "$OSTYPE" == "darwin"* ]]; then if [[ "$OSTYPE" == "darwin"* ]]; then
# Mac OS # Mac OS
if [[ $EUID -eq 0 ]]; then if [[ $EUID -eq 0 ]]; then
# Running as root is discouraged on Mac OS. Run under the current user instead. # Running as root is discouraged on Mac OS. Run under the current user instead.
echo "This script should not be run as root." echo "This script should not be run as root."
return return
fi fi
BASH_PROFILE_SCRIPT="$HOME/btcpay-env.sh" BASH_PROFILE_SCRIPT="$HOME/btcpay-env.sh"
# Mac OS doesn't use /etc/profile.d/xxx.sh. Instead we create a new file and load that from ~/.bash_profile # Mac OS doesn't use /etc/profile.d/xxx.sh. Instead we create a new file and load that from ~/.bash_profile
if [[ ! -f "$HOME/.bash_profile" ]]; then if [[ ! -f "$HOME/.bash_profile" ]]; then
touch "$HOME/.bash_profile" touch "$HOME/.bash_profile"
fi
if [[ -z $(grep ". \"$BASH_PROFILE_SCRIPT\"" "$HOME/.bash_profile") ]]; then
# Line does not exist, add it
echo ". \"$BASH_PROFILE_SCRIPT\"" >> "$HOME/.bash_profile"
fi fi
if [[ -z $(grep ". \"$BASH_PROFILE_SCRIPT\"" "$HOME/.bash_profile") ]]; then
# Line does not exist, add it
echo ". \"$BASH_PROFILE_SCRIPT\"" >> "$HOME/.bash_profile"
fi
else else
# Root user is not needed for Mac OS # Root user is not needed for Mac OS
@ -150,14 +150,14 @@ if ! [[ "$START" ]]; then
fi fi
if [[ -z "$BTCPAYGEN_CRYPTO1" ]]; then if [[ -z "$BTCPAYGEN_CRYPTO1" ]]; then
if [[ "$OSTYPE" != "darwin"* ]]; then if [[ "$OSTYPE" != "darwin"* ]]; then
# Not Mac OS - Mac OS uses it's own env file # Not Mac OS - Mac OS uses it's own env file
if [[ -f "$BASH_PROFILE_SCRIPT" ]]; then if [[ -f "$BASH_PROFILE_SCRIPT" ]]; then
echo "This script must be run as root after running \"sudo su -\"" echo "This script must be run as root after running \"sudo su -\""
else else
echo "BTCPAYGEN_CRYPTO1 should not be empty" echo "BTCPAYGEN_CRYPTO1 should not be empty"
fi fi
return return
fi fi
fi fi
@ -234,7 +234,7 @@ fi
if [[ "${BTCPAYGEN_ADDITIONAL_FRAGMENTS}" == *opt-txindex* ]] && \ if [[ "${BTCPAYGEN_ADDITIONAL_FRAGMENTS}" == *opt-txindex* ]] && \
[[ "${BTCPAYGEN_ADDITIONAL_FRAGMENTS}" == *opt-save-storage* ]];then [[ "${BTCPAYGEN_ADDITIONAL_FRAGMENTS}" == *opt-save-storage* ]];then
echo "Error: BTCPAYGEN_ADDITIONAL_FRAGMENTS contains both opt-txindex and opt-save-storage*" echo "Error: BTCPAYGEN_ADDITIONAL_FRAGMENTS contains both opt-txindex and opt-save-storage*"
echo "opt-txindex requires an unpruned node, so you cannot use opt-save-storage with it" echo "opt-txindex requires an unpruned node, so you cannot use opt-save-storage with it"
return return
fi fi
@ -352,28 +352,28 @@ if ! [[ -x "$(command -v docker)" ]] || ! [[ -x "$(command -v docker-compose)" ]
fi fi
if ! [[ -x "$(command -v docker)" ]]; then if ! [[ -x "$(command -v docker)" ]]; then
if [[ "$(uname -m)" == "x86_64" ]] || [[ "$(uname -m)" == "armv7l" ]]; then if [[ "$(uname -m)" == "x86_64" ]] || [[ "$(uname -m)" == "armv7l" ]]; then
if [[ "$OSTYPE" == "darwin"* ]]; then if [[ "$OSTYPE" == "darwin"* ]]; then
# Mac OS # Mac OS
if ! [[ -x "$(command -v brew)" ]]; then if ! [[ -x "$(command -v brew)" ]]; then
# Brew is not installed, install it now # Brew is not installed, install it now
echo "Homebrew, the package manager for Mac OS, is not installed. Installing it now..." echo "Homebrew, the package manager for Mac OS, is not installed. Installing it now..."
/usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)" /usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
fi fi
if [[ -x "$(command -v brew)" ]]; then if [[ -x "$(command -v brew)" ]]; then
echo "Homebrew is installed, but Docker isn't. Installing it now using brew..." echo "Homebrew is installed, but Docker isn't. Installing it now using brew..."
# Brew is installed, install docker now # Brew is installed, install docker now
# This sequence is a bit strange, but it's what what needed to get it working on a fresh Mac OS X Mojave install # This sequence is a bit strange, but it's what what needed to get it working on a fresh Mac OS X Mojave install
brew cask install docker brew cask install docker
brew install docker brew install docker
brew link docker brew link docker
fi fi
else else
# Not Mac OS # Not Mac OS
echo "Trying to install docker..." echo "Trying to install docker..."
curl -fsSL https://get.docker.com -o get-docker.sh curl -fsSL https://get.docker.com -o get-docker.sh
chmod +x get-docker.sh chmod +x get-docker.sh
sh get-docker.sh sh get-docker.sh
rm get-docker.sh rm get-docker.sh
fi fi
elif [[ "$(uname -m)" == "aarch64" ]]; then elif [[ "$(uname -m)" == "aarch64" ]]; then
echo "Trying to install docker for armv7 on a aarch64 board..." echo "Trying to install docker for armv7 on a aarch64 board..."
@ -401,7 +401,7 @@ if ! [[ -x "$(command -v docker)" ]] || ! [[ -x "$(command -v docker-compose)" ]
chmod +x /usr/local/bin/docker-compose chmod +x /usr/local/bin/docker-compose
rm -rf "dist" rm -rf "dist"
fi fi
fi fi
fi fi
if $HAS_DOCKER; then if $HAS_DOCKER; then
@ -425,14 +425,14 @@ fi
# Schedule for reboot # Schedule for reboot
if $STARTUP_REGISTER && [[ -x "$(command -v systemctl)" ]]; then if $STARTUP_REGISTER && [[ -x "$(command -v systemctl)" ]]; then
# Use systemd # Use systemd
if [[ -e "/etc/init/start_containers.conf" ]]; then if [[ -e "/etc/init/start_containers.conf" ]]; then
echo -e "Uninstalling upstart script /etc/init/start_containers.conf" echo -e "Uninstalling upstart script /etc/init/start_containers.conf"
rm "/etc/init/start_containers.conf" rm "/etc/init/start_containers.conf"
initctl reload-configuration initctl reload-configuration
fi fi
echo "Adding btcpayserver.service to systemd" echo "Adding btcpayserver.service to systemd"
echo " echo "
[Unit] [Unit]
Description=BTCPayServer service Description=BTCPayServer service
After=docker.service network-online.target After=docker.service network-online.target
@ -449,27 +449,27 @@ ExecReload=/bin/bash -c '. \"$BASH_PROFILE_SCRIPT\" && cd \"\$BTCPAY_BASE_DIRECT
[Install] [Install]
WantedBy=multi-user.target" > /etc/systemd/system/btcpayserver.service WantedBy=multi-user.target" > /etc/systemd/system/btcpayserver.service
if ! [[ -f "/etc/docker/daemon.json" ]] && [ -w "/etc/docker" ]; then if ! [[ -f "/etc/docker/daemon.json" ]] && [ -w "/etc/docker" ]; then
echo "{ echo "{
\"log-driver\": \"json-file\", \"log-driver\": \"json-file\",
\"log-opts\": {\"max-size\": \"5m\", \"max-file\": \"3\"} \"log-opts\": {\"max-size\": \"5m\", \"max-file\": \"3\"}
}" > /etc/docker/daemon.json }" > /etc/docker/daemon.json
echo "Setting limited log files in /etc/docker/daemon.json" echo "Setting limited log files in /etc/docker/daemon.json"
$START && systemctl restart docker $START && systemctl restart docker
fi fi
echo -e "BTCPay Server systemd configured in /etc/systemd/system/btcpayserver.service\n" echo -e "BTCPay Server systemd configured in /etc/systemd/system/btcpayserver.service\n"
systemctl daemon-reload systemctl daemon-reload
systemctl enable btcpayserver systemctl enable btcpayserver
if $START; then if $START; then
echo "BTCPay Server starting... this can take 5 to 10 minutes..." echo "BTCPay Server starting... this can take 5 to 10 minutes..."
systemctl start btcpayserver systemctl start btcpayserver
echo "BTCPay Server started" echo "BTCPay Server started"
fi fi
elif $STARTUP_REGISTER && [[ -x "$(command -v initctl)" ]]; then elif $STARTUP_REGISTER && [[ -x "$(command -v initctl)" ]]; then
# Use upstart # Use upstart
echo "Using upstart" echo "Using upstart"
echo " echo "
# File is saved under /etc/init/start_containers.conf # File is saved under /etc/init/start_containers.conf
# After file is modified, update config with : $ initctl reload-configuration # After file is modified, update config with : $ initctl reload-configuration
@ -489,10 +489,10 @@ script
end script" > /etc/init/start_containers.conf end script" > /etc/init/start_containers.conf
echo -e "BTCPay Server upstart configured in /etc/init/start_containers.conf\n" echo -e "BTCPay Server upstart configured in /etc/init/start_containers.conf\n"
if $START; then if $START; then
initctl reload-configuration initctl reload-configuration
echo "BTCPay Server started" echo "BTCPay Server started"
fi fi
fi fi

Loading…
Cancel
Save