Update 'root/usr/libexec/apps/btcpayserver/btcpayserver.sh'

main
ben 1 year ago
parent 4dbb63cebe
commit 047357e61c

@ -1,36 +1,43 @@
#!/bin/sh
ACTION=${1}
APP_NAME="node-red"
ACTION="${1}"
shift 1
get_image() {
IMAGE_NAME=$(uci get btcpayserver.@btcpayserver[0].image_name 2>/dev/null)
do_install_detail
}
do_install_detail() {
local config port IMAGE_NAME username password LAN_IP
config=$(uci get btcpayserver.@btcpayserver[0].config_path 2>/dev/null)
port=$(uci get btcpayserver.@btcpayserver[0].port 2>/dev/null)
IMAGE_NAME=$(uci get btcpayserver.@btcpayserver[0].image_name 2>/dev/null)
username=$(uci get btcpayserver.@btcpayserver[0].username 2>/dev/null)
password=$(uci get btcpayserver.@btcpayserver[0].password 2>/dev/null)
APP_NAME="node-red"
GEN_PASS=$(head -c14 /dev/urandom | tr -dc A-Za-z0-9)
GEN_PASS2=$(head -c14 /dev/urandom | tr -dc A-Za-z0-9)
GEN_PASS=$(< /dev/urandom tr -dc A-Za-z0-9 2>/dev/null | head -c 14; echo)
GEN_PASS2=$(< /dev/urandom tr -dc A-Za-z0-9 2>/dev/null | head -c 14; echo)
LAN_IP=$(uci get network.lan.ipaddr)
LAN_IP="${LAN_IP%/*}"
[ -z "$config" ] && { echo "config path is empty!"; exit 1; }
[ -z "$port" ] && port=8888
[ -z "$IMAGE_NAME" ] && IMAGE_NAME=clightning
}
if [ -z "$config" ]; then
echo "config path is empty!"
exit 1
fi
setup_btcpayserver() {
git clone https://github.com/btcpayserver/btcpayserver-docker /opt/docker2/compose/btcpayserver/btcpayserver-docker/
[ -z "$port" ] && port=1880
[ -z "$IMAGE_NAME" ] && IMAGE_NAME="btcpayserver/node-red:latest"
touch /opt/docker2/compose/btcpayserver/btcpayserver-docker/go.sh
chmod +x /opt/docker2/compose/btcpayserver/btcpayserver-docker/go.sh
cat > /opt/docker2/compose/btcpayserver/btcpayserver-docker/go.sh <<EOF
#!/bin/bash
rm -r /opt/docker2/compose/btcpayserver 2>/dev/null
mkdir -p /opt/docker2/compose/btcpayserver/
cat > /opt/docker2/compose/btcpayserver/satoshi.sh <<EOF
git clone https://github.com/btcpayserver/btcpayserver-docker
cd btcpayserver-docker
export BTCPAY_HOST="${LAN_IP}"
export NBITCOIN_NETWORK="${config}"
export BTCPAYGEN_CRYPTO1="btc"
@ -42,30 +49,17 @@ export NOREVERSEPROXY_HTTP_PORT="${port}"
export BTCPAY_PROTOCOL="http"
export BTCPAYGEN_REVERSEPROXY="none"
bash /opt/docker2/compose/btcpayserver/btcpayserver-docker/btcpay-setup.sh -i
. ./btcpay-setup.sh -i
EOF
}
if [ "$(id -u)" -ne 0 ]; then
echo "This script must be run as root."
exit 1
fi
setup_btcpayserver
chmod +x /opt/docker2/compose/btcpayserver/btcpayserver-docker/go.sh
echo "Please open a terminal window and login via SSH to $LAN_IP"
echo "Copy paste the commands to finish the BTCpay server Install"
echo ".................Enter commands below......................"
echo "cd /opt/docker2/compose/btcpayserver/btcpayserver-docker"
echo ". ./go.sh -i"
echo "..........................................................."
bash /opt/docker2/compose/btcpayserver/satoshi.sh
uci add shortcutmenu lists
uci set shortcutmenu.@lists[-1].webname="$IMAGE_NAME"
uci set shortcutmenu.@lists[-1].webname="$APP_NAME"
uci set shortcutmenu.@lists[-1].weburl="$LAN_IP:$port"
uci set shortcutmenu.@lists[-1].webpath="/"
uci commit shortcutmenu
}
usage() {
echo "usage: $0 sub-command"
@ -78,25 +72,37 @@ usage() {
}
case "${ACTION}" in
"install")
get_image
do_install_detail
;;
"upgrade")
get_image
"install" | "upgrade")
do_install_detail
;;
"rm")
docker-compose -f /opt/docker2/compose/btcpayserver/btcpayserver-docker/$BTCPAY_DOCKER_COMPOSE down --volumes
IMAGE_NAME=$(uci get btcpayserver.@btcpayserver[0].image_name 2>/dev/null)
[ -z "$IMAGE_NAME" ] && IMAGE_NAME="btcpayserver"
CONTAINER_IDS=$(docker ps -a --filter "ancestor=${IMAGE_NAME}" --format '{{.ID}}')
echo "Stopping and removing containers..."
for ID in $CONTAINER_IDS; do
docker stop "$ID"
docker rm "$ID"
done
docker rmi -f "$IMAGE_NAME"
rm -r /opt/docker2/compose/btcpayserver 2>/dev/null
;;
"start" | "stop" | "restart")
docker "${ACTION}" btcpayserver
APP_NAME="btcpayserver"
CONTAINER_IDS=$(docker ps -a --filter "ancestor=${APP_NAME}" --format '{{.ID}}')
for ID in $CONTAINER_IDS; do
docker "${ACTION}" "${ID}"
done
;;
"status")
docker ps --all -f 'name=btcpayserver' --format '{{.State}}'
APP_NAME="btcpayserver"
CONTAINER_NAMES=$(docker ps -a --filter "name=${APP_NAME}" --format '{{.Names}}')
docker ps --all -f "name=${CONTAINER_NAMES}" --format '{{.Status}}'
;;
"port")
docker ps --all -f 'name=btcpayserver' --format '{{.Ports}}' | grep -om1 '0.0.0.0:[0-9]*' | sed 's/0.0.0.0://'
APP_NAME="btcpayserver"
CONTAINER_NAMES=$(docker ps -a --filter "ancestor=${APP_NAME}" --format '{{.Names}}')
docker ps --all -f "name=${CONTAINER_NAMES}" --format '{{.Ports}}' | grep -o -m1 '0.0.0.0:[0-9]*' | sed 's/0.0.0.0://'
;;
*)
usage

Loading…
Cancel
Save