#!/bin/bash # # You can also pass some arguments to script to set some these options: # --config: change the user and password to grafana and specify the mikrotik IP address # stop: stop docker containers # For example: # sh run.sh --config # # # set -e REPO=Grafana-Mikrotik ENV_FILE=${ENV_FILE:-.env} #? Colors RED=$(printf '\033[31m') # GREEN=$(printf '\033[32m') YELLOW=$(printf '\033[33m') BLUE=$(printf '\033[34m') BOLD=$(printf '\033[1m') RESET=$(printf '\033[m') #? No Color BOLD=$(printf '\033[1m') #? Docker DCUID=$(id -u) DCGID=$(id -g) ask() { local prompt default reply if [[ ${2:-} = 'Y' ]]; then prompt='Y/n' default='Y' elif [[ ${2:-} = 'N' ]]; then prompt='y/N' default='N' else prompt='y/n' default='' fi while true; do #? Ask the question (not using "read -p" as it uses stderr not stdout) echo -n "$1 [$prompt] " #? Read the answer (use /dev/tty in case stdin is redirected from somewhere else) read -r reply /dev/null 2>&1 } fmt_error() { printf '%sError: %s%s\n' "$BOLD$RED" "$*" "$RESET" >&2 } helper() { if [ "$HELP" = yes ]; then cat <