commit 03873b8182a3ba43d32b7084d58d4e6569efbc44 Author: Alexandr Antonov Date: Wed Mar 24 13:02:30 2021 +0300 Init for redmine diff --git a/check.sh b/check.sh new file mode 100644 index 0000000..9642797 --- /dev/null +++ b/check.sh @@ -0,0 +1,10 @@ +#!/bin/bash + + +echo "select id,login from users where auth_source_id=2 and status=1 and id not in (select user_id from groups_users where group_id=19);" | mysql -s redmine | while read a; do +ID=$(echo $a | cut -f 1 -d\ ) +LOGIN=$(echo $a | cut -f 2 -d\ ) +echo "insert into groups_users $ID,19;" +done + + diff --git a/procmail.sh b/procmail.sh new file mode 100755 index 0000000..4b1cb30 --- /dev/null +++ b/procmail.sh @@ -0,0 +1,9 @@ +#!/bin/bash +mail=`cat` +b=$(echo "${mail}" | formail -X Subject | xargs | ~/bin/parse.pl ) +#echo $b +if [ "$b" == "NULL" ]; then + rake redmine:email:read RAILS_ENV="production" project=foo tracker=bug ;fi + echo IMPORT NEW; exit 0; fi +if [ "$b" == "ok" ]; then echo IMPORT ANSWER; exit 0; fi +if [ "$b" == "fail" ]; then exit 0; fi diff --git a/redmine_logs.sh b/redmine_logs.sh new file mode 100755 index 0000000..4ad2c83 --- /dev/null +++ b/redmine_logs.sh @@ -0,0 +1,4 @@ +#!/bin/bash +journalctl -f | while read a; do message=$(echo "$a" | grep error | sed 's/"//g' | sed "s/'//g"); +if [[ ! -z "$message" ]]; then /root/bin/tg.sh "$message" 72278815;/root/bin/tg.sh "$message" 476184487;fi; +done >/dev/null 2>/dev/null diff --git a/sql_dump b/sql_dump new file mode 100755 index 0000000..30e6dc8 --- /dev/null +++ b/sql_dump @@ -0,0 +1,13 @@ +#!/bin/bash +DATE=$(date "+%u") +BACKUP=/backup/sql/ +NAME=$(date "+%F_%T") +#echo $NAME +#find $BACKUP -type f -mtime +15 -name "*.bz2" | while read a; do mv $a ../diff/; done +find $BACKUP/1 $BACKUP/2 $BACKUP/3 $BACKUP/4 $BACKUP/5 $BACKUP/6 $BACKUP/7 -type f -mtime +7 -name "*.bz2" | while read a; do rm $a; done + +mkdir -p $BACKUP/$DATE +/usr/bin/mysqldump --single-transaction -f --databases redmine --opt >$BACKUP/$DATE/$NAME.sql +bzip2 -9 $BACKUP/$DATE/$NAME.sql +rm "$BACKUP/last" +ln -s $BACKUP/$DATE/$NAME.sql.bz2 $BACKUP/last \ No newline at end of file diff --git a/tg.sh b/tg.sh new file mode 100755 index 0000000..bcda6e2 --- /dev/null +++ b/tg.sh @@ -0,0 +1,23 @@ +#!/bin/bash + +echo $0 $1 $2 >>/tmp/tgargs + +if [ -z "$1" ] || [ -z "$2" ]; then exit +fi + + +message=$( echo "$1" | sed 's/"//g' | sed "s/'//g") +apiToken="373934223:AAHOML90vOtbSCWmCmxPJTBjljoY0IeZ2k0" +chatId="$2"; + + +send() { +#echo "curl -X POST https://api.telegram.org/bot$apiToken/sendMessage -d text=\"$message\" -d chat_id=$chatId" + +curl -X POST https://api.telegram.org/bot$apiToken/sendMessage -d text="$message" -d chat_id=$chatId +} + +# +if [[ ! -z "$message" ]]; then + send +fi