Init for redmine

This commit is contained in:
Alexandr Antonov 2021-03-24 13:02:30 +03:00
commit 03873b8182
5 changed files with 59 additions and 0 deletions

10
check.sh Normal file
View File

@ -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

9
procmail.sh Executable file
View File

@ -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

4
redmine_logs.sh Executable file
View File

@ -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

13
sql_dump Executable file
View File

@ -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

23
tg.sh Executable file
View File

@ -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