* [Bismark-commits] rev 349 - trunk/server/scripts
@ 2011-05-26 11:36 walter
0 siblings, 0 replies; only message in thread
From: walter @ 2011-05-26 11:36 UTC (permalink / raw)
To: bismark-commits
Author: walter
Date: 2011-05-26 13:36:22 +0200 (Thu, 26 May 2011)
New Revision: 349
Modified:
trunk/server/scripts/bdm
Log:
bdm: added check on device id
added cleardev command
Modified: trunk/server/scripts/bdm
===================================================================
--- trunk/server/scripts/bdm 2011-05-26 08:22:51 UTC (rev 348)
+++ trunk/server/scripts/bdm 2011-05-26 11:36:22 UTC (rev 349)
@@ -52,6 +52,8 @@
clearmsg [id] Delete pending messages
+ cleardev [id] Delete device from list
+
Options:
-o <ssh_opts> Additional SSH options
@@ -104,6 +106,7 @@
done
fi
else
+ check_device_id $2 || { echo -e "Unknown device $2\n"; help tunnel; }
[ $3 == "on" ] && start_tunnel $2 $4
[ $3 == "off" ] && stop_tunnel $2 $4
fi
@@ -111,11 +114,13 @@
gtunnel)
[ $2 ] || { echo -e "Missing parameter: <dev_id>\n"; help gtunnel; }
[ $2 == ALL ] && { echo -e "ALL not allowed\n"; help gtunnel; }
+ check_device_id $2 || { echo -e "Unknown device $2\n"; help gtunnel; }
start_gtunnel $2 $3
;;
console)
[ $2 ] || { echo -e "Missing parameter: <dev_id>\n"; help console; }
[ $2 == ALL ] && { echo -e "ALL not allowed\n"; help console; }
+ check_device_id $2 || { echo -e "Unknown device $2\n"; help console; }
echo "Connecting to $2"
console $2
;;
@@ -123,6 +128,7 @@
[ $2 ] || { echo -e "Missing parameter: <dev_id>\n"; help exec; }
[ $3 ] || { echo -e "Missing parameter: <command>\n"; help exec; }
[ $2 == ALL ] && { echo -e "ALL not allowed\n"; help exec; }
+ check_device_id $2 || { echo -e "Unknown device $2\n"; help exec; }
echo "Executing \"${p#* * }\" on $2"
console $2 ${p#* * }
;;
@@ -138,16 +144,19 @@
;;
upgrade)
[ $2 ] || { echo -e "Missing parameter: <dev_id>\n"; help upgrade; }
+ check_device_id $2 || { echo -e "Unknown device $2\n"; help upgrade; }
upgrade $2 $3
;;
config)
[ $2 ] || { echo -e "Missing parameter: <dev_id>\n"; help config; }
- [ $2 == ALL ] && echo $* | grep -q DEVICE_ID && { echo -e "ALL not allowed for DEVICE_ID\n"; help console; }
+ [ $2 == ALL ] && echo $* | grep -q DEVICE_ID && { echo -e "ALL not allowed for DEVICE_ID\n"; help config; }
+ check_device_id $2 || { echo -e "Unknown device $2\n"; help config; }
$*
;;
setuser)
[ $2 ] || { echo -e "Missing parameter: <dev_id>\n"; help setuser; }
[ $3 ] || { echo -e "Missing parameter: <username>\n"; help setuser; }
+ check_device_id $2 || { echo -e "Unknown device $2\n"; help setuser; }
setuser $2 $3
;;
settunnel)
@@ -161,11 +170,15 @@
copy)
[ $2 ] || { echo -e "Missing parameter: <file>\n"; help copy; }
[ $3 ] || { echo -e "Missing parameter: <dev_id>\n"; help copy; }
+ check_device_id $2 || { echo -e "Unknown device $2\n"; help copy; }
copy $2 $3
;;
clearmsg)
clearmsg $2
;;
+ cleardev)
+ cleardev $2
+ ;;
*)
[ $1 ] && echo "Unknown command: $1"
help
@@ -224,6 +237,18 @@
done
}
+# Check device ID
+# $1 = device id
+function check_device_id()
+{
+ if [ $(query $BDM_DB "SELECT id FROM devices WHERE \"id\"='$1';") ]; then
+ return 0
+ else
+ return 1
+ fi
+}
+
+
# Check forwarding port
# $1 = port number
function check_fwd_port()
@@ -665,6 +690,19 @@
fi
}
+# Clear pending messages
+# $1 = id
+function cleardev()
+{
+ if [ $1 ]; then
+ query $BDM_DB "DELETE FROM devices WHERE id=$1;"
+ else
+ echo "Delete all devices (yes/no)?"
+ read a
+ [ $a == "yes" ] && query $BDM_DB "DELETE FROM devices;"
+ fi
+}
+
## Main ##
# Set random seed
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2011-05-26 11:22 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2011-05-26 11:36 [Bismark-commits] rev 349 - trunk/server/scripts walter
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox