From 5fac7d2f19df0a60e7c36352d9cdfd6e37e471bb Mon Sep 17 00:00:00 2001 From: "nicolas.dorier" Date: Sun, 27 Jan 2019 16:12:30 +0900 Subject: [PATCH] Remove unused tooling from setup --- btcpay-setup.sh | 15 ++++----------- btcpay-update.sh | 13 ++----------- helpers.sh | 46 ++++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 52 insertions(+), 22 deletions(-) create mode 100755 helpers.sh diff --git a/btcpay-setup.sh b/btcpay-setup.sh index 75af55a..4405b5a 100755 --- a/btcpay-setup.sh +++ b/btcpay-setup.sh @@ -365,15 +365,8 @@ if [[ -f "$BTCPAY_HOST_SSHKEYFILE" ]]; then docker cp "$BTCPAY_HOST_SSHKEYFILE" $(docker ps --filter "name=_btcpayserver_" -q):$BTCPAY_SSHKEYFILE fi -cd $ORIGINAL_DIRECTORY - -for scriptname in *.sh; do - if [ "$scriptname" == "build.sh" -o "$scriptname" == "build-pregen.sh" ] ; then - continue; - fi - echo "Adding symlink of $scriptname to /usr/bin" - chmod +x $scriptname - rm /usr/bin/$scriptname &> /dev/null - ln -s "$(pwd)/$scriptname" /usr/bin -done +cd "$BTCPAY_BASE_DIRECTORY/btcpayserver-docker" +. helpers.sh +install_tooling +cd $ORIGINAL_DIRECTORY diff --git a/btcpay-update.sh b/btcpay-update.sh index 82cbcdd..4e771f8 100755 --- a/btcpay-update.sh +++ b/btcpay-update.sh @@ -36,17 +36,8 @@ if ! grep -Fxq "export COMPOSE_HTTP_TIMEOUT=\"180\"" "/etc/profile.d/btcpay-env. echo "Adding COMPOSE_HTTP_TIMEOUT=180 in btcpay-env.sh" fi -for scriptname in *.sh; do - if [ "$scriptname" == "build.sh" ] || \ - [ "$scriptname" == "build-pregen.sh" ] || \ - [ "$scriptname" == "btcpay-setclocale.sh" ]; then - continue; - fi - echo "Adding symlink of $scriptname to /usr/bin" - chmod +x $scriptname - [ -e /usr/bin/$scriptname ] && rm /usr/bin/$scriptname - ln -s "$(pwd)/$scriptname" /usr/bin -done +. helpers.sh +install_tooling cd "`dirname $BTCPAY_ENV_FILE`" docker-compose -f $BTCPAY_DOCKER_COMPOSE up -d --remove-orphans -t "${COMPOSE_HTTP_TIMEOUT:-180}" diff --git a/helpers.sh b/helpers.sh new file mode 100755 index 0000000..4224887 --- /dev/null +++ b/helpers.sh @@ -0,0 +1,46 @@ +install_tooling() { + scripts=( \ + "btcpayserver_bitcoind" "bitcoin-cli.sh" "Command line for your Bitcoin instance" \ + "btcpayserver_clightning_bitcoin" "bitcoin-lightning-cli.sh" "Command line for your Bitcoin C-Lightning instance" \ + "btcpayserver_lnd_bitcoin" "bitcoin-lncli.sh" "Command line for your Bitcoin LND instance" \ + "btcpayserver_bgoldd" "bgold-cli.sh" "Command line for your BGold instance" \ + "btcpayserver_bitcored" "bitcore-cli.sh" "Command line for your Bitcore instance" \ + "btcpayserver_bitcoinplusd" "bplus-cli.sh" "Command line for your BPlus instance" \ + "btcpayserver_dashd" "dash-cli.sh" "Command line for your Dash instance" \ + "btcpayserver_dogecoind" "dogecoin-cli.sh" "Command line for your Dogecoin instance" \ + "btcpayserver_feathercoind" "feathercoin-cli.sh" "Command line for your Feathercoin instance" \ + "btcpayserver_groestlcoind" "groestlcoin-cli.sh" "Command line for your Groestlcoin instance" \ + "btcpayserver_clightning_groestlcoin" "groestlcoin-lightning-cli.sh" "Command line for your Groestlcoin C-Lightning instance" \ + "btcpayserver_litecoind" "litecoin-cli.sh" "Command line for your Litecoin instance" \ + "btcpayserver_clightning_litecoin" "litecoin-lightning-cli.sh" "Command line for your Litecoin C-Lightning instance" \ + "btcpayserver_lnd_litecoin" "litecoin-lncli.sh" "Command line for your Litecoin LND instance" \ + "btcpayserver_monacoind" "monacoin-cli.sh" "Command line for your Monacoin instance" \ + "btcpayserver_trezarcoind" "trezarcoin-cli.sh" "Command line for your Trezar instance" \ + "btcpayserver_viacoind" "viacoin-cli.sh" "Command line for your Viacoin instance" \ + "*" "btcpay-down.sh" "Command line for stopping all services related to BTCPay Server" \ + "*" "btcpay-restart.sh" "Command line for restarting all services related to BTCPay Server" \ + "*" "btcpay-setup.sh" "Command line for restarting all services related to BTCPay Server" \ + "*" "btcpay-up.sh" "Command line for starting all services related to BTCPay Server" \ + "*" "btcpay-update.sh" "Command line for updating your BTCPay Server to the latest commit of this repository" \ + "*" "changedomain.sh" "Command line for changing the external domain of your BTCPay Server" \ + ) + + i=0 + while [ $i -lt ${#scripts[@]} ]; do + scriptname="${scripts[$i+1]}" + dependency="${scripts[$i+0]}" + comment="${scripts[$i+2]}" + + [ -e /usr/bin/$scriptname ] && rm /usr/bin/$scriptname + if [ -e "$scriptname" ]; then + if [ "$dependency" == "*" ] || grep -q "$dependency" "$BTCPAY_DOCKER_COMPOSE"; then + chmod +x $scriptname + ln -s "$(pwd)/$scriptname" /usr/bin + echo "Installed $scriptname to /usr/bin: $comment" + fi + else + echo "WARNING: Script $scriptname referenced, but not existing" + fi + i=`expr $i + 3` + done +} \ No newline at end of file