Consolidate gnusocial hourly scripts

This commit is contained in:
Bob Mottram 2017-04-04 11:11:19 +01:00
parent a915812150
commit ce8696f0fa
3 changed files with 33 additions and 46 deletions

View File

@ -222,27 +222,6 @@ function gnusocial_create_database {
create_database gnusocial "$GNUSOCIAL_ADMIN_PASSWORD" $MY_USERNAME
}
function gnusocial_running_script {
# check that the daemon is running
echo '#!/bin/bash' > /etc/cron.hourly/gnusocial-daemons
echo -n 'daemon_lines=$(ps aux | grep "'>> /etc/cron.hourly/gnusocial-daemons
echo -n "${GNUSOCIAL_DOMAIN_NAME}">> /etc/cron.hourly/gnusocial-daemons
echo '/htdocs/scripts/queuedaemon.php" | grep "/var/www")' >> /etc/cron.hourly/gnusocial-daemons
echo 'if [[ $daemon_lines != *"/var/www/"* ]]; then' >> /etc/cron.hourly/gnusocial-daemons
echo " ADMIN_USER=\$(cat $COMPLETION_FILE | grep 'Admin user' | awk -F ':' '{print \$2}')" >> /etc/cron.hourly/gnusocial-daemons
echo ' MY_EMAIL_ADDRESS=$ADMIN_USER@$HOSTNAME' >> /etc/cron.hourly/gnusocial-daemons
echo ' echo "Restarting GNU Social daemons" | mail -s "GNU Social daemons not found" $MY_EMAIL_ADDRESS' >> /etc/cron.hourly/gnusocial-daemons
echo " cd /var/www/${GNUSOCIAL_DOMAIN_NAME}/htdocs" >> /etc/cron.hourly/gnusocial-daemons
echo ' scripts/startdaemons.sh' >> /etc/cron.hourly/gnusocial-daemons
echo 'fi' >> /etc/cron.hourly/gnusocial-daemons
echo 'php scripts/delete_orphan_files.php > /dev/null' >> /etc/cron.hourly/gnusocial-daemons
echo 'php scripts/clean_thumbnails.php -y > /dev/null' >> /etc/cron.hourly/gnusocial-daemons
echo 'php scripts/clean_file_table.php -y > /dev/null' >> /etc/cron.hourly/gnusocial-daemons
echo 'php scripts/upgrade.php > /dev/null' >> /etc/cron.hourly/gnusocial-daemons
chmod +x /etc/cron.hourly/gnusocial-daemons
}
function reconfigure_gnusocial {
echo -n ''
}
@ -334,9 +313,7 @@ function upgrade_gnusocial {
rm /var/www/$GNUSOCIAL_DOMAIN_NAME/htdocs/install.php
fi
function_check gnusocial_running_script
gnusocial_running_script
gnusocial_hourly_script gnusocial $GNUSOCIAL_DOMAIN_NAME
upgrade_pleroma "$GNUSOCIAL_DOMAIN_NAME" "gnusocial" "$GNUSOCIAL_BACKGROUND_IMAGE_URL" "$GNUSOCIAL_TITLE"
}
@ -492,8 +469,7 @@ function install_gnusocial_main {
return
fi
function_check gnusocial_running_script
gnusocial_running_script
gnusocial_hourly_script gnusocial $GNUSOCIAL_DOMAIN_NAME
function_check install_mariadb
install_mariadb

View File

@ -197,30 +197,12 @@ function postactiv_create_database {
}
function postactiv_running_script {
# check that the daemon is running
echo '#!/bin/bash' > /etc/cron.hourly/postactiv-daemons
echo -n 'daemon_lines=$(ps aux | grep "' >> /etc/cron.hourly/postactiv-daemons
echo -n "${POSTACTIV_DOMAIN_NAME}" >> /etc/cron.hourly/postactiv-daemons
echo '/htdocs/scripts/queuedaemon.php" | grep "/var/www")' >> /etc/cron.hourly/postactiv-daemons
echo 'if [[ $daemon_lines != *"/var/www/"* ]]; then' >> /etc/cron.hourly/postactiv-daemons
gnusocial_hourly_script postactiv $POSTACTIV_DOMAIN_NAME
echo " ADMIN_USER=\$(cat $COMPLETION_FILE | grep 'Admin user' | awk -F ':' '{print \$2}')" >> /etc/cron.hourly/postactiv-daemons
echo ' MY_EMAIL_ADDRESS=$ADMIN_USER@$HOSTNAME' >> /etc/cron.hourly/postactiv-daemons
echo ' echo "Restarting postactiv daemons" | mail -s "postactiv daemons not found" $MY_EMAIL_ADDRESS' >> /etc/cron.hourly/postactiv-daemons
echo " cd /var/www/${POSTACTIV_DOMAIN_NAME}/htdocs" >> /etc/cron.hourly/postactiv-daemons
echo ' scripts/startdaemons.sh' >> /etc/cron.hourly/postactiv-daemons
echo 'fi' >> /etc/cron.hourly/postactiv-daemons
echo "cd /var/www/${POSTACTIV_DOMAIN_NAME}/htdocs" >> /etc/cron.hourly/postactiv-daemons
# This was a hack to fix a bug in master, but may no longer be needed
echo "if ! grep -q \"//define('POSTACTIV',true);\" scripts/commandline.inc; then" >> /etc/cron.hourly/postactiv-daemons
echo " sed -i \"s|define('POSTACTIV',true);|//define('POSTACTIV',true);|g\" scripts/commandline.inc" >> /etc/cron.hourly/postactiv-daemons
echo 'fi' >> /etc/cron.hourly/postactiv-daemons
echo 'php scripts/delete_orphan_files.php > /dev/null' >> /etc/cron.hourly/postactiv-daemons
echo 'php scripts/clean_thumbnails.php -y > /dev/null' >> /etc/cron.hourly/postactiv-daemons
echo 'php scripts/clean_file_table.php -y > /dev/null' >> /etc/cron.hourly/postactiv-daemons
echo 'php scripts/upgrade.php > /dev/null' >> /etc/cron.hourly/postactiv-daemons
chmod +x /etc/cron.hourly/postactiv-daemons
}
function reconfigure_postactiv {

View File

@ -236,4 +236,33 @@ function upgrade_pleroma {
fi
}
function gnusocial_hourly_script {
gnusocial_type=$1
domain_name=$2
# check that the daemon is running
echo '#!/bin/bash' > /etc/cron.hourly/${gnusocial_type}-daemons
echo -n 'daemon_lines=$(ps aux | grep "' >> /etc/cron.hourly/${gnusocial_type}-daemons
echo -n "${domain_name}" >> /etc/cron.hourly/${gnusocial_type}-daemons
echo '/htdocs/scripts/queuedaemon.php" | grep "/var/www")' >> /etc/cron.hourly/${gnusocial_type}-daemons
echo 'if [[ $daemon_lines != *"/var/www/"* ]]; then' >> /etc/cron.hourly/${gnusocial_type}-daemons
echo " ADMIN_USER=\$(cat $COMPLETION_FILE | grep 'Admin user' | awk -F ':' '{print \$2}')" >> /etc/cron.hourly/${gnusocial_type}-daemons
echo ' MY_EMAIL_ADDRESS=$ADMIN_USER@$HOSTNAME' >> /etc/cron.hourly/${gnusocial_type}-daemons
echo -n " echo \"Restarting ${gnusocial_type} daemons\" | mail -s \"${gnusocial_type} " >> /etc/cron.hourly/${gnusocial_type}-daemons
echo 'daemons not found" $MY_EMAIL_ADDRESS' >> /etc/cron.hourly/${gnusocial_type}-daemons
echo " cd /var/www/${domain_name}/htdocs" >> /etc/cron.hourly/${gnusocial_type}-daemons
echo ' scripts/startdaemons.sh' >> /etc/cron.hourly/${gnusocial_type}-daemons
echo 'fi' >> /etc/cron.hourly/${gnusocial_type}-daemons
echo "cd /var/www/${domain_name}/htdocs" >> /etc/cron.hourly/${gnusocial_type}-daemons
echo 'php scripts/delete_orphan_files.php > /dev/null' >> /etc/cron.hourly/${gnusocial_type}-daemons
echo 'php scripts/clean_thumbnails.php -y > /dev/null' >> /etc/cron.hourly/${gnusocial_type}-daemons
echo 'php scripts/clean_file_table.php -y > /dev/null' >> /etc/cron.hourly/${gnusocial_type}-daemons
echo 'php scripts/upgrade.php > /dev/null' >> /etc/cron.hourly/${gnusocial_type}-daemons
chmod +x /etc/cron.hourly/${gnusocial_type}-daemons
}
# NOTE: deliberately there is no "exit 0"