Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion lgsm/functions/alert_telegram.sh
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ EOF
)

fn_print_dots "Sending Telegram alert"
telegramsend=$(${curlpath} -sSL -H "Content-Type: application/json" -X POST -d """${json}""" "https://api.telegram.org/bot${telegramtoken}/sendMessage" ${curlcustomstring} | grep "error_code")
telegramsend=$(${curlpath} -sSL -H "Content-Type: application/json" -X POST -d """${json}""" "https://api.telegram.org/bot${telegramtoken}/sendMessage" "${curlcustomstring}" | grep "error_code")

if [ -n "${telegramsend}" ]; then
fn_print_fail_nl "Sending Telegram alert: ${telegramsend}"
Expand Down
20 changes: 10 additions & 10 deletions lgsm/functions/check_deps.sh
Original file line number Diff line number Diff line change
Expand Up @@ -27,13 +27,13 @@ fn_install_mono_repo(){
if [ "${distroid}" == "ubuntu" ]; then
if [ "${distroversion}" == "18.04" ]; then
cmd="sudo apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv-keys 3FA7E0328081BFF6A14DA29AA6A19B38D3D831EF;echo 'deb https://download.mono-project.com/repo/ubuntu stable-bionic main' | sudo tee /etc/apt/sources.list.d/mono-official-stable.list;sudo apt update"
eval ${cmd}
eval "${cmd}"
elif [ "${distroversion}" == "16.04" ]; then
cmd="sudo apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv-keys 3FA7E0328081BFF6A14DA29AA6A19B38D3D831EF;sudo apt install apt-transport-https;echo 'deb https://download.mono-project.com/repo/ubuntu stable-xenial main' | sudo tee /etc/apt/sources.list.d/mono-official-stable.list;sudo apt update"
eval ${cmd}
eval "${cmd}"
elif [ "${distroversion}" == "14.04" ]; then
cmd="sudo apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv-keys 3FA7E0328081BFF6A14DA29AA6A19B38D3D831EF;sudo apt install apt-transport-https;echo 'deb https://download.mono-project.com/repo/ubuntu stable-trusty main' | sudo tee /etc/apt/sources.list.d/mono-official-stable.list;sudo apt update"
eval ${cmd}
eval "${cmd}"
else
fn_print_warn_nl "Installing Mono repository"
echo -e "Mono auto install not available for ${distroname}"
Expand All @@ -44,13 +44,13 @@ fn_install_mono_repo(){
elif [ "${distroid}" == "debian" ]; then
if [ "${distroversion}" == "10" ]; then
cmd="sudo apt install apt-transport-https dirmngr;sudo apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv-keys 3FA7E0328081BFF6A14DA29AA6A19B38D3D831EF;echo 'deb https://download.mono-project.com/repo/debian stable-buster main' | sudo tee /etc/apt/sources.list.d/mono-official-stable.list;sudo apt update"
eval ${cmd}
eval "${cmd}"
elif [ "${distroversion}" == "9" ]; then
cmd="sudo apt install apt-transport-https dirmngr;sudo apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv-keys 3FA7E0328081BFF6A14DA29AA6A19B38D3D831EF;echo 'deb https://download.mono-project.com/repo/debian stable-stretch main' | sudo tee /etc/apt/sources.list.d/mono-official-stable.list;sudo apt update"
eval ${cmd}
eval "${cmd}"
elif [ "${distroversion}" == "8" ]; then
cmd="sudo apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv-keys 3FA7E0328081BFF6A14DA29AA6A19B38D3D831EF;sudo apt install apt-transport-https;echo 'deb https://download.mono-project.com/repo/debian stable-jessie main' | sudo tee /etc/apt/sources.list.d/mono-official-stable.list;sudo apt update"
eval ${cmd}
eval "${cmd}"
else
echo -e "Mono auto install not available for ${distroname}"
echo -e " Follow instructions on mono site to install the latest version of Mono."
Expand All @@ -60,13 +60,13 @@ fn_install_mono_repo(){
elif [ "${distroid}" == "centos" ]; then
if [ "${distroversion}" == "8" ]; then
cmd="rpm --import 'https://keyserver.ubuntu.com/pks/lookup?op=get&search=0x3FA7E0328081BFF6A14DA29AA6A19B38D3D831EF';su -c 'curl https://download.mono-project.com/repo/centos8-stable.repo | tee /etc/yum.repos.d/mono-centos8-stable.repo'"
eval ${cmd}
eval "${cmd}"
elif [ "${distroversion}" == "7" ]; then
cmd="rpm --import 'https://keyserver.ubuntu.com/pks/lookup?op=get&search=0x3FA7E0328081BFF6A14DA29AA6A19B38D3D831EF';su -c 'curl https://download.mono-project.com/repo/centos7-stable.repo | tee /etc/yum.repos.d/mono-centos7-stable.repo'"
eval ${cmd}
eval "${cmd}"
elif [ "${distroversion}" == "6" ]; then
cmd="rpm --import 'https://keyserver.ubuntu.com/pks/lookup?op=get&search=0x3FA7E0328081BFF6A14DA29AA6A19B38D3D831EF';su -c 'curl https://download.mono-project.com/repo/centos6-stable.repo | tee /etc/yum.repos.d/mono-centos6-stable.repo'"
eval ${cmd}
eval "${cmd}"
else
echo -e "Mono auto install not available for ${distroname}"
echo -e " Follow instructions on mono site to install the latest version of Mono."
Expand All @@ -75,7 +75,7 @@ fn_install_mono_repo(){
fi
elif [ "${distroid}" == "fedora" ]; then
cmd="rpm --import 'https://keyserver.ubuntu.com/pks/lookup?op=get&search=0x3FA7E0328081BFF6A14DA29AA6A19B38D3D831EF'; su -c 'curl https://download.mono-project.com/repo/centos7-stable.repo | tee /etc/yum.repos.d/mono-centos7-stable.repo'; dnf update"
eval ${cmd}
eval "${cmd}"
else
echo -e "Mono auto install not available for ${distroname}"
echo -e " Follow instructions on mono site to install the latest version of Mono."
Expand Down
1 change: 1 addition & 0 deletions lgsm/functions/core_dl.sh
Original file line number Diff line number Diff line change
Expand Up @@ -168,6 +168,7 @@ fn_fetch_file(){
fn_dl_md5
# Execute file if run is set.
if [ "${run}" == "run" ]; then
# shellcheck source=/dev/null
source "${local_filedir}/${local_filename}"
fi
fi
Expand Down
68 changes: 34 additions & 34 deletions lgsm/functions/core_messages.sh
Original file line number Diff line number Diff line change
Expand Up @@ -119,18 +119,18 @@ fn_script_log_info(){
# [ .... ]
fn_print_dots(){
if [ -n "${commandaction}" ]; then
echo -en "${creeol}[ .... ] ${commandaction} ${selfname}: $@"
echo -en "${creeol}[ .... ] ${commandaction} ${servicename}: $*"
else
echo -en "${creeol}[ .... ] $@"
echo -en "${creeol}[ .... ] $*"
fi
fn_sleep_time
}

fn_print_dots_nl(){
if [ -n "${commandaction}" ]; then
echo -e "${creeol}[ .... ] ${commandaction} ${selfname}: $@"
echo -e "${creeol}[ .... ] ${commandaction} ${servicename}: $*"
else
echo -e "${creeol}[ .... ] $@"
echo -e "${creeol}[ .... ] $*"
fi
fn_sleep_time
echo -en "\n"
Expand All @@ -139,18 +139,18 @@ fn_print_dots_nl(){
# [ OK ]
fn_print_ok(){
if [ -n "${commandaction}" ]; then
echo -en "${creeol}[${green} OK ${default}] ${commandaction} ${selfname}: $@"
echo -en "${creeol}[${green} OK ${default}] ${commandaction} ${servicename}: $*"
else
echo -en "${creeol}[${green} OK ${default}] $@"
echo -en "${creeol}[${green} OK ${default}] $*"
fi
fn_sleep_time
}

fn_print_ok_nl(){
if [ -n "${commandaction}" ]; then
echo -en "${creeol}[${green} OK ${default}] ${commandaction} ${selfname}: $@"
echo -en "${creeol}[${green} OK ${default}] ${commandaction} ${servicename}: $*"
else
echo -en "${creeol}[${green} OK ${default}] $@"
echo -en "${creeol}[${green} OK ${default}] $*"
fi
fn_sleep_time
echo -en "\n"
Expand All @@ -159,18 +159,18 @@ fn_print_ok_nl(){
# [ FAIL ]
fn_print_fail(){
if [ -n "${commandaction}" ]; then
echo -en "${creeol}[${red} FAIL ${default}] ${commandaction} ${selfname}: $@"
echo -en "${creeol}[${red} FAIL ${default}] ${commandaction} ${servicename}: $*"
else
echo -en "${creeol}[${red} FAIL ${default}] $@"
echo -en "${creeol}[${red} FAIL ${default}] $*"
fi
fn_sleep_time
}

fn_print_fail_nl(){
if [ -n "${commandaction}" ]; then
echo -en "${creeol}[${red} FAIL ${default}] ${commandaction} ${selfname}: $@"
echo -en "${creeol}[${red} FAIL ${default}] ${commandaction} ${servicename}: $*"
else
echo -en "${creeol}[${red} FAIL ${default}] $@"
echo -en "${creeol}[${red} FAIL ${default}] $*"
fi
fn_sleep_time
echo -en "\n"
Expand All @@ -179,18 +179,18 @@ fn_print_fail_nl(){
# [ ERROR ]
fn_print_error(){
if [ -n "${commandaction}" ]; then
echo -en "${creeol}[${red}ERROR ${default}] ${commandaction} ${selfname}: $@"
echo -en "${creeol}[${red}ERROR ${default}] ${commandaction} ${servicename}: $*"
else
echo -en "${creeol}[${red}ERROR ${default}] $@"
echo -en "${creeol}[${red}ERROR ${default}] $*"
fi
fn_sleep_time
}

fn_print_error_nl(){
if [ -n "${commandaction}" ]; then
echo -en "${creeol}[${red}ERROR ${default}] ${commandaction} ${selfname}: $@"
echo -en "${creeol}[${red}ERROR ${default}] ${commandaction} ${servicename}: $*"
else
echo -en "${creeol}[${red}ERROR ${default}] $@"
echo -en "${creeol}[${red}ERROR ${default}] $*"
fi
fn_sleep_time
echo -en "\n"
Expand All @@ -199,18 +199,18 @@ fn_print_error_nl(){
# [ WARN ]
fn_print_warn(){
if [ -n "${commandaction}" ]; then
echo -en "${creeol}[${lightyellow} WARN ${default}] ${commandaction} ${selfname}: $@"
echo -en "${creeol}[${lightyellow} WARN ${default}] ${commandaction} ${servicename}: $*"
else
echo -en "${creeol}[${lightyellow} WARN ${default}] $@"
echo -en "${creeol}[${lightyellow} WARN ${default}] $*"
fi
fn_sleep_time
}

fn_print_warn_nl(){
if [ -n "${commandaction}" ]; then
echo -en "${creeol}[${lightyellow} WARN ${default}] ${commandaction} ${selfname}: $@"
echo -en "${creeol}[${lightyellow} WARN ${default}] ${commandaction} ${servicename}: $*"
else
echo -en "${creeol}[${lightyellow} WARN ${default}] $@"
echo -en "${creeol}[${lightyellow} WARN ${default}] $*"
fi
fn_sleep_time
echo -en "\n"
Expand All @@ -219,18 +219,18 @@ fn_print_warn_nl(){
# [ INFO ]
fn_print_info(){
if [ -n "${commandaction}" ]; then
echo -en "${creeol}[${cyan} INFO ${default}] ${commandaction} ${selfname}: $@"
echo -en "${creeol}[${cyan} INFO ${default}] ${commandaction} ${servicename}: $*"
else
echo -en "${creeol}[${cyan} INFO ${default}] $@"
echo -en "${creeol}[${cyan} INFO ${default}] $*"
fi
fn_sleep_time
}

fn_print_info_nl(){
if [ -n "${commandaction}" ]; then
echo -en "${creeol}[${cyan} INFO ${default}] ${commandaction} ${selfname}: $@"
echo -en "${creeol}[${cyan} INFO ${default}] ${commandaction} ${servicename}: $*"
else
echo -en "${creeol}[${cyan} INFO ${default}] $@"
echo -en "${creeol}[${cyan} INFO ${default}] $*"
fi
fn_sleep_time
echo -en "\n"
Expand All @@ -249,56 +249,56 @@ fn_print_header(){

# Complete!
fn_print_complete(){
echo -en "${green}Complete!${default} $@"
echo -en "${green}Complete!${default} $*"
fn_sleep_time
}

fn_print_complete_nl(){
echo -e "${green}Complete!${default} $@"
echo -e "${green}Complete!${default} $*"
fn_sleep_time
}

# Failure!
fn_print_failure(){
echo -en "${red}Failure!${default} $@"
echo -en "${red}Failure!${default} $*"
fn_sleep_time
}

fn_print_failure_nl(){
echo -e "${red}Failure!${default} $@"
echo -e "${red}Failure!${default} $*"
fn_sleep_time
}

# Error!
fn_print_error2(){
echo -en "${red}Error!${default} $@"
echo -en "${red}Error!${default} $*"
fn_sleep_time
}

fn_print_error2_nl(){
echo -e "${red}Error!${default} $@"
echo -e "${red}Error!${default} $*"
fn_sleep_time
}

# Warning!
fn_print_warning(){
echo -en "${lightyellow}Warning!${default} $@"
echo -en "${lightyellow}Warning!${default} $*"
fn_sleep_time
}

fn_print_warning_nl(){
echo -e "${lightyellow}Warning!${default} $@"
echo -e "${lightyellow}Warning!${default} $*"
fn_sleep_time
}

# Information!
fn_print_information(){
echo -en "${cyan}Information!${default} $@"
echo -en "${cyan}Information!${default} $*"
fn_sleep_time
}

fn_print_information_nl(){
echo -e "${cyan}Information!${default} $@"
echo -e "${cyan}Information!${default} $*"
fn_sleep_time
}

Expand Down
2 changes: 1 addition & 1 deletion lgsm/functions/info_distro.sh
Original file line number Diff line number Diff line change
Expand Up @@ -235,7 +235,7 @@ if [ -z "${extip}" ]; then
echo -e "${extip}" > "${tmpdir}/extip.txt"
else
if [ -f "${tmpdir}/extip.txt" ]; then
extip=$(cat ${tmpdir}/extip.txt)
extip=$(cat "${tmpdir}/extip.txt")
else
echo -e "x.x.x.x"
fi
Expand Down
16 changes: 11 additions & 5 deletions linuxgsm.sh
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,7 @@ fn_bootstrap_fetch_file(){
if [ -f "${local_filedir}/${local_filename}" ]; then
# Run file if run is set.
if [ "${run}" == "run" ]; then
# shellcheck source=/dev/null
source "${local_filedir}/${local_filename}"
fi
fi
Expand All @@ -127,7 +128,7 @@ fn_bootstrap_fetch_file_github(){

fn_print_center() {
columns="$(tput cols)"
line="$@"
line="$*"
printf "%*s\n" $(( (${#line} + columns) / 2)) "${line}"
}

Expand Down Expand Up @@ -347,20 +348,25 @@ else
fi
fi
fi
# shellcheck source=/dev/null
source "${configdirserver}/_default.cfg"
# Load the common.cfg config. If missing download it.
if [ ! -f "${configdirserver}/common.cfg" ]; then
fn_fetch_config "lgsm/config-default/config-lgsm" "common-template.cfg" "${configdirserver}" "common.cfg" "${chmodx}" "nochmodx" "norun" "noforcedl" "nomd5"
# shellcheck source=/dev/null
source "${configdirserver}/common.cfg"
else
# shellcheck source=/dev/null
source "${configdirserver}/common.cfg"
fi
# Load the instance.cfg config. If missing download it.
if [ ! -f "${configdirserver}/${selfname}.cfg" ]; then
fn_fetch_config "lgsm/config-default/config-lgsm" "instance-template.cfg" "${configdirserver}" "${selfname}.cfg" "nochmodx" "norun" "noforcedl" "nomd5"
source "${configdirserver}/${selfname}.cfg"
if [ ! -f "${configdirserver}/${servicename}.cfg" ]; then
fn_fetch_config "lgsm/config-default/config-lgsm" "instance-template.cfg" "${configdirserver}" "${servicename}.cfg" "nochmodx" "norun" "noforcedl" "nomd5"
# shellcheck source=/dev/null
source "${configdirserver}/${servicename}.cfg"
else
source "${configdirserver}/${selfname}.cfg"
# shellcheck source=/dev/null
source "${configdirserver}/${servicename}.cfg"
fi

# Load the linuxgsm.sh in to tmpdir. If missing download it.
Expand Down
26 changes: 13 additions & 13 deletions tests/tests_defaultcfg/tests_defaultcfg.sh
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ while IFS= read -r -d $'\0' line; do
diffoutput=$(diff tests/tests_defaultcfg/defaultcfg_0.txt defaultcfgtemp.txt)
if [ "${diffoutput}" ]; then
echo "File with errors:"
echo "${line}"
echo "${line}"
echo -e "================================="
echo "${diffoutput}"
echo ""
Expand All @@ -27,11 +27,11 @@ echo -e "test checks that vars present in ALL _default.cfg files are correct."
echo -e ""
find lgsm/config-default/config-lgsm/ ! -name '*template.cfg' -name "*.cfg" -type f -print0 |
while IFS= read -r -d $'\0' line; do
grep = ${line} | cut -f1 -d"=" > defaultcfgtemp.txt
grep "=" "${line}" | cut -f1 -d"=" > defaultcfgtemp.txt
diffoutput=$(diff tests/tests_defaultcfg/defaultcfg_0.txt defaultcfgtemp.txt | grep '^<')
if [ "${diffoutput}" ]; then
echo "File with errors:"
echo "${line}"
echo "${line}"
echo -e "================================="
echo "${diffoutput}"
echo ""
Expand All @@ -47,14 +47,14 @@ echo -e "test checks that comments in ALL _default.cfg files are correct."
echo -e ""
find lgsm/config-default/config-lgsm/ ! -name '*template.cfg' -name "*.cfg" -type f -print0 |
while IFS= read -r -d $'\0' line; do
grep "#" ${line} > defaultcfgtemp.txt
diffoutput=$(diff tests/tests_defaultcfg/defaultcfg_1.txt defaultcfgtemp.txt | grep '^<')
if [ "${diffoutput}" ]; then
echo "File with errors:"
echo "${line}"
echo -e "================================="
echo "${diffoutput}"
echo ""
fi
rm defaultcfgtemp.txt
grep "#" "${line}" > defaultcfgtemp.txt
diffoutput=$(diff tests/tests_defaultcfg/defaultcfg_1.txt defaultcfgtemp.txt | grep '^<')
if [ "${diffoutput}" ]; then
echo "File with errors:"
echo "${line}"
echo -e "================================="
echo "${diffoutput}"
echo ""
fi
rm defaultcfgtemp.txt
done
Loading