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