Mac os support (#156)

* Mac OS support

* Mac OS support

* Improved output + fixed docker command not being linked

* Improved docker install

* Added manual installation message if needed

* Fixed issue with if … fi nesting + using double [[ ]] now as better practise

* Fixed indentation + using double [[ ]] everywhere

* More [[ ]] changes

* Fixed issue due to bad merge

* Empty if statement gives error

* Cannot set logging in /etc/docker/daemon.json for Mac

* Better quoting of $BASH_PROFILE_SCRIPT

* Removed comment + Added “elif”

* Added quotes

* Added quotes

* Removed TODO, BTCPay server works after reboot and all commands run fine.

* Fixed broken detection if line is already in $HOME/.bash_profile
This commit is contained in:
Wouter Samaey
2019-06-24 10:21:05 +02:00
committed by Nicolas Dorier
parent bf4f104f59
commit dc5cdf27a9
5 changed files with 213 additions and 102 deletions

View File

@@ -1,6 +1,16 @@
#!/bin/bash #!/bin/bash
. /etc/profile.d/btcpay-env.sh if [[ "$OSTYPE" == "darwin"* ]]; then
# Mac OS
BASH_PROFILE_SCRIPT="$HOME/btcpay-env.sh"
else
# Linux
BASH_PROFILE_SCRIPT="/etc/profile.d/btcpay-env.sh"
fi
. "$BASH_PROFILE_SCRIPT"
cd "$BTCPAY_BASE_DIRECTORY/btcpayserver-docker" cd "$BTCPAY_BASE_DIRECTORY/btcpayserver-docker"
. helpers.sh . helpers.sh
btcpay_down btcpay_down

View File

@@ -1,6 +1,15 @@
#!/bin/bash #!/bin/bash
. /etc/profile.d/btcpay-env.sh if [[ "$OSTYPE" == "darwin"* ]]; then
# Mac OS
BASH_PROFILE_SCRIPT="$HOME/btcpay-env.sh"
else
# Linux
BASH_PROFILE_SCRIPT="/etc/profile.d/btcpay-env.sh"
fi
. ${BASH_PROFILE_SCRIPT}
cd "$BTCPAY_BASE_DIRECTORY/btcpayserver-docker" cd "$BTCPAY_BASE_DIRECTORY/btcpayserver-docker"
. helpers.sh . helpers.sh

View File

@@ -1,22 +1,49 @@
#!/bin/bash #!/bin/bash
if [ "$0" = "$BASH_SOURCE" ]; then set +x
if [[ "$0" = "$BASH_SOURCE" ]]; then
echo "This script must be sourced \". btcpay-setup.sh\"" echo "This script must be sourced \". btcpay-setup.sh\""
exit 1 exit 1
fi fi
if [[ $EUID -ne 0 ]]; then if [[ "$OSTYPE" == "darwin"* ]]; then
echo "This script must be run as root after running \"sudo su -\"" # Mac OS
return
if [[ $EUID -eq 0 ]]; then
# Running as root is discouraged on Mac OS. Run under the current user instead.
echo "This script should not be run as root."
return
fi
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
if [[ ! -f "$HOME/.bash_profile" ]]; then
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
else
# Root user is not needed for Mac OS
BASH_PROFILE_SCRIPT="/etc/profile.d/btcpay-env.sh"
if [[ $EUID -ne 0 ]]; then
echo "This script must be run as root after running \"sudo su -\""
return
fi
fi fi
# Verify we are in right folder. If we are not, let's go in the parent folder of the current docker-compose. # Verify we are in right folder. If we are not, let's go in the parent folder of the current docker-compose.
if ! git -C . rev-parse &> /dev/null || [ ! -d "Generated" ]; then if ! git -C . rev-parse &> /dev/null || [ ! -d "Generated" ]; then
if [ ! -z $BTCPAY_DOCKER_COMPOSE ]; then if [[ ! -z $BTCPAY_DOCKER_COMPOSE ]]; then
cd $(dirname $BTCPAY_DOCKER_COMPOSE) cd $(dirname $BTCPAY_DOCKER_COMPOSE)
cd .. cd ..
fi fi
if ! git -C . rev-parse || [ ! -d "Generated" ]; then if ! git -C . rev-parse || [[ ! -d "Generated" ]]; then
echo "You must run this script inside the git repository of btcpayserver-docker" echo "You must run this script inside the git repository of btcpayserver-docker"
return return
fi fi
@@ -28,7 +55,7 @@ Usage:
------ ------
Install BTCPay on this server Install BTCPay on this server
This script must be run as root This script must be run as root, except on Mac OS
-i : Run install and start BTCPay Server -i : Run install and start BTCPay Server
--install-only : Run install only --install-only : Run install only
@@ -46,8 +73,8 @@ You can run again this script if you desire to change your configuration.
Except BTC and LTC, other crypto currencies are maintained by their own community. Run at your own risk. Except BTC and LTC, other crypto currencies are maintained by their own community. Run at your own risk.
Make sure you own a domain with DNS record pointing to your website. Make sure you own a domain with DNS record pointing to your website.
If you want HTTPS setup automatically with Let's Encrypt, leave `REVERSEPROXY_HTTP_PORT` at it's default value of 80 and make sure this port is accessible from the internet. If you want HTTPS setup automatically with Let's Encrypt, leave REVERSEPROXY_HTTP_PORT at it's default value of 80 and make sure this port is accessible from the internet.
Or, if you want to offload SSL because you have an existing web proxy, change `REVERSEPROXY_HTTP_PORT` to any port you want. You can then forward the traffic. Just don't forget to pass the X-Forwarded-Proto header. Or, if you want to offload SSL because you have an existing web proxy, change REVERSEPROXY_HTTP_PORT to any port you want. You can then forward the traffic. Just don't forget to pass the X-Forwarded-Proto header.
Environment variables: Environment variables:
BTCPAY_HOST: The hostname of your website (eg. btcpay.example.com) BTCPAY_HOST: The hostname of your website (eg. btcpay.example.com)
@@ -76,27 +103,30 @@ Add-on specific variables:
END END
} }
if [ "$1" != "-i" ] && [ "$1" != "--install-only" ]; then if [[ "$1" != "-i" ]] && [[ "$1" != "--install-only" ]]; then
display_help display_help
return return
fi fi
START=true START=true
if [ "$1" == "--install-only" ]; then if [[ "$1" == "--install-only" ]]; then
START=false START=false
fi fi
if [ -z "$BTCPAYGEN_CRYPTO1" ]; then if [[ -z "$BTCPAYGEN_CRYPTO1" ]]; then
if [ -f "/etc/profile.d/btcpay-env.sh" ]; then if [[ "$OSTYPE" != "darwin"* ]]; then
echo "This script must be run as root after running \"sudo su -\"" # Not Mac OS - Mac OS uses it's own env file
else if [[ -f "$BASH_PROFILE_SCRIPT" ]]; then
echo "BTCPAYGEN_CRYPTO1 should not be empty" echo "This script must be run as root after running \"sudo su -\""
else
echo "BTCPAYGEN_CRYPTO1 should not be empty"
fi
return
fi fi
return
fi fi
######### Migration: old pregen environment to new environment ############ ######### Migration: old pregen environment to new environment ############
if [ ! -z $BTCPAY_DOCKER_COMPOSE ] && [ ! -z $DOWNLOAD_ROOT ] && [ -z $BTCPAYGEN_OLD_PREGEN ]; then if [[ ! -z $BTCPAY_DOCKER_COMPOSE ]] && [[ ! -z $DOWNLOAD_ROOT ]] && [[ -z $BTCPAYGEN_OLD_PREGEN ]]; then
echo "Your deployment is too old, you need to migrate by following instructions on this link https://github.com/btcpayserver/btcpayserver-docker/tree/master#i-deployed-before-btcpay-setupsh-existed-before-may-17-can-i-migrate-to-this-new-system" echo "Your deployment is too old, you need to migrate by following instructions on this link https://github.com/btcpayserver/btcpayserver-docker/tree/master#i-deployed-before-btcpay-setupsh-existed-before-may-17-can-i-migrate-to-this-new-system"
return return
fi fi
@@ -120,7 +150,7 @@ OLD_BTCPAY_DOCKER_COMPOSE="$BTCPAY_DOCKER_COMPOSE"
ORIGINAL_DIRECTORY="$(pwd)" ORIGINAL_DIRECTORY="$(pwd)"
BTCPAY_BASE_DIRECTORY="$(dirname "$(pwd)")" BTCPAY_BASE_DIRECTORY="$(dirname "$(pwd)")"
if [ "$BTCPAYGEN_OLD_PREGEN" == "true" ]; then if [[ "$BTCPAYGEN_OLD_PREGEN" == "true" ]]; then
if [[ $(dirname $BTCPAY_DOCKER_COMPOSE) == *Production ]]; then if [[ $(dirname $BTCPAY_DOCKER_COMPOSE) == *Production ]]; then
BTCPAY_DOCKER_COMPOSE="$(pwd)/Production/docker-compose.generated.yml" BTCPAY_DOCKER_COMPOSE="$(pwd)/Production/docker-compose.generated.yml"
elif [[ $(dirname $BTCPAY_DOCKER_COMPOSE) == *Production-NoReverseProxy ]]; then elif [[ $(dirname $BTCPAY_DOCKER_COMPOSE) == *Production-NoReverseProxy ]]; then
@@ -202,19 +232,21 @@ BTCPAY_ANNOUNCEABLE_HOST:$BTCPAY_ANNOUNCEABLE_HOST
---------------------- ----------------------
" "
if [ -z "$BTCPAYGEN_CRYPTO1" ]; then if [[ -z "$BTCPAYGEN_CRYPTO1" ]]; then
echo "BTCPAYGEN_CRYPTO1 should not be empty" echo "BTCPAYGEN_CRYPTO1 should not be empty"
return return
fi fi
if [ "$NBITCOIN_NETWORK" != "mainnet" ] && [ "$NBITCOIN_NETWORK" != "testnet" ] && [ "$NBITCOIN_NETWORK" != "regtest" ]; then if [[ "$NBITCOIN_NETWORK" != "mainnet" ]] && [[ "$NBITCOIN_NETWORK" != "testnet" ]] && [[ "$NBITCOIN_NETWORK" != "regtest" ]]; then
echo "NBITCOIN_NETWORK should be equal to mainnet, testnet or regtest" echo "NBITCOIN_NETWORK should be equal to mainnet, testnet or regtest"
fi fi
# Put the variables in /etc/profile.d when a user log interactively
touch "/etc/profile.d/btcpay-env.sh"
echo "#!/bin/bash
# Init the variables when a user log interactively
touch "$BASH_PROFILE_SCRIPT"
echo "
#!/bin/bash
export COMPOSE_HTTP_TIMEOUT=\"180\" export COMPOSE_HTTP_TIMEOUT=\"180\"
export BTCPAYGEN_OLD_PREGEN=\"$BTCPAYGEN_OLD_PREGEN\" export BTCPAYGEN_OLD_PREGEN=\"$BTCPAYGEN_OLD_PREGEN\"
export BTCPAYGEN_CRYPTO1=\"$BTCPAYGEN_CRYPTO1\" export BTCPAYGEN_CRYPTO1=\"$BTCPAYGEN_CRYPTO1\"
@@ -239,20 +271,21 @@ if cat \"\$BTCPAY_ENV_FILE\" &> /dev/null; then
! [[ \"\$line\" == \"#\"* ]] && [[ \"\$line\" == *\"=\"* ]] && export \"\$line\" ! [[ \"\$line\" == \"#\"* ]] && [[ \"\$line\" == *\"=\"* ]] && export \"\$line\"
done < \"\$BTCPAY_ENV_FILE\" done < \"\$BTCPAY_ENV_FILE\"
fi fi
" > /etc/profile.d/btcpay-env.sh " > ${BASH_PROFILE_SCRIPT}
chmod +x /etc/profile.d/btcpay-env.sh
echo -e "BTCPay Server environment variables successfully saved in /etc/profile.d/btcpay-env.sh\n" chmod +x ${BASH_PROFILE_SCRIPT}
echo -e "BTCPay Server environment variables successfully saved in $BASH_PROFILE_SCRIPT\n"
btcpay_update_docker_env btcpay_update_docker_env
echo -e "BTCPay Server docker-compose parameters saved in $BTCPAY_ENV_FILE\n" echo -e "BTCPay Server docker-compose parameters saved in $BTCPAY_ENV_FILE\n"
. /etc/profile.d/btcpay-env.sh . "$BASH_PROFILE_SCRIPT"
if ! [ -x "$(command -v docker)" ] || ! [ -x "$(command -v docker-compose)" ]; then if ! [[ -x "$(command -v docker)" ]] || ! [[ -x "$(command -v docker-compose)" ]]; then
if ! [ -x "$(command -v curl)" ]; then if ! [[ -x "$(command -v curl)" ]]; then
apt-get update 2>error apt-get update 2>error
apt-get install -y \ apt-get install -y \
curl \ curl \
@@ -261,13 +294,36 @@ if ! [ -x "$(command -v docker)" ] || ! [ -x "$(command -v docker-compose)" ]; t
software-properties-common \ software-properties-common \
2>error 2>error
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
echo "Trying to install docker..."
curl -fsSL https://get.docker.com -o get-docker.sh if [[ "$OSTYPE" == "darwin"* ]]; then
chmod +x get-docker.sh # Mac OS
sh get-docker.sh if ! [[ -x "$(command -v brew)" ]]; then
rm get-docker.sh # Brew is not installed, install 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)"
fi
if [[ -x "$(command -v brew)" ]]; then
echo "Homebrew is installed, but Docker isn't. Installing it now using brew..."
# 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
brew cask install docker
brew install docker
brew link docker
fi
else
# Not Mac OS
echo "Trying to install docker..."
curl -fsSL https://get.docker.com -o get-docker.sh
chmod +x get-docker.sh
sh get-docker.sh
rm get-docker.sh
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..."
curl -fsSL https://download.docker.com/linux/ubuntu/gpg | apt-key add - curl -fsSL https://download.docker.com/linux/ubuntu/gpg | apt-key add -
@@ -275,7 +331,7 @@ if ! [ -x "$(command -v docker)" ] || ! [ -x "$(command -v docker-compose)" ]; t
if [[ "$RELEASE" == "bionic" ]]; then if [[ "$RELEASE" == "bionic" ]]; then
RELEASE=xenial RELEASE=xenial
fi fi
if [ -x "$(command -v dpkg)" ]; then if [[ -x "$(command -v dpkg)" ]]; then
dpkg --add-architecture armhf dpkg --add-architecture armhf
fi fi
add-apt-repository "deb https://download.docker.com/linux/$(. /etc/os-release; echo "$ID") $RELEASE stable" add-apt-repository "deb https://download.docker.com/linux/$(. /etc/os-release; echo "$ID") $RELEASE stable"
@@ -284,57 +340,63 @@ if ! [ -x "$(command -v docker)" ] || ! [ -x "$(command -v docker-compose)" ]; t
apt-get install -y docker-ce:armhf zlib1g:armhf apt-get install -y docker-ce:armhf zlib1g:armhf
fi fi
fi fi
if ! [ -x "$(command -v docker-compose)" ]; then
if [[ "$(uname -m)" == "x86_64" ]]; then
DOCKER_COMPOSE_DOWNLOAD="https://github.com/docker/compose/releases/download/1.23.2/docker-compose-`uname -s`-`uname -m`" if ! [[ "$OSTYPE" == "darwin"* ]]; then
echo "Trying to install docker-compose by downloading on $DOCKER_COMPOSE_DOWNLOAD ($(uname -m))" # Not Mac OS
curl -L "$DOCKER_COMPOSE_DOWNLOAD" -o /usr/local/bin/docker-compose if ! [[ -x "$(command -v docker-compose)" ]]; then
chmod +x /usr/local/bin/docker-compose if [[ "$(uname -m)" == "x86_64" ]]; then
else DOCKER_COMPOSE_DOWNLOAD="https://github.com/docker/compose/releases/download/1.23.2/docker-compose-`uname -s`-`uname -m`"
echo "Trying to install docker-compose by using the docker-compose-builder ($(uname -m))" echo "Trying to install docker-compose by downloading on $DOCKER_COMPOSE_DOWNLOAD ($(uname -m))"
! [ -d "dist" ] && mkdir dist curl -L "$DOCKER_COMPOSE_DOWNLOAD" -o /usr/local/bin/docker-compose
docker run --rm -ti -v "$(pwd)/dist:/dist" btcpayserver/docker-compose-builder:1.23.2 chmod +x /usr/local/bin/docker-compose
mv dist/docker-compose /usr/local/bin/docker-compose else
chmod +x /usr/local/bin/docker-compose echo "Trying to install docker-compose by using the docker-compose-builder ($(uname -m))"
rm -rf "dist" ! [[ -d "dist" ]] && mkdir dist
fi docker run --rm -ti -v "$(pwd)/dist:/dist" btcpayserver/docker-compose-builder:1.23.2
fi mv dist/docker-compose /usr/local/bin/docker-compose
chmod +x /usr/local/bin/docker-compose
rm -rf "dist"
fi
fi
fi
fi fi
if ! [ -x "$(command -v docker)" ]; then if ! [[ -x "$(command -v docker)" ]]; then
echo "Failed to install docker" echo "Failed to install 'docker'. Please install docker manually, then retry."
return return
fi fi
if ! [ -x "$(command -v docker-compose)" ]; then if ! [[ -x "$(command -v docker-compose)" ]]; then
echo "Failed to install docker-compose" echo "Failed to install 'docker-compose'. Please install docker-compose manually, then retry."
return return
fi fi
if $START && [ -x "$(command -v ischroot)" ] && ischroot; then if $START && [[ -x "$(command -v ischroot)" ]] && ischroot; then
echo "chroot detected, running dockerd in background..." echo "chroot detected, running dockerd in background..."
dockerd & dockerd &
echo "Waiting /var/run/docker.sock to be created..." echo "Waiting /var/run/docker.sock to be created..."
while [ ! -f "/var/run/docker.sock" ]; do sleep 1; done while [[ ! -f "/var/run/docker.sock" ]]; do sleep 1; done
echo "/var/run/docker.sock is created" echo "/var/run/docker.sock is created"
fi fi
# Generate the docker compose in BTCPAY_DOCKER_COMPOSE # Generate the docker compose in BTCPAY_DOCKER_COMPOSE
. ./build.sh . ./build.sh
if [ "$BTCPAYGEN_OLD_PREGEN" == "true" ]; then if [[ "$BTCPAYGEN_OLD_PREGEN" == "true" ]]; then
cp Generated/docker-compose.generated.yml $BTCPAY_DOCKER_COMPOSE cp Generated/docker-compose.generated.yml $BTCPAY_DOCKER_COMPOSE
fi fi
# Schedule for reboot # Schedule for reboot
if [ -x "$(command -v systemctl)" ]; then # Use systemd if [[ -x "$(command -v systemctl)" ]]; then
if [ -e "/etc/init/start_containers.conf" ]; then # Use systemd
echo -e "Uninstalling upstart script /etc/init/start_containers.conf" if [[ -e "/etc/init/start_containers.conf" ]]; then
rm "/etc/init/start_containers.conf" echo -e "Uninstalling upstart script /etc/init/start_containers.conf"
initctl reload-configuration rm "/etc/init/start_containers.conf"
fi initctl reload-configuration
echo "Adding btcpayserver.service to systemd" fi
echo " echo "Adding btcpayserver.service to systemd"
echo "
[Unit] [Unit]
Description=BTCPayServer service Description=BTCPayServer service
After=docker.service network-online.target After=docker.service network-online.target
@@ -344,33 +406,35 @@ Requires=docker.service network-online.target
Type=oneshot Type=oneshot
RemainAfterExit=yes RemainAfterExit=yes
ExecStart=/bin/bash -c '. /etc/profile.d/btcpay-env.sh && cd \"\$BTCPAY_BASE_DIRECTORY/btcpayserver-docker\" && . helpers.sh && btcpay_up' ExecStart=/bin/bash -c '. \"$BASH_PROFILE_SCRIPT\" && cd \"\$BTCPAY_BASE_DIRECTORY/btcpayserver-docker\" && . helpers.sh && btcpay_up'
ExecStop=/bin/bash -c '. /etc/profile.d/btcpay-env.sh && cd \"\$BTCPAY_BASE_DIRECTORY/btcpayserver-docker\" && . helpers.sh && btcpay_down' ExecStop=/bin/bash -c '. \"$BASH_PROFILE_SCRIPT\" && cd \"\$BTCPAY_BASE_DIRECTORY/btcpayserver-docker\" && . helpers.sh && btcpay_down'
ExecReload=/bin/bash -c '. /etc/profile.d/btcpay-env.sh && cd \"\$BTCPAY_BASE_DIRECTORY/btcpayserver-docker\" && . helpers.sh && btcpay_restart' ExecReload=/bin/bash -c '. \"$BASH_PROFILE_SCRIPT\" && cd \"\$BTCPAY_BASE_DIRECTORY/btcpayserver-docker\" && . helpers.sh && btcpay_restart'
[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" ]; then if ! [[ -f "/etc/docker/daemon.json" ]]; 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"
systemctl restart docker 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
else # Use upstart
echo "Using upstart" elif [[ -x "$(command -v initctl)" ]]; then
echo " # Use upstart
echo "Using upstart"
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
@@ -383,25 +447,28 @@ stop on runlevel [!2345]
# respawn # might cause over charge # respawn # might cause over charge
script script
. /etc/profile.d/btcpay-env.sh . \"$BASH_PROFILE_SCRIPT\"
cd \"\$BTCPAY_BASE_DIRECTORY/btcpayserver-docker\" cd \"\$BTCPAY_BASE_DIRECTORY/btcpayserver-docker\"
. helpers.sh . helpers.sh
btcpay_up btcpay_up
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
initctl reload-configuration if $START; then
echo "BTCPay Server started" initctl reload-configuration
fi echo "BTCPay Server started"
fi
fi fi
cd "$(dirname $BTCPAY_ENV_FILE)" cd "$(dirname $BTCPAY_ENV_FILE)"
if [ ! -z "$OLD_BTCPAY_DOCKER_COMPOSE" ] && [ "$OLD_BTCPAY_DOCKER_COMPOSE" != "$BTCPAY_DOCKER_COMPOSE" ]; then if [[ ! -z "$OLD_BTCPAY_DOCKER_COMPOSE" ]] && [[ "$OLD_BTCPAY_DOCKER_COMPOSE" != "$BTCPAY_DOCKER_COMPOSE" ]]; then
echo "Closing old docker-compose at $OLD_BTCPAY_DOCKER_COMPOSE..." echo "Closing old docker-compose at $OLD_BTCPAY_DOCKER_COMPOSE..."
docker-compose -f "$OLD_BTCPAY_DOCKER_COMPOSE" down -t "${COMPOSE_HTTP_TIMEOUT:-180}" docker-compose -f "$OLD_BTCPAY_DOCKER_COMPOSE" down -t "${COMPOSE_HTTP_TIMEOUT:-180}"
fi fi
$START && btcpay_up $START && btcpay_up
! $START && docker-compose -f "$BTCPAY_DOCKER_COMPOSE" pull ! $START && docker-compose -f "$BTCPAY_DOCKER_COMPOSE" pull
@@ -414,7 +481,7 @@ fi
cd "$BTCPAY_BASE_DIRECTORY/btcpayserver-docker" cd "$BTCPAY_BASE_DIRECTORY/btcpayserver-docker"
install_tooling install_tooling
if $START && [ -x "$(command -v ischroot)" ] && ischroot; then if $START && [[ -x "$(command -v ischroot)" ]] && ischroot; then
echo "Killing dockerd in the background..." echo "Killing dockerd in the background..."
kill %- kill %-
fi fi

View File

@@ -1,6 +1,15 @@
#!/bin/bash #!/bin/bash
. /etc/profile.d/btcpay-env.sh if [[ "$OSTYPE" == "darwin"* ]]; then
# Mac OS
BASH_PROFILE_SCRIPT="$HOME/btcpay-env.sh"
else
# Linux
BASH_PROFILE_SCRIPT="/etc/profile.d/btcpay-env.sh"
fi
. ${BASH_PROFILE_SCRIPT}
cd "$BTCPAY_BASE_DIRECTORY/btcpayserver-docker" cd "$BTCPAY_BASE_DIRECTORY/btcpayserver-docker"
. helpers.sh . helpers.sh

View File

@@ -2,7 +2,16 @@
set -e set -e
. /etc/profile.d/btcpay-env.sh if [[ "$OSTYPE" == "darwin"* ]]; then
# Mac OS
BASH_PROFILE_SCRIPT="$HOME/btcpay-env.sh"
else
# Linux
BASH_PROFILE_SCRIPT="/etc/profile.d/btcpay-env.sh"
fi
. ${BASH_PROFILE_SCRIPT}
if [ ! -z $BTCPAY_DOCKER_COMPOSE ] && [ ! -z $DOWNLOAD_ROOT ] && [ -z $BTCPAYGEN_OLD_PREGEN ]; then if [ ! -z $BTCPAY_DOCKER_COMPOSE ] && [ ! -z $DOWNLOAD_ROOT ] && [ -z $BTCPAYGEN_OLD_PREGEN ]; then
echo "Your deployment is too old, you need to migrate by following instructions on this link https://github.com/btcpayserver/btcpayserver-docker/tree/master#i-deployed-before-btcpay-setupsh-existed-before-may-17-can-i-migrate-to-this-new-system" echo "Your deployment is too old, you need to migrate by following instructions on this link https://github.com/btcpayserver/btcpayserver-docker/tree/master#i-deployed-before-btcpay-setupsh-existed-before-may-17-can-i-migrate-to-this-new-system"
@@ -22,22 +31,29 @@ if [[ "$1" != "--skip-git-pull" ]]; then
return return
fi fi
if ! [ -f "/etc/docker/daemon.json" ]; then
echo "{ if ! [[ "$OSTYPE" == "darwin"* ]]; then
# Not Mac OS
# TODO Should we configure logging for Mac OS too? The file path will be different and access rights need to be considered too...
if ! [ -f "/etc/docker/daemon.json" ]; then
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"
fi
fi fi
. ./build.sh . ./build.sh
if [ "$BTCPAYGEN_OLD_PREGEN" == "true" ]; then if [ "$BTCPAYGEN_OLD_PREGEN" == "true" ]; then
cp Generated/docker-compose.generated.yml $BTCPAY_DOCKER_COMPOSE cp Generated/docker-compose.generated.yml $BTCPAY_DOCKER_COMPOSE
cp Generated/torrc.tmpl "$(dirname "$BTCPAY_DOCKER_COMPOSE")/torrc.tmpl" cp Generated/torrc.tmpl "$(dirname "$BTCPAY_DOCKER_COMPOSE")/torrc.tmpl"
fi fi
if ! grep -Fxq "export COMPOSE_HTTP_TIMEOUT=\"180\"" "/etc/profile.d/btcpay-env.sh"; then if ! grep -Fxq "export COMPOSE_HTTP_TIMEOUT=\"180\"" "$BASH_PROFILE_SCRIPT"; then
echo "export COMPOSE_HTTP_TIMEOUT=\"180\"" >> /etc/profile.d/btcpay-env.sh echo "export COMPOSE_HTTP_TIMEOUT=\"180\"" >> "$BASH_PROFILE_SCRIPT"
export COMPOSE_HTTP_TIMEOUT=180 export COMPOSE_HTTP_TIMEOUT=180
echo "Adding COMPOSE_HTTP_TIMEOUT=180 in btcpay-env.sh" echo "Adding COMPOSE_HTTP_TIMEOUT=180 in btcpay-env.sh"
fi fi