This commit is contained in:
Bob Mottram 2018-05-09 18:22:35 +01:00
commit e79f2c9390
9 changed files with 111 additions and 45 deletions

View File

@ -203,6 +203,7 @@ function install_apps_selected {
fi fi
fi fi
app_index=$((app_index+1)) app_index=$((app_index+1))
done done
# if no apps to be installed then don't do anything # if no apps to be installed then don't do anything

View File

@ -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=

View File

@ -30,6 +30,7 @@ VARIANTS='full full-vim social'
IN_DEFAULT_INSTALL=0 IN_DEFAULT_INSTALL=0
SHOW_ON_ABOUT=1 SHOW_ON_ABOUT=1
NOT_ON_ONION=1
GNUSOCIAL_DOMAIN_NAME= GNUSOCIAL_DOMAIN_NAME=
GNUSOCIAL_CODE= GNUSOCIAL_CODE=
@ -581,6 +582,7 @@ function remove_gnusocial {
fi fi
kill_pid=$(pgrep "/var/www/$GNUSOCIAL_DOMAIN_NAME/htdocs/scripts/queuedaemon.php" | head -n 1) kill_pid=$(pgrep "/var/www/$GNUSOCIAL_DOMAIN_NAME/htdocs/scripts/queuedaemon.php" | head -n 1)
kill -9 "$kill_pid" kill -9 "$kill_pid"
pkill "$GNUSOCIAL_DOMAIN_NAME/htdocs/scripts/queuedaemon.php"
if [ -d "/var/www/$GNUSOCIAL_DOMAIN_NAME" ]; then if [ -d "/var/www/$GNUSOCIAL_DOMAIN_NAME" ]; then
rm -rf "/var/www/$GNUSOCIAL_DOMAIN_NAME" rm -rf "/var/www/$GNUSOCIAL_DOMAIN_NAME"
@ -911,8 +913,8 @@ function install_gnusocial_main {
} }
function install_gnusocial { function install_gnusocial {
if [ ! "$ONION_ONLY" ]; then if [[ "$ONION_ONLY" != 'no' ]]; then
ONION_ONLY='no' return
fi fi
install_gnusocial_main 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" sed -i 's|"theme":.*|"theme": "base16-apathy.css",|g' "/var/www/${GNUSOCIAL_DOMAIN_NAME}/htdocs/static/config.json"
fi 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 cd "/var/www/$GNUSOCIAL_DOMAIN_NAME/htdocs" || exit 236482684
php scripts/checkschema.php php scripts/checkschema.php
sh scripts/startdaemons.sh
/etc/cron.hourly/gnusocial-daemons /etc/cron.hourly/gnusocial-daemons
systemctl restart nginx systemctl restart nginx

View File

@ -30,6 +30,7 @@ VARIANTS='full full-vim social'
IN_DEFAULT_INSTALL=0 IN_DEFAULT_INSTALL=0
SHOW_ON_ABOUT=1 SHOW_ON_ABOUT=1
NOT_ON_ONION=1
HUBZILLA_DOMAIN_NAME= HUBZILLA_DOMAIN_NAME=
HUBZILLA_CODE= HUBZILLA_CODE=

View File

@ -32,6 +32,7 @@ VARIANTS=""
IN_DEFAULT_INSTALL=0 IN_DEFAULT_INSTALL=0
SHOW_ON_ABOUT=0 SHOW_ON_ABOUT=0
NOT_ON_ONION=1
VIDEOBRIDGE_PORT=5347 VIDEOBRIDGE_PORT=5347
JITSI_ONION_PORT=8102 JITSI_ONION_PORT=8102

View File

@ -36,6 +36,8 @@ VARIANTS='full full-vim chat'
IN_DEFAULT_INSTALL=0 IN_DEFAULT_INSTALL=0
SHOW_ON_ABOUT=1 SHOW_ON_ABOUT=1
NOT_ON_ONION=1
MINIMUM_RAM_MB=1500
MATRIX_DOMAIN_NAME= MATRIX_DOMAIN_NAME=
MATRIX_CODE= MATRIX_CODE=

View File

@ -30,6 +30,7 @@ VARIANTS='full full-vim media'
IN_DEFAULT_INSTALL=0 IN_DEFAULT_INSTALL=0
SHOW_ON_ABOUT=1 SHOW_ON_ABOUT=1
NOT_ON_ONION=1
POSTACTIV_DOMAIN_NAME= POSTACTIV_DOMAIN_NAME=
POSTACTIV_CODE= POSTACTIV_CODE=
@ -595,6 +596,7 @@ function remove_postactiv {
fi fi
kill_pid=$(pgrep "/var/www/$POSTACTIV_DOMAIN_NAME/htdocs/scripts/queuedaemon.php" | head -n 1) kill_pid=$(pgrep "/var/www/$POSTACTIV_DOMAIN_NAME/htdocs/scripts/queuedaemon.php" | head -n 1)
kill -9 "$kill_pid" kill -9 "$kill_pid"
pkill "$POSTACTIV_DOMAIN_NAME/htdocs/scripts/queuedaemon.php"
if [ -d "/var/www/$POSTACTIV_DOMAIN_NAME" ]; then if [ -d "/var/www/$POSTACTIV_DOMAIN_NAME" ]; then
rm -rf "/var/www/$POSTACTIV_DOMAIN_NAME" rm -rf "/var/www/$POSTACTIV_DOMAIN_NAME"
@ -926,8 +928,8 @@ function install_postactiv_main {
} }
function install_postactiv { function install_postactiv {
if [ ! "$ONION_ONLY" ]; then if [[ "$ONION_ONLY" != 'no' ]]; then
ONION_ONLY='no' return
fi fi
install_postactiv_main install_postactiv_main
@ -952,7 +954,12 @@ function install_postactiv {
expire_gnusocial_posts "$POSTACTIV_DOMAIN_NAME" "postactiv" "$POSTACTIV_EXPIRE_MONTHS" 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 /etc/cron.hourly/postactiv-daemons
systemctl restart nginx systemctl restart nginx

View File

@ -30,6 +30,7 @@ VARIANTS='full full-vim chat'
IN_DEFAULT_INSTALL=0 IN_DEFAULT_INSTALL=0
SHOW_ON_ABOUT=1 SHOW_ON_ABOUT=1
NOT_ON_ONION=1
RIOT_VERSION='0.13.3' RIOT_VERSION='0.13.3'
RIOT_FILENAME="riot-v${RIOT_VERSION}" RIOT_FILENAME="riot-v${RIOT_VERSION}"

View File

@ -272,6 +272,39 @@ function get_apps_installed_names {
done 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 # 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-*"
@ -285,11 +318,14 @@ 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
# shellcheck disable=SC2068 if [[ $(app_not_on_onion_only "$app_name") != "0" ]]; then
if ! item_in_array "${app_name}" ${APPS_AVAILABLE[@]}; then # shellcheck disable=SC2068
APPS_AVAILABLE+=("${app_name}") if ! item_in_array "${app_name}" ${APPS_AVAILABLE[@]}; then
APPS_CHOSEN+=("0") APPS_AVAILABLE+=("${app_name}")
APPS_CHOSEN+=("0")
fi
fi
fi fi
done done
@ -318,16 +354,20 @@ function detect_installable_apps {
do do
app_name=$(echo "${filename}" | awk -F '-app-' '{print $2}') app_name=$(echo "${filename}" | awk -F '-app-' '{print $2}')
# shellcheck disable=SC2068 if [[ $(enough_ram_for_app "$app_name") == "0" ]]; then
if ! item_in_array "${app_name}" ${APPS_AVAILABLE[@]}; then if [[ $(app_not_on_onion_only "$app_name") != "0" ]]; then
variants_list=$(app_variants "$filename") # shellcheck disable=SC2068
# check for empty string if ! item_in_array "${app_name}" ${APPS_AVAILABLE[@]}; then
if [ ${#variants_list} -gt 0 ]; then variants_list=$(app_variants "$filename")
APPS_AVAILABLE+=("${app_name}") # check for empty string
APPS_CHOSEN+=("0") if [ ${#variants_list} -gt 0 ]; then
APPS_INSTALLED+=("$(app_is_installed "$app_name")") APPS_AVAILABLE+=("${app_name}")
if [[ $(app_is_installed "$app_name") == "1" ]]; then APPS_CHOSEN+=("0")
APPS_INSTALLED_NAMES+=("$app_name") 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 fi
fi fi
@ -350,13 +390,17 @@ 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 [[ $(app_is_installed "$app_name") == "1" ]]; then if [[ $(enough_ram_for_app "$app_name") == "0" ]]; then
# shellcheck disable=SC2068 if [[ $(app_not_on_onion_only "$app_name") != "0" ]]; then
if ! item_in_array "${app_name}" ${APPS_AVAILABLE[@]}; then if [[ $(app_is_installed "$app_name") == "1" ]]; then
variants_list=$(app_variants "$filename") # shellcheck disable=SC2068
if [ ${#variants_list} -gt 0 ]; then if ! item_in_array "${app_name}" ${APPS_AVAILABLE[@]}; then
APPS_AVAILABLE+=("${app_name}") variants_list=$(app_variants "$filename")
APPS_INSTALLED_NAMES+=("$app_name") if [ ${#variants_list} -gt 0 ]; then
APPS_AVAILABLE+=("${app_name}")
APPS_INSTALLED_NAMES+=("$app_name")
fi
fi
fi fi
fi fi
fi fi
@ -385,27 +429,30 @@ 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
# shellcheck disable=SC2068 if [[ $(app_not_on_onion_only "$app_name") != "0" ]]; then
if item_in_array "${app_name}" ${APPS_AVAILABLE[@]}; then # shellcheck disable=SC2068
if grep -q "VARIANTS=" "${filename}"; then if item_in_array "${app_name}" ${APPS_AVAILABLE[@]}; then
variants_list=$(app_variants "$filename") if grep -q "VARIANTS=" "${filename}"; then
if [[ "${variants_list}" == 'all'* || \ variants_list=$(app_variants "$filename")
"${variants_list}" == "$variant_name" || \ if [[ "${variants_list}" == 'all'* || \
"${variants_list}" == "$variant_name "* || \ "${variants_list}" == "$variant_name" || \
"${variants_list}" == *" $variant_name "* || \ "${variants_list}" == "$variant_name "* || \
"${variants_list}" == *" $variant_name" ]]; then "${variants_list}" == *" $variant_name "* || \
if [[ $(app_is_removed "${a}") == "0" ]]; then "${variants_list}" == *" $variant_name" ]]; then
#echo $"${app_name} chosen" if [[ $(app_is_removed "${a}") == "0" ]]; then
APPS_CHOSEN+=("1") #echo $"${app_name} chosen"
APPS_CHOSEN+=("1")
else
APPS_CHOSEN+=("0")
fi
else
APPS_CHOSEN+=("0")
fi
else else
APPS_CHOSEN+=("0") APPS_CHOSEN+=("0")
fi fi
else
APPS_CHOSEN+=("0")
fi fi
else
APPS_CHOSEN+=("0")
fi fi
fi fi
done done