123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117 |
- #!/bin/bash
- clear
- TEXT='\033[30;107;2m'
- INFO='\033[97;44m'
- WARNING='\033[97;43m'
- ERROR='\033[97;41m'
- SUCCESS='\033[97;42m'
- GREEN='\033[92m'
- YELLOW='\033[93m'
- RESET='\033[0m'
- if [ "${EUID}" -ne 0 ]; then
- echo -e "${ERROR} ERROR ${RESET}${TEXT} You need to run this script as root! ${RESET}" && exit 1
- fi
- function installPkg {
- clear
- read -p "Continue with the reinstallation? " _yesno
- if [[ "$_yesno" =~ ^[Yy]$ ]]; then
- if [[ ! -f /etc/stunnel/stunnel.conf ]]; then
- wget -q -O - https://raw.githubusercontent.com/cybertize/doctype/default/packages/stunnel.sh | bash
- fi
- apt-get -y -qq --purge remove stunnel &>/dev/null
- apt-get -y -qq autoremove &>/dev/null
- apt-get -qq autoclean &>/dev/null
- clear; sleep 3
- wget -q -O - https://raw.githubusercontent.com/cybertize/doctype/default/packages/stunnel.sh | bash
- else
- echo -e "${ERROR} ERROR ${RESET}${TEXT} Aborted... ${RESET}"; exit 1
- fi
- }
- function uninstallPkg {
- clear
- read -p "Are you sure you want to uninstall stunnel4? [Y/n] " _yesno
- if [[ "$_yesno" =~ ^[Yy]$ ]]; then
- apt-get -y -qq --purge remove stunnel &>/dev/null
- apt-get -y -qq autoremove &>/dev/null
- apt-get -y -qq autoclean &>/dev/null
- echo -e "${SUCCESS} SUCCESS ${RESET}${TEXT} Purge & Removing stunnel package ${RESET}"; exit 0
- else
- echo -e "${ERROR} ERROR ${RESET}${TEXT} Aborted... ${RESET}"; exit 1
- fi
- }
- function detailPkg {
- clear
- local unit_id=$(systemctl show stunnel4.service -p Id | cut -d '=' -f 2)
- local unit_name=$(systemctl show stunnel4.service -p Names | cut -d '=' -f 2)
- local unit_desc=$(systemctl show stunnel4.service -p Description | cut -d '=' -f 2)
- local is_active=$(systemctl is-active stunnel4.service)
- local is_enable=$(systemctl is-enabled stunnel4.service)
- echo
- echo -e "${TEXT} ========================================================== ${RESET}"
- echo -e "${TEXT} Stunnel4 service detail ${RESET}"
- echo -e "${TEXT} ---------------------------------------------------------- ${RESET}"
- echo
- echo -e "${YELLOW} ID:${RESET} ${GREEN}$unit_id${RESET}"
- echo -e "${YELLOW} Name:${RESET} ${GREEN}$unit_name${RESET}"
- echo -e "${YELLOW} Desc:${RESET} ${GREEN}$unit_desc${RESET}"
- echo -e "${YELLOW} Status:${RESET} ${GREEN}$is_active & $is_enable${RESET}"
- # echo -e "${YELLOW}Listening:${RESET} ${GREEN}$squid_ports{RESET}";
- echo
- echo -e "${TEXT} ---------------------------------------------------------- ${RESET}"
- echo -e "${TEXT} Created by Doctype, Powered by Cybertize. ${RESET}"
- echo -e "${TEXT} Copyright 2021, Allright Reserved. ${RESET}"
- echo -e "${TEXT} ========================================================== ${RESET}"
- echo
- }
- function stunnelMenu {
- echo
- echo -e "${TEXT} ========================================================== ${RESET}"
- echo -e "${TEXT} STUNNEL MENU ${RESET}"
- echo -e "${TEXT} ---------------------------------------------------------- ${RESET}"
- echo
- echo -e "[01] ${GREEN}reinstall${RESET} - ${YELLOW}Reinstall stunnel package${RESET}"
- echo -e "[02] ${GREEN}uninstall${RESET} - ${YELLOW}Uninstall stunnel package${RESET}"
- echo -e "[03] ${GREEN}detail ${RESET} - ${YELLOW}Show stunnel detail & status${RESET}"
- echo -e "[00] ${GREEN}quit ${RESET} - ${YELLOW}Exit from menu${RESET}"
- echo
- echo -e "${TEXT} ---------------------------------------------------------- ${RESET}"
- echo -e "${TEXT} Created by Doctype, Powered by Cybertize. ${RESET}"
- echo -e "${TEXT} Copyright 2021, Allright Reserved. ${RESET}"
- echo -e "${TEXT} ========================================================== ${RESET}"
- echo
- while true; do
- read -p "Enter your choice: " _choice
- case "$_choice" in
- 01|reinstall)
- installPkg && break
- ;;
- 02|uninstall)
- uninstallPkg && break
- ;;
- 03|detail)
- detailPkg && break
- ;;
- 00|quit)
- exit 0
- ;;
- *)
- echo -e "${ERROR} ERROR ${RESET}${TEXT} Invalid option! ${RESET}"; stunnelMenu
- ;;
- esac
- done
- }
- if [[ -f /etc/stunnel/stunnel.conf ]]; then
- stunnelMenu
- elif [[ ! -f /etc/stunnel/stunnel.conf ]]; then
- installPkg
- fi
|