mirror of
https://github.com/Retropex/btcpayserver-docker.git
synced 2025-05-13 05:20:40 +02:00
Refactor btcpay up, down and restart in helpers.sh
This commit is contained in:
parent
1c3f7fc641
commit
5ad1d3c5b6
@ -1,10 +1,6 @@
|
|||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
|
|
||||||
. /etc/profile.d/btcpay-env.sh
|
. /etc/profile.d/btcpay-env.sh
|
||||||
|
cd "$BTCPAY_BASE_DIRECTORY/btcpayserver-docker"
|
||||||
cd "`dirname $BTCPAY_ENV_FILE`"
|
. helpers.sh
|
||||||
|
btcpay_down
|
||||||
docker-compose -f $BTCPAY_DOCKER_COMPOSE down -t "${COMPOSE_HTTP_TIMEOUT:-180}"
|
|
||||||
if ! [ $? -eq 0 ]; then
|
|
||||||
docker-compose -f $BTCPAY_DOCKER_COMPOSE down
|
|
||||||
fi
|
|
@ -2,5 +2,5 @@
|
|||||||
|
|
||||||
. /etc/profile.d/btcpay-env.sh
|
. /etc/profile.d/btcpay-env.sh
|
||||||
|
|
||||||
cd "`dirname $BTCPAY_ENV_FILE`"
|
cd "$BTCPAY_BASE_DIRECTORY/btcpayserver-docker"
|
||||||
docker-compose -f $BTCPAY_DOCKER_COMPOSE restart -t "${COMPOSE_HTTP_TIMEOUT:-180}"
|
btcpay_restart
|
||||||
|
@ -321,9 +321,9 @@ 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 \"\$(dirname \$BTCPAY_ENV_FILE)\" && docker-compose -f \"\$BTCPAY_DOCKER_COMPOSE\" up -d -t \"\$COMPOSE_HTTP_TIMEOUT\"'
|
ExecStart=/bin/bash -c '. /etc/profile.d/btcpay-env.sh && cd \"\$BTCPAY_BASE_DIRECTORY/btcpayserver-docker\" && . helpers.sh && btcpay_up'
|
||||||
ExecStop=/bin/bash -c '. /etc/profile.d/btcpay-env.sh && cd \"\$(dirname \$BTCPAY_ENV_FILE)\" && docker-compose -f \"\$BTCPAY_DOCKER_COMPOSE\" stop -t \"\$COMPOSE_HTTP_TIMEOUT\"'
|
ExecStop=/bin/bash -c '. /etc/profile.d/btcpay-env.sh && cd \"\$BTCPAY_BASE_DIRECTORY/btcpayserver-docker\" && . helpers.sh && btcpay_down'
|
||||||
ExecReload=/bin/bash -c '. /etc/profile.d/btcpay-env.sh && cd \"\$(dirname \$BTCPAY_ENV_FILE)\" && docker-compose -f \"\$BTCPAY_DOCKER_COMPOSE\" restart -t \"\$COMPOSE_HTTP_TIMEOUT\"'
|
ExecReload=/bin/bash -c '. /etc/profile.d/btcpay-env.sh && 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
|
||||||
@ -361,8 +361,9 @@ stop on runlevel [!2345]
|
|||||||
|
|
||||||
script
|
script
|
||||||
. /etc/profile.d/btcpay-env.sh
|
. /etc/profile.d/btcpay-env.sh
|
||||||
cd \"\$(dirname \$BTCPAY_ENV_FILE)\"
|
cd \"\$BTCPAY_BASE_DIRECTORY/btcpayserver-docker\"
|
||||||
docker-compose -f \"\$BTCPAY_DOCKER_COMPOSE\" up -d
|
. helpers.sh
|
||||||
|
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
|
if $START; then
|
||||||
@ -378,7 +379,7 @@ if [ ! -z "$OLD_BTCPAY_DOCKER_COMPOSE" ] && [ "$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 && docker-compose -f "$BTCPAY_DOCKER_COMPOSE" up -d --remove-orphans -t "${COMPOSE_HTTP_TIMEOUT:-180}"
|
$START && btcpay_up
|
||||||
! $START && docker-compose -f "$BTCPAY_DOCKER_COMPOSE" pull
|
! $START && docker-compose -f "$BTCPAY_DOCKER_COMPOSE" pull
|
||||||
|
|
||||||
# Give SSH key to BTCPay
|
# Give SSH key to BTCPay
|
||||||
|
@ -2,5 +2,6 @@
|
|||||||
|
|
||||||
. /etc/profile.d/btcpay-env.sh
|
. /etc/profile.d/btcpay-env.sh
|
||||||
|
|
||||||
cd "`dirname $BTCPAY_ENV_FILE`"
|
cd "$BTCPAY_BASE_DIRECTORY/btcpayserver-docker"
|
||||||
docker-compose -f $BTCPAY_DOCKER_COMPOSE up --remove-orphans -d -t "${COMPOSE_HTTP_TIMEOUT:-180}"
|
. helpers.sh
|
||||||
|
btcpay_up
|
||||||
|
@ -44,6 +44,4 @@ fi
|
|||||||
. helpers.sh
|
. helpers.sh
|
||||||
install_tooling
|
install_tooling
|
||||||
btcpay_update_docker_env
|
btcpay_update_docker_env
|
||||||
|
btcpay_up
|
||||||
cd "`dirname $BTCPAY_ENV_FILE`"
|
|
||||||
docker-compose -f $BTCPAY_DOCKER_COMPOSE up -d --remove-orphans -t "${COMPOSE_HTTP_TIMEOUT:-180}"
|
|
||||||
|
@ -13,13 +13,10 @@ echo "Changing domain from \"$OLD_HOST\" to \"$NEW_HOST\""
|
|||||||
export BTCPAY_HOST="$NEW_HOST"
|
export BTCPAY_HOST="$NEW_HOST"
|
||||||
export ACME_CA_URI="https://acme-v01.api.letsencrypt.org/directory"
|
export ACME_CA_URI="https://acme-v01.api.letsencrypt.org/directory"
|
||||||
|
|
||||||
ORIGINAL_DIRECTORY="$(pwd)"
|
pushd
|
||||||
# Modify environment file
|
# Modify environment file
|
||||||
cd "$BTCPAY_BASE_DIRECTORY/btcpayserver-docker"
|
cd "$BTCPAY_BASE_DIRECTORY/btcpayserver-docker"
|
||||||
. helpers.sh
|
. helpers.sh
|
||||||
btcpay_update_docker_env
|
btcpay_update_docker_env
|
||||||
cd "$ORIGINAL_DIRECTORY"
|
btcpay_up
|
||||||
|
popd
|
||||||
cd "`dirname $BTCPAY_ENV_FILE`"
|
|
||||||
docker-compose -f "$BTCPAY_DOCKER_COMPOSE" up -d -t "${COMPOSE_HTTP_TIMEOUT:-180}"
|
|
||||||
fi
|
|
33
helpers.sh
33
helpers.sh
@ -82,4 +82,37 @@ LIBREPATRON_HOST=$LIBREPATRON_HOST
|
|||||||
BTCTRANSMUTER_HOST=$BTCTRANSMUTER_HOST
|
BTCTRANSMUTER_HOST=$BTCTRANSMUTER_HOST
|
||||||
BTCPAY_CRYPTOS=$BTCPAY_CRYPTOS
|
BTCPAY_CRYPTOS=$BTCPAY_CRYPTOS
|
||||||
WOOCOMMERCE_HOST=$WOOCOMMERCE_HOST" > $BTCPAY_ENV_FILE
|
WOOCOMMERCE_HOST=$WOOCOMMERCE_HOST" > $BTCPAY_ENV_FILE
|
||||||
|
}
|
||||||
|
|
||||||
|
btcpay_up() {
|
||||||
|
pushd
|
||||||
|
cd "$(dirname "$BTCPAY_ENV_FILE")"
|
||||||
|
docker-compose -f $BTCPAY_DOCKER_COMPOSE up --remove-orphans -d -t "${COMPOSE_HTTP_TIMEOUT:-180}"
|
||||||
|
# Depending on docker-compose, either the timeout does not work, or "compose -d and --timeout cannot be combined"
|
||||||
|
if ! [ $? -eq 0 ]; then
|
||||||
|
docker-compose -f $BTCPAY_DOCKER_COMPOSE up --remove-orphans -d
|
||||||
|
fi
|
||||||
|
popd
|
||||||
|
}
|
||||||
|
|
||||||
|
btcpay_down() {
|
||||||
|
pushd
|
||||||
|
cd "$(dirname "$BTCPAY_ENV_FILE")"
|
||||||
|
docker-compose -f $BTCPAY_DOCKER_COMPOSE down -t "${COMPOSE_HTTP_TIMEOUT:-180}"
|
||||||
|
# Depending on docker-compose, the timeout does not work.
|
||||||
|
if ! [ $? -eq 0 ]; then
|
||||||
|
docker-compose -f $BTCPAY_DOCKER_COMPOSE down
|
||||||
|
fi
|
||||||
|
popd
|
||||||
|
}
|
||||||
|
|
||||||
|
btcpay_restart() {
|
||||||
|
pushd
|
||||||
|
cd "$(dirname "$BTCPAY_ENV_FILE")"
|
||||||
|
docker-compose -f $BTCPAY_DOCKER_COMPOSE restart -t "${COMPOSE_HTTP_TIMEOUT:-180}"
|
||||||
|
# Depending on docker-compose, the timeout does not work.
|
||||||
|
if ! [ $? -eq 0 ]; then
|
||||||
|
docker-compose -f $BTCPAY_DOCKER_COMPOSE restart
|
||||||
|
fi
|
||||||
|
popd
|
||||||
}
|
}
|
Loading…
Reference in New Issue
Block a user