diff --git a/pica-wekan-scripts/ids_example.sh b/pica-wekan-scripts/ids_example.sh index a644277587a671de7b2fbb097d9b02f4c9909b52..5fa2ccab1b3f8fe04ea8eef98014313881bff1dc 100644 --- a/pica-wekan-scripts/ids_example.sh +++ b/pica-wekan-scripts/ids_example.sh @@ -1,4 +1,4 @@ -#!/bin/bash +#!/bin/sh username="username" password="password" diff --git a/pica-wekan-scripts/policy.sh b/pica-wekan-scripts/policy.sh index 774a7cef06f03994bdbd371e30e0111afbe8b172..52e48f1384942e603e4fbcf7c0c9472b8b86733d 100755 --- a/pica-wekan-scripts/policy.sh +++ b/pica-wekan-scripts/policy.sh @@ -1,15 +1,13 @@ -#!/bin/bash +#!/bin/sh -. ids.sh # contient $username et $password pour authentification - -boardsToDelete[init]=false +. ./ids.sh # contient $username et $password pour authentification # Paramètres -boardExpirationDurationYears=0 # années -boardExpirationDurationMonths=12 # mois -boardExpirationDurationDays=0 # jours -url=https://wekan.test.picasoft.net +boardExpirationDurationYears=${boardExpirationDurationYears-0} # années +boardExpirationDurationMonths=${boardExpirationDurationMonths-12} # mois +boardExpirationDurationDays=${boardExpirationDurationDays-0} # jours +url=${url-"https://wekan.test.picasoft.net"} # Deadline = somme des durées du dessus deadlineTimeStamp=$(date -d "-"$boardExpirationDurationYears"years-"$boardExpirationDurationMonths"months-"$boardExpirationDurationDays"days" +%s) delete=false @@ -17,6 +15,7 @@ while getopts "d" option do delete=true done +boardsToDelete="" # Récupération du token de connexion queryPica=$(curl -s $url/users/login -d 'username='"$username"'&password='"$password"'') @@ -60,12 +59,12 @@ do echo "Suppresion du board "$boardTitle" (_id "$userBoard", modifié le "$lastModificationDate")" # Suppression du board si trop ancien - curl -X DELETE https://wekan.test.picasoft.net/api/boards/$userBoard \ - -H 'Authorization: Bearer '"$token"'' - elif [ ${boardsToDelete[$userBoard]} = false ] + # curl -X DELETE https://wekan.test.picasoft.net/api/boards/$userBoard \ + # -H 'Authorization: Bearer '"$token"'' + elif [ $(echo $boardsToDelete | grep -c $userBoard) -eq 0 ] then - boardsToDelete[$userBoard]=true echo "Board "$boardTitle" trop ancien (modifié le "$lastModificationDate")" + boardsToDelete=$boardsToDelete$userBoard fi fi done diff --git a/pica-wekan-scripts/run.sh b/pica-wekan-scripts/run.sh index bed27861d33836d5ebe18fa26c8e3ad7cc75950d..64c53e15d66e6f851a00bb6db1411bc3b561a786 100755 --- a/pica-wekan-scripts/run.sh +++ b/pica-wekan-scripts/run.sh @@ -1,7 +1,7 @@ #!/bin/bash -if [$DRYRUN -eq 0] +if [ $DRYRUN -eq 0 ] then ./policy.sh -d else