summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDeepti Kulkarni <deepti@vyatta.com>2010-07-23 18:19:16 +0000
committerDeepti Kulkarni <deepti@vyatta.com>2010-07-23 18:19:16 +0000
commit7d4d9c74b8105a27cc54f55ddb98ea90112e13c6 (patch)
tree50fa41374693fa9d1a6b34034a7e7d6eb450c68c
parent6e3565d26d29120f73a13f5747d10038ed5e5b67 (diff)
downloadvyatta-op-7d4d9c74b8105a27cc54f55ddb98ea90112e13c6.tar.gz
vyatta-op-7d4d9c74b8105a27cc54f55ddb98ea90112e13c6.zip
Adding 'generate tech-support archive'command
-rw-r--r--Makefile.am1
-rwxr-xr-xscripts/tech-support-archive72
-rwxr-xr-xscripts/vyatta-remote-copy.pl4
-rw-r--r--templates/generate/node.def1
-rw-r--r--templates/generate/tech-support/archive/node.def2
-rw-r--r--templates/generate/tech-support/archive/node.tag/node.def4
-rw-r--r--templates/generate/tech-support/node.def1
7 files changed, 85 insertions, 0 deletions
diff --git a/Makefile.am b/Makefile.am
index 589bb2c..e2c30a9 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -29,6 +29,7 @@ bin_SCRIPTS += scripts/show-image-storage.pl
bin_SCRIPTS += scripts/node-exists.pl
bin_SCRIPTS += scripts/vyatta-remote-copy.pl
bin_SCRIPTS += scripts/vyatta-show-current-user
+bin_SCRIPTS += scripts/tech-support-archive
sbin_SCRIPTS = scripts/dhcpv6-client-show-leases.pl
diff --git a/scripts/tech-support-archive b/scripts/tech-support-archive
new file mode 100755
index 0000000..977bce3
--- /dev/null
+++ b/scripts/tech-support-archive
@@ -0,0 +1,72 @@
+# implement "generate tech-support archive"
+# usage: tech-support archive [ <filename> | <scp://> | <ftp://> ]
+
+FLAG=2
+REMOTE=0
+DEFAULT_PATH=/opt/vyatta/etc/config/support
+DEFAULT_GROUP=users
+FILE_NAME=0
+
+do_rotate ()
+{
+ local count=`ls -t $DEFAULT_PATH/*.tech-support-archive.* 2>/dev/null |wc -l`
+ if (( count >= 5 )); then
+ local dfile=`ls -t $DEFAULT_PATH/*.tech-support-archive.* 2>/dev/null |tail -1`
+ rm -f $dfile >&/dev/null \
+ && echo "Removed old tech-support output file '$dfile'"
+ fi
+}
+
+HOSTNAME=`hostname`
+CURTIME=`date +%F-%H%M%S`
+
+ if [ -n "$1" ]; then
+ if [[ "$1" =~ scp:///* ]]; then
+ OUT="$HOSTNAME.tech-support-archive.$CURTIME"
+ REMOTE="1"
+ elif [[ "$1" =~ ftp:///* ]]; then
+ OUT="$HOSTNAME.tech-support-archive.$CURTIME"
+ REMOTE="1"
+ else
+ #file to be save locally
+ OUT="$1.$HOSTNAME.tech-support-archive.$CURTIME"
+ fi
+ else
+ OUT="$HOSTNAME.tech-support-archive.$CURTIME"
+ fi
+
+ if [[ $OUT != /* ]]; then
+ FILE_NAME=$OUT
+ do_rotate
+ # it's not absolute path. save in default path.
+ OUT="$DEFAULT_PATH/$OUT"
+ mkdir -p $OUT >& /dev/null
+ chgrp $DEFAULT_GROUP $OUT >& /dev/null
+ chmod 775 $OUT >& /dev/null
+ else
+ mkdir -p $OUT >& /dev/null
+ chgrp $DEFAULT_GROUP $OUT >& /dev/null
+ chmod 775 $OUT >& /dev/null
+ FILE_NAME=`echo $OUT | sed -e 's/\//\n/g' | tail -1`
+ fi
+builtin cd "$OUT"
+echo "Saving the archivals..."
+sudo tar -zcf config.tgz /opt/vyatta/etc/config --exclude "*tech-support-archive*" >& /dev/null
+sudo tar -zcf etc.tgz /etc >& /dev/null
+#sudo tar -zcf home.tgz /home >& /dev/null
+sudo tar -zcf var-log.tgz /var/log >& /dev/null
+sudo tar -zcf root.tgz /root >& /dev/null
+sudo tar -zcf tmp.tgz /tmp >& /dev/null
+sudo tar -zcf core-dump.tgz /var/core >& /dev/null
+
+builtin cd "../"
+sudo tar -zcvf $FILE_NAME.tgz $FILE_NAME >& /dev/null
+sudo rm -r $FILE_NAME
+OUT=$OUT.tgz
+echo "Saved tech-support archival at $OUT"
+
+if [ $REMOTE == "1" ]; then
+ perl /opt/vyatta/bin/vyatta-remote-copy.pl $1 $OUT $FLAG
+fi
+
+exit
diff --git a/scripts/vyatta-remote-copy.pl b/scripts/vyatta-remote-copy.pl
index 93507ad..78959ec 100755
--- a/scripts/vyatta-remote-copy.pl
+++ b/scripts/vyatta-remote-copy.pl
@@ -54,6 +54,10 @@ if ($flag == 0)
{
$save_file=$save_file . ".gz"
}
+if ($flag == 2)
+{
+ $save_file=$save_file . ".tgz"
+}
if ($mode eq 'url') {
print "Saving output to $save_file\n";
my $rc = system("curl -# -T $tmp_file $save_file");
diff --git a/templates/generate/node.def b/templates/generate/node.def
new file mode 100644
index 0000000..4acc647
--- /dev/null
+++ b/templates/generate/node.def
@@ -0,0 +1 @@
+help: Generate tech-support archival.
diff --git a/templates/generate/tech-support/archive/node.def b/templates/generate/tech-support/archive/node.def
new file mode 100644
index 0000000..68a5a2c
--- /dev/null
+++ b/templates/generate/tech-support/archive/node.def
@@ -0,0 +1,2 @@
+help: Generate tech-support archival at the specified path.
+run: ${vyatta_bindir}/tech-support-archive
diff --git a/templates/generate/tech-support/archive/node.tag/node.def b/templates/generate/tech-support/archive/node.tag/node.def
new file mode 100644
index 0000000..c6384ec
--- /dev/null
+++ b/templates/generate/tech-support/archive/node.tag/node.def
@@ -0,0 +1,4 @@
+help: Generate ecompressed tech-support archival at the specificed path.
+allowed: echo -n '<file> <scp://<user>:<passwd>@<host>/<file>> <ftp://<user>:<passwd>@<host>/<file>>'
+run: ${vyatta_bindir}/tech-support-archive "$4"
+
diff --git a/templates/generate/tech-support/node.def b/templates/generate/tech-support/node.def
new file mode 100644
index 0000000..b916eaa
--- /dev/null
+++ b/templates/generate/tech-support/node.def
@@ -0,0 +1 @@
+help: Generate tech-support archival for escalations.