95 Star 186 Fork 67

kongkong / monitor-http-server

Create your Gitee Account
Explore and code with more than 6 million developers,Free private repositories !:)
Sign up
Clone or download
toolboxrc 2.30 KB
Copy Edit Web IDE Raw Blame History
2011-181 authored 2015-03-27 16:17 . add other file
#!/usr/bin/env bash
# ps -p $$ which shell the script
###########################################################################
# UTILITAIRES CHAINES #
###########################################################################
# change case from lower case to upper case
l2u() {
echo "$@" |tr '[:lower:]' '[:upper:]';
}
# change case from lower case to upper case
u2l() {
echo "$@" |tr '[:upper:]' '[:lower:]' ;
}
###########################################################################
# DATE #
###########################################################################
today() {
echo "$(u2l "$(date '+%Y-%b-%d')")"
}
now() {
echo "$(u2l "$(date '+%Y-%b-%d-%H:%M')")"
}
checkDirectory()
{
p=1;
for arg in "$@";
do
if [[ -z "$arg" || ! -d "$arg" ]] # missing argument or folder
then
printf "[!] Argument #%s or directory missing: %s\n" "$p" "$arg"
printf "[!] Aborting...\n"
return 0
fi
((p++))
done
}
checkFile()
{
p=1;
for arg in "$@";
do
if [[ -z "$arg" || ! -e "$arg" ]] # missing argument or folder
then
printf "[!] Argument #%s or directory missing: %s\n" "$p" "$arg"
printf "[!] Aborting...\n"
return 0
fi
((p++))
done
return 1
}
checkArgument()
{
for arg in "$@";
do
if [[ -z "$arg" ]] # empty argument
then
printf "[!] Argument #%s missing: %s\n" "$p" "$arg"
printf "[!] Aborting...\n"
return 0
else
return 1
fi
done
}
# @description: check if given directories exists, display missing one and quit if at least one directory is missing
# @param: array of string representing path to directories
quitIfMissing() {
let status=0 # 0 = no problem, >0 = missing directory
for directory in "$@";
do
if [[ ! -z "$directory" ]] && [[ ! -d "$directory" ]] # vrai si: chemin non-vide et dossier inexistant
then
printf "[!] Dossier inexistant: %s\n" "$directory"
((status+=1)) # increment status
fi
done
if (($status > 0 ));
then
printf "%s\n[i] Directories are missing, you need them to run this script.\n\n" "--"
return $status;
fi
}
# eof

Comment ( 0 )

Sign in for post a comment

Java
1
https://gitee.com/yeetrack/monitor-http-server.git
git@gitee.com:yeetrack/monitor-http-server.git
yeetrack
monitor-http-server
monitor-http-server
master

Search

103611 48b8ff67 1899542 103622 4d02230c 1899542