From a5b1812e2891670be2be3f5674c596969a71c8d2 Mon Sep 17 00:00:00 2001 From: Bob Mottram Date: Wed, 6 Jul 2016 16:47:55 +0100 Subject: [PATCH] Selecting apps from variant name --- src/freedombone-app-babel | 3 ++- src/freedombone-app-batman | 3 ++- src/freedombone-app-blog | 2 ++ src/freedombone-app-cjdns | 3 ++- src/freedombone-app-dlna | 2 ++ src/freedombone-app-emacs | 2 ++ src/freedombone-app-gnusocial | 2 ++ src/freedombone-app-gogs | 2 ++ src/freedombone-app-hubzilla | 2 ++ src/freedombone-app-ipfs | 2 ++ src/freedombone-app-irc | 2 ++ src/freedombone-app-mediagoblin | 2 ++ src/freedombone-app-mumble | 2 ++ src/freedombone-app-rss | 2 ++ src/freedombone-app-searx | 2 ++ src/freedombone-app-sip | 2 ++ src/freedombone-app-syncthing | 2 ++ src/freedombone-app-tox | 2 ++ src/freedombone-app-vpn | 2 ++ src/freedombone-app-webmail | 2 ++ src/freedombone-app-wiki | 2 ++ src/freedombone-app-xmpp | 2 ++ src/freedombone-app-zeronet | 2 ++ src/freedombone-utils-selector | 44 +++++++++++++++++++++++++++++++++ src/freedombone-utils-setup | 11 ++++++--- 25 files changed, 98 insertions(+), 6 deletions(-) diff --git a/src/freedombone-app-babel b/src/freedombone-app-babel index 55b1e31e..6cc383c2 100755 --- a/src/freedombone-app-babel +++ b/src/freedombone-app-babel @@ -28,7 +28,8 @@ # You should have received a copy of the GNU Affero General Public License # along with this program. If not, see . -# Babel mesh +VARIANTS='' + ENABLE_BABEL="no" BABEL_PORT=6696 diff --git a/src/freedombone-app-batman b/src/freedombone-app-batman index 01525f5e..d259c2d0 100755 --- a/src/freedombone-app-batman +++ b/src/freedombone-app-batman @@ -28,7 +28,8 @@ # You should have received a copy of the GNU Affero General Public License # along with this program. If not, see . -# B.A.T.M.A.N settings +VARIANTS='mesh' + ENABLE_BATMAN="no" BATMAN_CELLID='any' diff --git a/src/freedombone-app-blog b/src/freedombone-app-blog index 671ec7cc..838ad2c8 100755 --- a/src/freedombone-app-blog +++ b/src/freedombone-app-blog @@ -28,6 +28,8 @@ # You should have received a copy of the GNU Affero General Public License # along with this program. If not, see . +VARIANTS="full writer" + FULLBLOG_DOMAIN_NAME= FULLBLOG_CODE= FULLBLOG_ONION_PORT=8086 diff --git a/src/freedombone-app-cjdns b/src/freedombone-app-cjdns index 35957ad7..963b76dc 100755 --- a/src/freedombone-app-cjdns +++ b/src/freedombone-app-cjdns @@ -28,7 +28,8 @@ # You should have received a copy of the GNU Affero General Public License # along with this program. If not, see . -# cjdns settings +VARIANTS='' + ENABLE_CJDNS="no" CJDNS_PRIVATE_KEY= CJDNS_PUBLIC_KEY= diff --git a/src/freedombone-app-dlna b/src/freedombone-app-dlna index 6744dd1b..f8f11f33 100755 --- a/src/freedombone-app-dlna +++ b/src/freedombone-app-dlna @@ -28,6 +28,8 @@ # You should have received a copy of the GNU Affero General Public License # along with this program. If not, see . +VARIANTS='full media' + function upgrade_dlna { echo '' } diff --git a/src/freedombone-app-emacs b/src/freedombone-app-emacs index f5861578..0dd52745 100755 --- a/src/freedombone-app-emacs +++ b/src/freedombone-app-emacs @@ -28,6 +28,8 @@ # You should have received a copy of the GNU Affero General Public License # along with this program. If not, see . +VARIANTS='all' + function upgrade_emacs { echo '' } diff --git a/src/freedombone-app-gnusocial b/src/freedombone-app-gnusocial index f47d972c..df0fd016 100755 --- a/src/freedombone-app-gnusocial +++ b/src/freedombone-app-gnusocial @@ -28,6 +28,8 @@ # You should have received a copy of the GNU Affero General Public License # along with this program. If not, see . +VARIANTS='full media' + MICROBLOG_DOMAIN_NAME= MICROBLOG_CODE= MICROBLOG_ONION_PORT=8087 diff --git a/src/freedombone-app-gogs b/src/freedombone-app-gogs index f5d4c2f2..51cd8088 100755 --- a/src/freedombone-app-gogs +++ b/src/freedombone-app-gogs @@ -28,6 +28,8 @@ # You should have received a copy of the GNU Affero General Public License # along with this program. If not, see . +VARIANTS='full developer' + GIT_DOMAIN_NAME= GIT_CODE= GIT_ONION_PORT=8090 diff --git a/src/freedombone-app-hubzilla b/src/freedombone-app-hubzilla index 7cdd30d5..afd06c44 100755 --- a/src/freedombone-app-hubzilla +++ b/src/freedombone-app-hubzilla @@ -28,6 +28,8 @@ # You should have received a copy of the GNU Affero General Public License # along with this program. If not, see . +VARIANTS='full social' + HUBZILLA_DOMAIN_NAME= HUBZILLA_CODE= HUBZILLA_ONION_PORT=8085 diff --git a/src/freedombone-app-ipfs b/src/freedombone-app-ipfs index 8a0607d1..690434b9 100755 --- a/src/freedombone-app-ipfs +++ b/src/freedombone-app-ipfs @@ -28,6 +28,8 @@ # You should have received a copy of the GNU Affero General Public License # along with this program. If not, see . +VARIANTS='mesh' + IPFS_GO_REPO="https://github.com/ipfs/go-ipfs" IPFS_COMMIT='20b06a4cbce8884f5b194da6e98cb11f2c77f166' IPFS_PORT=4001 diff --git a/src/freedombone-app-irc b/src/freedombone-app-irc index 526c26c0..bd0494f9 100755 --- a/src/freedombone-app-irc +++ b/src/freedombone-app-irc @@ -28,6 +28,8 @@ # You should have received a copy of the GNU Affero General Public License # along with this program. If not, see . +VARIANTS='full chat' + IRC_PORT=6697 IRC_ONION_PORT=6697 diff --git a/src/freedombone-app-mediagoblin b/src/freedombone-app-mediagoblin index b5a8c899..dae87f57 100755 --- a/src/freedombone-app-mediagoblin +++ b/src/freedombone-app-mediagoblin @@ -28,6 +28,8 @@ # You should have received a copy of the GNU Affero General Public License # along with this program. If not, see . +VARIANTS='' + MEDIAGOBLIN_DOMAIN_NAME= MEDIAGOBLIN_CODE= MEDIAGOBLIN_REPO="git://git.savannah.gnu.org/mediagoblin.git" diff --git a/src/freedombone-app-mumble b/src/freedombone-app-mumble index 6d80eda7..971c4d4b 100755 --- a/src/freedombone-app-mumble +++ b/src/freedombone-app-mumble @@ -28,6 +28,8 @@ # You should have received a copy of the GNU Affero General Public License # along with this program. If not, see . +VARIANTS='full chat' + # Password used for VoIP server VOIP_SERVER_PASSWORD= # Port on which VoIP server listens diff --git a/src/freedombone-app-rss b/src/freedombone-app-rss index f9270286..e238e04f 100755 --- a/src/freedombone-app-rss +++ b/src/freedombone-app-rss @@ -28,6 +28,8 @@ # You should have received a copy of the GNU Affero General Public License # along with this program. If not, see . +VARIANTS='full writer' + RSS_READER_REPO="https://tt-rss.org/git/tt-rss.git" RSS_READER_COMMIT='9e84bab449f9ed55e02e60378b0af1521026f3b8' RSS_READER_ADMIN_PASSWORD= diff --git a/src/freedombone-app-searx b/src/freedombone-app-searx index cab470eb..0a7ff61b 100755 --- a/src/freedombone-app-searx +++ b/src/freedombone-app-searx @@ -28,6 +28,8 @@ # You should have received a copy of the GNU Affero General Public License # along with this program. If not, see . +VARIANTS='' + SEARX_REPO="https://github.com/asciimoo/searx" SEARX_COMMIT='fee556c9904637051a9ba874ba7e71cd9f10789f' SEARX_PATH=/etc diff --git a/src/freedombone-app-sip b/src/freedombone-app-sip index c46984cd..5eafbc42 100755 --- a/src/freedombone-app-sip +++ b/src/freedombone-app-sip @@ -28,6 +28,8 @@ # You should have received a copy of the GNU Affero General Public License # along with this program. If not, see . +VARIANTS='full chat' + SIP_SERVER_PASSWORD= SIP_PORT=5060 SIP_TLS_PORT=5061 diff --git a/src/freedombone-app-syncthing b/src/freedombone-app-syncthing index 5e46cc2c..7a55226a 100755 --- a/src/freedombone-app-syncthing +++ b/src/freedombone-app-syncthing @@ -28,6 +28,8 @@ # You should have received a copy of the GNU Affero General Public License # along with this program. If not, see . +VARIANTS='full cloud' + SYNCTHING_ID= SYNCTHING_CONFIG_PATH=/root/.config/syncthing SYNCTHING_CONFIG_FILE=$SYNCTHING_CONFIG_PATH/config.xml diff --git a/src/freedombone-app-tox b/src/freedombone-app-tox index 68b76259..66ed8137 100755 --- a/src/freedombone-app-tox +++ b/src/freedombone-app-tox @@ -28,6 +28,8 @@ # You should have received a copy of the GNU Affero General Public License # along with this program. If not, see . +VARIANTS='full chat' + TOX_PORT=33445 TOXCORE_REPO="git://github.com/irungentoo/toxcore.git" TOXCORE_COMMIT='532629d486e3361c7d8d95b38293cc7d61dc4ee5' diff --git a/src/freedombone-app-vpn b/src/freedombone-app-vpn index 85bc234d..37facbe9 100755 --- a/src/freedombone-app-vpn +++ b/src/freedombone-app-vpn @@ -28,6 +28,8 @@ # You should have received a copy of the GNU Affero General Public License # along with this program. If not, see . +VARIANTS='' + function upgrade_vpn { echo '' } diff --git a/src/freedombone-app-webmail b/src/freedombone-app-webmail index cc1cdf35..9efd0380 100755 --- a/src/freedombone-app-webmail +++ b/src/freedombone-app-webmail @@ -28,6 +28,8 @@ # You should have received a copy of the GNU Affero General Public License # along with this program. If not, see . +VARIANTS='' + WEBMAIL_REPO="https://github.com/roundcube/roundcubemail" WEBMAIL_COMMIT='78cf9c2e5cff2d78cd8beb647d60570f195a2a9c' WEBMAIL_ONION_HOSTNAME= diff --git a/src/freedombone-app-wiki b/src/freedombone-app-wiki index db2a119f..93345481 100755 --- a/src/freedombone-app-wiki +++ b/src/freedombone-app-wiki @@ -28,6 +28,8 @@ # You should have received a copy of the GNU Affero General Public License # along with this program. If not, see . +VARIANTS='full writer' + WIKI_DOMAIN_NAME= WIKI_ADMIN_PASSWORD= WIKI_TITLE="${PROJECT_NAME} Wiki" diff --git a/src/freedombone-app-xmpp b/src/freedombone-app-xmpp index 78374412..252dcd14 100755 --- a/src/freedombone-app-xmpp +++ b/src/freedombone-app-xmpp @@ -28,6 +28,8 @@ # You should have received a copy of the GNU Affero General Public License # along with this program. If not, see . +VARIANTS='full chat' + # Directory where XMPP settings are stored XMPP_DIRECTORY="/var/lib/prosody" XMPP_PASSWORD= diff --git a/src/freedombone-app-zeronet b/src/freedombone-app-zeronet index 4e1528c2..3f884f8a 100755 --- a/src/freedombone-app-zeronet +++ b/src/freedombone-app-zeronet @@ -28,6 +28,8 @@ # You should have received a copy of the GNU Affero General Public License # along with this program. If not, see . +VARIANTS='mesh' + ZERONET_REPO="https://github.com/HelloZeroNet/ZeroNet.git" ZERONET_COMMIT='675bd462556c541d65e2d95f91f899146a373aad' ZERONET_BLOG_REPO="https://github.com/HelloZeroNet/ZeroBlog" diff --git a/src/freedombone-utils-selector b/src/freedombone-utils-selector index 53b57426..3b698489 100755 --- a/src/freedombone-utils-selector +++ b/src/freedombone-utils-selector @@ -82,6 +82,50 @@ function detect_apps { get_apps_installed } +# creates the APPS_AVAILABLE and APPS_CHOSEN arrays based on +# the given variant name +function choose_apps_for_variant { + variant_name="$1" + + FILES=$PROJECT_INSTALL_DIR/${PROJECT_NAME}-app-* + + APPS_AVAILABLE=() + APPS_CHOSEN=() + + # for all the app scripts + for filename in $FILES + do + app_name=$(echo "${filename}" | awk -F '-app-' '{print $2}') + if [[ $(item_in_array ${app_name} ${APPS_AVAILABLE[@]}) != 0 ]]; then + APPS_AVAILABLE+=("${app_name}") + + if grep -q "VARIANTS=" ${filename}; then + variants_list=$(cat ${filename} | grep "VARIANTS=" | awk -F '=' '{print $2}' | awk -F "'" '{print $2}') + if [[ ${variants_list} == "$variant_name "* || ${variants_list} == *" $variant_name "* || ${variants_list} == *" $variant_name" ]]; then + APPS_CHOSEN+=("1") + else + APPS_CHOSEN+=("0") + fi + else + APPS_CHOSEN+=("0") + fi + + fi + done + get_apps_installed +} + +function list_chosen_apps { + app_index=0 + for a in "${APPS_AVAILABLE[@]}" + do + if [[ ${APPS_CHOSEN[$app_index]} == "1" ]]; then + echo $"${a}" + fi + app_index=$[app_index+1] + done +} + function remove_apps { app_index=0 for a in "${APPS_AVAILABLE[@]}" diff --git a/src/freedombone-utils-setup b/src/freedombone-utils-setup index 0ca30761..2293b817 100755 --- a/src/freedombone-utils-setup +++ b/src/freedombone-utils-setup @@ -319,10 +319,15 @@ function setup_web { } function setup_apps { - function_check detect_apps - detect_apps + function_check choose_apps_for_variant + choose_apps_for_variant "$SYSTEM_TYPE" - # TODO choose apps based upon variants + echo $"System variant: $SYSTEM_TYPE" + echo $'The following apps have been selected' + echo '' + function_check list_chosen_apps + list_chosen_apps + echo '' function_check install_apps install_apps