2 # Gammu configuration generator
3 # Copyright (C) 2003 - 2009 Michal Cihar <michal@cihar.com>
4 # vim: expandtab sw=4 ts=4 sts=4:
11 NAME
="Gammu configurator"
13 COPYRIGHT
="Copyright (C) 2003 - 2009 Michal Cihar <michal@cihar.com>"
27 TEMPFILE
=`mktemp /tmp/gammu-config.XXXXXXXXXX`
33 echo "Usage: `basename $0` [-f|--force] [-c|--config config]"
39 grep '^[[:space:]]*'$1'[[:space:]]*=' "$CONFIG"|
sed 's/^[^=]*=[[:space:]]*\([^#;]*\)[#;]\?.*$/\1/'
42 while [ "$#" -ge 1 ] ; do
48 if [ "x$2" != "x" ] ; then
62 if type dialog
> /dev
/null
2>&1 ; then
64 elif type cdialog
> /dev
/null
2>&1 ; then
66 elif type whiptail
> /dev
/null
2>&1 ; then
69 echo "You need dialog, cdialog or whiptail installed to make this work"
73 if [ -f "$CONFIG" ] ; then
74 if [ ! -w "$CONFIG" ] ; then
75 $DIALOG --msgbox "Configuration file \"$CONFIG\" is not writable!" $DIALOG_SIZE
79 if [ $FORCE -ne 1 ] ; then
80 $DIALOG --yesno "Configuration file \"$CONFIG\" exists.\nDo you still wish to configure Gammu?" $DIALOG_SIZE
81 if [ $?
-eq 1 ] ; then
86 $DIALOG --yesno "Configuration file \"$CONFIG\" exists.\nDo you wish to read defaults from it?" $DIALOG_SIZE
87 if [ $?
-eq 0 ] ; then
88 echo "Parsing current Gammu configuration form \"$CONFIG\""
91 CONNECTION
=`cfgread connection`
92 SYNCHRONIZETIME
=`cfgread synchronizetime`
93 LOGFILE
=`cfgread logfile`
94 LOGFORMAT
=`cfgread logformat`
95 LOCKING
=`cfgread use_locking`
96 GAMMULOC
=`cfgread gammuloc`
101 if [ $DIALOG = dialog
] ; then
102 EXTRA
="--help-button --ok-label Edit --cancel-label Exit --extra-button --extra-label Save"
106 EXTRA_MENU
="H Help S Save"
108 $DIALOG $EXTRA --menu "Current Gammu configuration" $MENU_SIZE \
109 P
"Port (${PORT:-$D_PORT})" \
110 C
"Connection (${CONNECTION:-$D_CONNECTION})" \
111 M
"Model (${MODEL:-$D_MODEL})" \
112 D
"Synchronize time (${SYNCHRONIZETIME:-$D_SYNCHRONIZETIME})" \
113 F
"Log file (${LOGFILE:-$D_LOGFILE})" \
114 O
"Log format (${LOGFORMAT:-$D_LOGFORMAT})" \
115 L
"Use locking (${LOCKING:-$D_LOCKING})" \
116 G
"Gammu localisation (${GAMMULOC:-$D_GAMMULOC})" \
120 ITEM
=`cat "$TEMPFILE"`
121 if [ "$DIALOG" = whiptail
-a "$BUTTON" = 0 ] ; then
122 if [ "$ITEM" = H
] ; then
124 elif [ "$ITEM" = S
] ; then
131 if [ $DIALOG = dialog
] ; then
132 $DIALOG --fselect "${PORT:-$D_PORT}" $FILE_SIZE 2>"$TEMPFILE"
137 if [ $err -eq 255 ] ; then
138 if $DIALOG --inputbox "Enter phone port" $INPUT_SIZE "${PORT:-$D_PORT}" 2>"$TEMPFILE" ; then
139 PORT
=`cat "$TEMPFILE"`
141 elif [ $err -eq 0 ] ; then
142 PORT
=`cat "$TEMPFILE"`
147 $DIALOG --textbox /proc
/self
/fd
/5 0 0 5<< EOT
148 # Port : in Windows/DOS: "com*:",
149 # (instead of "*" please put "1", "2", etc.)
150 # in other (Linux/Unix) "/dev/ttyS%"
151 # or "/dev/ircomm%" ("irda" connection)
152 # (instead of "%" please put "0", "1", "2", etc.)
153 # Model : use only, when Gammu doesn't recognize your phone model.
154 # Put it here. Example values: "6110", "6150", "6210", "8210"
155 # Connection : type of connection. Use "fbus" or "mbus" or "dlr3" or
156 # "irda" (Infrared over sockets) or "infrared" (DirectIR)
157 # or "at19200" (AT commands on 19200, 8 bits, None parity,
158 # 1 stop bit, no flow control) or "at115200" (AT commands on
159 # 115200, 8 bits, None parity, 1 stop bit, no flow control)
160 # or "atblue" (AT over BlueTooth) or "dlr3blue" (FBUS
162 # SynchronizeTime: if you want to set time from computer to phone during
163 # starting connection. Do not rather use this option when want
164 # to reset phone during connection (in some phones need to
165 # set time again after restart)
166 # Logfile : Use, when want to have logfile from communication.
167 # Logformat : What debug info and format should be used:
168 # "nothing" - no debug level, "text" - transmission dump in
169 # text format, "textall" - all possible info in text format,
170 # "errors" - errors in text format, "binary" - transmission
171 # dump in binary format
172 # Use_Locking : under Unix/Linux use "yes", if want to lock used device
173 # to prevent using it by other applications
174 # GammuLoc : name of localisation file
184 if ( $DIALOG --menu "$TITLE" $MENU_SIZE "$@" 2>"$TEMPFILE" ) ; then
185 VALUE
=`cat "$TEMPFILE"`
191 editgeneral
"Select your phone connection" CONNECTION \
219 editgeneral
"Select your phone model" MODEL \
220 "" "Automatic detection (use this if unsure)" \
221 at "AT Generic phones" \
222 alcatel
"Alcatel BE5 (501,701)" \
223 7110 "Nokia 6210|6250|7110|7190" \
225 6110 "Nokia 3210|33x0|3410|51x0|5210|5510|61x0|82x0|88x0" \
226 6510 "Nokia 3510|6310|6310i|6510|8310|8910" \
227 NAUTO
"Nokia with autodetection"
231 editgeneral
"Synchronize time with PC on each connect?" SYNCHRONIZETIME \
237 if [ $DIALOG = dialog
] ; then
238 $DIALOG --fselect "${LOGFILE:-$D_LOGFILE}" $FILE_SIZE 2>"$TEMPFILE"
243 if [ $err = 255 ] ; then
244 if ( $DIALOG --inputbox "Enter log file" $INPUT_SIZE "${LOGFILE:-$D_LOG_FILE}" 2>"$TEMPFILE" ) ; then
245 LOGFILE
=`cat "$TEMPFILE"`
247 elif [ $err = 0] ; then
248 LOGFILE
=`cat "$TEMPFILE"`
253 editgeneral
"Select log format" LOGFORMAT \
254 nothing
"no debug level" \
255 text
"transmission dump in text format" \
256 textdate
"transmission dump in text format with date" \
257 textall
"all possible info in text format" \
258 textalldate
"all possible info in text format with date" \
259 errors
"errors in text format" \
260 errorsdate
"errors in text format with date" \
261 binary
"transmission dump in binary format"
265 editgeneral
"Use device locking?" LOCKING \
271 if [ $DIALOG = dialog
] ; then
272 $DIALOG --fselect "${GAMMULOC:-${D_GAMMULOC:-/}}" $FILE_SIZE 2>"$TEMPFILE"
277 if [ $err = 255 ] ; then
278 if ( $DIALOG --inputbox "Enter localisation file" $INPUT_SIZE "${GAMMULOC:-${D_GAMMULOC:-/}}" 2>"$TEMPFILE" ) ; then
279 LOGFILE
=`cat "$TEMPFILE"`
281 elif [ $err = 0] ; then
282 LOGFILE
=`cat "$TEMPFILE"`
289 while [ $BUTTON -eq 0 -o $BUTTON -eq 2 ] ; do
290 if [ $BUTTON -eq 2 ] ; then
299 if [ $BUTTON -eq 3 ] ; then
300 if [ -f "$CONFIG" -a $FORCE -ne 1 ] ; then
301 $DIALOG --yesno "Do you really wish to overwrite file \"$CONFIG\", with selected Gammu configuration?" $DIALOG_SIZE
302 if [ $?
-eq 1 ] ; then
307 cat > "$CONFIG" << EOT
308 # This is a generated gammurc file.
309 # It was generated by $NAME $VERSION
311 # In Unix/Linux : copy it into your home directory and name it .gammurc
312 # or into /etc and name it gammurc
313 # In Win32 : copy it into directory with Gammu.exe and name gammurc
315 # Port : in Windows/DOS: "com*:",
316 # (instead of "*" please put "1", "2", etc.)
317 # in other (Linux/Unix) "/dev/ttyS%"
318 # or "/dev/ircomm%" ("irda" connection)
319 # (instead of "%" please put "0", "1", "2", etc.)
320 # Model : use only, when Gammu doesn't recognize your phone model.
321 # Put it here. Example values: "6110", "6150", "6210", "8210"
322 # Connection : type of connection. Use "fbus" or "mbus" or "dlr3" or
323 # "irda" (Infrared over sockets) or "infrared" (DirectIR)
324 # or "at19200" (AT commands on 19200, 8 bits, None parity,
325 # 1 stop bit, no flow control) or "at115200" (AT commands on
326 # 115200, 8 bits, None parity, 1 stop bit, no flow control)
327 # or "atblue" (AT over BlueTooth) or "dlr3blue" (FBUS
329 # SynchronizeTime: if you want to set time from computer to phone during
330 # starting connection. Do not rather use this option when want
331 # to reset phone during connection (in some phones need to
332 # set time again after restart)
333 # Logfile : Use, when want to have logfile from communication.
334 # Logformat : What debug info and format should be used:
335 # "nothing" - no debug level, "text" - transmission dump in
336 # text format, "textall" - all possible info in text format,
337 # "errors" - errors in text format, "binary" - transmission
338 # dump in binary format
339 # Use_Locking : under Unix/Linux use "yes", if want to lock used device
340 # to prevent using it by other applications
341 # GammuLoc : name of localisation file
345 port = ${PORT:-$D_PORT}
346 model = ${MODEL:-$D_MODEL}
347 connection = ${CONNECTION:-$D_CONNECTION}
348 synchronizetime = ${SYNCHRONIZETIME:-$D_SYNCHRONIZETIME}
349 logfile = ${LOGFILE:-$D_LOGFILE}
350 logformat = ${LOGFORMAT:-$D_LOGFORMAT}
351 use_locking = ${LOCKING:-$D_LOCKING}
352 gammuloc = ${GAMMULOC:-$D_GAMMULOC}
354 $DIALOG --msgbox "Configuration saved to \"$CONFIG\"" $DIALOG_SIZE