From 4c68294141e72f1be9019342858263f70335fd6f Mon Sep 17 00:00:00 2001 From: Bob Mottram <bob@robotics.uk.to> Date: Fri, 14 Oct 2016 14:56:14 +0100 Subject: [PATCH] Tidying --- src/freedombone-app-blog | 8 ++------ src/freedombone-app-gnusocial | 8 ++------ src/freedombone-app-sip | 2 +- src/freedombone-blog | 22 +++++++++++++--------- src/freedombone-sec | 14 +++++++------- 5 files changed, 25 insertions(+), 29 deletions(-) diff --git a/src/freedombone-app-blog b/src/freedombone-app-blog index 31fb8026f..139b9e670 100755 --- a/src/freedombone-app-blog +++ b/src/freedombone-app-blog @@ -197,9 +197,7 @@ function reconfigure_blog { } function upgrade_blog { - if grep -q "FULLBLOG_DOMAIN_NAME" $CONFIGURATION_FILE; then - FULLBLOG_DOMAIN_NAME=$(grep "FULLBLOG_DOMAIN_NAME" $CONFIGURATION_FILE | awk -F '=' '{print $2}') - fi + read_config_param "FULLBLOG_DOMAIN_NAME" function_check set_repo_commit set_repo_commit /var/www/$FULLBLOG_DOMAIN_NAME/htdocs "blog commit" "$FULLBLOG_COMMIT" $FULLBLOG_REPO @@ -333,9 +331,7 @@ function remove_blog { return fi - if grep -q "FULLBLOG_DOMAIN_NAME" $CONFIGURATION_FILE; then - FULLBLOG_DOMAIN_NAME=$(grep "FULLBLOG_DOMAIN_NAME" $CONFIGURATION_FILE | awk -F '=' '{print $2}') - fi + read_config_param "FULLBLOG_DOMAIN_NAME" nginx_dissite $FULLBLOG_DOMAIN_NAME if [ -f /etc/nginx/sites-available/$FULLBLOG_DOMAIN_NAME ]; then rm -f /etc/nginx/sites-available/$FULLBLOG_DOMAIN_NAME diff --git a/src/freedombone-app-gnusocial b/src/freedombone-app-gnusocial index 198e805c8..96e8c9215 100755 --- a/src/freedombone-app-gnusocial +++ b/src/freedombone-app-gnusocial @@ -351,12 +351,8 @@ function remove_gnusocial { if [ ${#MICROBLOG_DOMAIN_NAME} -eq 0 ]; then return fi - if grep -q "MICROBLOG_DOMAIN_NAME" $CONFIGURATION_FILE; then - MICROBLOG_DOMAIN_NAME=$(grep "MICROBLOG_DOMAIN_NAME" $CONFIGURATION_FILE | head -n 1 | awk -F '=' '{print $2}') - fi - if grep -q "MY_USERNAME" $CONFIGURATION_FILE; then - MY_USERNAME=$(grep "MY_USERNAME" $CONFIGURATION_FILE | awk -F '=' '{print $2}') - fi + read_config_param "MICROBLOG_DOMAIN_NAME" + read_config_param "MY_USERNAME" echo "Removing $MICROBLOG_DOMAIN_NAME" nginx_dissite $MICROBLOG_DOMAIN_NAME if [ -d /var/www/$MICROBLOG_DOMAIN_NAME ]; then diff --git a/src/freedombone-app-sip b/src/freedombone-app-sip index 97af130d0..7061f935b 100755 --- a/src/freedombone-app-sip +++ b/src/freedombone-app-sip @@ -76,7 +76,7 @@ function add_user_sip { # add user for SIP STUN/TURN if [ -d /etc/turnserver ]; then if grep -q "DEFAULT_DOMAIN_NAME" $CONFIGURATION_FILE; then - DEFAULT_DOMAIN_NAME=$(grep "DEFAULT_DOMAIN_NAME" $CONFIGURATION_FILE | head -n 1 | awk -F '=' '{print $2}') + read_config_param "DEFAULT_DOMAIN_NAME" echo "${new_username}:${new_user_password}:${DEFAULT_DOMAIN_NAME}:authorized" >> /etc/turnserver/turnusers.txt fi fi diff --git a/src/freedombone-blog b/src/freedombone-blog index 52e295232..9cfaea5a7 100755 --- a/src/freedombone-blog +++ b/src/freedombone-blog @@ -35,13 +35,17 @@ export TEXTDOMAINDIR="/usr/share/locale" CONFIGURATION_FILE=$HOME/${PROJECT_NAME}.cfg -HOSTNAME= +UTILS_FILES=/usr/share/${PROJECT_NAME}/utils/${PROJECT_NAME}-utils-* +for f in $UTILS_FILES +do + source $f +done + AVATAR= # get the blog hostname -if grep -q "FULLBLOG_DOMAIN_NAME" $CONFIGURATION_FILE; then - HOSTNAME=$(grep "FULLBLOG_DOMAIN_NAME" $CONFIGURATION_FILE | awk -F '=' '{print $2}') -fi +read_config_param "FULLBLOG_DOMAIN_NAME" +HOSTNAME=$FULLBLOG_DOMAIN_NAME BASE_DIR=/var/www/$HOSTNAME/htdocs @@ -98,19 +102,19 @@ function set_avatar_from_file { echo $'Source file not found' exit 2 fi - + # copy the source image cd $BASE_DIR AVATAR_FILES=$(find . -name avatar.png) read -a arr <<<$AVATAR_FILES for i in "${arr[@]}" - do + do FILENAME="$BASE_DIR$(echo \"$i\" | awk -F '.' '{print $2}')".png if [[ "$FILENAME" != "$SOURCE_IMAGE_FILE" ]]; then cp -f $SOURCE_IMAGE_FILE "$FILENAME" - fi - done + fi + done } function set_avatar_from_url { @@ -137,7 +141,7 @@ function set_avatar_from_url { if [ -f avatar ]; then mv avatar avatar.png fi - + # standard size mogrify -resize 150x150 avatar.png if [ ! -f $BASE_DIR/customimages/avatar.png ]; then diff --git a/src/freedombone-sec b/src/freedombone-sec index f683c84a3..4e1f12460 100755 --- a/src/freedombone-sec +++ b/src/freedombone-sec @@ -36,7 +36,11 @@ export TEXTDOMAINDIR="/usr/share/locale" CONFIGURATION_FILE=$HOME/${PROJECT_NAME}.cfg COMPLETION_FILE=$HOME/${PROJECT_NAME}-completed.txt -source /usr/share/${PROJECT_NAME}/utils/${PROJECT_NAME}-utils-validation +UTILS_FILES=/usr/share/${PROJECT_NAME}/utils/${PROJECT_NAME}-utils-* +for f in $UTILS_FILES +do + source $f +done SSL_PROTOCOLS= SSL_CIPHERS= @@ -359,9 +363,7 @@ function regenerate_ssh_host_keys { echo $'ssh small moduli removed' # update monkeysphere DEFAULT_DOMAIN_NAME= - if grep -q "DEFAULT_DOMAIN_NAME" $CONFIGURATION_FILE; then - DEFAULT_DOMAIN_NAME=$(grep "DEFAULT_DOMAIN_NAME" $CONFIGURATION_FILE | awk -F '=' '{print $2}') - fi + read_config_param "DEFAULT_DOMAIN_NAME" monkeysphere-host import-key /etc/ssh/ssh_host_rsa_key ssh://$DEFAULT_DOMAIN_NAME SSH_ONION_HOSTNAME=$(cat ${COMPLETION_FILE} | grep 'ssh onion domain' | awk -F ':' '{print $2}') monkeysphere-host import-key /etc/ssh/ssh_host_rsa_key ssh://$SSH_ONION_HOSTNAME @@ -615,9 +617,7 @@ function enable_monkeysphere { esac if [ $monkey ]; then - if grep -q "MY_USERNAME" $CONFIGURATION_FILE; then - MY_USERNAME=$(grep "MY_USERNAME" $CONFIGURATION_FILE | awk -F '=' '{print $2}') - fi + read_config_param "MY_USERNAME" if [ ! -f /home/$MY_USERNAME/.monkeysphere/authorized_user_ids ]; then dialog --title $"GPG based authentication" \ -- GitLab