forked from vbkunin/itop-docker
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
logrotate, updated setup-itop-cron.sh
- Loading branch information
Showing
3 changed files
with
30 additions
and
15 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,13 +3,14 @@ MAINTAINER Vladimir Kunin <[email protected]> | |
|
||
# Install additional packages | ||
RUN apt-get update && \ | ||
apt-get -y install php5-mcrypt php5-gd php5-ldap php5-cli php-soap php5-json graphviz wget unzip | ||
RUN php5enmod mcrypt ldap gd | ||
apt-get -y install php5-mcrypt php5-gd php5-ldap php5-cli php-soap php5-json php5-imap graphviz wget unzip | ||
RUN php5enmod mcrypt ldap gd imap | ||
|
||
# Add cron config and scripts | ||
ADD supervisord-cron.conf /etc/supervisor/conf.d/supervisord-cron.conf | ||
ADD start-cron.sh /start-cron.sh | ||
ADD setup-itop-cron.sh /setup-itop-cron.sh | ||
ADD itop-cron.logrotate /etc/logrotate.d/itop-cron | ||
|
||
# Add update Russian translations script | ||
ADD update-russian-translations.sh /update-russian-translations.sh | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
/var/log/itop-cron.log { | ||
rotate 10 | ||
size=16M | ||
compress | ||
missingok | ||
notifempty | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,26 +1,33 @@ | ||
#!/bin/bash | ||
USER=$1 | ||
PWD=$2 | ||
LOG_DIR=$3 | ||
LOG_FILE=$4 | ||
LOG_FILE=$3 | ||
|
||
if [[ -z $USER ]] || [[ -z $PWD ]]; then | ||
echo "Specify username and password of iTop cron profile as the first and the second argument." | ||
echo "Usage: /setup-itop-cron.sh username password [log_folder [log_file]]" | ||
echo "Specify username and password of iTop cron profile as the first and the second argument. Default log file is /var/log/itop-cron.log." | ||
echo "Usage: /setup-itop-cron.sh <username> <password> [--without-logs | <log_file>]" | ||
exit 1 | ||
fi | ||
|
||
if [[ -z $LOG_DIR ]]; then | ||
LOG_DIR=/dev/null | ||
LOG_FILE='' | ||
elif [[ ! -d $LOG_DIR ]]; then | ||
echo "Log folder $LOG_DIR not found." | ||
exit 1 | ||
if [[ $LOG_FILE == '--without-logs' ]]; then | ||
LOG_FILE=/dev/null | ||
elif [[ -z $LOG_FILE ]]; then | ||
LOG_FILE=itop-cron.log | ||
LOG_FILE=/var/log/itop-cron.log | ||
elif [[ -z ${LOG_FILE##*/} ]]; then | ||
echo "It looks like a directory name: $LOG_FILE. Did you forget to specify file name itself?" | ||
exit 1 | ||
elif [[ ! -d $(dirname $LOG_FILE) ]]; then | ||
echo "Log directory $(dirname $LOG_FILE)/ not found. Is it exists?" | ||
exit 1 | ||
fi | ||
|
||
echo "*/5 * * * * root /usr/bin/php /app/webservices/cron.php --auth_user=$USER --auth_pwd=$PWD >> $LOG_DIR$LOG_FILE 2>&1" > /etc/cron.d/itop | ||
echo "Following job was added to cron:" | ||
echo "*/5 * * * * root /usr/bin/php /app/webservices/cron.php --auth_user=$USER --auth_pwd=$PWD >> $LOG_FILE 2>&1" > /etc/cron.d/itop | ||
echo -e "\nThe following job has been added to cron (/etc/cron.d/itop):" | ||
cat /etc/cron.d/itop | ||
|
||
if [[ $LOG_FILE != /dev/null ]]; then | ||
sed -i -e "1s:^.*\( {\):$LOG_FILE\1:" /etc/logrotate.d/itop-cron | ||
echo -e "\nThe logrotate config (/etc/logrotate.d/itop-cron):" | ||
cat /etc/logrotate.d/itop-cron | ||
fi | ||
echo -e "\nBye!" |