Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Automated] Merge 5.x into master #177

Merged
merged 3 commits into from
Jan 31, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions templates/docker-monolithic/backup.sh
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ GTE_v420="$(docker exec supportpal php -r "\$release = require '/var/www/support
if [[ "$GTE_v420" = "0" ]]; then COMMAND_PATH="/var/www/supportpal"; else COMMAND_PATH="/var/www/supportpal/app-manager"; fi

echo "Stopping services..."
docker exec supportpal bash -c "sudo find -L /etc/service -maxdepth 1 -mindepth 1 -type d ! -name 'redis' ! -name 'mysql' -printf '%f\n' -exec sv stop {} \;"
docker exec supportpal bash -c "sudo find -L /etc/service -maxdepth 1 -mindepth 1 -type d ! -name 'redis' ! -name '00redis' ! -name 'mysql' ! -name '00mysql' -printf '%f\n' -exec sv stop {} \;"

echo 'Backing up filesystem...'
docker exec supportpal bash -c "mkdir -p ${TEMP_BACKUP_DIR}/filesystem-${TIMESTAMP}/config/production" # create the farthest directory
Expand All @@ -23,7 +23,7 @@ docker exec supportpal bash -c "cp -r /var/www/supportpal/addons ${TEMP_BACKUP_D
docker exec supportpal bash -c "cd ${TEMP_BACKUP_DIR} && tar -czf ${FILESYSTEM_BACKUP_NAME} filesystem-${TIMESTAMP}"

echo 'Backing up database...'
DB_BACKUP_PATH=$(docker exec supportpal bash -c "cd ${COMMAND_PATH} && php artisan db:backup | grep -oE '/var/www/supportpal/.*/database-.*'")
DB_BACKUP_PATH=$(docker exec supportpal bash -c "cd ${COMMAND_PATH} && php artisan db:backup --store-local | grep -oE '/var/www/supportpal/.*/database-.*'")
DB_FILE_NAME=$(echo "${DB_BACKUP_PATH}" | xargs basename)
docker exec supportpal bash -c "mv ${DB_BACKUP_PATH} ${TEMP_BACKUP_DIR}/"

Expand Down
2 changes: 1 addition & 1 deletion templates/docker-monolithic/restore.sh
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ if [[ "$GTE_v420" = "0" ]]; then COMMAND_PATH="/var/www/supportpal"; else COMMAN
echo "Found ${LAST_BACKUP_FILE}..."

echo "Stopping services..."
docker exec supportpal bash -c "sudo find -L /etc/service -maxdepth 1 -mindepth 1 -type d ! -name 'redis' ! -name 'mysql' -printf '%f\n' -exec sv stop {} \;"
docker exec supportpal bash -c "sudo find -L /etc/service -maxdepth 1 -mindepth 1 -type d ! -name 'redis' ! -name '00redis' ! -name 'mysql' ! -name '00mysql' -printf '%f\n' -exec sv stop {} \;"

echo "Restoring..."

Expand Down
31 changes: 31 additions & 0 deletions templates/docker-monolithic/setup.sh
Original file line number Diff line number Diff line change
Expand Up @@ -224,6 +224,36 @@ configure() {
bash <(curl -LsS https://raw.githubusercontent.com/supportpal/helpdesk-install/"${ref}"/templates/docker-monolithic/create_volumes.sh)
}

check_memory() {
if ! [ -f /proc/meminfo ]; then
return
fi

# Get total memory (RAM + Swap) in kilobytes
total_memory=$(awk '/MemTotal/ {mem=$2} /SwapTotal/ {swap=$2} END {print mem+swap}' /proc/meminfo)

# 4GB (approx)
required_memory=$((4*1000*1000))

if (( total_memory < required_memory )); then
echo "##### ##### ##### ##### ##### ##### ##### ##### ##### ##### #####"
echo " !! WARNING !! "
echo "##### ##### ##### ##### ##### ##### ##### ##### ##### ##### #####"
echo ""
echo "The system has less than 4GB of total memory (RAM + Swap),"
echo "detected ${total_memory}KB. The system may crash if launched with"
echo "insufficient memory."
echo
echo "Greater than ${required_memory}KB is recommended."
echo
echo "Press CTRL+C to exit and add more RAM/Swap. Continuing in 15s..."
echo
echo "##### ##### ##### ##### ##### ##### ##### ##### ##### ##### #####"
echo
sleep 15
fi
}

cat << "EOF"
____ _ ____ _
/ ___| _ _ _ __ _ __ ___ _ __| |_| _ \ __ _| |
Expand All @@ -235,6 +265,7 @@ EOF

echo
identify_os
check_memory
configure_windows
check_docker
check_docker_compose
Expand Down
Loading