Skip to content

Commit 6b0e1cb

Browse files
committed
Add free open base scripts for nginx-proxy
1 parent f6ffeb9 commit 6b0e1cb

File tree

6 files changed

+324
-0
lines changed

6 files changed

+324
-0
lines changed
Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
#-----------------------------------------------------------------------
2+
#
3+
# Basescript function
4+
#
5+
# The basescript functions were designed to work as abstract function,
6+
# so it could be used in many different contexts executing specific job
7+
# always remembering Unix concept DOTADIW - "Do One Thing And Do It Well"
8+
#
9+
# Developed by
10+
# Evert Ramos <evert.ramos@gmail.com>
11+
#
12+
# Copyright Evert Ramos
13+
#
14+
#-----------------------------------------------------------------------
15+
#
16+
# Be carefull when editing this file, it is part of a bigger script!
17+
#
18+
# Basescript - https://github.com/evertramos/basescript
19+
#
20+
#-----------------------------------------------------------------------
21+
22+
#-----------------------------------------------------------------------
23+
# This function has one main objective:
24+
# 1. Check if the .env file exists in the base folder
25+
#
26+
# You must/might inform the parameters below:
27+
# 1. n/a
28+
# 2. [optional] (default: ) n/a
29+
#
30+
#-----------------------------------------------------------------------
31+
32+
checkbaseenvfile()
33+
{
34+
if [[ "$DEBUG" == true ]]; then
35+
echo "Check if base folder '.env' file is set."
36+
fi
37+
38+
cd $SCRIPT_PATH"/../"
39+
40+
if [[ -e .env ]]; then
41+
source .env
42+
cd - > /dev/null 2>&1
43+
else
44+
MESSAGE="'.env' file not found at the base folder. Please check! \n\n path: $(pwd)"
45+
return 1
46+
fi
47+
}
Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
#-----------------------------------------------------------------------
2+
#
3+
# Basescript function
4+
#
5+
# The basescript functions were designed to work as abstract function,
6+
# so it could be used in many different contexts executing specific job
7+
# always remembering Unix concept DOTADIW - "Do One Thing And Do It Well"
8+
#
9+
# Developed by
10+
# Evert Ramos <evert.ramos@gmail.com>
11+
#
12+
# Copyright Evert Ramos
13+
#
14+
#-----------------------------------------------------------------------
15+
#
16+
# Be carefull when editing this file, it is part of a bigger script!
17+
#
18+
# Basescript - https://github.com/evertramos/basescript
19+
#
20+
#-----------------------------------------------------------------------
21+
22+
#-----------------------------------------------------------------------
23+
# This function has one main objective:
24+
# 1. Script to check if docker is running
25+
#
26+
# You must/might inform the parameters below:
27+
# 1. n/a
28+
# 2. [optional] (default: ) n/a
29+
#
30+
#-----------------------------------------------------------------------
31+
32+
DOCKER_COMMAND="docker"
33+
34+
# Check if Docker is installed in the System
35+
checkdocker()
36+
{
37+
if [[ "$DEBUG" == true ]]; then
38+
echo "Check if '$DOCKER_COMMAND' is installed and running."
39+
fi
40+
if [[ ! -x "$(command -v "$DOCKER_COMMAND")" ]]; then
41+
MESSAGE="'docker' is not installed!"
42+
return 1
43+
fi
44+
45+
if [[ ! "$(systemctl is-active "$DOCKER_COMMAND")" == "active" ]]; then
46+
MESSAGE="'docker' is not running..."
47+
return 1
48+
fi
49+
}
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
# This file is part of a bigger script!
2+
#
3+
# Be carefull when editing it
4+
5+
# ----------------------------------------------------------------------
6+
#
7+
# Script devoloped to BM Digital
8+
#
9+
# Developed by
10+
# Evert Ramos <evert.ramos@gmail.com>
11+
#
12+
# Copyright Evert Ramos with usage right granted to BM Digital
13+
#
14+
# ----------------------------------------------------------------------
15+
16+
# Script to check if there is another instance of the script running
17+
check_running_script()
18+
{
19+
local LOCAL_PID_FILE
20+
21+
LOCAL_PID_FILE=${1:-$PID_FILE}
22+
23+
[[ "$DEBUG" == true ]] && echo "Check if there is another instance of the script running..."
24+
25+
PID=$SCRIPT_PATH/$LOCAL_PID_FILE
26+
27+
[[ "$DEBUG" = true ]] && echo "pid: "$PID
28+
29+
if [[ -e "$PID" ]]; then
30+
MESSAGE="Script already running."
31+
return 1
32+
fi
33+
}
Lines changed: 108 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,108 @@
1+
#-----------------------------------------------------------------------
2+
#
3+
# Basescript function
4+
#
5+
# The basescript functions were designed to work as abstract function,
6+
# so it could be used in many different contexts executing specific job
7+
# always remembering Unix concept DOTADIW - "Do One Thing And Do It Well"
8+
#
9+
# Developed by
10+
# Evert Ramos <evert.ramos@gmail.com>
11+
#
12+
# Copyright Evert Ramos
13+
#
14+
#-----------------------------------------------------------------------
15+
#
16+
# Be carefull when editing this file, it is part of a bigger scripts!
17+
#
18+
# Basescript - https://github.com/evertramos/basescript
19+
#
20+
#-----------------------------------------------------------------------
21+
22+
# ----------------------------------------------------------------------
23+
# This function has one main objective:
24+
# 1. Show output messages
25+
#
26+
# You must inform the parameters below:
27+
# 1. Message that should be outputed
28+
# 2. [optional] Stopping execution on messaging (default: 'depends')
29+
#
30+
# ----------------------------------------------------------------------
31+
32+
# Error message
33+
echoerr()
34+
{
35+
local LOCAL_STOP_EXECUTION_ON_ERROR
36+
37+
LOCAL_STOP_EXECUTION_ON_ERROR=${2:-true}
38+
39+
# Check $SILENT mode
40+
if [[ "$SILENT" == true ]]; then
41+
echo $1
42+
else
43+
echo "${red}[ERROR]---------------------------------------------------------------${reset}"
44+
printf "${red}${1//\\n/\\n}${reset}" 1>&2;
45+
echo
46+
echo "${red}----------------------------------------------------------------------${reset}"
47+
echo
48+
fi
49+
50+
[[ "$LOCAL_STOP_EXECUTION_ON_ERROR" == true ]] && exit 1
51+
}
52+
53+
# Warning message
54+
echowarning()
55+
{
56+
local LOCAL_STOP_EXECUTION_ON_ERROR
57+
58+
LOCAL_STOP_EXECUTION_ON_ERROR=${2:-false}
59+
60+
# Check $SILENT mode
61+
if [[ "$SILENT" != true ]]; then
62+
echo "${yellow}[WARNING]-------------------------------------------------------------${reset}"
63+
printf "${yellow}${1//\\n/\\n}${reset}" 1>&2;
64+
echo
65+
echo "${yellow}----------------------------------------------------------------------${reset}"
66+
echo
67+
fi
68+
69+
[[ "$LOCAL_STOP_EXECUTION_ON_ERROR" == true ]] && exit 1
70+
}
71+
72+
# Success message
73+
echosuccess()
74+
{
75+
local LOCAL_STOP_EXECUTION_ON_ERROR
76+
77+
LOCAL_STOP_EXECUTION_ON_ERROR=${2:-false}
78+
79+
# Check $SILENT mode
80+
if [[ "$SILENT" != true ]]; then
81+
echo "${green}[SUCCESS]-------------------------------------------------------------${reset}"
82+
printf "${green}${1//\\n/\\n}${reset}" 1>&2;
83+
echo
84+
echo "${green}----------------------------------------------------------------------${reset}"
85+
echo
86+
fi
87+
88+
[[ "$LOCAL_STOP_EXECUTION_ON_ERROR" == true ]] && exit 1
89+
}
90+
91+
# Regular line message
92+
echoline()
93+
{
94+
local LOCAL_STOP_EXECUTION_ON_ERROR
95+
96+
LOCAL_STOP_EXECUTION_ON_ERROR=${2:-false}
97+
98+
# Check $SILENT mode
99+
if [[ "$SILENT" != true ]]; then
100+
echo "----------------------------------------------------------------------"
101+
printf " ${1//\\n/\\n}" 1>&2;
102+
echo
103+
echo "----------------------------------------------------------------------"
104+
echo
105+
fi
106+
107+
[[ "$LOCAL_STOP_EXECUTION_ON_ERROR" == true ]] && exit 1
108+
}

