From c669c5433668f5268d250b010d49ae2e20be5f6c Mon Sep 17 00:00:00 2001 From: qtwrk Date: Sat, 18 Jan 2020 00:11:07 +0100 Subject: [PATCH] utility 2 --- cyberpanel.sh | 10 +++++++--- cyberpanel_upgrade.sh | 26 ++++++++++++++++++++++++++ cyberpanel_utility.sh | 12 +++--------- 3 files changed, 36 insertions(+), 12 deletions(-) diff --git a/cyberpanel.sh b/cyberpanel.sh index ae557d56d..38550d5d4 100644 --- a/cyberpanel.sh +++ b/cyberpanel.sh @@ -44,15 +44,19 @@ wget -q -O /usr/bin/cyberpanel_utility https://cyberpanel.sh/misc/cyberpanel_uti chmod 700 /usr/bin/cyberpanel_utility fi -if ! cat /root/.bashrc | grep -q cyberpanel_utility ; then +if ! cat /etc/bash.bashrc | grep -q cyberpanel_utility ; then echo -e "\n\ncyberpanel() { if [[ $1 == "utility" ]] ; then /usr/bin/cyberpanel_utility ${@:2:99} +elif [[ $1 == "help" ]] ; then +/usr/bin/cyberpanel_utility --help +elif [[ $1 == "upgrade" ]] || [[ $1 == "update" ]] ; then +/usr/bin/cyberpanel_utility --upgrade else /usr/bin/cyberpanel "$@" fi -}" >> /root/.bashrc -source /root/.bashrc +}" >> /etc/bash.bashrc +source /etc/bash.bashrc fi } diff --git a/cyberpanel_upgrade.sh b/cyberpanel_upgrade.sh index 976d63b25..a9c0eb124 100644 --- a/cyberpanel_upgrade.sh +++ b/cyberpanel_upgrade.sh @@ -6,6 +6,28 @@ SUDO_TEST=$(set) SERVER_OS='Undefined' OUTPUT=$(cat /etc/*release) +install_utility() { +if [[ ! -f /usr/bin/cyberpanel_utility ]] ; then +wget -q -O /usr/bin/cyberpanel_utility https://cyberpanel.sh/misc/cyberpanel_utility.sh +chmod 700 /usr/bin/cyberpanel_utility +fi + +if ! cat /etc/bash.bashrc | grep -q cyberpanel_utility ; then +echo -e "\n\ncyberpanel() { +if [[ $1 == "utility" ]] ; then +/usr/bin/cyberpanel_utility ${@:2:99} +elif [[ $1 == "help" ]] ; then +/usr/bin/cyberpanel_utility --help +elif [[ $1 == "upgrade" ]] || [[ $1 == "update" ]] ; then +/usr/bin/cyberpanel_utility --upgrade +else +/usr/bin/cyberpanel "$@" +fi +}" >> /etc/bash.bashrc +source /etc/bash.bashrc +fi +} + check_root() { echo -e "\nChecking root privileges...\n" if echo $SUDO_TEST | grep SUDO > /dev/null ; then @@ -147,6 +169,10 @@ cp lswsgi /usr/local/CyberCP/bin/ chmod 700 /usr/bin/adminPass +install_utility + + + ## systemctl restart lscpd diff --git a/cyberpanel_utility.sh b/cyberpanel_utility.sh index dcdcb6c6e..91758476f 100644 --- a/cyberpanel_utility.sh +++ b/cyberpanel_utility.sh @@ -20,7 +20,7 @@ if [[ $TMP_YN == "1" ]] ; then if [[ ! -f /etc/cyberpanel/watchdog.sh ]] ; then echo -e "\nWatchDog no found..." wget -O /etc/cyberpanel/watchdog.sh https://cyberpanel.sh/misc/watchdog.sh - chmod +x /etc/cyberpanel/watchdog.sh + chmod 700 /etc/cyberpanel/watchdog.sh ln -s /etc/cyberpanel/watchdog.sh /usr/local/bin/watchdog echo -e "\nWatchDos has been installed..." set_watchdog @@ -105,13 +105,13 @@ cyberpanel_upgrade() { echo -e "CyberPanel upgrading..." rm -f /usr/local/cyberpanel_upgrade.sh wget -O /usr/local/cyberpanel_upgrade.sh -q https://raw.githubusercontent.com/usmannasir/cyberpanel/$BRANCH_NAME/cyberpanel_upgrade.sh -chmod +x /usr/local/cyberpanel_upgrade.sh +chmod 700 /usr/local/cyberpanel_upgrade.sh /usr/local/cyberpanel_upgrade.sh rm -f /usr/local/cyberpanel_upgrade.sh exit } -get_faq() { +show_help() { echo -e "\nFetching information...\n" curl https://cyberpanel.sh/misc/faq.txt exit @@ -184,12 +184,6 @@ sudo_check() { fi } -show_help() { -echo -e "\nCyberPanel Utility Script" -echo -e "\nYou can use argument --upgrade to run CyberPanel upgrade without interaction for automated job." -echo -e "\nExample: cyberpanel utility --upgrade" -exit -} panel_check