diff --git a/src/freedombone-addremove b/src/freedombone-addremove index d42c3796..af5c9a60 100755 --- a/src/freedombone-addremove +++ b/src/freedombone-addremove @@ -203,6 +203,7 @@ function install_apps_selected { fi fi app_index=$((app_index+1)) + done # if no apps to be installed then don't do anything diff --git a/src/freedombone-app-etherpad b/src/freedombone-app-etherpad index 807c8f79..2ae82191 100755 --- a/src/freedombone-app-etherpad +++ b/src/freedombone-app-etherpad @@ -30,6 +30,7 @@ VARIANTS="full full-vim writer" IN_DEFAULT_INSTALL=0 SHOW_ON_ABOUT=1 +MINIMUM_RAM_MB=2000 ETHERPAD_DOMAIN_NAME= ETHERPAD_CODE= diff --git a/src/freedombone-app-gnusocial b/src/freedombone-app-gnusocial index 7859ea5b..640e5343 100755 --- a/src/freedombone-app-gnusocial +++ b/src/freedombone-app-gnusocial @@ -30,6 +30,7 @@ VARIANTS='full full-vim social' IN_DEFAULT_INSTALL=0 SHOW_ON_ABOUT=1 +NOT_ON_ONION=1 GNUSOCIAL_DOMAIN_NAME= GNUSOCIAL_CODE= @@ -581,6 +582,7 @@ function remove_gnusocial { fi kill_pid=$(pgrep "/var/www/$GNUSOCIAL_DOMAIN_NAME/htdocs/scripts/queuedaemon.php" | head -n 1) kill -9 "$kill_pid" + pkill "$GNUSOCIAL_DOMAIN_NAME/htdocs/scripts/queuedaemon.php" if [ -d "/var/www/$GNUSOCIAL_DOMAIN_NAME" ]; then rm -rf "/var/www/$GNUSOCIAL_DOMAIN_NAME" @@ -911,8 +913,8 @@ function install_gnusocial_main { } function install_gnusocial { - if [ ! "$ONION_ONLY" ]; then - ONION_ONLY='no' + if [[ "$ONION_ONLY" != 'no' ]]; then + return fi install_gnusocial_main @@ -935,9 +937,12 @@ function install_gnusocial { sed -i 's|"theme":.*|"theme": "base16-apathy.css",|g' "/var/www/${GNUSOCIAL_DOMAIN_NAME}/htdocs/static/config.json" fi - # unleash the daemons! + # this has to be run as root initially, otherwise database tables + # don't get created cd "/var/www/$GNUSOCIAL_DOMAIN_NAME/htdocs" || exit 236482684 php scripts/checkschema.php + sh scripts/startdaemons.sh + /etc/cron.hourly/gnusocial-daemons systemctl restart nginx diff --git a/src/freedombone-app-hubzilla b/src/freedombone-app-hubzilla index dade690e..27d86461 100755 --- a/src/freedombone-app-hubzilla +++ b/src/freedombone-app-hubzilla @@ -30,6 +30,7 @@ VARIANTS='full full-vim social' IN_DEFAULT_INSTALL=0 SHOW_ON_ABOUT=1 +NOT_ON_ONION=1 HUBZILLA_DOMAIN_NAME= HUBZILLA_CODE= diff --git a/src/freedombone-app-jitsi b/src/freedombone-app-jitsi index 80290874..5250ec5c 100755 --- a/src/freedombone-app-jitsi +++ b/src/freedombone-app-jitsi @@ -32,6 +32,7 @@ VARIANTS="" IN_DEFAULT_INSTALL=0 SHOW_ON_ABOUT=0 +NOT_ON_ONION=1 VIDEOBRIDGE_PORT=5347 JITSI_ONION_PORT=8102 diff --git a/src/freedombone-app-matrix b/src/freedombone-app-matrix index 55e8c641..3992238d 100755 --- a/src/freedombone-app-matrix +++ b/src/freedombone-app-matrix @@ -36,6 +36,8 @@ VARIANTS='full full-vim chat' IN_DEFAULT_INSTALL=0 SHOW_ON_ABOUT=1 +NOT_ON_ONION=1 +MINIMUM_RAM_MB=1500 MATRIX_DOMAIN_NAME= MATRIX_CODE= diff --git a/src/freedombone-app-postactiv b/src/freedombone-app-postactiv index dc98d3ce..1af2c2af 100755 --- a/src/freedombone-app-postactiv +++ b/src/freedombone-app-postactiv @@ -30,6 +30,7 @@ VARIANTS='full full-vim media' IN_DEFAULT_INSTALL=0 SHOW_ON_ABOUT=1 +NOT_ON_ONION=1 POSTACTIV_DOMAIN_NAME= POSTACTIV_CODE= @@ -595,6 +596,7 @@ function remove_postactiv { fi kill_pid=$(pgrep "/var/www/$POSTACTIV_DOMAIN_NAME/htdocs/scripts/queuedaemon.php" | head -n 1) kill -9 "$kill_pid" + pkill "$POSTACTIV_DOMAIN_NAME/htdocs/scripts/queuedaemon.php" if [ -d "/var/www/$POSTACTIV_DOMAIN_NAME" ]; then rm -rf "/var/www/$POSTACTIV_DOMAIN_NAME" @@ -926,8 +928,8 @@ function install_postactiv_main { } function install_postactiv { - if [ ! "$ONION_ONLY" ]; then - ONION_ONLY='no' + if [[ "$ONION_ONLY" != 'no' ]]; then + return fi install_postactiv_main @@ -952,7 +954,12 @@ function install_postactiv { expire_gnusocial_posts "$POSTACTIV_DOMAIN_NAME" "postactiv" "$POSTACTIV_EXPIRE_MONTHS" - # unleash the daemons! + # this has to be run as root initially, otherwise database tables + # don't get created + cd "/var/www/$POSTACTIV_DOMAIN_NAME/htdocs" || exit 3658254254 + sh scripts/startdaemons.sh + php scripts/checkschema.php + /etc/cron.hourly/postactiv-daemons systemctl restart nginx diff --git a/src/freedombone-app-riot b/src/freedombone-app-riot index a1111a4c..4337430d 100755 --- a/src/freedombone-app-riot +++ b/src/freedombone-app-riot @@ -30,6 +30,7 @@ VARIANTS='full full-vim chat' IN_DEFAULT_INSTALL=0 SHOW_ON_ABOUT=1 +NOT_ON_ONION=1 RIOT_VERSION='0.13.3' RIOT_FILENAME="riot-v${RIOT_VERSION}" diff --git a/src/freedombone-utils-selector b/src/freedombone-utils-selector index 63b854e0..25ed118e 100755 --- a/src/freedombone-utils-selector +++ b/src/freedombone-utils-selector @@ -272,6 +272,39 @@ function get_apps_installed_names { done } +function app_not_on_onion_only { + app_name="$1" + + read_config_param ONION_ONLY + + if [[ "$ONION_ONLY" != 'no' ]]; then + if grep -q "NOT_ON_ONION=1" "/usr/share/${PROJECT_NAME}/apps/${PROJECT_NAME}-app-${app_name}"; then + echo "0" + return + fi + fi + 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 function detect_apps { FILES="/usr/share/${PROJECT_NAME}/apps/${PROJECT_NAME}-app-*" @@ -285,11 +318,14 @@ function detect_apps { for filename in $FILES do app_name=$(echo "${filename}" | awk -F '-app-' '{print $2}') - - # shellcheck disable=SC2068 - if ! item_in_array "${app_name}" ${APPS_AVAILABLE[@]}; then - APPS_AVAILABLE+=("${app_name}") - APPS_CHOSEN+=("0") + if [[ $(enough_ram_for_app "$app_name") == "0" ]]; then + if [[ $(app_not_on_onion_only "$app_name") != "0" ]]; then + # shellcheck disable=SC2068 + if ! item_in_array "${app_name}" ${APPS_AVAILABLE[@]}; then + APPS_AVAILABLE+=("${app_name}") + APPS_CHOSEN+=("0") + fi + fi fi done @@ -318,16 +354,20 @@ function detect_installable_apps { do app_name=$(echo "${filename}" | awk -F '-app-' '{print $2}') - # shellcheck disable=SC2068 - if ! item_in_array "${app_name}" ${APPS_AVAILABLE[@]}; then - variants_list=$(app_variants "$filename") - # check for empty string - if [ ${#variants_list} -gt 0 ]; then - APPS_AVAILABLE+=("${app_name}") - APPS_CHOSEN+=("0") - APPS_INSTALLED+=("$(app_is_installed "$app_name")") - if [[ $(app_is_installed "$app_name") == "1" ]]; then - APPS_INSTALLED_NAMES+=("$app_name") + if [[ $(enough_ram_for_app "$app_name") == "0" ]]; then + if [[ $(app_not_on_onion_only "$app_name") != "0" ]]; then + # shellcheck disable=SC2068 + if ! item_in_array "${app_name}" ${APPS_AVAILABLE[@]}; then + variants_list=$(app_variants "$filename") + # check for empty string + if [ ${#variants_list} -gt 0 ]; then + APPS_AVAILABLE+=("${app_name}") + APPS_CHOSEN+=("0") + APPS_INSTALLED+=("$(app_is_installed "$app_name")") + if [[ $(app_is_installed "$app_name") == "1" ]]; then + APPS_INSTALLED_NAMES+=("$app_name") + fi + fi fi fi fi @@ -350,13 +390,17 @@ function detect_installed_apps { do app_name=$(echo "${filename}" | awk -F '-app-' '{print $2}') - if [[ $(app_is_installed "$app_name") == "1" ]]; then - # shellcheck disable=SC2068 - if ! item_in_array "${app_name}" ${APPS_AVAILABLE[@]}; then - variants_list=$(app_variants "$filename") - if [ ${#variants_list} -gt 0 ]; then - APPS_AVAILABLE+=("${app_name}") - APPS_INSTALLED_NAMES+=("$app_name") + if [[ $(enough_ram_for_app "$app_name") == "0" ]]; then + if [[ $(app_not_on_onion_only "$app_name") != "0" ]]; then + if [[ $(app_is_installed "$app_name") == "1" ]]; then + # shellcheck disable=SC2068 + if ! item_in_array "${app_name}" ${APPS_AVAILABLE[@]}; then + variants_list=$(app_variants "$filename") + if [ ${#variants_list} -gt 0 ]; then + APPS_AVAILABLE+=("${app_name}") + APPS_INSTALLED_NAMES+=("$app_name") + fi + fi fi fi fi @@ -385,27 +429,30 @@ function choose_apps_for_variant { for filename in $FILES do app_name=$(echo "${filename}" | awk -F '-app-' '{print $2}') - - # shellcheck disable=SC2068 - if item_in_array "${app_name}" ${APPS_AVAILABLE[@]}; then - if grep -q "VARIANTS=" "${filename}"; then - variants_list=$(app_variants "$filename") - if [[ "${variants_list}" == 'all'* || \ - "${variants_list}" == "$variant_name" || \ - "${variants_list}" == "$variant_name "* || \ - "${variants_list}" == *" $variant_name "* || \ - "${variants_list}" == *" $variant_name" ]]; then - if [[ $(app_is_removed "${a}") == "0" ]]; then - #echo $"${app_name} chosen" - APPS_CHOSEN+=("1") + if [[ $(enough_ram_for_app "$app_name") == "0" ]]; then + if [[ $(app_not_on_onion_only "$app_name") != "0" ]]; then + # shellcheck disable=SC2068 + if item_in_array "${app_name}" ${APPS_AVAILABLE[@]}; then + if grep -q "VARIANTS=" "${filename}"; then + variants_list=$(app_variants "$filename") + if [[ "${variants_list}" == 'all'* || \ + "${variants_list}" == "$variant_name" || \ + "${variants_list}" == "$variant_name "* || \ + "${variants_list}" == *" $variant_name "* || \ + "${variants_list}" == *" $variant_name" ]]; then + if [[ $(app_is_removed "${a}") == "0" ]]; then + #echo $"${app_name} chosen" + APPS_CHOSEN+=("1") + else + APPS_CHOSEN+=("0") + fi + else + APPS_CHOSEN+=("0") + fi else APPS_CHOSEN+=("0") fi - else - APPS_CHOSEN+=("0") fi - else - APPS_CHOSEN+=("0") fi fi done