#!/bin/sh # To run from Internet: # sudo sh -c "$(curl -s http://apps.control2net.com/apt/install-logrotate-dingo-stack)" # Check if logrotate file exists for DINGO-Stack echo "Check logrotate file..." FILE="/etc/logrotate.d/dingo-stack" if [ ! -f "$FILE" ]; then # Then download the file echo "Download logrotate file..." cd /etc/logrotate.d wget -N "http://apps.control2net.com/apt/misc/RPI/configfiles/etc/logrotate.d/dingo-stack" fi # Do some cleanup. Remove all backup files echo "Cleanup backup files..." sudo cp -p /etc/logrotate.d/dingo-stack.* /opt/GoIoT/backup 2>/dev/null sudo rm -f /etc/logrotate.d/dingo-stack.* # Check if upload script exists echo "Check upload script..." FILE="/opt/GoIoT/DinGo/bin/general/rn_upload_last_log.sh" if [ ! -f "$FILE" ]; then # Then download the file echo "Download upload script..." cd /opt/GoIoT/DinGo/bin/general wget -N "http://apps.control2net.com/apt/misc/RPI/configfiles/general/rn_upload_last_log.sh" sudo chmod +x rn_upload_last_log.sh fi # Do database update # Check if table exists. If it does, then check if records exists. If it does not, then add it. # Add hourly schedule to crontab # Check if schedule exists. If not then add it. echo "Set hourly schedule..." sudo grep -q -F 'logrotate.d/dingo-stack' /etc/crontab || sudo sed -i -e '$i \35 * * * * root logrotate /etc/logrotate.d/dingo-stack\n' /etc/crontab echo "Finished."