Interactive config for static blog
This commit is contained in:
parent
5cc277740b
commit
4421c64357
|
@ -33,20 +33,84 @@ VARIANTS=''
|
|||
IN_DEFAULT_INSTALL=0
|
||||
SHOW_ON_ABOUT=0
|
||||
|
||||
PELICAN_BLOG_DOMAIN=
|
||||
PELICAN_BLOG_CODE=
|
||||
|
||||
STATIC_BLOG_INSTALL_DIR=/etc/staticblog
|
||||
PELICAN_THEMES_REPO="https://github.com/getpelican/pelican-themes"
|
||||
PELICAN_PLUGINS_REPO="https://github.com/getpelican/pelican-plugins"
|
||||
DEFAULT_BLOG_TITLE=$"Freedombone Blog"
|
||||
|
||||
pelican_variables=(MY_USERNAME
|
||||
STATIC_BLOG_DOMAIN)
|
||||
ONION_ONLY
|
||||
PELICAN_BLOG_DOMAIN
|
||||
PELICAN_BLOG_CODE)
|
||||
|
||||
function configure_interactive_pelican {
|
||||
echo -n ''
|
||||
}
|
||||
|
||||
function install_interactive_pelican {
|
||||
echo -n ''
|
||||
if [ ! $ONION_ONLY ]; then
|
||||
ONION_ONLY='no'
|
||||
fi
|
||||
|
||||
if [[ $ONION_ONLY != "no" ]]; then
|
||||
PELICAN_BLOG_DOMAIN='pelican.local'
|
||||
else
|
||||
PELICAN_DETAILS_COMPLETE=
|
||||
while [ ! $PELICAN_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 $"Pelican Blog Configuration" \
|
||||
--form $"\nPlease enter your blog details.\n\nIMPORTANT: This should be a domain name which is supported by Let's Encrypt:" 14 65 2 \
|
||||
$"Domain:" 1 1 "$(grep 'PELICAN_BLOG_DOMAIN' temp.cfg | awk -F '=' '{print $2}')" 1 25 33 40 \
|
||||
$"Code:" 2 1 "$(grep 'PELICAN_BLOG_CODE' temp.cfg | awk -F '=' '{print $2}')" 2 25 33 255 \
|
||||
2> $data
|
||||
else
|
||||
dialog --backtitle $"Freedombone Configuration" \
|
||||
--title $"Pelican Blog Configuration" \
|
||||
--form $"\nPlease enter your GNU Social details. The background image URL can be left blank.\n\nIMPORTANT: This should be a domain name which is supported by Let's Encrypt:" 14 65 2 \
|
||||
$"Domain:" 1 1 "$(grep 'PELICAN_BLOG_DOMAIN' temp.cfg | awk -F '=' '{print $2}')" 1 25 33 40 \
|
||||
2> $data
|
||||
fi
|
||||
sel=$?
|
||||
case $sel in
|
||||
1) exit 1;;
|
||||
255) exit 1;;
|
||||
esac
|
||||
PELICAN_BLOG_DOMAIN=$(cat $data | sed -n 1p)
|
||||
if [ $PELICAN_BLOG_DOMAIN ]; then
|
||||
if [[ $PELICAN_BLOG_DOMAIN == "$HUBZILLA_DOMAIN_NAME" ]]; then
|
||||
PELICAN_BLOG_DOMAIN=""
|
||||
fi
|
||||
TEST_DOMAIN_NAME=$PELICAN_BLOG_DOMAIN
|
||||
validate_domain_name
|
||||
if [[ $TEST_DOMAIN_NAME != $PELICAN_BLOG_DOMAIN ]]; then
|
||||
PELICAN_BLOG_DOMAIN=
|
||||
dialog --title $"Domain name validation" --msgbox "$TEST_DOMAIN_NAME" 15 50
|
||||
else
|
||||
if [[ $DDNS_PROVIDER == "default@freedns.afraid.org" ]]; then
|
||||
PELICAN_BLOG_CODE=$(cat $data | sed -n 2p)
|
||||
validate_freedns_code "$PELICAN_BLOG_CODE"
|
||||
if [ ! $VALID_CODE ]; then
|
||||
PELICAN_BLOG_DOMAIN=
|
||||
fi
|
||||
fi
|
||||
fi
|
||||
fi
|
||||
if [ $PELICAN_BLOG_DOMAIN ]; then
|
||||
PELICAN_DETAILS_COMPLETE="yes"
|
||||
fi
|
||||
done
|
||||
|
||||
# save the results in the config file
|
||||
write_config_param "PELICAN_BLOG_CODE" "$PELICAN_BLOG_CODE"
|
||||
fi
|
||||
write_config_param "PELICAN_BLOG_DOMAIN" "$PELICAN_BLOG_DOMAIN"
|
||||
APP_INSTALLED=1
|
||||
}
|
||||
|
||||
|
@ -75,11 +139,11 @@ function restore_remote_pelican {
|
|||
}
|
||||
|
||||
function remove_pelican {
|
||||
if [ -d /var/www/$STATIC_BLOG_DOMAIN/htdocs ]; then
|
||||
rm -rf /var/www/$STATIC_BLOG_DOMAIN/htdocs
|
||||
if [ -d /var/www/$PELICAN_BLOG_DOMAIN/htdocs ]; then
|
||||
rm -rf /var/www/$PELICAN_BLOG_DOMAIN/htdocs
|
||||
fi
|
||||
pip uninstall pelican
|
||||
remove_certs $STATIC_BLOG_DOMAIN
|
||||
remove_certs $PELICAN_BLOG_DOMAIN
|
||||
}
|
||||
|
||||
function create_pelican_conf {
|
||||
|
@ -319,7 +383,7 @@ function install_pelican {
|
|||
pip install pelican
|
||||
|
||||
STATIC_BLOG_INSTALL_DIR=/etc/blog
|
||||
STATIC_BLOG_PATH=/var/www/$STATIC_BLOG_DOMAIN/htdocs
|
||||
STATIC_BLOG_PATH=/var/www/$PELICAN_BLOG_DOMAIN/htdocs
|
||||
|
||||
if [ ! -d $STATIC_BLOG_INSTALL_DIR ]; then
|
||||
mkdir -p $STATIC_BLOG_INSTALL_DIR
|
||||
|
|
Loading…
Reference in New Issue