Skip to content
Snippets Groups Projects
Commit ce8696f0 authored by Bob Mottram's avatar Bob Mottram
Browse files

Consolidate gnusocial hourly scripts

parent a9158121
No related branches found
No related tags found
No related merge requests found
...@@ -222,27 +222,6 @@ function gnusocial_create_database { ...@@ -222,27 +222,6 @@ function gnusocial_create_database {
create_database gnusocial "$GNUSOCIAL_ADMIN_PASSWORD" $MY_USERNAME 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 { function reconfigure_gnusocial {
echo -n '' echo -n ''
} }
...@@ -334,9 +313,7 @@ function upgrade_gnusocial { ...@@ -334,9 +313,7 @@ function upgrade_gnusocial {
rm /var/www/$GNUSOCIAL_DOMAIN_NAME/htdocs/install.php rm /var/www/$GNUSOCIAL_DOMAIN_NAME/htdocs/install.php
fi fi
function_check gnusocial_running_script gnusocial_hourly_script gnusocial $GNUSOCIAL_DOMAIN_NAME
gnusocial_running_script
upgrade_pleroma "$GNUSOCIAL_DOMAIN_NAME" "gnusocial" "$GNUSOCIAL_BACKGROUND_IMAGE_URL" "$GNUSOCIAL_TITLE" upgrade_pleroma "$GNUSOCIAL_DOMAIN_NAME" "gnusocial" "$GNUSOCIAL_BACKGROUND_IMAGE_URL" "$GNUSOCIAL_TITLE"
} }
...@@ -492,8 +469,7 @@ function install_gnusocial_main { ...@@ -492,8 +469,7 @@ function install_gnusocial_main {
return return
fi fi
function_check gnusocial_running_script gnusocial_hourly_script gnusocial $GNUSOCIAL_DOMAIN_NAME
gnusocial_running_script
function_check install_mariadb function_check install_mariadb
install_mariadb install_mariadb
......
...@@ -197,30 +197,12 @@ function postactiv_create_database { ...@@ -197,30 +197,12 @@ function postactiv_create_database {
} }
function postactiv_running_script { function postactiv_running_script {
# check that the daemon is running gnusocial_hourly_script postactiv $POSTACTIV_DOMAIN_NAME
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
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 "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 " 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 '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 { function reconfigure_postactiv {
......
...@@ -236,4 +236,33 @@ function upgrade_pleroma { ...@@ -236,4 +236,33 @@ function upgrade_pleroma {
fi 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" # NOTE: deliberately there is no "exit 0"
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment