~ubuntu-branches/debian/jessie/smstools/jessie

« back to all changes in this revision

Viewing changes to scripts/sendsms

  • Committer: Bazaar Package Importer
  • Author(s): Jan Wagner
  • Date: 2010-06-21 10:19:52 UTC
  • mfrom: (1.1.11 upstream)
  • Revision ID: james.westby@ubuntu.com-20100621101952-pz5h5zctan8vumbi
Tags: 3.1.10-0.1
* Non-maintainer upload, as requested by maintainer
* New Upstream version (Closes: #586643)
* Bump Standards to 3.8.4, no changes needed
* Define source format 1.0 in debian/source/format
* Add $remote_fs as dependency for Required-Start and Required-Stop in the
  init script, removed $local_fs, which is implicit

Show diffs side-by-side

added added

removed removed

Lines of Context:
10
10
# If a destination is asked, you can type multiple numbers
11
11
# delimited with spaces.
12
12
 
 
13
# Keys for example: "password" and "keke":
 
14
# KEYS="5f4dcc3b5aa765d61d8327deb882cf99 4a5ea11b030ec1cfbc8b9947fdf2c872 "
 
15
 
 
16
KEYS=""
 
17
 
 
18
# When creating keys, remember to use -n for echo:
 
19
# echo -n "key" | md5sum
 
20
 
13
21
smsd_user="smsd"
14
22
 
15
23
# Will need echo which accepts -n argument:
20
28
    ;;
21
29
esac
22
30
 
 
31
if ! [ -z "$KEYS" ]; then
 
32
  printf "Key: "
 
33
  read KEY
 
34
  if [ -z "$KEY" ]; then
 
35
    echo "Key required, stopping."
 
36
    exit 1
 
37
  fi
 
38
  KEY=`$ECHO -n "$KEY" | md5sum | awk '{print $1;}'`
 
39
  if ! echo "$KEYS" | grep "$KEY" >/dev/null; then
 
40
    echo "Incorrect key, stopping."
 
41
    exit 1
 
42
  fi
 
43
fi
 
44
 
23
45
DEST=$1
24
46
TEXT=$2
25
47
 
53
75
  destinations=$DEST
54
76
fi
55
77
 
 
78
echo "-- "
56
79
echo "Text: $TEXT"
57
80
 
 
81
ALPHABET=""
 
82
if which iconv > /dev/null 2>&1; then
 
83
  if ! $ECHO -n "$TEXT" | iconv -t ISO-8859-15 >/dev/null 2>&1; then
 
84
    ALPHABET="Alphabet: UCS"
 
85
    TEXT=`$ECHO -n "$TEXT" | iconv -t UNICODEBIG`
 
86
  fi
 
87
fi
 
88
 
 
89
owner=""
 
90
if [ -f /etc/passwd ]; then
 
91
  if grep $smsd_user: /etc/passwd >/dev/null; then
 
92
    owner=$smsd_user
 
93
  fi
 
94
fi
 
95
 
58
96
for destination in $destinations
59
97
do
60
98
  echo "To: $destination"
61
99
 
62
 
  owner=""
63
 
  if [ -f /etc/passwd ]; then
64
 
    if grep $smsd_user: /etc/passwd >/dev/null; then
65
 
      owner=$smsd_user
66
 
    fi
67
 
  fi
68
 
 
69
100
  TMPFILE=`mktemp /tmp/smsd_XXXXXX`
70
101
 
71
102
  $ECHO "To: $destination" >> $TMPFILE
 
103
  [ -n "$ALPHABET" ] && $ECHO "$ALPHABET" >> $TMPFILE
72
104
  $ECHO "" >> $TMPFILE
73
105
  $ECHO -n "$TEXT" >> $TMPFILE
74
106