author | spiralman <spiralman> | 2002-09-01 14:42:39 (UTC) |
---|---|---|
committer | spiralman <spiralman> | 2002-09-01 14:42:39 (UTC) |
commit | dfac71239116c4804081d925e9cf3021680b1e2c (patch) (side-by-side diff) | |
tree | cf6a5c3897e9b73eb3415d470de95b77245abdad /noncore | |
parent | 27b087fc3458d3d0c01eb0485490a64b2a201541 (diff) | |
download | opie-dfac71239116c4804081d925e9cf3021680b1e2c.zip opie-dfac71239116c4804081d925e9cf3021680b1e2c.tar.gz opie-dfac71239116c4804081d925e9cf3021680b1e2c.tar.bz2 |
initial import of gonz's opie-sh scripts
-rwxr-xr-x | noncore/tools/opie-sh/scripts/diskfree.sh | 44 | ||||
-rwxr-xr-x | noncore/tools/opie-sh/scripts/filesystem_mounter.sh | 126 | ||||
-rwxr-xr-x | noncore/tools/opie-sh/scripts/hostlist.sh | 80 | ||||
-rwxr-xr-x | noncore/tools/opie-sh/scripts/killproc.sh | 71 | ||||
-rwxr-xr-x | noncore/tools/opie-sh/scripts/launcher_refresh.sh | 44 | ||||
-rwxr-xr-x | noncore/tools/opie-sh/scripts/logviewer.sh | 116 | ||||
-rwxr-xr-x | noncore/tools/opie-sh/scripts/opie-sh-wavelanchooser.sh | 62 | ||||
-rwxr-xr-x | noncore/tools/opie-sh/scripts/rsyncme.sh | 109 | ||||
-rwxr-xr-x | noncore/tools/opie-sh/scripts/service_manager.sh | 110 | ||||
-rwxr-xr-x | noncore/tools/opie-sh/scripts/usbnetctrl.sh | 90 |
10 files changed, 852 insertions, 0 deletions
diff --git a/noncore/tools/opie-sh/scripts/diskfree.sh b/noncore/tools/opie-sh/scripts/diskfree.sh new file mode 100755 index 0000000..6fcd709 --- a/dev/null +++ b/noncore/tools/opie-sh/scripts/diskfree.sh @@ -0,0 +1,44 @@ +#!/bin/sh + +# diskfree.sh - a demonstration of opie-sh +# +# Copyright (C) 2002 gonz@directbox.com +# +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 2, or (at your option) +# any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# 20020524-5 - bugfix +# 20020524-1 - initial release + +OPIE_SH=/opt/QtPalmtop/bin/opie-sh + +# there must be a better way to do this with sed, but i had no time +# time to look into this yet... + +( echo "<img src=/opt/QtPalmtop/pics/opie-sh-scripts/fsmounter.png>" + echo "<h3>diskfree</h3> how much space is left ?<br>" + echo "<p><table>" + + df -Ph \ + | grep -v "Mounted on" \ + | sed 's/ / /g' \ + | sed 's/ / /g' \ + | sed 's/ / /g' \ + | sed 's/ / /g' \ + | sed 's/ / /g' \ + | sed 's/ / /g' \ + | sed "s/ / /g" \ + | cut -d " " -f4- \ + | sed 's/ /<\/td><td>/g' \ + | sed 's/$/<\/td><\/tr>/' \ + | sed 's/^/<tr><td>/' ; echo "</table>" \ +) | $OPIE_SH -t "Space left" -f + +rm -f /tmp/qcop-msg-diskfree.sh diff --git a/noncore/tools/opie-sh/scripts/filesystem_mounter.sh b/noncore/tools/opie-sh/scripts/filesystem_mounter.sh new file mode 100755 index 0000000..faaf37c --- a/dev/null +++ b/noncore/tools/opie-sh/scripts/filesystem_mounter.sh @@ -0,0 +1,126 @@ +#!/bin/sh + +# filesystem_mounter.sh - a demonstration of opie-sh +# +# Copyright (C) 2002 gonz@directbox.com +# +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 2, or (at your option) +# any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# 20020524-2 - using df from diskfree now +# 20020524-1 - just code optix +# 20020519-1 - added information screen with manpage excerpt, added +# better returncode-checking +# 20020517-2 - fixed output bug +# 20020517-1 - nicer fullscreen, added about, tried icon +# + +OPIE_SH=/opt/QtPalmtop/bin/opie-sh + +###################################################################### +# subroutines + +about() { + ( echo "<img src=/opt/QtPalmtop/pics/opie-sh-scripts/fsmounter.png>" + echo "<h3>About</h3>" + echo "This little App should make it possible for you to " + echo "easily mount and unmount filesystems from /etc/fstab" + echo "<p>" + ) | $OPIE_SH -t fsmounter -f & + SCREENCLEAN=$! + sleep 1 +} + +beforemount() { + ( echo "<img src=/opt/QtPalmtop/pics/opie-sh-scripts/fsmounter.png>" + echo "<h3>mount or unmount $MOUNTPOINT ?</h3>" + echo "<b>excerpt from MOUNT(8) manpage:</b><p>" + echo "All files accessible in a Unix system are arranged in one + big tree, the file hierarchy, rooted at <b>/</b>. These files + can be spread out over several devices. The <b>mount</b> command + serves to attach the file system found on some device to + the big file tree. Conversely, the <b>umount(8)</b> command will + detach it again." + echo "<p>" + ) | $OPIE_SH -t fsmounter -f & + SCREENCLEAN2=$! + sleep 1 +} + + +cleanup() { + kill $SCREENCLEAN $SCREENCLEAN2 + rm -f /tmp/qcop-msg-filesystem_mounter.sh +} + +get_action() { +# ask what to do (start/stop/status) +# +$OPIE_SH -m -t "Select Action" \ + -M "action for $MOUNTPOINT ?" \ + -g -0 mount -1 umount +RETURNCODE=$? + +case $RETURNCODE in + -1|255) echo unexpected input detected, exiting. | $OPIE_SH -f + cleanup ;; + 0) ACTION=mount ;; + 1) ACTION=umount ;; +esac +kill $SCREENCLEAN2 +} + +select_mountpoint() { +# present service list and choose +# +MOUNTPOINT=` cat /etc/fstab | cut -f1 \ + | cut -d " " -f1 \ + | egrep -v "(tmpfs|proc|devpts|^#)" \ + | $OPIE_SH -i -l \ + -g -t "SELECT MOUNTPOINT" \ + -L "select fs: " ` +} + +###################################################################### +# main + +about +select_mountpoint +beforemount +get_action + +if [ "$MOUNTPOINT" = "" ] +then echo "ugly error...." | $OPIE_SH -f ; cleanup +fi + +( echo "<img src=/opt/QtPalmtop/pics/opie-sh-scripts/fsmounter.png>" + echo "<h3>Output of $ACTION $MOUNTPOINT :</h3>" + echo "<pre>" + $ACTION $MOUNTPOINT 2>&1 + echo "</pre><p>" + echo "<h3>diskfree</h3> how much space is left ?<br>" + echo "<p><table>" + + df -Ph \ + | grep -v "Mounted on" \ + | sed 's/ / /g' \ + | sed 's/ / /g' \ + | sed 's/ / /g' \ + | sed 's/ / /g' \ + | sed 's/ / /g' \ + | sed 's/ / /g' \ + | sed "s/ / /g" \ + | cut -d " " -f4- \ + | sed 's/ /<\/td><td>/g' \ + | sed 's/$/<\/td><\/tr>/' \ + | sed 's/^/<tr><td>/' ; echo "</table>" \ +) | $OPIE_SH -f + +cleanup diff --git a/noncore/tools/opie-sh/scripts/hostlist.sh b/noncore/tools/opie-sh/scripts/hostlist.sh new file mode 100755 index 0000000..6575e9c --- a/dev/null +++ b/noncore/tools/opie-sh/scripts/hostlist.sh @@ -0,0 +1,80 @@ +#!/bin/sh + +# hostlist.sh - a demonstration of opie-sh +# +# Copyright (C) 2002 gonz@directbox.com +# +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 2, or (at your option) +# any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# 20020524-1 - icon to hostlist +# 20020517-1 - added icon, changed name in launcher +# + +CFG=/opt/QtPalmtop/share/config/hostlist.cfg +OPIE_SH=opie-sh + +hostlist() { +( echo "<img src=/opt/QtPalmtop/pics/opie-sh-scripts/hostlist.png>" + echo "<h3>Hostlist</h3><br>" + HOSTLIST=`cat $CFG` + for HOST in $HOSTLIST + do + PT=` ping -c1 $HOST | grep avg|cut -d " " -f4-` + if [ "$PT" != "" ] + then echo "<b><font color=#00ff00> " + echo "$HOST is up<br></font></b>[$PT]<br>" + else echo "<b><font color=#ff0000> " + echo "$HOST is down<br></font></b>[$PT]<br>" + fi + done +) | $OPIE_SH -t "Which are up ?" -f + + +} + +cleanup() { + kill $SCREENCLEAN + rm -f /tmp/qcop-msg-hostlist.sh +} + +about() { + ( echo "<img src=/opt/QtPalmtop/pics/opie-sh-scripts/hostlist.png>" + echo "<h3>About</h3>" + echo "This little App should make it possible for you to " + echo "check some hosts for availability." + echo "<p>" + ) | $OPIE_SH -t hostlist -f & + SCREENCLEAN=$! + sleep 1 +} + +##################################################################### +# +# main + +about + +# ask to: start or edit list +$OPIE_SH -m -g -t Hostlist -M "Welcome!" -0 Start -1 "Edit Hostlist" +RETURNCODE=$? +case $RETURNCODE in +-1) echo died unexpectedly... | $OPIE_SH -f + cleanup + exit ;; +1) textedit $CFG + cleanup ;; +0) if [ -f $CFG ] + then hostlist + else echo www,handhelds.org >$CFG ; hostlist + fi + cleanup + ;; +esac diff --git a/noncore/tools/opie-sh/scripts/killproc.sh b/noncore/tools/opie-sh/scripts/killproc.sh new file mode 100755 index 0000000..8afb4b8 --- a/dev/null +++ b/noncore/tools/opie-sh/scripts/killproc.sh @@ -0,0 +1,71 @@ +#!/bin/sh + +# killproc.sh - a demonstration of opie-sh +# +# Copyright (C) 2002 gonz@directbox.com +# +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 2, or (at your option) +# any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# 20020524-1 - code optix +# 20020519-1 - added icon to output +# 20020517-1 - nicer fullscreen, added about, tried icon + +OPIE_SH=/opt/QtPalmtop/bin/opie-sh + +###################################################################### +# subroutines + +about() { + ( echo "<img src=/opt/QtPalmtop/pics/opie-sh-scripts/killproc.png>" + echo "<h3>About</h3>" + echo "This little util sends the TERM signal " + echo "to the specified process or process group. " + echo "The TERM signal will kill processes which " + echo "do not catch this signal. " + echo "<p> " + ) | $OPIE_SH -t opie-killproc -f & + SCREENCLEAN=$! + sleep 1 +} + +cleanup() { + kill $SCREENCLEAN + rm -f /tmp/qcop-msg-killproc.sh +} + +select_process() { + # present process list and choose + # + PROCESS=`ps -eaf | cut -b 10-15,40- \ + | cut -b -40 \ + | grep -v "TIME CMD" \ + | $OPIE_SH -i -l -g \ + -t "Select Process" ` +} + +###################################################################### +# main + +about +select_process + +PROCESS=`echo $PROCESS | cut -b -4` + + +( echo "<img src=/opt/QtPalmtop/pics/opie-sh-scripts/killproc.png>" + echo "<h3>Output of kill $PROCESS</h3>" + echo "<pre>" + kill $PROCESS 2>&1 + echo "</pre><p>" + echo done. +) | $OPIE_SH -f + +cleanup diff --git a/noncore/tools/opie-sh/scripts/launcher_refresh.sh b/noncore/tools/opie-sh/scripts/launcher_refresh.sh new file mode 100755 index 0000000..7850508 --- a/dev/null +++ b/noncore/tools/opie-sh/scripts/launcher_refresh.sh @@ -0,0 +1,44 @@ +#!/bin/sh + +# launcher_refresh.sh - a demonstration of opie-sh +# +# Copyright (C) 2002 gonz@directbox.com +# +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 2, or (at your option) +# any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. + +OPIE_SH=opie-sh + +launcher_refresh() { +( echo "<img src=/opt/QtPalmtop/pics/opie-sh-scripts/launcher_refresh.png>" + echo "<h3>Refresh successful!</h3><br>" + echo the launcher has been refreshed. + echo + echo this is useful if you installed packages using ipk instead of + echo oipkg. it is also helping if you are changing .desktop-files + echo often. + echo "<p>" it also refreshes the input-methods. +) | $OPIE_SH -t "launcher-refresh" -f +} + +cleanup() { + rm -f /tmp/qcop-msg-launcher_refresh.sh +} + +##################################################################### +# +# main + +/opt/QtPalmtop/bin/qcop QPE/TaskBar "reloadInputMethods()" +#/opt/QtPalmtop/bin/qcop QPE/System "restart()" +/opt/QtPalmtop/bin/qcop QPE/System "linkChanged(QString)" + +launcher_refresh +cleanup diff --git a/noncore/tools/opie-sh/scripts/logviewer.sh b/noncore/tools/opie-sh/scripts/logviewer.sh new file mode 100755 index 0000000..e9657b4 --- a/dev/null +++ b/noncore/tools/opie-sh/scripts/logviewer.sh @@ -0,0 +1,116 @@ +#!/bin/sh + +# logviewer.sh - a demonstration of opie-sh +# +# Copyright (C) 2002 gonz@directbox.com +# +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 2, or (at your option) +# any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# 20020526-1a - initial release... +# + +OPIE_SH=/opt/QtPalmtop/bin/opie-sh +INITPATH=/etc/init.d + +###################################################################### +# subroutines + +about() { + ( echo "<img src=/opt/QtPalmtop/pics/opie-sh-scripts/logviewer.png>" + echo "<h3>About</h3>" + echo "This little App should make it possible for you to " + echo "easily have a look at some of the syslogs. " + echo "<p>" + ) | $OPIE_SH -t logviewer -f & + SCREENCLEAN=$! + sleep 1 +} + +cleanup() { + kill $SCREENCLEAN 2>/dev/null + rm -f /tmp/qcop-msg-logviewer.sh +} + +choose_log() { + # ask what to do (start/stop/status) + # + $OPIE_SH -m -t "Select Log" \ + -M "which logfile are you interested in ?<br>" \ + -g -0 "PROC" -1 "SYSLOG" + RETURNCODE=$? + + case $RETURNCODE in + -1) echo unexpected input detected, exiting. + cleanup ;; + 0) LOGMETHOD=proc ;; + 1) LOGMETHOD=syslog ;; + esac +} + +###################################################################### +# main + +about +choose_log + +case $LOGMETHOD in + proc) $OPIE_SH -m -t "Select Log" \ + -M "which procfile ?<br>" \ + -g -0 kmsg -1 "ksyms" + RETURNCODE=$? + case $RETURNCODE in + -1) cleanup ;; + 0) + +cat /proc/kmsg >/tmp/log.$$ & +PID=$! +sleep 2 +kill $PID +( echo "<img src=/opt/QtPalmtop/pics/opie-sh-scripts/logviewer.png>" + echo "<h3>/proc/kmsg</h3>" + cat /tmp/log.$$ +) | $OPIE_SH -t kmsg -f +rm -f /tmp/$$ +cleanup ;; + + 1) + +cat /proc/ksyms >/tmp/log.$$ & +PID=$! +sleep 2 +kill $PID +( echo "<img src=/opt/QtPalmtop/pics/opie-sh-scripts/logviewer.png>" + echo "<h3>/proc/ksyms</h3>" + cat /tmp/log.$$ +) | $OPIE_SH -t ksyms -f +rm -f /tmp/$$ +cleanup ;; + + *) cleanup ;; + esac + cleanup ;; + + syslog) + +if [ -f /var/log/messages ] +then + $OPIE_SH -t syslog -f /var/log/messages +else + echo "no syslogd installed or /var/log/messages inexistent." \ + | $OPIE_SH -t syslog -f +fi +;; + *) cleanup ;; + esac + + +cleanup + diff --git a/noncore/tools/opie-sh/scripts/opie-sh-wavelanchooser.sh b/noncore/tools/opie-sh/scripts/opie-sh-wavelanchooser.sh new file mode 100755 index 0000000..13a1e79 --- a/dev/null +++ b/noncore/tools/opie-sh/scripts/opie-sh-wavelanchooser.sh @@ -0,0 +1,62 @@ +#!/bin/sh + +# wavelanchooser.sh - a demonstration of opie-sh +# +# Copyright (C) 2002 gonz@directbox.com +# +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 2, or (at your option) +# any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# 20020528-1 - fixed filename in cleanup +# 20020526-1 - rudimental but working +# 20020524-1 - initial working release planned +# + +OPIE_SH=opie-sh + +about() { + ( echo "<img src=/opt/QtPalmtop/pics/opie-sh-scripts/qtwavelan.png>" + echo "<h3>About</h3>" + echo "This little App is for changing the location setting" + echo "for your wireless card. <br>" + echo "actually it only starts /etc/init.d/[home|work] and can" + echo "be easily turned into a quick program to start the service" + echo "or init script you use most." + echo "<p>" + ) | $OPIE_SH -t wavelanchooser -f & + SCREENCLEAN=$! + sleep 1 +} + +cleanup() { + kill $SCREENCLEAN $SCREENCLEAN2 + rm -f /tmp/qcop-msg-opie-sh-wavelanchooser.sh +} + + +about + +# choose if work or home +$OPIE_SH -m -t "network-settings dialog" \ + -M "which configuration do you want ? " \ + -w -0 home -1 work -g + +if [ "$?" = "0" ] +then DECISION=home +else DECISION=work +fi + +( echo "you decided to choose $DECISION configuration. " + echo "remember to reinsert card." + /etc/init.d/$DECISION start +) | $OPIE_SH -t "confirmation" -f \ + + +cleanup 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 @@ +#!/bin/sh + +# rsyncme.sh - a demonstration of opie-sh +# +# Copyright (C) 2002 gonz@directbox.com +# +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 2, or (at your option) +# any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# 20020517-1 - added icon, changed name in launcher +# + +CFG=/opt/QtPalmtop/share/config/rsyncme.cfg +OPIE_SH=opie-sh + +update_cfg() { + # check if dir is in CFG and if not add it + if [ "`grep -c $DIR $CFG`" = "0" ] + then echo $DIR >>$CFG + fi +} + +ask_dirs() { + # get source and destination dir + DIR=`$OPIE_SH -g -i -t "Choose Source Directory" -l -L DIR: -E -F $CFG ` + update_cfg + SRCDIR=$DIR + + DIR=`$OPIE_SH -g -i -t "Choose Destination Directory" -l -L DIR: -E -F $CFG ` + update_cfg + DESTDIR=$DIR +} + +ask_options() { + # now ask for options + OPTIONS="--archive --verbose --checksum --recursive --update --links --partial --dry-run --rsh=ssh --existing --compress --recursive" + OUTPUT=`( for OPTION in $OPTIONS + do + echo "$OPTION" + done ) | $OPIE_SH -t "Select options" -g -i -b -F ` +} + +rsync_output() { + ( echo "<h3>Output of your rsync:</h3>" + echo "command: rsync $OUTPUT $SRCDIR $DESTDIR" + echo "<pre>" + rsync $OUTPUT $SRCDIR $DESTDIR 2>&1 + echo "</pre>done." + ) | $OPIE_SH -t "Result:" -f +} + +cleanup() { + kill $SCREENCLEAN + rm -f /tmp/qcop-msg-rsyncme.sh +} + +show_dirs() { + ( echo "<h3>Directorys chosen for sync:</h3>" + echo "<ul><li>$SRCDIR<li>$DESTDIR</ul>" ) \ + | $OPIE_SH -t "Got directories" -f +} + +about() { + ( echo "<img src=/opt/QtPalmtop/pics/opie-sh-scripts/rsyncme.png>" + echo "<h3>About</h3>" + echo "This little App should make it possible for you to " + echo "easily choose the wanted options for an rsync process." + echo "<p>" + ) | $OPIE_SH -t rsync-helper -f & + SCREENCLEAN=$! + sleep 1 +} + + + + +##################################################################### +# +# main + +about + +# ask to: start rsync, edit dirlist, show about +$OPIE_SH -m -g -t RsyncMe -M "Welcome!" -0 Start -1 Dirlist +RETURNCODE=$? +case $RETURNCODE in +-1) echo died unexpectedly... | $OPIE_SH -f + cleanup + exit ;; +1) textedit $CFG + cleanup ;; +0) if [ -f $CFG ] + then ask_dirs + show_dirs + ask_options + rsync_output + else ( echo no config file seems to exist - see About... ) \ + | $OPIE_SH -t "SORRY..." -f + fi + cleanup + ;; +esac diff --git a/noncore/tools/opie-sh/scripts/service_manager.sh b/noncore/tools/opie-sh/scripts/service_manager.sh new file mode 100755 index 0000000..d1423a5 --- a/dev/null +++ b/noncore/tools/opie-sh/scripts/service_manager.sh @@ -0,0 +1,110 @@ +#!/bin/sh + +# service_manager.sh - a demonstration of opie-sh +# +# Copyright (C) 2002 gonz@directbox.com +# +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 2, or (at your option) +# any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# 20020524-1 - added icon to statusinfo... +# 20020518-1 - optix +# 20020517-1 - added about and fullscreen +# + +OPIE_SH=/opt/QtPalmtop/bin/opie-sh +INITPATH=/etc/init.d + +###################################################################### +# subroutines + +about() { + ( echo "<img src=/opt/QtPalmtop/pics/opie-sh-scripts/service_manager.png>" + echo "<h3>About</h3>" + echo "This little App should make it possible for you to " + echo "easily start and stop services in /etc/init.d." + echo "<p>" + ) | $OPIE_SH -t service-manager -f & + SCREENCLEAN=$! + sleep 1 +} + +cleanup() { + kill $SCREENCLEAN + rm -f /tmp/qcop-msg-service_manager.sh +} + +get_action() { + # ask what to do (start/stop/status) + # + $OPIE_SH -m -t "Select Action" \ + -M "which action do you want to do to $SERVICE ?<br>" \ + -g -0 start -1 stop -2 status + RETURNCODE=$? + + case $RETURNCODE in + -1) echo unexpected input detected, exiting. + exit ;; + 0) ACTION=start ;; + 1) ACTION=stop ;; + 2) ACTION=status ;; + esac +} + +status_disclaimer() { + # tell that init scripts are not too standard + # + cat | $OPIE_SH -f <<EOT +<img src=/opt/QtPalmtop/pics/opie-sh-scripts/service_manager.png> +<h3>status has been disabled</h3> + + the status service has been disabled + because it is not supported by the + most init scripts that come with + familiar ...<p> + + perhaps it will be replaced with + something more useful in the future... +EOT +} + +select_service() { + # present service list and choose + # + cd $INITPATH/ + SERVICE=` ls -1 | $OPIE_SH -i -l \ + -g -t "Select Service" \ + ` + cd - +} + +###################################################################### +# main + +about +select_service +get_action + +if [ "$SERVICE" = "" ] +then cleanup ; exit +fi + +if [ "$ACTION" = "status" ] +then status_disclaimer +else ( echo "<h3>Output of $INITPATH/$SERVICE $ACTION:</h3>" + echo "<pre>" + $INITPATH/$SERVICE $ACTION + echo "</pre><p>" + echo done. + ) | $OPIE_SH -f +fi + +cleanup + diff --git a/noncore/tools/opie-sh/scripts/usbnetctrl.sh b/noncore/tools/opie-sh/scripts/usbnetctrl.sh new file mode 100755 index 0000000..a12f74b --- a/dev/null +++ b/noncore/tools/opie-sh/scripts/usbnetctrl.sh @@ -0,0 +1,90 @@ +#!/bin/sh + +# usbnetctrl.sh - a demonstration of opie-sh +# +# Copyright (C) 2002 gonz@directbox.com +# +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 2, or (at your option) +# any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# 20020524-1 - code beautification, added icons and reset +# 20020517-2 - bugfixed fullscreen, added info about ifconfig +# 20020517-1 - added about, fullscreen and icon + +OPIE_SH=/opt/QtPalmtop/bin/opie-sh + +###################################################################### +# subroutines + +about() { + ( echo "<img src=/opt/QtPalmtop/pics/opie-sh-scripts/usbnetctrl.png>" + echo "<h3>About</h3>" + echo "This little App should make it easy for you to " + echo "activate / deactivate the usbnet-driver (on ipaq)" + echo "<p>" + echo "To use it at first, you need to change the ifconfig" + echo "line in /opt/QtPalmtop/bin/usbnetctrl.sh." + ) | $OPIE_SH -t "usbnet control" -f & + SCREENCLEAN=$! + sleep 1 +} + +startup() { + ( echo "<img src=/opt/QtPalmtop/pics/opie-sh-scripts/usbnetctrl.png>" + echo "<h3>usbnet up</h3>" + modprobe usb-eth + + ifconfig usbf 10.3.0.226 netmask 255.255.255.0 \ + broadcast 10.3.0.255 + + ) 2>&1 | $OPIE_SH -t Output -f + if [ -f /root/masq.sh ] + then sh /root/masq.sh + fi +} + +stopit() { + ( echo "<img src=/opt/QtPalmtop/pics/opie-sh-scripts/usbnetctrl.png>" + echo "<h3>usbnet down</h3>" + ifconfig usbf down + sleep 1 + rmmod usb-eth + rmmod sa1100usb_core + ) 2>&1 | $OPIE_SH -t Output -f +} + + +cleanup() { + kill $SCREENCLEAN + rm -f /tmp/qcop-msg-usbnetctrl.sh +} + + +yesorno() { + $OPIE_SH -m -t "USB-Net start/stop" -M "What to do with usbnet: " \ + -g -0 Start -1 Stop -2 Restart + RETURNCODE=$? + + case $RETURNCODE in + -1) echo error... + cleanup + exit ;; + 0) startup ;; + 1) stopit ;; + 2) stopit ; sleep 1 ; startup ;; + esac +} + +###################################################################### +# main + +about +yesorno +cleanup |