mirror of
https://github.com/IgorKha/Grafana-Mikrotik.git
synced 2025-12-06 02:19:28 +00:00
small update sh & add action
This commit is contained in:
parent
980c4d2a25
commit
02c59f0211
2 changed files with 47 additions and 12 deletions
34
.github/workflows/action.yml
vendored
Normal file
34
.github/workflows/action.yml
vendored
Normal file
|
|
@ -0,0 +1,34 @@
|
|||
name: simple test
|
||||
on:
|
||||
push:
|
||||
branches: master
|
||||
|
||||
jobs:
|
||||
|
||||
lint:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@v2
|
||||
- name: Run Shellcheck
|
||||
uses: azohra/shell-linter@latest
|
||||
with:
|
||||
path: "run.sh"
|
||||
severity: "warning, error"
|
||||
|
||||
test:
|
||||
needs: lint
|
||||
runs-on: ubuntu-latest
|
||||
|
||||
steps:
|
||||
- name: deploy with sh script
|
||||
run: sh -c "$(curl -fsSL https://raw.githubusercontent.com/IgorKha/practice-git-1/master/run.sh?token=AARJYMOSNNLREAAM2J7HL4LBMR3CA)" ""
|
||||
|
||||
- name: Test Grafana
|
||||
run: sleep 5 && curl -ILsS --retry 5 --retry-delay 2 "http://localhost:3000/login"
|
||||
|
||||
- name: Test Prometheus
|
||||
run: curl -ILsS --retry 5 --retry-delay 2 "http://localhost:9090"
|
||||
|
||||
- name: Test snmp_exporter
|
||||
run: curl -ILsS --retry 5 --retry-delay 2 "http://localhost:9116"
|
||||
|
||||
25
run.sh
25
run.sh
|
|
@ -1,4 +1,5 @@
|
|||
#!/bin/sh
|
||||
#!/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
|
||||
|
|
@ -16,7 +17,7 @@ ENV_FILE=${ENV_FILE:-.env}
|
|||
|
||||
#? Colors
|
||||
RED=$(printf '\033[31m')
|
||||
GREEN=$(printf '\033[32m')
|
||||
# GREEN=$(printf '\033[32m')
|
||||
YELLOW=$(printf '\033[33m')
|
||||
BLUE=$(printf '\033[34m')
|
||||
BOLD=$(printf '\033[1m')
|
||||
|
|
@ -109,15 +110,15 @@ clone_git() {
|
|||
router_ip() {
|
||||
if [ "$CONFIG" = yes ]; then
|
||||
if ask "Change target mikrotik IP address ?" Y; then
|
||||
read -p 'Enter target mikrotik IP address: ' IP
|
||||
read -rp 'Enter target mikrotik IP address: ' IP
|
||||
if [ -d "./${REPO}" ]; then
|
||||
sed -i -e 's/192.168.88.1/'"${IP}"'/g' \
|
||||
${REPO}/prometheus/prometheus.yml
|
||||
sed -ri -e 's/^(MIKROTIK_IP=)(.*)$/\1'"$IP"'/g' $ENV_FILE
|
||||
sed -ri -e 's/^(MIKROTIK_IP=)(.*)$/\1'"$IP"'/g' "$ENV_FILE"
|
||||
else
|
||||
sed -i -e 's/192.168.88.1/'"${IP}"'/g' \
|
||||
./prometheus/prometheus.yml
|
||||
sed -ri -e 's/^(MIKROTIK_IP=)(.*)$/\1'"$IP"'/g' $ENV_FILE
|
||||
sed -ri -e 's/^(MIKROTIK_IP=)(.*)$/\1'"$IP"'/g' "$ENV_FILE"
|
||||
fi
|
||||
return
|
||||
fi
|
||||
|
|
@ -129,11 +130,11 @@ grafana_credentials() {
|
|||
if [ "$CONFIG" = yes ]; then
|
||||
echo "${YELLOW}Grafana${RESET}"
|
||||
if ask "Change default credentials Grafana ?" N; then
|
||||
read -p 'Enter grafana Username: ' GF_USER
|
||||
read -sp 'Enter grafana Password: ' GF_PASSWD
|
||||
read -rp 'Enter grafana Username: ' GF_USER
|
||||
read -rsp 'Enter grafana Password: ' GF_PASSWD
|
||||
|
||||
sed -ri -e 's/^(GF_ADMIN_USER=)(.*)$/\1'"$GF_USER"'/g' $ENV_FILE
|
||||
sed -ri -e 's/^(GF_ADMIN_PASSWORD=)(.*)$/\1'"$GF_PASSWD"'/g' $ENV_FILE
|
||||
sed -ri -e 's/^(GF_ADMIN_USER=)(.*)$/\1'"$GF_USER"'/g' "$ENV_FILE"
|
||||
sed -ri -e 's/^(GF_ADMIN_PASSWORD=)(.*)$/\1'"$GF_PASSWD"'/g' "$ENV_FILE"
|
||||
else
|
||||
echo "Default Grafana:
|
||||
User: ${YELLOW}admin${RESET}
|
||||
|
|
@ -169,8 +170,8 @@ docker() {
|
|||
|
||||
print_success() {
|
||||
echo "============================================="
|
||||
echo "${YELLOW}Grafana http://localhost:3000${RESET}"
|
||||
echo "${BLUE}Prometheus http://localhost:9090/targets${RESET}"
|
||||
echo "${GREEN}Grafana http://localhost:3000"
|
||||
echo "Prometheus http://localhost:9090/targets${RESET}"
|
||||
}
|
||||
|
||||
main() {
|
||||
|
|
@ -201,7 +202,7 @@ main() {
|
|||
grafana_credentials
|
||||
|
||||
# Change UID:GID prometheus container to current user
|
||||
sed -ri -e 's/^(CURRENT_USER=)(.*)$/\1'"$DCUID\:$DCGID"'/g' $ENV_FILE
|
||||
sed -ri -e 's/^(CURRENT_USER=)(.*)$/\1'"$DCUID\:$DCGID"'/g' "$ENV_FILE"
|
||||
|
||||
docker
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue