postactiv interactive configuration

This commit is contained in:
Bob Mottram 2017-02-22 21:14:56 +00:00
parent 35bbaca5a7
commit 54f4d95e8a
2 changed files with 71 additions and 3 deletions

View File

@ -246,7 +246,7 @@ function gnusocial_set_background_image {
trap "rm -f $data" 0 1 2 5 15
dialog --title $"GNU Social" \
--backtitle $"Freedombone Control Panel" \
--inputbox $'Set a login screen background image URL' 10 60 2>$data
--inputbox $'Set a background image URL' 10 60 2>$data
sel=$?
case $sel in
0)
@ -254,7 +254,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 "$domain_name" "$GNUSOCIAL_BACKGROUND_IMAGE_URL" "$GNUSOCIAL_TITLE") == "0" ]]; then
if [[ $(pleroma_set_background_image_from_url "$GNUSOCIAL_DOMAIN_NAME" "$GNUSOCIAL_BACKGROUND_IMAGE_URL" "$GNUSOCIAL_TITLE") == "0" ]]; then
dialog --title $"Set GNU Social login background" \
--msgbox $"The background image has been set" 6 60
fi
@ -293,7 +293,7 @@ function configure_interactive_gnusocial {
dialog --backtitle $"Freedombone Control Panel" \
--title $"GNU Social" \
--radiolist $"Choose an operation:" 12 70 3 \
1 $"Set a login screen background image" off \
1 $"Set a background image" off \
2 $"Set the title" off \
3 $"Exit" on 2> $data
sel=$?

View File

@ -225,6 +225,74 @@ function reconfigure_postactiv {
echo -n ''
}
function postactiv_set_background_image {
data=$(tempfile 2>/dev/null)
trap "rm -f $data" 0 1 2 5 15
dialog --title $"PostActiv" \
--backtitle $"Freedombone Control Panel" \
--inputbox $'Set a background image URL' 10 60 2>$data
sel=$?
case $sel in
0)
temp_background=$(<$data)
if [ ${#temp_background} -gt 0 ]; then
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") == "0" ]]; then
dialog --title $"Set PostActiv background" \
--msgbox $"The background image has been set" 6 60
fi
fi
;;
esac
}
function postactiv_set_title {
data=$(tempfile 2>/dev/null)
trap "rm -f $data" 0 1 2 5 15
dialog --title $"PostActiv" \
--backtitle $"Freedombone Control Panel" \
--inputbox $'Set a title' 10 60 2>$data
sel=$?
case $sel in
0)
new_title=$(<$data)
if [ ${#new_title} -gt 0 ]; then
POSTACTIV_TITLE="$new_title"
write_config_param "POSTACTIV_TITLE" "$POSTACTIV_TITLE"
cd /var/www/$POSTACTIV_DOMAIN_NAME/htdocs/static
sed -i "s|\"name\":.*|\"name\": \"${POSTACTIV_TITLE}\",|g" config.json
dialog --title $"Set PostActiv title" \
--msgbox $"The title has been set" 6 60
fi
;;
esac
}
function configure_interactive_postactiv {
while true
do
data=$(tempfile 2>/dev/null)
trap "rm -f $data" 0 1 2 5 15
dialog --backtitle $"Freedombone Control Panel" \
--title $"PostActiv" \
--radiolist $"Choose an operation:" 12 70 3 \
1 $"Set a background image" off \
2 $"Set the title" off \
3 $"Exit" on 2> $data
sel=$?
case $sel in
1) return;;
255) return;;
esac
case $(cat $data) in
1) postactiv_set_background_image;;
2) postactiv_set_title;;
3) break;;
esac
done
}
function upgrade_postactiv {
if grep -q "postactiv domain" $COMPLETION_FILE; then
POSTACTIV_DOMAIN_NAME=$(get_completion_param "postactiv domain")