Preparing interactive configuration for Hubzilla

This commit is contained in:
Bob Mottram 2015-09-06 22:36:38 +01:00
parent 7b68fa1847
commit a17ed9867e
1 changed files with 111 additions and 41 deletions

View File

@ -31,6 +31,9 @@
NO_OF_ARGS=$# NO_OF_ARGS=$#
# whether to enable hubzilla or redmatrix
ENABLE_HUBZILLA="no"
# Web site # Web site
FREEDOMBONE_WEBSITE="http://freedombone.uk.to" FREEDOMBONE_WEBSITE="http://freedombone.uk.to"
@ -82,6 +85,8 @@ OWNCLOUD_DOMAIN_NAME=
OWNCLOUD_CODE= OWNCLOUD_CODE=
REDMATRIX_DOMAIN_NAME= REDMATRIX_DOMAIN_NAME=
REDMATRIX_CODE= REDMATRIX_CODE=
HUBZILLA_DOMAIN_NAME=
HUBZILLA_CODE=
MICROBLOG_DOMAIN_NAME= MICROBLOG_DOMAIN_NAME=
MICROBLOG_CODE= MICROBLOG_CODE=
GIT_DOMAIN_NAME= GIT_DOMAIN_NAME=
@ -213,6 +218,12 @@ function save_configuration_file {
if [ $REDMATRIX_CODE ]; then if [ $REDMATRIX_CODE ]; then
echo "REDMATRIX_CODE=$REDMATRIX_CODE" >> $CONFIGURATION_FILE echo "REDMATRIX_CODE=$REDMATRIX_CODE" >> $CONFIGURATION_FILE
fi fi
if [ $HUBZILLA_DOMAIN_NAME ]; then
echo "HUBZILLA_DOMAIN_NAME=$HUBZILLA_DOMAIN_NAME" >> $CONFIGURATION_FILE
fi
if [ $HUBZILLA_CODE ]; then
echo "HUBZILLA_CODE=$HUBZILLA_CODE" >> $CONFIGURATION_FILE
fi
if [ $MICROBLOG_DOMAIN_NAME ]; then if [ $MICROBLOG_DOMAIN_NAME ]; then
echo "MICROBLOG_DOMAIN_NAME=$MICROBLOG_DOMAIN_NAME" >> $CONFIGURATION_FILE echo "MICROBLOG_DOMAIN_NAME=$MICROBLOG_DOMAIN_NAME" >> $CONFIGURATION_FILE
fi fi
@ -1223,6 +1234,7 @@ function interactive_configuration {
fi fi
if [[ $SYSTEM_TYPE == "$VARIANT_SOCIAL" || $SYSTEM_TYPE == "$VARIANT_FULL" ]]; then if [[ $SYSTEM_TYPE == "$VARIANT_SOCIAL" || $SYSTEM_TYPE == "$VARIANT_FULL" ]]; then
if [[ $ENABLE_HUBZILLA == "no" ]]; then
REDMATRIX_DETAILS_COMPLETE= REDMATRIX_DETAILS_COMPLETE=
while [ ! $REDMATRIX_DETAILS_COMPLETE ] while [ ! $REDMATRIX_DETAILS_COMPLETE ]
do do
@ -1268,6 +1280,55 @@ function interactive_configuration {
REDMATRIX_DETAILS_COMPLETE="yes" REDMATRIX_DETAILS_COMPLETE="yes"
fi fi
done done
else
HUBZILLA_DETAILS_COMPLETE=
while [ ! $HUBZILLA_DETAILS_COMPLETE ]
do
data=$(tempfile 2>/dev/null)
trap "rm -f $data" 0 1 2 5 15
if [[ $DDNS_PROVIDER == "default@freedns.afraid.org" ]]; then
dialog --backtitle "Freedombone Configuration" \
--title "Hubzilla Configuration" \
--form "\nPlease enter your Hubzilla details:" 11 55 3 \
"Domain:" 1 1 "$(grep 'HUBZILLA_DOMAIN_NAME' temp.cfg | awk -F '=' '{print $2}')" 1 16 25 30 \
"Code:" 2 1 "$(grep 'HUBZILLA_CODE' temp.cfg | awk -F '=' '{print $2}')" 2 16 25 30 \
2> $data
else
dialog --backtitle "Freedombone Configuration" \
--title "Hubzilla Configuration" \
--form "\nPlease enter your Hubzilla details:" 11 55 3 \
"Domain:" 1 1 "$(grep 'HUBZILLA_DOMAIN_NAME' temp.cfg | awk -F '=' '{print $2}')" 1 16 25 30 \
2> $data
fi
sel=$?
case $sel in
1) exit 1;;
255) exit 1;;
esac
HUBZILLA_DOMAIN_NAME=$(cat $data | sed -n 1p)
if [ $HUBZILLA_DOMAIN_NAME ]; then
TEST_DOMAIN_NAME=$HUBZILLA_DOMAIN_NAME
validate_domain_name
if [[ $TEST_DOMAIN_NAME != $HUBZILLA_DOMAIN_NAME ]]; then
HUBZILLA_DOMAIN_NAME=
dialog --title "Domain name validation" --msgbox "$TEST_DOMAIN_NAME" 15 50
else
if [[ $DDNS_PROVIDER == "default@freedns.afraid.org" ]]; then
HUBZILLA_CODE=$(cat $data | sed -n 2p)
if [ ${#HUBZILLA_CODE} -lt 30 ]; then
HUBZILLA_DOMAIN_NAME=
dialog --title "FreeDNS code" --msgbox "$FREEDNS_MESSAGE" 15 50
fi
fi
fi
fi
if [ $HUBZILLA_DOMAIN_NAME ]; then
HUBZILLA_DETAILS_COMPLETE="yes"
fi
done
fi
save_configuration_file save_configuration_file
fi fi
@ -1301,6 +1362,9 @@ function interactive_configuration {
if [[ $MICROBLOG_DOMAIN_NAME == "$REDMATRIX_DOMAIN_NAME" ]]; then if [[ $MICROBLOG_DOMAIN_NAME == "$REDMATRIX_DOMAIN_NAME" ]]; then
MICROBLOG_DOMAIN_NAME="" MICROBLOG_DOMAIN_NAME=""
fi fi
if [[ $MICROBLOG_DOMAIN_NAME == "$HUBZILLA_DOMAIN_NAME" ]]; then
MICROBLOG_DOMAIN_NAME=""
fi
TEST_DOMAIN_NAME=$MICROBLOG_DOMAIN_NAME TEST_DOMAIN_NAME=$MICROBLOG_DOMAIN_NAME
validate_domain_name validate_domain_name
if [[ $TEST_DOMAIN_NAME != $MICROBLOG_DOMAIN_NAME ]]; then if [[ $TEST_DOMAIN_NAME != $MICROBLOG_DOMAIN_NAME ]]; then
@ -1558,6 +1622,12 @@ function read_configuration {
if grep -q "REDMATRIX_CODE" $CONFIGURATION_FILE; then if grep -q "REDMATRIX_CODE" $CONFIGURATION_FILE; then
REDMATRIX_CODE=$(grep "REDMATRIX_CODE" $CONFIGURATION_FILE | awk -F '=' '{print $2}') REDMATRIX_CODE=$(grep "REDMATRIX_CODE" $CONFIGURATION_FILE | awk -F '=' '{print $2}')
fi fi
if grep -q "HUBZILLA_DOMAIN_NAME" $CONFIGURATION_FILE; then
HUBZILLA_DOMAIN_NAME=$(grep "HUBZILLA_DOMAIN_NAME" $CONFIGURATION_FILE | awk -F '=' '{print $2}')
fi
if grep -q "HUBZILLA_CODE" $CONFIGURATION_FILE; then
HUBZILLA_CODE=$(grep "HUBZILLA_CODE" $CONFIGURATION_FILE | awk -F '=' '{print $2}')
fi
if grep -q "OWNCLOUD_DOMAIN_NAME" $CONFIGURATION_FILE; then if grep -q "OWNCLOUD_DOMAIN_NAME" $CONFIGURATION_FILE; then
OWNCLOUD_DOMAIN_NAME=$(grep "OWNCLOUD_DOMAIN_NAME" $CONFIGURATION_FILE | awk -F '=' '{print $2}') OWNCLOUD_DOMAIN_NAME=$(grep "OWNCLOUD_DOMAIN_NAME" $CONFIGURATION_FILE | awk -F '=' '{print $2}')
fi fi