mirror of
https://github.com/stefanpejcic/openpanel
synced 2025-06-26 18:28:26 +00:00
Update INSTALL.sh
This commit is contained in:
parent
b3825778e4
commit
7f131703b6
37
INSTALL.sh
37
INSTALL.sh
@ -47,6 +47,8 @@ INSTALL_MAIL=false
|
|||||||
OVERLAY=false
|
OVERLAY=false
|
||||||
IPSETS=true
|
IPSETS=true
|
||||||
SET_HOSTNAME_NOW=false
|
SET_HOSTNAME_NOW=false
|
||||||
|
SETUP_SWAP_ANYWAY=false
|
||||||
|
SWAP_FILE="1"
|
||||||
SELFHOSTED_SCREENSHOTS=false
|
SELFHOSTED_SCREENSHOTS=false
|
||||||
SEND_EMAIL_AFTER_INSTALL=false
|
SEND_EMAIL_AFTER_INSTALL=false
|
||||||
|
|
||||||
@ -351,6 +353,7 @@ parse_args() {
|
|||||||
echo " --enable-mail Install Mail (experimental)."
|
echo " --enable-mail Install Mail (experimental)."
|
||||||
echo " --post_install=<path> Specify the post install script path."
|
echo " --post_install=<path> Specify the post install script path."
|
||||||
echo " --screenshots=<url> Set the screenshots API URL."
|
echo " --screenshots=<url> Set the screenshots API URL."
|
||||||
|
echo " --swap=<2> Set space in GB to be allocated for SWAP."
|
||||||
echo " --debug Display debug information during installation."
|
echo " --debug Display debug information during installation."
|
||||||
echo " --repair Retry and overwrite everything."
|
echo " --repair Retry and overwrite everything."
|
||||||
echo " -h, --help Show this help message and exit."
|
echo " -h, --help Show this help message and exit."
|
||||||
@ -424,6 +427,11 @@ parse_args() {
|
|||||||
CUSTOM_VERSION=true
|
CUSTOM_VERSION=true
|
||||||
version="${1#*=}"
|
version="${1#*=}"
|
||||||
;;
|
;;
|
||||||
|
--swap=*)
|
||||||
|
# Extract path after "--swap="
|
||||||
|
SETUP_SWAP_ANYWAY=true
|
||||||
|
SWAP="${1#*=}"
|
||||||
|
;;
|
||||||
--email=*)
|
--email=*)
|
||||||
# Extract path after "--email="
|
# Extract path after "--email="
|
||||||
SEND_EMAIL_AFTER_INSTALL=true
|
SEND_EMAIL_AFTER_INSTALL=true
|
||||||
@ -1322,18 +1330,39 @@ rm_helpers(){
|
|||||||
|
|
||||||
|
|
||||||
setup_swap(){
|
setup_swap(){
|
||||||
# if ram less than 8GB, create swap
|
# Function to create swap file
|
||||||
memory=$(grep 'MemTotal' /proc/meminfo |tr ' ' '\n' |grep [0-9])
|
create_swap() {
|
||||||
if [ -z "$(swapon -s)" ] && [ $memory -lt 8140752 ]; then
|
fallocate -l ${SWAP_FILE}G /swapfile
|
||||||
fallocate -l 1G /swapfile
|
|
||||||
chmod 600 /swapfile
|
chmod 600 /swapfile
|
||||||
mkswap /swapfile
|
mkswap /swapfile
|
||||||
swapon /swapfile
|
swapon /swapfile
|
||||||
echo "/swapfile none swap sw 0 0" >> /etc/fstab
|
echo "/swapfile none swap sw 0 0" >> /etc/fstab
|
||||||
|
}
|
||||||
|
|
||||||
|
# Check if swap space already exists
|
||||||
|
if [ -n "$(swapon -s)" ]; then
|
||||||
|
echo "ERROR: Skipping creating swap space as there already exists a swap partition."
|
||||||
|
return
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Check if we should set up swap anyway
|
||||||
|
if [ "$SETUP_SWAP_ANYWAY" = true ]; then
|
||||||
|
create_swap
|
||||||
|
else
|
||||||
|
# Only create swap if RAM is less than 8GB
|
||||||
|
memory_kb=$(grep 'MemTotal' /proc/meminfo | awk '{print $2}')
|
||||||
|
memory_gb=$(awk "BEGIN {print $memory_kb/1024/1024}")
|
||||||
|
|
||||||
|
if [ $(awk "BEGIN {print ($memory_gb < 8)}") -eq 1 ]; then
|
||||||
|
create_swap
|
||||||
|
else
|
||||||
|
echo "Total available memory is ${memory_gb}GB, skipping creating swap file."
|
||||||
|
fi
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
support_message() {
|
support_message() {
|
||||||
echo ""
|
echo ""
|
||||||
echo "🎉 Welcome aboard and thank you for choosing OpenPanel! 🎉"
|
echo "🎉 Welcome aboard and thank you for choosing OpenPanel! 🎉"
|
||||||
|
Loading…
Reference in New Issue
Block a user