Last active
October 1, 2015 15:53
-
-
Save DILL44/bb18e0f028cb3c8c0c41 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
mail='' | |
choix='4' | |
retardataire=0 | |
nom_photo='photo' | |
sujet='votre photo' | |
corp='vote photo grace au programme <a href="https://gist.github.com/DILL44/bb18e0f028cb3c8c0c41">photo mail</a>' | |
clear | |
ligne_separation(){ | |
echo "#######################################################" | |
} | |
install(){ | |
# test dpkg -l gphoto2 jp2a postfix | |
echo "tout est ok" | |
} | |
##################################photo | |
retardataire(){ | |
sleep $retardataire | |
} | |
prendre_photo(){ | |
compteur_photo=$((compteur_photo+1)) | |
date=`date %F_%X` | |
file="$nom_photo$date.jpg" | |
retardataire | |
gphoto2 --capture-image-and-download --filename $file | |
} | |
affiche_photo(){ | |
jp2a $file>test_image.txt | |
cat test_image.txt | |
} | |
envoyer_mail(){ | |
read -p "entrer votre mail: " mail | |
# valid_mail="^(([-a-zA-Z0-9\!#\$%\&\'*+/=?^_\`{\|}~]+|(\"([][,:;<>\&@a-zA-Z0-9\!#\$%\&\'*+/=?^_\`{\|}~-]|(\\\\[\\ \"]))+\"))\.)*([-a-zA-Z0-9\!#\$%\&\'*+/=?^_\`{\|}~]+|(\"([][,:;<>\&@a-zA-Z0-9\!#\$%\&\'*+/=?^_\`{\|}~-]|(\\\\[\\ \"]))+\"))@\w((-|\w)*\w)*\.(\w((-|\w)*\w)*\.)*\w{2,4}$" | |
# while [ $mail=~$valid_mail ] | |
# do | |
# read -p "mail non valid, entrer votre mail: " mail | |
# done | |
# echo "$corp" | mutt -a "$file" -s "$sujet" -- $mail | |
}# | |
###############################config | |
affiche_config(){ | |
echo "temps de minuterie : $retardataire" | |
echo "prefix du fichier : $nom_photo" | |
echo "sujet mail : $sujet" | |
echo "corp mail : $corp" | |
} | |
modifier_mail(){ | |
read -p "sujet du mail: " sujet | |
read -p "corp du mail: " corp | |
} | |
modifier_prefix_photo(){ | |
read -p "prefix du nom de la photo:" nom_photo | |
} | |
modifier_minuteur(){ | |
read -p "temp du minuteur: " retardataire | |
# while [ ! "$(echo $retardataire | grep "^[ [:digit:] ]*$")" || $retardataire -ge 10 ] | |
while [ ! "$(echo $retardataire | grep "^[ [:digit:] ]*$")" ] | |
do | |
read -p "mauvais temps indiqué, il doit être inferieur à 10: " retardataire | |
done | |
} | |
###############################menu | |
menu_config(){ | |
choix_conf=4 | |
while [ ! X$choix_conf == X0 ] | |
do | |
case $choix_conf in | |
"1" ) clear; modifier_minuteur ;; | |
"2" ) clear; modifier_prefix_photo ;; | |
"3" ) clear; modifier_mail ;; | |
* ) echo "choix non valide tape votre choix et entrer" | |
esac | |
ligne_separation | |
affiche_config | |
ligne_separation | |
echo "quitter : 0" | |
echo "modifier minuteur : 1" | |
echo "modifier prefix photo: 2" | |
echo "modifier le mail : 3" | |
ligne_separation | |
read -p "choix: " choix_conf | |
done | |
} | |
menu(){ | |
ligne_separation | |
affiche_config | |
ligne_separation | |
echo "quitter : 0" | |
echo "prendre une photo: 1" | |
echo "l'envoyé par mail: 2" | |
echo "configuration : 3" | |
ligne_separation | |
} | |
while [ ! X$choix == X0 ] | |
do | |
case $choix in | |
"1" ) ligne_separation; prendre_photo; clear; affiche_photo;; | |
"2" ) ligne_separation; envoyer_mail; clear; affiche_photo;; | |
"3" ) clear; affiche_config; menu_config;; | |
* ) echo "choix non valide tape votre choix et entrer" | |
esac | |
menu | |
read -p "choix: " choix | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment