diff --git a/pica-wekan/policy.sh b/pica-wekan/policy.sh index e7b853806bd388bf80b79c25fab189aa18ad9b53..bf7405e4f3938d1f59682bc1399159b5cc9467fc 100755 --- a/pica-wekan/policy.sh +++ b/pica-wekan/policy.sh @@ -2,17 +2,21 @@ . ids.sh # contient $username et $password pour authentification +# Paramètres +boardExpirationDurationMonth=12 +deadlineTimeStamp=$(date -d "-"$boardExpirationDurationMonth"months" +%s) + queryPica=$(curl -s https://wekan.test.picasoft.net/users/login -d 'username='"$username"'&password='"$password"'') token=$(echo $queryPica | jq -r .token) -expirationDate=$(echo $queryPica | jq -r .tokenExpires) +tokenExpirationDate=$(echo $queryPica | jq -r .tokenExpires) # récupération des ids de tous les boards publics idBoards=$(curl -s -X GET https://wekan.test.picasoft.net/api/boards \ -H 'Accept: application/json' \ -H 'Authorization: Bearer '"$token"'' | jq -r '.[]._id') -# affiche la dernière date de modification de tous les boards publics +# affiche les boards publics qui n'ont pas été modifié depuis for idBoard in $idBoards do board=$(curl -s -X GET https://wekan.test.picasoft.net/api/boards/$idBoard \ @@ -20,11 +24,15 @@ do -H 'Authorization: Bearer '"$token"'') lastModificationDate=$(echo $board | jq -r '.modifiedAt') - creationDate=$(echo $board | jq -r '.createdAt') + if [ $lastModificationDate = null ] then - echo "Board" $idBoard ":" $creationDate - else - echo "Board" $idBoard ":" $lastModificationDate + lastModificationDate=$(echo $board | jq -r '.createdAt') + fi + + if [ $(($deadlineTimeStamp-$(date -d $lastModificationDate +%s))) -gt 0 ] + then + echo "deadline plus récente que date de modif : board "$idBoard" à supprimer" + # board à supprimer fi done