Add armadillo UI

This commit is contained in:
Bob Mottram 2017-05-07 18:19:45 +01:00
parent 368fd5b8d2
commit ca08ef487d
3 changed files with 198 additions and 57 deletions

View File

@ -311,14 +311,15 @@ function configure_interactive_gnusocial {
trap "rm -f $data" 0 1 2 5 15
dialog --backtitle $"Freedombone Control Panel" \
--title $"GNU Social" \
--radiolist $"Choose an operation:" 16 70 7 \
--radiolist $"Choose an operation:" 17 70 8 \
1 $"Set a background image" off \
2 $"Set the title" off \
3 $"Set post expiry period (currently $GNUSOCIAL_EXPIRE_MONTHS months)" off \
4 $"Select Qvitter user interface" off \
5 $"Select Pleroma user interface" off \
6 $"Select Classic user interface" off \
7 $"Exit" on 2> $data
7 $"Select Armadillo user interface" off \
8 $"Exit" on 2> $data
sel=$?
case $sel in
1) return;;
@ -331,7 +332,8 @@ function configure_interactive_gnusocial {
4) gnusocial_use_qvitter gnusocial;;
5) gnusocial_use_pleroma gnusocial;;
6) gnusocial_use_classic gnusocial;;
7) break;;
7) gnusocial_use_armadillo gnusocial;;
8) break;;
esac
done
}

View File

