summaryrefslogtreecommitdiff
path: root/noncore/tools/opie-sh/scripts/rsyncme.sh
Unidiff
Diffstat (limited to 'noncore/tools/opie-sh/scripts/rsyncme.sh') (more/less context) (show whitespace changes)
-rwxr-xr-xnoncore/tools/opie-sh/scripts/rsyncme.sh109
1 files changed, 109 insertions, 0 deletions
diff --git a/noncore/tools/opie-sh/scripts/rsyncme.sh b/noncore/tools/opie-sh/scripts/rsyncme.sh
new file mode 100755
index 0000000..c09aea8
--- a/dev/null
+++ b/noncore/tools/opie-sh/scripts/rsyncme.sh
@@ -0,0 +1,109 @@
1#!/bin/sh
2
3# rsyncme.sh - a demonstration of opie-sh
4#
5# Copyright (C) 2002 gonz@directbox.com
6#
7# This program is free software; you can redistribute it and/or modify
8# it under the terms of the GNU General Public License as published by
9# the Free Software Foundation; either version 2, or (at your option)
10# any later version.
11#
12# This program is distributed in the hope that it will be useful,
13# but WITHOUT ANY WARRANTY; without even the implied warranty of
14# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15# GNU General Public License for more details.
16#
17# 20020517-1 - added icon, changed name in launcher
18#
19
20CFG=/opt/QtPalmtop/share/config/rsyncme.cfg
21OPIE_SH=opie-sh
22
23update_cfg() {
24 # check if dir is in CFG and if not add it
25 if [ "`grep -c $DIR $CFG`" = "0" ]
26 thenecho $DIR >>$CFG
27 fi
28}
29
30ask_dirs() {
31 # get source and destination dir
32 DIR=`$OPIE_SH -g -i -t "Choose Source Directory" -l -L DIR: -E -F $CFG `
33 update_cfg
34 SRCDIR=$DIR
35
36 DIR=`$OPIE_SH -g -i -t "Choose Destination Directory" -l -L DIR: -E -F $CFG `
37 update_cfg
38 DESTDIR=$DIR
39}
40
41ask_options() {
42 # now ask for options
43 OPTIONS="--archive --verbose --checksum --recursive --update --links --partial --dry-run --rsh=ssh --existing --compress --recursive"
44 OUTPUT=`( for OPTION in $OPTIONS
45 do
46 echo "$OPTION"
47 done ) | $OPIE_SH -t "Select options" -g -i -b -F `
48}
49
50rsync_output() {
51 ( echo "<h3>Output of your rsync:</h3>"
52 echo "command: rsync $OUTPUT $SRCDIR $DESTDIR"
53 echo "<pre>"
54 rsync $OUTPUT $SRCDIR $DESTDIR 2>&1
55 echo "</pre>done."
56 ) | $OPIE_SH -t "Result:" -f
57}
58
59cleanup() {
60 kill $SCREENCLEAN
61 rm -f /tmp/qcop-msg-rsyncme.sh
62}
63
64show_dirs() {
65 ( echo "<h3>Directorys chosen for sync:</h3>"
66 echo "<ul><li>$SRCDIR<li>$DESTDIR</ul>" ) \
67 | $OPIE_SH -t "Got directories" -f
68}
69
70about() {
71 ( echo "<img src=/opt/QtPalmtop/pics/opie-sh-scripts/rsyncme.png>"
72 echo "<h3>About</h3>"
73 echo "This little App should make it possible for you to "
74 echo "easily choose the wanted options for an rsync process."
75 echo "<p>"
76 ) | $OPIE_SH -t rsync-helper -f &
77 SCREENCLEAN=$!
78 sleep 1
79}
80
81
82
83
84#####################################################################
85#
86# main
87
88about
89
90# ask to: start rsync, edit dirlist, show about
91$OPIE_SH -m -g -t RsyncMe -M "Welcome!" -0 Start -1 Dirlist
92RETURNCODE=$?
93case $RETURNCODE in
94 -1)echo died unexpectedly... | $OPIE_SH -f
95 cleanup
96 exit ;;
971) textedit $CFG
98 cleanup ;;
99 0)if [ -f $CFG ]
100 thenask_dirs
101 show_dirs
102 ask_options
103 rsync_output
104 else ( echo no config file seems to exist - see About... ) \
105 | $OPIE_SH -t "SORRY..." -f
106 fi
107 cleanup
108 ;;
109esac