ajout de l'API pour envoi de...
|
1 |
#!/bin/bash |
2 | ||
3 |
basename=$(basename $0) |
|
4 |
dirname=$(dirname $0) |
|
5 | ||
6 |
for dir in $dirname /usr/local/share/$basename $HOME/.config/$basename; do |
|
7 |
test -r $dir/$basename.conf && source $dir/$basename.conf |
|
8 |
done |
|
9 |
test -n "$ID" -a -n "$PASS" -a -n "$1" || exit 1 |
|
10 | ||
11 |
HSUP=${HSUP:-22} |
|
12 |
HINF=${HINF:-9} |
|
13 | ||
14 |
urlapi="https://smsapi.free-mobile.fr/sendmsg" |
|
15 |
msg="msg=$1" # $1 contient le message en entier |
|
16 |
PRIO="${PRIO:-$2}" # $PRIO ou $2 non vide = envoi même dans les heures interdites |
|
17 |
PASS="pass=$PASS" |
|
18 |
ID="user=$ID" |
|
19 |
hour=$(date +%H) |
|
20 | ||
21 |
if test \( $hour -gt $HSUP -o $hour -lt $HINF \) -a -x /usr/bin/at -a -z "$PRIO"; then |
|
22 |
msg="${msg}%0a(message retardé depuis le $(date '+%d %B %H:%M'))" |
|
23 |
echo "curl --silent --insecure --get $urlapi --data \"$msg\" --data \"$PASS\" --data \"$ID\"" | at -M $HINF:$(printf "%.2d" $((RANDOM % (24 - $HSUP + $HINF) ))) |
|
24 |
else |
|
25 |
curl --silent --insecure --get $urlapi --data "$msg" --data "$PASS" --data "$ID" |
|
26 |
fi |