New Utils - installers

This commit is contained in:
2022-09-05 11:34:04 +03:00
parent 19c5cd5e09
commit eaf6125445
7 changed files with 499 additions and 3624 deletions
+77 -1837
View File
File diff suppressed because one or more lines are too long
+66 -1787
View File
File diff suppressed because one or more lines are too long
+117
View File
@@ -0,0 +1,117 @@
#!/bin/bash
name=""
value=""
type="export"
rename=""
delete_type="none"
. <(wget -qO- https://raw.githubusercontent.com/letsnode/Utils/main/bashbuilder/colors.sh) --
function option_value() {
echo "$1" | sed -e 's%^--[^=]*=%%g; s%^-[^=]*=%%g';
}
function printf_n() {
printf "$1\n" "${@:2}";
}
while test $# -gt 0; do
case "$1" in
-h|--help)
. <(wget -qO- https://raw.githubusercontent.com/letsnode/Utils/main/bashbuilder/logo.sh)
echo
echo -e "${C_LGn}Functionality${RES}: the script inserts variable or alias to ${C_LGn}$HOME/.bash_profile${RES}"
echo
echo -e "${C_LGn}Usage${RES}: script ${C_LGn}[OPTIONS]${RES}"
echo
echo -e "${C_LGn}Options${RES}:"
echo -e " -h, --help show the help page"
echo -e " -n, --name NAME variable or alias NAME (mandatory)"
echo -e " -v, --value VALUE variable or alias VALUE (leave blank for manual input)"
echo -e " -a, --alias inserting an alias"
echo -e " -r, --rename NAME_2 rename NAME_2 to NAME"
echo -e " -d, --delete delete the first occurrence of a variable or alias by NAME"
echo -e " -da, --delete-all delete all occurrences of a variable or alias by NAME"
echo
echo -e "You can use either \"=\" or \" \" as an option and value ${C_LGn}delimiter${RES}"
echo
echo -e "${C_LGn}Useful URLs${RES}:"
echo -e "Script URL: https://github.com/letsnode/Utils/new/main/bashbuilder/addvar.sh"
echo -e "Telegram comunity: https://t.me/letskynode"
echo
return 0 2>/dev/null; exit 0
;;
-n*|--name*)
if ! grep -q "=" <<< "$1"; then shift; fi
name=`option_value "$1"`
shift
;;
-v*|--value*)
if ! grep -q "=" <<< "$1"; then shift; fi
value=`option_value "$1"`
shift
;;
-a|--alias)
type="alias"
shift
;;
-r*|--rename*)
if ! grep -q "=" <<< "$1"; then shift; fi
rename=`option_value "$1"`
shift
;;
-d|--delete)
delete_type="delete"
shift
;;
-da|--delete-all)
delete_type="delete_all"
shift
;;
*|--)
break
;;
esac
done
touch $HOME/.bash_profile
. $HOME/.bash_profile
if [ ! -n "$name" ]; then
printf_n "${C_R}You didn't specify a name via${RES} -n ${C_R}option!${RES}"
return 1 2>/dev/null; exit 1
fi
if [ "$delete_type" != "none" ]; then
if [ "$delete_type" = "delete" ]; then
sed -i "0,/ ${name}=/{/ ${name}=/d;}" $HOME/.bash_profile
elif [ "$delete_type" = "delete_all" ]; then
sed -i "/ ${name}=/d" $HOME/.bash_profile
fi
unset "$name"
unalias "$name" 2>/dev/null
else
if [ -n "$rename" ]; then
sed -i "s%${rename}%${name}%" $HOME/.bash_profile
unset "$rename"
unalias "$rename" 2>/dev/null
if [ ! -n "$value" ]; then
return 0 2>/dev/null; exit 0
fi
fi
if [ ! -n "$value" ]; then
printf "${C_LGn}Enter the value:${RES} "
read -r value
fi
if ! cat $HOME/.bash_profile | grep -q " ${name}="; then
echo "${type} ${name}=\"${value}\"" >> $HOME/.bash_profile
elif ! cat $HOME/.bash_profile | grep -qF "${name}=\"${value}\""; then
sed -i "s%^.*${name}*=.*%${type} ${name}=\"${value}\"%" $HOME/.bash_profile
fi
variable=`cat $HOME/.bash_profile | grep -qF "${name}=\"${value}\""`
if ! grep -q "${type}" <<< "$variable"; then
sed -i "s%^.*${name}*=.*%${type} ${name}=\"${value}\"%" $HOME/.bash_profile
fi
fi
sed -i '/^$/d' $HOME/.bash_profile
. $HOME/.bash_profile
+138
View File
@@ -0,0 +1,138 @@
#!/bin/bash
# Reset
RES='\033[0m' # Reset format
# Base Characters
C_Bk='\033[0;30m' # Black
C_R='\033[0;31m' # Red
C_Gn='\033[0;32m' # Green
C_Y='\033[0;33m' # Yellow
C_Be='\033[0;34m' # Blue
C_P='\033[0;35m' # Purple
C_C='\033[0;36m' # Cyan
C_Gy='\033[1;37m' # Gray
# Light Characters
C_LR='\033[1;31m' # Light Red
C_LGn='\033[1;32m' # Light Green
C_LY='\033[1;33m' # Light Yellow
C_LBe='\033[1;34m' # Light Blue
C_LP='\033[1;35m' # Light Purple
C_LC='\033[1;36m' # Light Cyan
C_LGy='\033[0;37m' # Light Gray
# Dark Characters
C_DBk='\033[2;30m' # Dark Black
C_DR='\033[2;31m' # Dark Red
C_DGn='\033[2;32m' # Dark Green
C_DY='\033[2;33m' # Dark Yellow
C_DBe='\033[2;34m' # Dark Blue
C_DP='\033[2;35m' # Dark Purple
C_DC='\033[2;36m' # Dark Cyan
C_DGy='\033[2;37m' # Dark Gray
# Underline Characters
U_Bk='\033[4;30m' # Black
U_R='\033[4;31m' # Red
U_Gn='\033[4;32m' # Green
U_Y='\033[4;33m' # Yellow
U_Be='\033[4;34m' # Blue
U_P='\033[4;35m' # Purple
U_C='\033[4;36m' # Cyan
U_Gy='\033[4;37m' # Gray
# Blinking Characters
Bl_Bk='\033[5;30m' # Black
Bl_R='\033[5;31m' # Red
Bl_Gn='\033[5;32m' # Green
Bl_Y='\033[5;33m' # Yellow
Bl_Be='\033[5;34m' # Blue
Bl_P='\033[5;35m' # Purple
Bl_C='\033[5;36m' # Cyan
Bl_Gy='\033[5;37m' # Gray
# Background
Ba_Bk='\033[40m' # Black
Ba_R='\033[41m' # Red
Ba_Gn='\033[42m' # Green
Ba_Y='\033[43m' # Yellow
Ba_Be='\033[44m' # Blue
Ba_P='\033[45m' # Purple
Ba_C='\033[46m' # Cyan
Ba_Gy='\033[47m' # Gray
function option_value(){
echo "$1" | sed -e 's%^--[^=]*=%%g; s%^-[^=]*=%%g';
}
while test $# -gt 0; do
case "$1" in
-h|--help)
. <(wget -qO- https://raw.githubusercontent.com/letsnode/Utils/main/bashbuilder/logo.sh)
echo
echo -e "${C_LGn}Functionality${RES}: the script assigns variables with colors to be used in the texts (e.g."
echo -e "in the 'echo' and 'printf' commands)"
echo
echo -e "Usage: script ${C_LGn}[OPTIONS]${RES}"
echo
echo -e "${C_LGn}Options${RES}:"
echo -e " -h, --help show the help page"
echo
echo -e "${C_LGn}Colors${RES}:"
echo -e "Reset - \${RES}"
echo -e "┌─────────────────────────────┐ ┌─────────────────────────────┐"
echo -e "│ Base Characters │ │ Underline Characters │"
echo -e "├────────┬─────────┬──────────┤ ├────────┬─────────┬──────────┤"
echo -e "│ Color │ Example │ Variable │ │ Color │ Example │ Variable │"
echo -e "├────────┼─────────┼──────────┤ ├────────┼─────────┼──────────┤"
echo -e "│ Black │ ${C_Bk}Example${RES} │ \${C_Bk} │ │ Black │ ${U_Bk}Example${RES} │ \${U_Bk} │"
echo -e "│ Red │ ${C_R}Example${RES} │ \${C_R} │ │ Red │ ${U_R}Example${RES} │ \${U_R} │"
echo -e "│ Green │ ${C_Gn}Example${RES} │ \${C_Gn} │ │ Green │ ${U_Gn}Example${RES} │ \${U_Gn} │"
echo -e "│ Yellow │ ${C_Y}Example${RES} │ \${C_Y} │ │ Yellow │ ${U_Y}Example${RES} │ \${U_Y} │"
echo -e "│ Blue │ ${C_Be}Example${RES} │ \${C_Be} │ │ Blue │ ${U_Be}Example${RES} │ \${U_Be} │"
echo -e "│ Purple │ ${C_P}Example${RES} │ \${C_P} │ │ Purple │ ${U_P}Example${RES} │ \${U_P} │"
echo -e "│ Cyan │ ${C_C}Example${RES} │ \${C_C} │ │ Cyan │ ${U_C}Example${RES} │ \${U_C} │"
echo -e "│ Gray │ ${C_Gy}Example${RES} │ \${C_Gy} │ │ Gray │ ${U_Gy}Example${RES} │ \${U_Gy} │"
echo -e "└────────┴─────────┴──────────┘ └────────┴─────────┴──────────┘"
echo
echo -e "┌─────────────────────────────┐ ┌─────────────────────────────┐"
echo -e "│ Light Characters │ │ Blinking Characters │"
echo -e "├────────┬─────────┬──────────┤ ├────────┬─────────┬──────────┤"
echo -e "│ Color │ Example │ Variable │ │ Color │ Example │ Variable │"
echo -e "├────────┼─────────┼──────────┤ ├────────┼─────────┼──────────┤"
echo -e "│ │ │ │ │ Black │ ${Bl_Bk}Example${RES} │ \${Bl_Bk} │"
echo -e "│ Red │ ${C_LR}Example${RES} │ \${C_LR} │ │ Red │ ${Bl_R}Example${RES} │ \${Bl_R} │"
echo -e "│ Green │ ${C_LGn}Example${RES} │ \${C_LGn} │ │ Green │ ${Bl_Gn}Example${RES} │ \${Bl_Gn} │"
echo -e "│ Yellow │ ${C_LY}Example${RES} │ \${C_LY} │ │ Yellow │ ${Bl_Y}Example${RES} │ \${Bl_Y} │"
echo -e "│ Blue │ ${C_LBe}Example${RES} │ \${C_LBe} │ │ Blue │ ${Bl_Be}Example${RES} │ \${Bl_Be} │"
echo -e "│ Purple │ ${C_LP}Example${RES} │ \${C_LP} │ │ Purple │ ${Bl_P}Example${RES} │ \${Bl_P} │"
echo -e "│ Cyan │ ${C_LC}Example${RES} │ \${C_LC} │ │ Cyan │ ${Bl_C}Example${RES} │ \${Bl_C} │"
echo -e "│ Gray │ ${C_LGy}Example${RES} │ \${C_LGy} │ │ Gray │ ${Bl_Gy}Example${RES} │ \${Bl_Gy} │"
echo -e "└────────┴─────────┴──────────┘ └────────┴─────────┴──────────┘"
echo
echo -e "┌─────────────────────────────┐ ┌─────────────────────────────┐"
echo -e "│ Dark Characters │ │ Background │"
echo -e "├────────┬─────────┬──────────┤ ├────────┬─────────┬──────────┤"
echo -e "│ Color │ Example │ Variable │ │ Color │ Example │ Variable │"
echo -e "├────────┼─────────┼──────────┤ ├────────┼─────────┼──────────┤"
echo -e "│ Black │ ${C_DBk}Example${RES} │ \${C_DBk} │ │ Black │ ${Ba_Bk}Example${RES} │ \${Ba_Bk} │"
echo -e "│ Red │ ${C_DR}Example${RES} │ \${C_DR} │ │ Red │ ${Ba_R}Example${RES} │ \${Ba_R} │"
echo -e "│ Green │ ${C_DGn}Example${RES} │ \${C_DGn} │ │ Green │ ${Ba_Gn}Example${RES} │ \${Ba_Gn} │"
echo -e "│ Yellow │ ${C_DY}Example${RES} │ \${C_DY} │ │ Yellow │ ${Ba_Y}Example${RES} │ \${Ba_Y} │"
echo -e "│ Blue │ ${C_DBe}Example${RES} │ \${C_DBe} │ │ Blue │ ${Ba_Be}Example${RES} │ \${Ba_Be} │"
echo -e "│ Purple │ ${C_DP}Example${RES} │ \${C_DP} │ │ Purple │ ${Ba_P}Example${RES} │ \${Ba_P} │"
echo -e "│ Cyan │ ${C_DC}Example${RES} │ \${C_DC} │ │ Cyan │ ${Ba_C}Example${RES} │ \${Ba_C} │"
echo -e "│ Gray │ ${C_DGy}Example${RES} │ \${C_DGy} │ │ Gray │ ${Ba_Gy}Example${RES} │ \${Ba_Gy} │"
echo -e "└────────┴─────────┴──────────┘ └────────┴─────────┴──────────┘"
echo
echo -e "${C_LGn}Useful URLs${RES}:"
echo -e "Script URL: https://raw.githubusercontent.com/letsnode/Utils/main/bashbuilder/colors.sh"
echo -e "Telegram community: https://t.me/letskynode"
echo
return 0 2>/dev/null; exit 0
;;
*|--)
break
;;
esac
done
+20
View File
@@ -0,0 +1,20 @@
echo -e "\033[1;34m"
echo -e " _____________________________________________________________________________________ "
echo -e "|_____________________________________________________________________________________|"
echo -e "\033[1;36m"
echo -e " _ _ _ _ _ "
echo -e "| | _ | | | \ | | | | "
echo -e "| | | | | | | \ | | | | "
echo -e "| | ______ _| |__ |_| _____ | \ | | _____ ____| | ______ "
echo -e "| | / ____ \ |_ __| / ___/ | |\ \ | | / ___ \ / ___ | / ____ \ "
echo -e "| | | |____| | | | \ \_ | | \ \ | | | | | | | | | | | |____| |"
echo -e "| | | _____/ | | \_ \ | | \ \| | | | | | | | | | | _____/ "
echo -e "| | | / | | \ | | | \ | | | | | | | | | | / "
echo -e "| \_______ | \______ | \___ ___/ / | | \ | | |___| | | |___| | | \______ "
echo -e " \_______/ \______/ \___/ \___/ |_| \_| \_____/ \_____/ \______/ "
echo -e "\033[1;34m"
echo -e " _____________________________________________________________________________________ "
echo -e "|_____________________________________________________________________________________|"
echo
echo -e "\033[1;32mTelegram community: \033[5;31mhttps://t.me/letskynode\033[0m"
echo -e "\033[0m"
+10
View File
@@ -0,0 +1,10 @@
echo '{
"hosts": ["unix:///var/run/docker.sock", "tcp://$INTERNALIP:2376"],
"tls": true,
"tlscacert": "/root/certs/ca.crt",
"tlscert": "/root/certs/server.crt",
"tlskey": "/root/certs/server.key",
"tlsverify": true
}' > /etc/docker/daemon.json
echo '' >
+71
View File
@@ -0,0 +1,71 @@
#!/bin/bash
echo "-------------------------------------"
echo "-------Создаем SSL сертификаты-------"
echo "-------------------------------------"
CERT_LIFETIME=$1
function no_logs {
$1 &> /dev/null
}
function create_key() {
openssl genrsa -out $1.key 4096
}
function create_cert() {
name=$1
openssl req -new -x509 \
-days $CERT_LIFETIME -key $name.key \
-sha256 -out $name.crt \
-subj "/CN=."
}
function sign_cert() {
name=$1
openssl req -sha256 -new \
-key $name.key -out $name.csr \
-subj "/CN=."
openssl x509 -req -days $CERT_LIFETIME \
-sha256 -in $name.csr \
-CA ca.crt -CAkey ca.key \
-CAcreateserial -out $name.crt
}
function create_ca_pair() {
create_key ca
create_cert ca
}
function create_server_pair() {
create_key server
create_cert server
sign_cert server
}
function create_client_pair() {
create_key client
create_cert client
sign_cert client
}
function cleanup() {
rm *.srl *.csr
}
function run() {
no_logs create_ca_pair
no_logs create_server_pair
no_logs create_client_pair
cleanup
}
run
echo "-------------------------------------"
echo "---SSL сертификаты успешно созданы---"
echo "-------------------------------------"