@ -313,14 +313,15 @@ function configure_interactive_postactiv {
trap "rm -f $data" 0 1 2 5 15
dialog --backtitle $"Freedombone Control Panel" \
--title $"PostActiv" \
--radiolist $"Choose an operation:" 16 70 7 \
--radiolist $"Choose an operation:" 17 70 8 \
1 $"Set a background image" off \
2 $"Set the title" off \
3 $"Set post expiry period (currently $POSTACTIV_EXPIRE_MONTHS months)" off \
4 $"Select Qvitter user interface" off \
5 $"Select Pleroma user interface" off \
6 $"Select Classic user interface" off \
7 $"Exit" on 2> $data
7 $"Select Armadillo user interface" off \
8 $"Exit" on 2> $data
sel=$?
case $sel in
1) return;;
@ -333,7 +334,8 @@ function configure_interactive_postactiv {
4) gnusocial_use_qvitter postactiv;;
5) gnusocial_use_pleroma postactiv;;
6) gnusocial_use_classic postactiv;;
7) break;;
7) gnusocial_use_armadillo postactiv;;
8) break;;
esac
done
}
@ -789,6 +791,8 @@ function install_postactiv {
#function_check install_nodejs
#install_nodejs pleroma-postactiv
install_armadillo_front_end "postactiv" "$POSTACTIV_DOMAIN_NAME" "$POSTACTIV_BACKGROUND_IMAGE_URL"
# Currently Pleroma won't install on ARM systems
# because it uses node-sass which doesn't support ARM
if [[ "$(arch)" == "arm"* ]]; then

View File

@ -34,6 +34,24 @@ QVITTER_THEME_COMMIT='a7f82628402db3a7579bb9b2877da3c5737da77b'
PLEROMA_REPO="https://gitgud.io/lambadalambda/pleroma-fe"
PLEROMA_COMMIT='1f8d30386388f8b91aa84fdbd7861e588aa0d935'
ARMADILLO_REPO="https://git.postactiv.com/maiya/Armadillo"
ARMADILLO_COMMIT='ec3938a678f373156c4cbf37926c9a5ab68222c4'
function qvitter_update_background {
domain_name="$1"
ext=$2
if [ -d /var/www/${domain_name}/htdocs/local/plugins/Qvitter/img ]; then
cp bg_custom.${ext} /var/www/${domain_name}/htdocs/local/plugins/Qvitter/img
if ! grep -q "bg_custom.${ext}" /var/www/${domain_name}/htdocs/config.php; then
if grep -q 'sitebackground' /var/www/${domain_name}/htdocs/config.php; then
sed -i '/sitebackground/d' /var/www/${domain_name}/htdocs/config.php
fi
echo "\$config['site']['qvitter']['sitebackground'] = 'img/bg_custom.${ext}';" >> /var/www/${domain_name}/htdocs/config.php
fi
fi
}
function pleroma_set_background_image_from_url {
domain_name="$1"
url="$2"
@ -58,61 +76,31 @@ function pleroma_set_background_image_from_url {
fi
if [ ${#ext} -gt 0 ]; then
cd /var/www/${domain_name}/htdocs
# remove any existing image
if [ -f bg_custom.${ext} ]; then
rm bg_custom.${ext}
fi
# get the new image
wget "$url" -O bg_custom.${ext}
if [ ! -f bg_custom.${ext} ]; then
echo "$url"
echo $'Custom background image for pleroma could not be downloaded'
echo "1"
return
fi
if [ -d /var/www/${domain_name}/htdocs/static ]; then
cd /var/www/${domain_name}/htdocs/static
# remove any existing image
if [ -f bg_custom.${ext} ]; then
rm bg_custom.${ext}
fi
# get the new image
wget "$url" -O bg_custom.${ext}
if [ ! -f bg_custom.${ext} ]; then
echo "$url"
echo $'Custom background image for pleroma could not be downloaded'
echo "1"
return
fi
cp ../bg_custom.${ext} bg_custom.${ext}
sed -i "s|\"background\":.*|\"background\": \"/static/bg_custom.${ext}\",|g" config.json
# update the qvitter background
if [ -d /var/www/${domain_name}/htdocs/local/plugins/Qvitter/img ]; then
cp bg_custom.${ext} /var/www/${domain_name}/htdocs/local/plugins/Qvitter/img
if ! grep -q "bg_custom.${ext}" /var/www/${domain_name}/htdocs/config.php; then
if grep -q 'sitebackground' /var/www/${domain_name}/htdocs/config.php; then
sed -i '/sitebackground/d' /var/www/${domain_name}/htdocs/config.php
fi
echo "\$config['site']['qvitter']['sitebackground'] = 'img/bg_custom.${ext}';" >> /var/www/${domain_name}/htdocs/config.php
fi
fi
else
# qvitter background
if [ -d /var/www/${domain_name}/htdocs/local/plugins/Qvitter/img ]; then
cd /var/www/${domain_name}/htdocs/local/plugins/Qvitter/img
# remove any existing image
if [ -f bg_custom.${ext} ]; then
rm bg_custom.${ext}
fi
# get the new image
wget "$url" -O bg_custom.${ext}
if [ ! -f bg_custom.${ext} ]; then
echo "$url"
echo $'Custom background image for Qvitter could not be downloaded'
echo "3"
return
fi
if ! grep -q "bg_custom.${ext}" /var/www/${domain_name}/htdocs/config.php; then
if grep -q 'sitebackground' /var/www/${domain_name}/htdocs/config.php; then
sed -i '/sitebackground/d' /var/www/${domain_name}/htdocs/config.php
fi
echo "\$config['site']['qvitter']['sitebackground'] = 'img/bg_custom.${ext}';" >> /var/www/${domain_name}/htdocs/config.php
fi
fi
fi
qvitter_update_background ${domain_name} ${ext}
rm bg_custom.${ext}
else
echo "2"
return
@ -137,6 +125,62 @@ function pleroma_set_background_image_from_url {
echo "0"
}
function armadillo_set_background_image_from_url {
domain_name="$1"
url="$2"
if [ ${#domain_name} -eq 0 ]; then
echo "1"
return
fi
ext=
if [ ${#url} -gt 0 ]; then
if [[ "$url" == *".jpeg" || "$url" == *".jpg" ]]; then
ext="jpg"
fi
if [[ "$url" == *".png" ]]; then
ext="png"
fi
if [[ "$url" == *".gif" ]]; then
ext="gif"
fi
fi
if [ ${#ext} -gt 0 ]; then
cd /var/www/${domain_name}/htdocs
# remove any existing image
if [ -f bg_custom.${ext} ]; then
rm bg_custom.${ext}
fi
# get the new image
wget "$url" -O bg_custom.${ext}
if [ ! -f bg_custom.${ext} ]; then
echo "$url"
echo $'Custom background image for armadillo could not be downloaded'
echo "1"
return
fi
if [ -d /var/www/${domain_name}/htdocs/armadillo ]; then
cd /var/www/${domain_name}/htdocs/armadillo
cp ../bg_custom.${ext} media/img/bg_custom.${ext}
sed -i "s|\"background\":.*|\"background\": \"armadillo/media/img/background.jpeg\"," config.json
fi
qvitter_update_background ${domain_name} ${ext}
rm bg_custom.${ext}
else
echo "2"
return
fi
echo "0"
}
function install_qvitter {
domain_name=$1
app_name=$2
@ -238,6 +282,43 @@ function install_gnusocial_default_background {
fi
}
function install_armadillo_front_end {
app_name="$1"
armadillo_domain="$2"
background_url="$3"
if [ ! -d $INSTALL_DIR/armadillo ]; then
function_check git_clone
git_clone $ARMADILLO_REPO $INSTALL_DIR/armadillo
if [ ! -d $INSTALL_DIR/armadillo ]; then
echo $'Unable to clone armadillo repo'
exit 35722
fi
fi
cd $INSTALL_DIR/armadillo
git checkout $ARMADILLO_COMMIT -b $ARMADILLO_COMMIT
set_completion_param "${app_name} armadillo commit" "$ARMADILLO_COMMIT"
cp armadillo/config.json.example armadillo/config.json
sed -i "s|\"server\".*|\"server\": \"${armadillo_domain}\",|g" armadillo/config.json
cp -r $INSTALL_DIR/armadillo/armadillo /var/www/${armadillo_domain}/htdocs/
cp $INSTALL_DIR/armadillo/armadillo.html /var/www/${armadillo_domain}/htdocs/index.html
cp $INSTALL_DIR/armadillo/dash.html /var/www/${armadillo_domain}/htdocs/dash.html
armadillo_set_background_image_from_url "$armadillo_domain" "$background_url"
nginx_site=/etc/nginx/sites-available/${armadillo_domain}
sed -i 's|index index.php;|index index.html;|g' $nginx_site
if [ -f /var/www/${armadillo_domain}/htdocs/index.php ]; then
mv /var/www/${armadillo_domain}/htdocs/index.php /var/www/${armadillo_domain}/htdocs/index_qvitter.php
fi
sed -i 's|index.php|index_qvitter.php|g' $nginx_site
chown -R www-data:www-data /var/www/${armadillo_domain}/htdocs
}
function install_pleroma_front_end {
app_name="$1"
pleroma_domain="$2"
@ -344,6 +425,27 @@ function upgrade_pleroma {
fi
}
function upgrade_armadillo {
domain_name="$1"
app_name="$2"
background_url="$3"
if [ -d $INSTALL_DIR/armadillo ]; then
set_repo_commit $INSTALL_DIR/armadillo "${app_name} armadillo commit" "$ARMADILLO_COMMIT" $ARMADILLO_REPO
cd $INSTALL_DIR/armadillo
if [ -f $INSTALL_DIR/armadillo/armadillo/config.json ]; then
rm $INSTALL_DIR/armadillo/armadillo/config.json
fi
cp -r $INSTALL_DIR/armadillo/armadillo /var/www/${armadillo_domain}/htdocs/
cp $INSTALL_DIR/armadillo/armadillo.html /var/www/${armadillo_domain}/htdocs/index.html
cp $INSTALL_DIR/armadillo/dash.html /var/www/${armadillo_domain}/htdocs/dash.html
chown -R www-data:www-data /var/www/${domain_name}/htdocs
else
install_armadillo_front_end "${app_name}" "${domain_name}" "${background_url}"
fi
}
function gnusocial_hourly_script {
gnusocial_type=$1
domain_name=$2
@ -711,6 +813,39 @@ function gnusocial_use_pleroma {
sed -i "s|// addPlugin('Qvitter')|addPlugin('Qvitter')|g" /var/www/$domain_name/htdocs/config.php
fi
cp $INSTALL_DIR/pleroma/dist/index.html /var/www/${domain_name}/htdocs/index.html
systemctl restart nginx
}
function gnusocial_use_armadillo {
database_name=$1
domain_name=$(get_completion_param "$database_name domain")
if [ ! -d /var/www/$domain_name/htdocs/armadillo ]; then
return
fi
if [ -f /var/www/$domain_name/htdocs/index.php ]; then
mv /var/www/$domain_name/htdocs/index.php /var/www/$domain_name/htdocs/index_qvitter.php
fi
if [ -f /etc/nginx/sites-available/$domain_name ]; then
sed -i 's|index.php|index_qvitter.php|g' /etc/nginx/sites-available/$domain_name
sed -i 's|index index_qvitter.php|index index.html|g' /etc/nginx/sites-available/$domain_name
fi
if grep -q "//addPlugin('Qvitter')" /var/www/$domain_name/htdocs/config.php; then
sed -i "s|//addPlugin('Qvitter')|addPlugin('Qvitter')|g" /var/www/$domain_name/htdocs/config.php
fi
if grep -q "// addPlugin('Qvitter')" /var/www/$domain_name/htdocs/config.php; then
sed -i "s|// addPlugin('Qvitter')|addPlugin('Qvitter')|g" /var/www/$domain_name/htdocs/config.php
fi
cp $INSTALL_DIR/armadillo/armadillo.html /var/www/${domain_name}/htdocs/index.html
cp $INSTALL_DIR/armadillo/dash.html /var/www/${domain_name}/htdocs/dash.html
systemctl restart nginx
}