mirror of
https://github.com/usmannasir/cyberpanel.git
synced 2026-05-11 16:45:41 +02:00
Update cyberpanel.sh
Add desktop Os detection and bail
This commit is contained in:
@@ -73,6 +73,15 @@ Panel_Version=${Temp_Value:12:3}
|
||||
Panel_Build=${Temp_Value:25:1}
|
||||
|
||||
Branch_Name="v${Panel_Version}.${Panel_Build}"
|
||||
|
||||
if [[ $Branch_Name = v*.*.* ]] ; then
|
||||
echo -e "\nBranch name fetched...$Branch_Name"
|
||||
else
|
||||
echo -e "\nUnable to fetch Branch name..."
|
||||
echo -e "\nPlease try again in few moments, if this error still happens, please contact support"
|
||||
exit
|
||||
fi
|
||||
|
||||
Base_Number="1.9.3"
|
||||
|
||||
Total_RAM=$(free -m | awk '/Mem:/ { print $2 }')
|
||||
@@ -165,12 +174,7 @@ Retry_Command() {
|
||||
# shellcheck disable=SC2034
|
||||
for i in {1..50};
|
||||
do
|
||||
if [[ "$i" = "50" ]] ; then
|
||||
echo "command $1 failed for 50 times, exit..."
|
||||
exit 2
|
||||
else
|
||||
$1 && break || echo -e "\n$1 has failed for $i times\nWait for 3 seconds and try again...\n"; sleep 3;
|
||||
fi
|
||||
$1 && break || echo -e "\n$1 has failed for $i times\nWait for 3 seconds and try again...\n"; sleep 3;
|
||||
done
|
||||
}
|
||||
|
||||
@@ -234,6 +238,16 @@ if [[ ! -f /etc/os-release ]] ; then
|
||||
exit
|
||||
fi
|
||||
|
||||
# Reference: https://unix.stackexchange.com/questions/116539/how-to-detect-the-desktop-environment-in-a-bash-script
|
||||
if [ -z "$XDG_CURRENT_DESKTOP" ]; then
|
||||
echo "Desktop OS not detected. Proceeding"
|
||||
else
|
||||
echo "$XDG_CURRENT_DESKTOP defined appears to be a desktop OS. Bailing as CyberPanel is incompatible."
|
||||
echo -e "\nCyberPanel is supported on server OS types only. Such as Ubuntu 18.04 x86_64, Ubuntu 20.04 x86_64, Ubuntu 20.10 x86_64, CentOS 7.x, CentOS 8.x, AlmaLinux 8.x and CloudLinux 7.x...\n"
|
||||
exit
|
||||
fi
|
||||
|
||||
|
||||
if ! uname -m | grep -q 64 ; then
|
||||
echo -e "x64 system is required...\n"
|
||||
exit
|
||||
@@ -460,7 +474,7 @@ else
|
||||
Admin_Pass="1234567"
|
||||
else
|
||||
if [[ ${#1} -lt 8 ]]; then
|
||||
echo -e "\nPassword lenth less than 8 digital, please choose a more complicated password.\n"
|
||||
echo -e "\nPassword length less than 8 digital, please choose a more complicated password.\n"
|
||||
exit
|
||||
fi
|
||||
Admin_Pass="${1}"
|
||||
@@ -718,7 +732,7 @@ elif [[ $Tmp_Input =~ ^(s|S) ]]; then
|
||||
exit
|
||||
fi
|
||||
if [[ ${#Tmp_Input} -lt 8 ]]; then
|
||||
echo -e "\nPassword lenth less than 8 digital, please choose a more complicated password.\n"
|
||||
echo -e "\nPassword length less than 8 digital, please choose a more complicated password.\n"
|
||||
exit
|
||||
fi
|
||||
Tmp_Input1=$Tmp_Input
|
||||
@@ -990,7 +1004,7 @@ else
|
||||
update-locale LC_ALL="en_US.UTF-8"
|
||||
fi
|
||||
|
||||
Debug_Log2 "Installing required virtual enviroment,3"
|
||||
Debug_Log2 "Installing required virtual environment,3"
|
||||
|
||||
export LC_CTYPE=en_US.UTF-8
|
||||
export LC_ALL=en_US.UTF-8
|
||||
@@ -1037,7 +1051,7 @@ Debug_Log2 "Necessary components installed..,5"
|
||||
}
|
||||
|
||||
Pre_Install_System_Tweak() {
|
||||
Debug_Log2 "Setting up sytem tweak...,20"
|
||||
Debug_Log2 "Setting up system tweak...,20"
|
||||
Line_Number=$(grep -n "127.0.0.1" /etc/hosts | cut -d: -f 1)
|
||||
My_Hostname=$(hostname)
|
||||
|
||||
@@ -1089,12 +1103,6 @@ if ! grep -q "pid_max" /etc/rc.local 2>/dev/null ; then
|
||||
echo "echo 1000000 > /proc/sys/kernel/pid_max
|
||||
echo 1 > /sys/kernel/mm/ksm/run" >>/etc/rc.local
|
||||
chmod +x /etc/rc.local
|
||||
fi
|
||||
if grep -q "nf_conntrack_max" /etc/sysctl.conf ; then
|
||||
sysctl -w net.netfilter.nf_conntrack_max=2097152 > /dev/null
|
||||
sysctl -w net.nf_conntrack_max=2097152 > /dev/null
|
||||
echo "net.netfilter.nf_conntrack_max=2097152" >> /etc/sysctl.conf
|
||||
echo "net.nf_conntrack_max=2097152" >> /etc/sysctl.conf
|
||||
fi
|
||||
echo "fs.file-max = 65535" >>/etc/sysctl.conf
|
||||
sysctl -p >/dev/null
|
||||
@@ -1203,8 +1211,8 @@ else
|
||||
fi
|
||||
|
||||
if ./lshttpd -V |& grep "ERROR" || ./lshttpd -V |& grep "expire in 0 days" ; then
|
||||
echo -e "\n\nIt apeears to have some issue with license , please check above result..."
|
||||
Debug_Log2 "It appears to have some issue with LiteSpeed License, make sure you are using correct serial key. [404]"
|
||||
echo -e "\n\nThere appears to be an issue with license , please check above result..."
|
||||
Debug_Log2 "There appears to be an issue with LiteSpeed License, make sure you are using correct serial key. [404]"
|
||||
exit
|
||||
fi
|
||||
|
||||
@@ -1820,6 +1828,7 @@ fi
|
||||
# If valid hostname is set that resolves externally we can issue an ssl. This will create the hostname as a website so we can issue the SSL and do our first login without SSL warnings or exceptions needed.
|
||||
HostName=$(hostname --fqdn); [ -n "$(dig @1.1.1.1 +short "$HostName")" ] && echo "$HostName resolves to valid IP. Setting up hostname SSL" && cyberpanel createWebsite --package Default --owner admin --domainName $(hostname --fqdn) --email root@localhost --php 7.4 && cyberpanel hostNameSSL --domainName $(hostname --fqdn)
|
||||
|
||||
|
||||
}
|
||||
|
||||
Post_Install_CN_Replacement() {
|
||||
|
||||
Reference in New Issue
Block a user