diff --git a/src/freedombone-app-gnusocial b/src/freedombone-app-gnusocial index e1806cfa..78717c23 100755 --- a/src/freedombone-app-gnusocial +++ b/src/freedombone-app-gnusocial @@ -232,7 +232,7 @@ function gnusocial_set_background_image { if [ ${#temp_background} -gt 0 ]; then GNUSOCIAL_BACKGROUND_IMAGE_URL="$temp_background" write_config_param "GNUSOCIAL_BACKGROUND_IMAGE_URL" "$GNUSOCIAL_BACKGROUND_IMAGE_URL" - if [[ $(pleroma_set_background_image_from_url "$GNUSOCIAL_DOMAIN_NAME" "$GNUSOCIAL_BACKGROUND_IMAGE_URL" "$GNUSOCIAL_TITLE" | tail -n 1) == "0" ]]; then + if [[ $(pleroma_set_background_image_from_url /var/www/$GNUSOCIAL_DOMAIN_NAME/htdocs "$GNUSOCIAL_DOMAIN_NAME" "$GNUSOCIAL_BACKGROUND_IMAGE_URL" "$GNUSOCIAL_TITLE" | tail -n 1) == "0" ]]; then dialog --title $"Set GNU Social login background" \ --msgbox $"The background image has been set" 6 60 fi @@ -924,7 +924,7 @@ function install_gnusocial { gnusocial_use_qvitter gnusocial if [ $GNUSOCIAL_BACKGROUND_IMAGE_URL ]; then - pleroma_set_background_image_from_url "$GNUSOCIAL_DOMAIN_NAME" "$GNUSOCIAL_BACKGROUND_IMAGE_URL" "$GNUSOCIAL_TITLE" + pleroma_set_background_image_from_url /var/www/$GNUSOCIAL_DOMAIN_NAME/htdocs "$GNUSOCIAL_DOMAIN_NAME" "$GNUSOCIAL_BACKGROUND_IMAGE_URL" "$GNUSOCIAL_TITLE" fi APP_INSTALLED=1 diff --git a/src/freedombone-app-pleroma b/src/freedombone-app-pleroma index 3d10df97..246eb40b 100755 --- a/src/freedombone-app-pleroma +++ b/src/freedombone-app-pleroma @@ -238,7 +238,7 @@ function pleroma_set_background_image { if [ ${#temp_background} -gt 0 ]; then PLEROMA_BACKGROUND_IMAGE_URL="$temp_background" write_config_param "PLEROMA_BACKGROUND_IMAGE_URL" "$PLEROMA_BACKGROUND_IMAGE_URL" - if [[ $(pleroma_set_background_image_from_url "$PLEROMA_DOMAIN_NAME" "$PLEROMA_BACKGROUND_IMAGE_URL" "$PLEROMA_TITLE" | tail -n 1) == "0" ]]; then + if [[ $(pleroma_set_background_image_from_url $PLEROMA_DIR "$PLEROMA_DOMAIN_NAME" "$PLEROMA_BACKGROUND_IMAGE_URL" "$PLEROMA_TITLE" | tail -n 1) == "0" ]]; then dialog --title $"Set Pleroma login background" \ --msgbox $"The background image has been set" 6 60 fi @@ -262,8 +262,7 @@ function pleroma_set_title { PLEROMA_TITLE="$new_title" PLEROMA_DOMAIN_NAME=$(get_completion_param "pleroma domain") write_config_param "PLEROMA_TITLE" "$PLEROMA_TITLE" - cd /var/www/$PLEROMA_DOMAIN_NAME/htdocs/static - sed -i "s|\"name\":.*|\"name\": \"${PLEROMA_TITLE}\",|g" config.json + sed -i "s|\"name\":.*|\"name\": \"${PLEROMA_TITLE}\",|g" $PLEROMA_DIR/static/config.json sed -i "s|name: .*|name: \"${PLEROMA_TITLE}\",|g" $PLEROMA_DIR/config/config.exs systemctl restart pleroma dialog --title $"Set Pleroma title" \ @@ -527,8 +526,8 @@ function install_pleroma { install_nodejs pleroma-backend install_postgresql - if [ ! -d /var/www/$PLEROMA_DOMAIN_NAME ]; then - mkdir /var/www/$PLEROMA_DOMAIN_NAME + if [ ! -d /var/www/${PLEROMA_DOMAIN_NAME}/htdocs ]; then + mkdir -p /var/www/${PLEROMA_DOMAIN_NAME}/htdocs fi if [ -d $PLEROMA_DIR ]; then rm -rf $PLEROMA_DIR @@ -635,17 +634,6 @@ function install_pleroma { echo ' # include snippets/well-known.conf;' >> $pleroma_nginx_site echo '}' >> $pleroma_nginx_site - function_check create_site_certificate - create_site_certificate $PLEROMA_DOMAIN_NAME 'yes' - - function_check nginx_ensite - nginx_ensite $PLEROMA_DOMAIN_NAME - - systemctl restart postgresql - systemctl restart nginx - - set_completion_param "pleroma domain" "$PLEROMA_DOMAIN_NAME" - # back end cd $PLEROMA_DIR @@ -668,12 +656,34 @@ function install_pleroma { # front end install_pleroma_front_end "pleroma" "$PLEROMA_DOMAIN_NAME" "$PLEROMA_BACKGROUND_IMAGE_URL" "$PLEROMA_TITLE" install_gnusocial_default_background "gnusocial" "$PLEROMA_DOMAIN_NAME" - sed -i 's|"theme":.*|"theme": "base16-apathy.css",|g' /var/www/${PLEROMA_DOMAIN_NAME}/htdocs/static/config.json + if [ ! -f $PLEROMA_DIR/static/config.json ]; then + echo $"$PLEROMA_DIR/static/config.json file missing" + exit 323689 + fi + sed -i 's|"theme":.*|"theme": "base16-apathy.css",|g' $PLEROMA_DIR/static/config.json if [ $PLEROMA_BACKGROUND_IMAGE_URL ]; then - pleroma_set_background_image_from_url "$PLEROMA_DOMAIN_NAME" "$PLEROMA_BACKGROUND_IMAGE_URL" "$PLEROMA_TITLE" + pleroma_set_background_image_from_url $PLEROMA_DIR "$PLEROMA_DOMAIN_NAME" "$PLEROMA_BACKGROUND_IMAGE_URL" "$PLEROMA_TITLE" fi + if [ ! -f $PLEROMA_DIR/index.html ]; then + echo $'Pleroma index file missing' + exit 7825393 + fi + + + # Get certificate + function_check create_site_certificate + create_site_certificate $PLEROMA_DOMAIN_NAME 'yes' + + function_check nginx_ensite + nginx_ensite $PLEROMA_DOMAIN_NAME + + systemctl restart postgresql + systemctl restart nginx + + set_completion_param "pleroma domain" "$PLEROMA_DOMAIN_NAME" + # daemon echo '[Unit]' > /etc/systemd/system/pleroma.service diff --git a/src/freedombone-app-postactiv b/src/freedombone-app-postactiv index 6e69845d..5eaefcee 100755 --- a/src/freedombone-app-postactiv +++ b/src/freedombone-app-postactiv @@ -248,7 +248,7 @@ function postactiv_set_background_image { POSTACTIV_BACKGROUND_IMAGE_URL="$temp_background" write_config_param "POSTACTIV_BACKGROUND_IMAGE_URL" "$POSTACTIV_BACKGROUND_IMAGE_URL" - if [[ $(pleroma_set_background_image_from_url "$POSTACTIV_DOMAIN_NAME" "$POSTACTIV_BACKGROUND_IMAGE_URL" "$POSTACTIV_TITLE" | tail -n 1) == "0" ]]; then + if [[ $(pleroma_set_background_image_from_url /var/www/$POSTACTIV_DOMAIN_NAME/htdocs "$POSTACTIV_DOMAIN_NAME" "$POSTACTIV_BACKGROUND_IMAGE_URL" "$POSTACTIV_TITLE" | tail -n 1) == "0" ]]; then dialog --title $"Set PostActiv background" \ --msgbox $"The background image has been set" 6 60 fi @@ -945,7 +945,7 @@ function install_postactiv { gnusocial_use_qvitter postactiv if [ $POSTACTIV_BACKGROUND_IMAGE_URL ]; then - pleroma_set_background_image_from_url "$POSTACTIV_DOMAIN_NAME" "$POSTACTIV_BACKGROUND_IMAGE_URL" "$POSTACTIV_TITLE" + pleroma_set_background_image_from_url /var/www/$POSTACTIV_DOMAIN_NAME/htdocs "$POSTACTIV_DOMAIN_NAME" "$POSTACTIV_BACKGROUND_IMAGE_URL" "$POSTACTIV_TITLE" fi APP_INSTALLED=1 diff --git a/src/freedombone-utils-gnusocialtools b/src/freedombone-utils-gnusocialtools index 7a2ac329..63cb243b 100755 --- a/src/freedombone-utils-gnusocialtools +++ b/src/freedombone-utils-gnusocialtools @@ -88,9 +88,10 @@ function qvitter_update_background { } function pleroma_set_background_image_from_url { - domain_name="$1" - url="$2" - title="$3" + basedir="$1" + domain_name="$2" + url="$3" + title="$4" if [ ${#domain_name} -eq 0 ]; then echo "1" @@ -111,7 +112,7 @@ function pleroma_set_background_image_from_url { fi if [ ${#ext} -gt 0 ]; then - cd /var/www/${domain_name}/htdocs + cd $basedir # remove any existing image if [ -f bg_custom.${ext} ]; then @@ -127,13 +128,15 @@ function pleroma_set_background_image_from_url { return fi - if [ -d /var/www/${domain_name}/htdocs/static ]; then + if [ -d $basedir/static ]; then cp bg_custom.${ext} static/bg_custom.${ext} chown www-data:www-data static/bg_custom.${ext} sed -i "s|\"background\":.*|\"background\": \"/static/bg_custom.${ext}\",|g" static/config.json fi - qvitter_update_background ${domain_name} ${ext} + if [[ "$basedir" != $PLEROMA_DIR ]]; then + qvitter_update_background ${domain_name} ${ext} + fi rm bg_custom.${ext} else @@ -142,19 +145,19 @@ function pleroma_set_background_image_from_url { fi # customise the logo - if [ -f /var/www/${domain_name}/htdocs/static/logo.png ]; then + if [ -f $basedir/static/logo.png ]; then if [ -f ~/freedombone/img/logo_fbone3.png ]; then - cp ~/freedombone/img/logo_fbone3.png /var/www/${domain_name}/htdocs/static/logo.png + cp ~/freedombone/img/logo_fbone3.png $basedir/static/logo.png else if [ -f /home/$MY_USERNAME/freedombone/img/logo_fbone3.png ]; then - cp /home/$MY_USERNAME/freedombone/img/logo_fbone3.png /var/www/${domain_name}/htdocs/static/logo.png + cp /home/$MY_USERNAME/freedombone/img/logo_fbone3.png $basedir/static/logo.png fi fi fi # customise the title - if [ -f /var/www/${domain_name}/htdocs/static/config.json ]; then - sed -i "s|\"name\":.*|\"name\": \"${title}\",|g" /var/www/${domain_name}/htdocs/static/config.json + if [ -f $basedir/static/config.json ]; then + sed -i "s|\"name\":.*|\"name\": \"${title}\",|g" $basedir/static/config.json fi echo "0" @@ -328,9 +331,14 @@ function install_pleroma_front_end { exit 5282682 fi - cp -r $INSTALL_DIR/pleroma/dist/* /var/www/${pleroma_domain}/htdocs/ + if [[ "$app_name" != 'pleroma' ]]; then + cp -r $INSTALL_DIR/pleroma/dist/* /var/www/${pleroma_domain}/htdocs/ + pleroma_set_background_image_from_url /var/www/${pleroma_domain}/htdocs "$pleroma_domain" "$background_url" "$title" + else + cp -r $INSTALL_DIR/pleroma/dist/* $PLEROMA_DIR + pleroma_set_background_image_from_url $PLEROMA_DIR "$pleroma_domain" "$background_url" "$title" + fi - pleroma_set_background_image_from_url "$pleroma_domain" "$background_url" "$title" nginx_site=/etc/nginx/sites-available/${pleroma_domain} sed -i 's|index index.php;|index index.html;|g' $nginx_site @@ -345,7 +353,11 @@ function install_pleroma_front_end { rm -rf /root/.cache/yarn fi - chown -R www-data:www-data /var/www/${pleroma_domain}/htdocs + if [[ "$app_name" != 'pleroma' ]]; then + chown -R www-data:www-data /var/www/${pleroma_domain}/htdocs + else + chown -R pleroma:pleroma $PLEROMA_DIR + fi } function upgrade_pleroma_frontend {