2023-10-24 18:04:11 +02:00
|
|
|
on:
|
|
|
|
push:
|
|
|
|
branches:
|
2023-10-25 00:53:02 +02:00
|
|
|
- 'main'
|
2023-10-24 18:04:11 +02:00
|
|
|
|
|
|
|
jobs:
|
2023-11-30 18:26:23 +01:00
|
|
|
sync:
|
2023-10-24 18:04:11 +02:00
|
|
|
runs-on: linux_amd64
|
|
|
|
steps:
|
2023-11-30 18:26:23 +01:00
|
|
|
- name: Retrieve and sync files
|
2023-10-24 18:04:11 +02:00
|
|
|
shell: bash
|
|
|
|
run: |
|
|
|
|
git clone ${{ gitea.server_url }}/${{ gitea.repository }} dns
|
2023-11-30 17:56:32 +01:00
|
|
|
echo "Cloned sucessfully from ${{ gitea.server_url }}/${{ gitea.repository }}"
|
2023-11-30 18:30:05 +01:00
|
|
|
cd dns
|
2023-11-30 18:54:05 +01:00
|
|
|
echo "" > /var/cache/bind/.modified
|
2023-11-30 18:48:57 +01:00
|
|
|
|
2023-11-30 18:51:10 +01:00
|
|
|
if [ -z $(git diff-tree --no-commit-id --name-only -r main | grep '*.zone') ]; then
|
2023-11-30 18:48:57 +01:00
|
|
|
exit 0
|
|
|
|
fi
|
|
|
|
|
2023-11-30 18:51:10 +01:00
|
|
|
files=$(git diff-tree --no-commit-id --name-only -r main | grep '*.zone')
|
2023-11-30 17:56:32 +01:00
|
|
|
echo "Have to test $files"
|
2023-11-30 18:48:57 +01:00
|
|
|
|
2023-10-24 18:04:11 +02:00
|
|
|
for file in $files
|
|
|
|
do
|
|
|
|
domain=$(echo $file | sed "s/.zone//g")
|
2023-11-30 18:26:23 +01:00
|
|
|
/usr/sbin/named-checkzone "$domain" "$file" || echo "Error on file $file" && continue
|
|
|
|
echo "$file" >> /var/cache/bind/.modified
|
2023-10-24 18:04:11 +02:00
|
|
|
cp -f "$file" "/var/cache/bind/$file"
|
|
|
|
done
|
2023-11-30 18:26:23 +01:00
|
|
|
echo "Synced sucessfully"
|
|
|
|
|
2023-10-24 18:04:11 +02:00
|
|
|
|
|
|
|
deploiement:
|
|
|
|
runs-on: linux_amd64
|
2023-10-28 18:44:06 +02:00
|
|
|
needs: sync
|
2023-10-24 18:04:11 +02:00
|
|
|
steps:
|
|
|
|
- name: Reload bind
|
|
|
|
shell: bash
|
2023-10-25 00:35:17 +02:00
|
|
|
run: |
|
|
|
|
sudo systemctl reload bind9.service
|
2023-10-24 18:04:11 +02:00
|
|
|
- name: Check bind
|
|
|
|
shell: bash
|
|
|
|
run: |
|
|
|
|
echo Recherche de zones déployées
|
2023-11-30 18:59:22 +01:00
|
|
|
cd /var/cache/bind
|
2023-10-24 18:04:11 +02:00
|
|
|
files=$(cat /var/cache/bind/.modified)
|
2023-11-30 19:00:30 +01:00
|
|
|
|
|
|
|
if [ -z $files ]; then
|
|
|
|
exit 0
|
|
|
|
fi
|
|
|
|
|
2023-10-24 18:04:11 +02:00
|
|
|
count=$(cat /var/cache/bind/.modified | wc -l)
|
|
|
|
linecount=$(( count * 5 + 3))
|
2023-10-25 00:35:17 +02:00
|
|
|
echo "Vérification des zones $files..."
|
|
|
|
sudo grep named /var/log/syslog | tail -n $linecount | grep "reloading configuration succeeded" || exit 4
|
|
|
|
sudo grep named /var/log/syslog | tail -n $linecount | grep "reloading zones succeeded" || exit 5
|
|
|
|
sudo grep named /var/log/syslog | tail -n $linecount | grep "all zones loaded" || exit 6
|
|
|
|
sudo grep named /var/log/syslog | tail -n $linecount | grep "running" || exit 7
|
2023-10-25 00:40:10 +02:00
|
|
|
echo "Déploiement terminé."
|