|
|
@ -1,36 +1,43 @@
|
|
|
|
#!/bin/sh
|
|
|
|
#!/bin/sh
|
|
|
|
|
|
|
|
|
|
|
|
ACTION=${1}
|
|
|
|
APP_NAME="node-red"
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
ACTION="${1}"
|
|
|
|
shift 1
|
|
|
|
shift 1
|
|
|
|
|
|
|
|
|
|
|
|
get_image() {
|
|
|
|
get_image() {
|
|
|
|
IMAGE_NAME=$(uci get btcpayserver.@btcpayserver[0].image_name 2>/dev/null)
|
|
|
|
do_install_detail
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
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)
|
|
|
|
config=$(uci get btcpayserver.@btcpayserver[0].config_path 2>/dev/null)
|
|
|
|
port=$(uci get btcpayserver.@btcpayserver[0].port 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)
|
|
|
|
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_PASS=$(< /dev/urandom tr -dc A-Za-z0-9 2>/dev/null | head -c 14; echo)
|
|
|
|
GEN_PASS2=$(head -c14 /dev/urandom | tr -dc A-Za-z0-9)
|
|
|
|
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=$(uci get network.lan.ipaddr)
|
|
|
|
LAN_IP="${LAN_IP%/*}"
|
|
|
|
LAN_IP="${LAN_IP%/*}"
|
|
|
|
|
|
|
|
|
|
|
|
[ -z "$config" ] && { echo "config path is empty!"; exit 1; }
|
|
|
|
if [ -z "$config" ]; then
|
|
|
|
[ -z "$port" ] && port=8888
|
|
|
|
echo "config path is empty!"
|
|
|
|
[ -z "$IMAGE_NAME" ] && IMAGE_NAME=clightning
|
|
|
|
exit 1
|
|
|
|
}
|
|
|
|
fi
|
|
|
|
|
|
|
|
|
|
|
|
setup_btcpayserver() {
|
|
|
|
[ -z "$port" ] && port=1880
|
|
|
|
git clone https://github.com/btcpayserver/btcpayserver-docker /opt/docker2/compose/btcpayserver/btcpayserver-docker/
|
|
|
|
[ -z "$IMAGE_NAME" ] && IMAGE_NAME="btcpayserver/node-red:latest"
|
|
|
|
|
|
|
|
|
|
|
|
touch /opt/docker2/compose/btcpayserver/btcpayserver-docker/go.sh
|
|
|
|
rm -r /opt/docker2/compose/btcpayserver 2>/dev/null
|
|
|
|
chmod +x /opt/docker2/compose/btcpayserver/btcpayserver-docker/go.sh
|
|
|
|
mkdir -p /opt/docker2/compose/btcpayserver/
|
|
|
|
cat > /opt/docker2/compose/btcpayserver/btcpayserver-docker/go.sh <<EOF
|
|
|
|
|
|
|
|
#!/bin/bash
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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 BTCPAY_HOST="${LAN_IP}"
|
|
|
|
export NBITCOIN_NETWORK="${config}"
|
|
|
|
export NBITCOIN_NETWORK="${config}"
|
|
|
|
export BTCPAYGEN_CRYPTO1="btc"
|
|
|
|
export BTCPAYGEN_CRYPTO1="btc"
|
|
|
@ -42,34 +49,21 @@ export NOREVERSEPROXY_HTTP_PORT="${port}"
|
|
|
|
export BTCPAY_PROTOCOL="http"
|
|
|
|
export BTCPAY_PROTOCOL="http"
|
|
|
|
export BTCPAYGEN_REVERSEPROXY="none"
|
|
|
|
export BTCPAYGEN_REVERSEPROXY="none"
|
|
|
|
|
|
|
|
|
|
|
|
bash /opt/docker2/compose/btcpayserver/btcpayserver-docker/btcpay-setup.sh -i
|
|
|
|
. ./btcpay-setup.sh -i
|
|
|
|
|
|
|
|
|
|
|
|
EOF
|
|
|
|
EOF
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if [ "$(id -u)" -ne 0 ]; then
|
|
|
|
bash /opt/docker2/compose/btcpayserver/satoshi.sh
|
|
|
|
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 "..........................................................."
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
uci add shortcutmenu lists
|
|
|
|
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].weburl="$LAN_IP:$port"
|
|
|
|
uci set shortcutmenu.@lists[-1].webpath="/"
|
|
|
|
uci set shortcutmenu.@lists[-1].webpath="/"
|
|
|
|
uci commit shortcutmenu
|
|
|
|
uci commit shortcutmenu
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
usage() {
|
|
|
|
usage() {
|
|
|
|
echo "usage: $0 sub-command"
|
|
|
|
echo "usage: $0 sub-command"
|
|
|
|
echo " where sub-command is one of:"
|
|
|
|
echo "where sub-command is one of:"
|
|
|
|
echo " install Install btcpayserver"
|
|
|
|
echo " install Install btcpayserver"
|
|
|
|
echo " upgrade Upgrade btcpayserver"
|
|
|
|
echo " upgrade Upgrade btcpayserver"
|
|
|
|
echo " rm/start/stop/restart Remove/Start/Stop/Restart btcpayserver"
|
|
|
|
echo " rm/start/stop/restart Remove/Start/Stop/Restart btcpayserver"
|
|
|
@ -78,25 +72,37 @@ usage() {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
case "${ACTION}" in
|
|
|
|
case "${ACTION}" in
|
|
|
|
"install")
|
|
|
|
"install" | "upgrade")
|
|
|
|
get_image
|
|
|
|
|
|
|
|
do_install_detail
|
|
|
|
|
|
|
|
;;
|
|
|
|
|
|
|
|
"upgrade")
|
|
|
|
|
|
|
|
get_image
|
|
|
|
|
|
|
|
do_install_detail
|
|
|
|
do_install_detail
|
|
|
|
;;
|
|
|
|
;;
|
|
|
|
"rm")
|
|
|
|
"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")
|
|
|
|
"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")
|
|
|
|
"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")
|
|
|
|
"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
|
|
|
|
usage
|
|
|
|