Don't list apps when there's not enough ram to install them
This commit is contained in:
parent
fcb209d3a9
commit
fa49e53734
|
@ -30,6 +30,7 @@ VARIANTS="full full-vim writer"
|
||||||
|
|
||||||
IN_DEFAULT_INSTALL=0
|
IN_DEFAULT_INSTALL=0
|
||||||
SHOW_ON_ABOUT=1
|
SHOW_ON_ABOUT=1
|
||||||
|
MINIMUM_RAM_MB=2000
|
||||||
|
|
||||||
ETHERPAD_DOMAIN_NAME=
|
ETHERPAD_DOMAIN_NAME=
|
||||||
ETHERPAD_CODE=
|
ETHERPAD_CODE=
|
||||||
|
|
|
@ -286,6 +286,25 @@ function app_not_on_onion_only {
|
||||||
echo "1"
|
echo "1"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function enough_ram_for_app {
|
||||||
|
app_name="$1"
|
||||||
|
|
||||||
|
if ! grep -q "MINIMUM_RAM_MB=" "/usr/share/${PROJECT_NAME}/apps/${PROJECT_NAME}-app-${app_name}"; then
|
||||||
|
echo "0"
|
||||||
|
return
|
||||||
|
fi
|
||||||
|
|
||||||
|
minimum_ram_MB=$(grep "MINIMUM_RAM_MB=" "/usr/share/${PROJECT_NAME}/apps/${PROJECT_NAME}-app-${app_name}" | head -n 1 | awk -F '=' '{print $2}')
|
||||||
|
minimum_ram_bytes=$((minimum_ram_MB * 1024))
|
||||||
|
|
||||||
|
ram_available=$(grep MemTotal /proc/meminfo | awk '{print $2}')
|
||||||
|
if [ "$ram_available" -lt "$minimum_ram_bytes" ]; then
|
||||||
|
echo "1"
|
||||||
|
return
|
||||||
|
fi
|
||||||
|
echo "0"
|
||||||
|
}
|
||||||
|
|
||||||
# detects what apps are available
|
# detects what apps are available
|
||||||
function detect_apps {
|
function detect_apps {
|
||||||
FILES="/usr/share/${PROJECT_NAME}/apps/${PROJECT_NAME}-app-*"
|
FILES="/usr/share/${PROJECT_NAME}/apps/${PROJECT_NAME}-app-*"
|
||||||
|
@ -299,6 +318,7 @@ function detect_apps {
|
||||||
for filename in $FILES
|
for filename in $FILES
|
||||||
do
|
do
|
||||||
app_name=$(echo "${filename}" | awk -F '-app-' '{print $2}')
|
app_name=$(echo "${filename}" | awk -F '-app-' '{print $2}')
|
||||||
|
if [[ $(enough_ram_for_app "$app_name") != "0" ]]; then
|
||||||
if [[ $(app_not_on_onion_only "$app_name") != "0" ]]; then
|
if [[ $(app_not_on_onion_only "$app_name") != "0" ]]; then
|
||||||
# shellcheck disable=SC2068
|
# shellcheck disable=SC2068
|
||||||
if ! item_in_array "${app_name}" ${APPS_AVAILABLE[@]}; then
|
if ! item_in_array "${app_name}" ${APPS_AVAILABLE[@]}; then
|
||||||
|
@ -306,6 +326,7 @@ function detect_apps {
|
||||||
APPS_CHOSEN+=("0")
|
APPS_CHOSEN+=("0")
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
|
fi
|
||||||
done
|
done
|
||||||
|
|
||||||
function_check get_apps_installed
|
function_check get_apps_installed
|
||||||
|
@ -333,6 +354,7 @@ function detect_installable_apps {
|
||||||
do
|
do
|
||||||
app_name=$(echo "${filename}" | awk -F '-app-' '{print $2}')
|
app_name=$(echo "${filename}" | awk -F '-app-' '{print $2}')
|
||||||
|
|
||||||
|
if [[ $(enough_ram_for_app "$app_name") != "0" ]]; then
|
||||||
if [[ $(app_not_on_onion_only "$app_name") != "0" ]]; then
|
if [[ $(app_not_on_onion_only "$app_name") != "0" ]]; then
|
||||||
# shellcheck disable=SC2068
|
# shellcheck disable=SC2068
|
||||||
if ! item_in_array "${app_name}" ${APPS_AVAILABLE[@]}; then
|
if ! item_in_array "${app_name}" ${APPS_AVAILABLE[@]}; then
|
||||||
|
@ -348,6 +370,7 @@ function detect_installable_apps {
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
|
fi
|
||||||
done
|
done
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -367,6 +390,7 @@ function detect_installed_apps {
|
||||||
do
|
do
|
||||||
app_name=$(echo "${filename}" | awk -F '-app-' '{print $2}')
|
app_name=$(echo "${filename}" | awk -F '-app-' '{print $2}')
|
||||||
|
|
||||||
|
if [[ $(enough_ram_for_app "$app_name") != "0" ]]; then
|
||||||
if [[ $(app_not_on_onion_only "$app_name") != "0" ]]; then
|
if [[ $(app_not_on_onion_only "$app_name") != "0" ]]; then
|
||||||
if [[ $(app_is_installed "$app_name") == "1" ]]; then
|
if [[ $(app_is_installed "$app_name") == "1" ]]; then
|
||||||
# shellcheck disable=SC2068
|
# shellcheck disable=SC2068
|
||||||
|
@ -379,6 +403,7 @@ function detect_installed_apps {
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
|
fi
|
||||||
done
|
done
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -404,6 +429,7 @@ function choose_apps_for_variant {
|
||||||
for filename in $FILES
|
for filename in $FILES
|
||||||
do
|
do
|
||||||
app_name=$(echo "${filename}" | awk -F '-app-' '{print $2}')
|
app_name=$(echo "${filename}" | awk -F '-app-' '{print $2}')
|
||||||
|
if [[ $(enough_ram_for_app "$app_name") != "0" ]]; then
|
||||||
if [[ $(app_not_on_onion_only "$app_name") != "0" ]]; then
|
if [[ $(app_not_on_onion_only "$app_name") != "0" ]]; then
|
||||||
# shellcheck disable=SC2068
|
# shellcheck disable=SC2068
|
||||||
if item_in_array "${app_name}" ${APPS_AVAILABLE[@]}; then
|
if item_in_array "${app_name}" ${APPS_AVAILABLE[@]}; then
|
||||||
|
@ -428,6 +454,7 @@ function choose_apps_for_variant {
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
|
fi
|
||||||
done
|
done
|
||||||
|
|
||||||
function_check get_apps_installed
|
function_check get_apps_installed
|
||||||
|
|
Loading…
Reference in New Issue