basescript-free/starts/color.sh

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
#!/usr/bin/env bash
2+
3+
#-----------------------------------------------------------------------
4+
#
5+
# Basescript function
6+
#
7+
# The basescript functions were designed to work as abstract function,
8+
# so it could be used in many different contexts executing specific job
9+
# always remembering Unix concept DOTADIW - "Do One Thing And Do It Well"
10+
#
11+
# Developed by
12+
# Evert Ramos <evert.ramos@gmail.com>
13+
#
14+
# Copyright Evert Ramos
15+
#
16+
#-----------------------------------------------------------------------
17+
#
18+
# Be carefull when editing this file, it is part of a bigger scripts!
19+
#
20+
# Basescript - https://github.com/evertramos/basescript
21+
#
22+
#-----------------------------------------------------------------------
23+
#
24+
# source: https://stackoverflow.com/questions/5947742/how-to-change-the-output-color-of-echo-in-linux
25+
#
26+
# ----------------------------------------------------------------------
27+
# This script has one main objective:
28+
# 1. Set colors for output messages
29+
#
30+
# ----------------------------------------------------------------------
31+
32+
# Colors on output
33+
black=`tput setaf 0`
34+
red=`tput setaf 1`
35+
green=`tput setaf 2`
36+
yellow=`tput setaf 3`
37+
blue=`tput setaf 4`
38+
magenta=`tput setaf 5`
39+
cyan=`tput setaf 6`
40+
white=`tput setaf 7`
41+
42+
reset=`tput sgr0`
43+
Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
#-----------------------------------------------------------------------
2+
#
3+
# Basescript functions
4+
#
5+
# The basescript functions were designed to work as abstract function,
6+
# so it could be used in many different contexts executing specific job
7+
# always remembering Unix concept DOTADIW - "Do One Thing And Do It Well"
8+
#
9+
# Developed by
10+
# Evert Ramos <evert.ramos@gmail.com>
11+
#
12+
# Copyright Evert Ramos
13+
#
14+
#-----------------------------------------------------------------------
15+
#
16+
# Be carefull when editing this file, it is part of a bigger scripts!
17+
#
18+
# Basescript - https://github.com/evertramos/basescript
19+
#
20+
#-----------------------------------------------------------------------
21+
22+
# ----------------------------------------------------------------------
23+
# This function has one main objective:
24+
# 1. Check initial setup
25+
#
26+
# You must inform the parameters below:
27+
# 1. [optional] Pid file name (default: )
28+
#
29+
# ----------------------------------------------------------------------
30+
starts_initial_check()
31+
{
32+
local LOCAL_PID_FILE
33+
34+
LOCAL_PID_FILE=${1:-$PID_FILE}
35+
36+
# Check if docker is installed
37+
run_function checkdocker
38+
39+
# Check if there is an .env file in base folder
40+
run_function checkbaseenvfile
41+
42+
# Check if you are already running an instance of this Script
43+
run_function check_running_script $LOCAL_PID_FILE
44+
}

0 commit comments

Comments
 (0)