2024-03-07 16:02:59 +00:00
|
|
|
#!/bin/sh
|
2024-03-07 01:04:55 +00:00
|
|
|
|
2024-03-08 19:11:15 +00:00
|
|
|
docker__compose() {
|
2024-03-09 02:07:43 +00:00
|
|
|
CURRENT_UID=$(id -u) CURRENT_GID=$(id -g) command docker compose --env-file .env.sndev "$@"
|
2024-03-08 19:11:15 +00:00
|
|
|
}
|
|
|
|
|
2024-03-10 21:29:10 +00:00
|
|
|
docker__exec() {
|
2024-03-10 22:30:11 +00:00
|
|
|
command docker exec "$@"
|
2024-03-10 21:29:10 +00:00
|
|
|
}
|
|
|
|
|
2024-03-10 22:30:11 +00:00
|
|
|
docker__sn_lnd() {
|
|
|
|
docker__exec -u lnd sn_lnd lncli "$@"
|
2024-03-10 21:42:16 +00:00
|
|
|
}
|
|
|
|
|
2024-03-10 22:30:11 +00:00
|
|
|
docker__stacker_lnd() {
|
|
|
|
docker__exec -u lnd stacker_lnd lncli "$@"
|
2024-03-10 21:42:16 +00:00
|
|
|
}
|
|
|
|
|
2024-03-07 01:04:55 +00:00
|
|
|
sndev__start() {
|
|
|
|
if [ ! -x "$(command -v docker-compose)" ]; then
|
|
|
|
echo "docker compose is not installed"
|
|
|
|
echo "installation instructions are here: https://docs.docker.com/desktop/"
|
|
|
|
exit 0
|
|
|
|
fi
|
|
|
|
|
|
|
|
if ! [ -f .env.sndev ]; then
|
|
|
|
echo ".env.sndev does not exist."
|
|
|
|
echo "creating from .env.sample"
|
|
|
|
cp .env.sample .env.sndev
|
|
|
|
fi
|
|
|
|
|
|
|
|
echo "Starting application"
|
2024-03-08 19:11:15 +00:00
|
|
|
docker__compose up --build
|
2024-03-07 01:04:55 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
sndev__stop() {
|
|
|
|
echo "Stopping application"
|
2024-03-08 19:11:15 +00:00
|
|
|
docker__compose down
|
2024-03-07 01:04:55 +00:00
|
|
|
}
|
|
|
|
|
2024-03-10 22:30:11 +00:00
|
|
|
sndev__restart() {
|
|
|
|
docker__compose restart
|
|
|
|
}
|
|
|
|
|
2024-03-10 22:10:38 +00:00
|
|
|
sndev__status() {
|
|
|
|
shift
|
|
|
|
docker__compose ps --format 'table {{.Service}}\t{{.State}}\t{{.Status}}\t{{.Ports}}'
|
|
|
|
}
|
|
|
|
|
2024-03-07 01:04:55 +00:00
|
|
|
sndev__delete() {
|
|
|
|
echo "Deleting application"
|
2024-03-08 19:11:15 +00:00
|
|
|
docker__compose down --volumes --remove-orphans
|
2024-03-07 01:04:55 +00:00
|
|
|
}
|
|
|
|
|
2024-03-10 21:42:16 +00:00
|
|
|
sndev__fund() {
|
|
|
|
shift
|
2024-03-10 22:30:11 +00:00
|
|
|
docker__stacker_lnd payinvoice --force "$@"
|
2024-03-10 21:42:16 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
sndev__withdraw() {
|
2024-03-10 21:29:10 +00:00
|
|
|
shift
|
2024-03-10 22:30:11 +00:00
|
|
|
docker__stacker_lnd addinvoice --amt "$@" | jq -r '.payment_request'
|
|
|
|
}
|
|
|
|
|
|
|
|
sndev__compose() {
|
|
|
|
shift
|
|
|
|
docker__compose "$@"
|
|
|
|
}
|
|
|
|
|
|
|
|
sndev__sn_lncli() {
|
|
|
|
shift
|
|
|
|
docker__sn_lnd "$@"
|
|
|
|
}
|
|
|
|
|
|
|
|
sndev__stacker_lncli() {
|
|
|
|
shift
|
|
|
|
docker__stacker_lnd "$@"
|
2024-03-10 21:29:10 +00:00
|
|
|
}
|
|
|
|
|
2024-03-07 01:04:55 +00:00
|
|
|
sndev__help() {
|
|
|
|
if [ $# -eq 3 ]; then
|
|
|
|
call "sndev__$1__$2__$3" "$@"
|
|
|
|
elif [ $# -eq 2 ]; then
|
|
|
|
call "sndev__$1__$2" "$@"
|
|
|
|
else
|
2024-03-10 21:59:15 +00:00
|
|
|
help="
|
|
|
|
888
|
|
|
|
888
|
|
|
|
888
|
|
|
|
.d8888b 88888b. .d88888 .d88b. 888 888
|
|
|
|
88K 888 '88b d88' 888 d8P Y8b 888 888
|
|
|
|
'Y8888b. 888 888 888 888 88888888 Y88 88P
|
|
|
|
X88 888 888 Y88b 888 Y8b. Y8bd8P
|
|
|
|
88888P' 888 888 'Y88888 'Y8888 Y88P
|
|
|
|
|
|
|
|
manages a docker based stacker news development environment
|
2024-03-07 01:04:55 +00:00
|
|
|
|
|
|
|
USAGE
|
|
|
|
$ sndev [COMMAND]
|
|
|
|
|
|
|
|
COMMANDS
|
2024-03-10 22:30:11 +00:00
|
|
|
help show help
|
|
|
|
|
|
|
|
env:
|
|
|
|
start start env
|
|
|
|
stop stop env
|
|
|
|
restart restart env
|
|
|
|
status status of env
|
|
|
|
delete delete env
|
|
|
|
|
|
|
|
lnd:
|
|
|
|
fund pay a bolt11 for funding
|
|
|
|
withdraw make a bolt11 for withdrawal
|
|
|
|
|
|
|
|
raw:
|
|
|
|
compose call docker compose directly
|
|
|
|
sn_lncli call lncli on sn_lnd directly
|
|
|
|
stacker_lncli call lncli on stacker_lnd directly
|
2024-03-07 01:04:55 +00:00
|
|
|
"
|
|
|
|
echo "$help"
|
|
|
|
fi
|
|
|
|
}
|
|
|
|
|
|
|
|
call() {
|
|
|
|
func=$1
|
|
|
|
if type "$func" 1>/dev/null 2>&1; then
|
|
|
|
shift
|
|
|
|
"$func" "$@" # invoke our named function w/ all remaining arguments
|
|
|
|
else
|
|
|
|
sndev__help
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
}
|
|
|
|
|
|
|
|
call "sndev__$1" "$@"
|