2015-05-23 16:15:00 +00:00
|
|
|
#!/bin/bash
|
|
|
|
|
2015-05-24 20:20:44 +00:00
|
|
|
path=$(readlink -f $(dirname $0));
|
|
|
|
config_file="$path/.config";
|
|
|
|
|
|
|
|
editor_line=`cat $config_file | grep -E '^text_editor +=' | cut -d= -f2 | tr -d "[[:space:]]" | tr -d "\n"`;
|
|
|
|
editor="nano";
|
|
|
|
|
|
|
|
# si l'editeur est specifie on l enregistre sinon par defaut on met nano
|
|
|
|
if [ -z $editor_line ] || [ $editor_line = "" ]
|
|
|
|
then
|
|
|
|
echo "text_editor = nano" >> $config_file;
|
|
|
|
else
|
|
|
|
editor=$editor_line;
|
|
|
|
fi;
|
|
|
|
|
2015-05-23 20:21:42 +00:00
|
|
|
|
2015-05-24 16:02:06 +00:00
|
|
|
if [ $# -ge 1 ]
|
|
|
|
then # si 1 paramètre au moins
|
|
|
|
|
2015-05-24 20:20:44 +00:00
|
|
|
if [ $# -ge 2 ]
|
|
|
|
then # si au moins 2 parametres
|
2015-05-24 16:02:06 +00:00
|
|
|
param=$2;
|
|
|
|
else
|
|
|
|
param="";
|
|
|
|
fi;
|
|
|
|
|
2015-05-23 16:15:00 +00:00
|
|
|
case $1 in
|
2015-05-24 13:25:23 +00:00
|
|
|
'help') cat "$path/source/help"|less;;
|
2015-05-23 20:21:42 +00:00
|
|
|
'init') # initialise le contenu du fichier de config
|
2015-05-24 21:05:58 +00:00
|
|
|
echo "smtp_server = smtp.gmail.com" > "$path/.config";
|
|
|
|
echo "smtp_port = 587" >> "$path/.config";
|
2015-05-24 20:20:44 +00:00
|
|
|
echo "" >> "$path/.config";
|
2015-05-24 21:05:58 +00:00
|
|
|
echo "imap_server = imap.gmail.com" >> "$path/.config";
|
|
|
|
echo "imap_port = 993" >> "$path/.config";
|
2015-05-24 20:20:44 +00:00
|
|
|
echo "" >> "$path/.config";
|
|
|
|
echo "mail_address = test@mail.com" >> "$path/.config";
|
|
|
|
echo "" >> "$path/.config";
|
2015-05-24 21:05:58 +00:00
|
|
|
echo "login = equal_mailadress_or_different_login" >> "$path/.config";
|
2015-05-24 20:20:44 +00:00
|
|
|
echo "" >> "$path/.config";
|
2015-05-24 21:05:58 +00:00
|
|
|
echo "algorithm_complexity = 1" >> "$path/.config";
|
|
|
|
echo "" >> "$path/.config";
|
|
|
|
echo "text_editor = nano" >> "$path/.config";
|
2015-05-23 20:21:42 +00:00
|
|
|
;;
|
2015-05-24 20:20:44 +00:00
|
|
|
'config')
|
|
|
|
if [ -z $param ]
|
|
|
|
then # si aucun parametre alors on lance l'editeur choisi
|
|
|
|
$editor "$path/.config"; # ouvre en modification le fichier de config
|
|
|
|
else
|
|
|
|
$editor "$path/.config";
|
|
|
|
fi;;
|
|
|
|
'write') $editor "$path/bucket-file";; # ouvre en modification le bucket file
|
2015-05-24 13:25:23 +00:00
|
|
|
'empty') echo "">"$path/bucket-file";; # vide le bucket file
|
2015-05-23 20:21:42 +00:00
|
|
|
# ouvre en lecture le bucket file
|
2015-05-24 16:02:06 +00:00
|
|
|
'read') echo "\n======================================="; cat "$path/bucket-file"; echo "\n=======================================";;
|
|
|
|
'encode') python "$path/source/encode.py" $param;;
|
|
|
|
'decode') python "$path/source/decode.py" $param;;
|
|
|
|
'receive') python "$path/source/receive.py" $param;;
|
|
|
|
'send') python "$path/source/send.py" $param;;
|
2015-05-23 16:15:00 +00:00
|
|
|
*) echo "Erreur";
|
|
|
|
esac;
|
|
|
|
else
|
2015-05-24 12:54:46 +00:00
|
|
|
echo "Parametre manquant: enigmail help";
|
2015-05-23 16:15:00 +00:00
|
|
|
fi;
|