summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--Makefile.am1
-rwxr-xr-xfunctions/tech-support157
-rwxr-xr-xfunctions/tech-support-brief83
-rwxr-xr-xscripts/tech-support-archive78
-rwxr-xr-xscripts/vyatta-image-tools.pl99
-rwxr-xr-xscripts/vyatta-remote-copy.pl94
6 files changed, 165 insertions, 347 deletions
diff --git a/Makefile.am b/Makefile.am
index 3d5f475..1bc20b5 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -27,7 +27,6 @@ bin_SCRIPTS += scripts/show-dhcp-leases.pl
bin_SCRIPTS += scripts/vyatta-boot-image.pl
bin_SCRIPTS += scripts/rename-image.pl
bin_SCRIPTS += scripts/show-image-storage.pl
-bin_SCRIPTS += scripts/vyatta-remote-copy.pl
bin_SCRIPTS += scripts/vyatta-show-current-user
bin_SCRIPTS += scripts/tech-support-archive
bin_SCRIPTS += scripts/vyatta-op-cmd-wrapper
diff --git a/functions/tech-support b/functions/tech-support
index 5c619d6..14e3663 100755
--- a/functions/tech-support
+++ b/functions/tech-support
@@ -1,6 +1,6 @@
# implement "show tech-support"
# usage: tech-support [ save [ <filename> ] ]
-# usage: tech-support [ save-uncompressed [ <filename> ] ]
+# usage: tech-support [ save-uncompressed [ <filename> ] ]
# NOTE: this file is sourced, NOT executed
function header {
@@ -39,14 +39,14 @@ CURTIME=`date +%F-%H%M%S`
# "save" or save-uncompressed is specified. save output to file.
OUT="$HOSTNAME.tech-support.$CURTIME.txt"
if [ -n "$2" ]; then
- if [[ "$2" =~ scp:///* || "$2" =~ ftp:///* ]]; then
- REMOTE="1"
+ if [[ "$2" =~ scp:///* || "$2" =~ ftp:///* ]]; then
+ REMOTE="1"
else
- #file to be save locally
+ # File to be saved locally
OUT="$2.$OUT"
fi
fi
-
+
if [[ $OUT != /* ]]; then
# it's not absolute path. save in default path.
mkdir -p $DEFAULT_PATH >& /dev/null
@@ -59,7 +59,7 @@ if [[ $OUT != /* ]]; then
echo "Cannot create tech-support file '$OUT'"
exit 1
fi
- if [ $REMOTE != "1" ]; then
+ if [ $REMOTE != "1" ]; then
echo "Saving output to $OUT ..."
fi
fi
@@ -67,8 +67,8 @@ fi
(
export PATH=/sbin:/usr/sbin:$PATH
-header Show Tech-Support
-header CONFIGURATION
+header Show Tech-Support
+header CONFIGURATION
if cli-shell-api validateTmplPath entitlement; then
header Entitlement
@@ -78,16 +78,16 @@ fi
header VyOS Version and Package Changes
show version all
-header Configuration File
+header Configuration File
cat /opt/vyatta/etc/config/config.boot
header Running configuration
show configuration
-header Package Repository Configuration File
+header Package Repository Configuration File
cat /etc/apt/sources.list
-header User Startup Scripts
+header User Startup Scripts
cat /etc/rc.local
header Quagga Configuration
@@ -111,7 +111,7 @@ done
for eth in $(${vyos_completion_dir}/list_interfaces.py --type=ethernet)
do header "Physical Interface Details for $eth"
- show interfaces ethernet $eth physical
+ show interfaces ethernet $eth physical
/sbin/ethtool -k $eth
done
@@ -119,7 +119,7 @@ header "ARP Table (Total entries)"
show arp
header Number of incomplete entries in ARP table
-show arp | grep incomplete | wc -l
+show arp | grep incomplete | wc -l
header Bridge
/sbin/brctl show
@@ -168,19 +168,19 @@ show_route_limit ipv6 bgp 500
show_route_limit ipv6 '' 500
-header IPTABLES
+header IPTABLES
-header Filter Chain Details
+header Filter Chain Details
sudo /sbin/iptables -L -vn
-header Nat Chain Details
+header Nat Chain Details
sudo /sbin/iptables -t nat -L -vn
-header Mangle Chain Details
+header Mangle Chain Details
sudo /sbin/iptables -t mangle -L -vn
-header Raw Chain Details
+header Raw Chain Details
sudo /sbin/iptables -t raw -L -vn
header Save Iptables Rule-Set
@@ -188,7 +188,7 @@ sudo iptables-save -c
header SYSTEM
-header Show System Image Version
+header Show System Image Version
show system image version
header Show System Image Storage
@@ -196,7 +196,7 @@ show system image storage
header Current Time
date
-
+
header Installed Packages
dpkg -l
@@ -205,7 +205,7 @@ cat /proc/modules
header CPU
-header Installed CPU/s
+header Installed CPU/s
lscpu
header Cumulative CPU Time Used by Running Processes
@@ -213,7 +213,7 @@ top -n1 -b -S
header Hardware Interrupt Counters
cat /proc/interrupts
-
+
header Load Average
cat /proc/loadavg
@@ -222,7 +222,7 @@ ps -ef
header Memory
-header Installed Memory
+header Installed Memory
cat /proc/meminfo
header Memory Usage
@@ -249,12 +249,12 @@ cat /proc/mounts
header Diskstats
cat /proc/diskstats
-header Hard Drive Usage
+header Hard Drive Usage
df -h -x squashfs
header General System
-header Boot Messages
+header Boot Messages
cat /var/log/dmesg
header "Recent Kernel messages (dmesg)"
@@ -265,34 +265,34 @@ sudo lspci -vvx
header PCI Vendor and Device Codes
sudo lspci -nn
-
+
header System Info
${vyatta_bindir}/vyatta-show-dmi
header GRUB Command line
cat /proc/cmdline
-header Open Ports
+header Open Ports
sudo lsof -P -n -i
-header System Startup Files
+header System Startup Files
ls -l /etc/rc?.d
header Bash History
eval "cfg_users=($(cli-shell-api listActiveNodes system login user))"
for user in "${cfg_users[@]}"; do
- header "Bash History for $user";
- case $user in
+ header "Bash History for $user";
+ case $user in
root) file="/root/.bash_history";;
- *) file="/home/$user/.bash_history";;
- esac;
+ *) file="/home/$user/.bash_history";;
+ esac;
sudo cat $file | gawk '/^#[0-9]*/ {t = substr($0,2); next} {print strftime("%FT%T%z", t) " " $0}' | sort -u
done
-header Login History
+header Login History
last -ix
-header Recent Log Messages
+header Recent Log Messages
tail -n 250 /var/log/messages
header NTP
@@ -303,14 +303,14 @@ show ntp
###
-header BGP
+header BGP
if cli-shell-api existsActive protocols bgp; then
header BGP Summary
show ip bgp summary
header BGP Neighbors
show ip bgp neighbors
- header BGP Debugging Information
- show monitoring protocols bgp
+ header BGP Debugging Information
+ show monitoring protocols bgp
else
echo "BGP is not configured"
fi
@@ -323,7 +323,7 @@ else
echo "Clustering is not configured"
fi
-header DHCP Server
+header DHCP Server
if cli-shell-api existsActive service dhcp-server; then
header DHCP Leases
show dhcp server leases
@@ -342,20 +342,20 @@ header DHCP Client Leases
show dhcp client leases
fi
-header DHCPV6 Server
+header DHCPV6 Server
if cli-shell-api existsActive service dhcpv6-server; then
header DHCPV6 Server Status
- show dhcpv6 server status
+ show dhcpv6 server status
header DHCPV6 Server Leases
show dhcpv6 server leases
else
echo "DHCPV6 Server is not configured"
fi
-header DHCPV6 Relay
+header DHCPV6 Relay
if cli-shell-api existsActive service dhcpv6-relay; then
header DHCPV6 Relay Status
- show dhcpv6 relay-agent status
+ show dhcpv6 relay-agent status
else
echo "DHCPV6 Relay is not configured"
fi
@@ -365,31 +365,31 @@ is_dhcp=`show dhcpv6 client leases | wc -l`
if [ "$is_dhcp" == "1" ]; then
echo "DHCPV6 client is not configured"
else
-header DHCPV6 Client Leases
+header DHCPV6 Client Leases
show dhcpv6 client leases
fi
-header DNS
+header DNS
if cli-shell-api existsActive service dns; then
header DNS Dynamic Status
show dns dynamic status
header DNS Forwarding Statistics
show dns forwarding statistics
- header DNS Forwarding Nameservers
+ header DNS Forwarding Nameservers
show dns forwarding nameservers
else
echo "DNS is not configured"
fi
-header FIREWALL
+header FIREWALL
if cli-shell-api existsActive firewall; then
header Firewall Group
show firewall group
header Firewall Summary
show firewall summary
header Firewall Statistics
- show firewall statistics
+ show firewall statistics
else
echo "Firewall is not configured"
fi
@@ -404,7 +404,7 @@ if cli-shell-api existsActive vpn ipsec; then
show vpn ipsec sa detail
header IPSec sa Statistics
show vpn ipsec sa statistics
-
+
header /etc/ipsec.conf
cat /etc/ipsec.conf
@@ -431,7 +431,7 @@ fi
header FlowAccounting
if cli-shell-api existsActive system flow-accounting; then
- show flow-accounting
+ show flow-accounting
else
echo "Flow accounting is not configured"
fi
@@ -439,7 +439,7 @@ fi
header OPENVPN
if cli-shell-api existsActive interfaces openvpn; then
header OpenVPN Interfaces
- show interfaces openvpn detail
+ show interfaces openvpn detail
header OpenVPN Server Status
show openvpn status server
else
@@ -453,7 +453,7 @@ if cli-shell-api existsActive protocols ospf; then
header OSPF Route
show ip ospf route
header OSPF Debugging Information
- show monitoring protocols ospf
+ show monitoring protocols ospf
else
echo "OSPF is not configured"
fi
@@ -463,24 +463,24 @@ if cli-shell-api existsActive protocols ospfv3; then
header OSPFV3 Debugging Information
show monitoring protocols ospfv3
else
- echo "OSPFV3 is not configured"
+ echo "OSPFV3 is not configured"
fi
header Policy
if cli-shell-api existsActive policy; then
header IP Route Maps
- show ip protocol
+ show ip protocol
header Route-Map
show route-map
#header IP Access Lists
#show ip access-lists
header IP Community List
- show ip community-list
+ show ip community-list
else
echo "Policy is not configured"
fi
-
-header Traffic Policy
+
+header Traffic Policy
if cli-shell-api existsActive traffic-policy; then
header Current Traffic Policies
show queueing
@@ -491,16 +491,16 @@ fi
header RIP
if cli-shell-api existsActive protocols rip; then
header IP RIP
- show ip rip
+ show ip rip
header RIP Status
show ip rip status
header RIP Debugging Information
- show monitoring protocols rip
+ show monitoring protocols rip
else
echo "RIP is not configured"
fi
-header RIPNG
+header RIPNG
if cli-shell-api existsActive protocols ripng; then
header RIPNG Debugging Information
show monitoring protocols ripng
@@ -508,12 +508,12 @@ else
echo "RIPNG is not configured"
fi
-header VPN-L2TP
+header VPN-L2TP
if cli-shell-api existsActive vpn l2tp; then
header VPN ike secrets
show vpn ike secrets
header VPN rsa-keys
- show vpn ike rsa-keys
+ show vpn ike rsa-keys
header VPN ike sa
show vpn ike sa
header VPN ike Status
@@ -527,7 +527,7 @@ else
echo "VPN L2TP is not configured"
fi
-header VPN-PPTP
+header VPN-PPTP
if cli-shell-api existsActive vpn pptp; then
header VPN Remote-Access
show vpn remote-access
@@ -542,8 +542,8 @@ show vrrp detail
header WAN LOAD BALANCING
if cli-shell-api existsActive load-balancing wan; then
header Wan Load Balance
- show wan-load-balance
- header Wan Load Balance Status
+ show wan-load-balance
+ header Wan Load Balance Status
show wan-load-balance status
header Wan Load Balance Connection
show wan-load-balance connection
@@ -551,7 +551,7 @@ else
echo "Wan Load Balance is not configured"
fi
-header "WEBPROXY/URL-FILTERING"
+header "WEBPROXY/URL-FILTERING"
if cli-shell-api existsActive service webproxy url-filtering; then
header WebProxy Blacklist Categories
show webproxy blacklist categories
@@ -559,30 +559,31 @@ if cli-shell-api existsActive service webproxy url-filtering; then
show webproxy blacklist domains
header WebProxy Blacklist URLs
show webproxy blacklist urls
- header WebProxy Blacklist Log
+ header WebProxy Blacklist Log
show webproxy blacklist log summary
else
echo "Webproxy/URL-filtering is not configured"
fi
-
+
header "END OF TECH-SUPPORT FILE"
) 1>&$OUT 2>&1
if [ $OUT != "1" ]; then
chgrp $DEFAULT_GROUP $OUT >& /dev/null
chmod 664 $OUT >& /dev/null
- if [ $FLAG == "0" ]; then
+ if [ $FLAG == "0" ]; then
gzip $OUT
- OUT=$OUT.gz
- if [ $REMOTE != "1" ]; then
- echo "File $OUT is the compressed file."
- fi
- fi
-
- if [ $REMOTE != "1" ]; then
- echo "Done"
+ OUT=$OUT.gz
+ if [ $REMOTE != "1" ]; then
+ echo "File $OUT is the compressed file."
+ fi
+ fi
+
+ if [ $REMOTE != "1" ]; then
+ echo "Done."
fi
fi
-if [ $REMOTE == "1" ]; then
- perl /opt/vyatta/bin/vyatta-remote-copy.pl $2 $OUT $FLAG
+
+if [ $REMOTE == "1" ]; then
+ python3 -c "from vyos.remote import upload; upload(\"$OUT\", \"$2\")"
fi
diff --git a/functions/tech-support-brief b/functions/tech-support-brief
index 6035d4a..2c627d0 100755
--- a/functions/tech-support-brief
+++ b/functions/tech-support-brief
@@ -28,25 +28,25 @@ do_rotate ()
HOSTNAME=`hostname`
CURTIME=`date +%F-%H%M%S`
- if [ "$1" == "save-uncompressed" ]; then
- FLAG="1"
- elif [ "$1" == "save" ]; then
- FLAG="0"
- fi
+if [ "$1" == "save-uncompressed" ]; then
+ FLAG="1"
+elif [ "$1" == "save" ]; then
+ FLAG="0"
+fi
- if [ "$1" == "save" ] || [ "$1" == "save-uncompressed" ]; then
+if [ "$1" == "save" ] || [ "$1" == "save-uncompressed" ]; then
# "save" or save-uncompressed is specified. save output to file.
OUT="$HOSTNAME.tech-support.$CURTIME.txt"
if [ -n "$2" ]; then
- if [[ "$2" =~ scp:///* || "$2" =~ ftp:///* ]]; then
- REMOTE="1"
+ if [[ "$2" =~ scp:///* || "$2" =~ ftp:///* ]]; then
+ REMOTE="1"
else
#file to be save locally
OUT="$2.$OUT"
- fi
- fi
-
-if [[ $OUT != /* ]]; then
+ fi
+ fi
+
+ if [[ $OUT != /* ]]; then
# it's not absolute path. save in default path.
mkdir -p $DEFAULT_PATH >& /dev/null
chgrp $DEFAULT_GROUP $DEFAULT_PATH >& /dev/null
@@ -58,17 +58,16 @@ if [[ $OUT != /* ]]; then
echo "Cannot create tech-support file '$OUT'"
exit 1
fi
- if [ $REMOTE != "1" ]; then
- echo "Saving output to '$OUT'..."
- fi
-
+ if [ $REMOTE != "1" ]; then
+ echo "Saving output to '$OUT'..."
+ fi
fi
(
export PATH=/sbin:/usr/sbin:$PATH
-header Show Tech-Support Brief
-header CONFIGURATION
+header Show Tech-Support Brief
+header CONFIGURATION
header VyOS Version and Package Changes
@@ -86,19 +85,19 @@ header ROUTING
function show_route_limit ()
{
- NUM=$(show $1 route $2 | wc -l)
- # subtract 3 lines of header
- [ $NUM -gt 3 ] && NUM=$[$NUM - 3]
- OUTPUT=$(echo show $1 route $2 \(total $NUM\))
- CMD="show $1 route $2"
- if [ $3 -eq 0 ]
- then
- header $OUTPUT
- vtysh -c "$CMD"
- else
- header "$OUTPUT- limit $3"
- vtysh -c "$CMD" | head -n $3
- fi
+ NUM=$(show $1 route $2 | wc -l)
+ # subtract 3 lines of header
+ [ $NUM -gt 3 ] && NUM=$[$NUM - 3]
+ OUTPUT=$(echo show $1 route $2 \(total $NUM\))
+ CMD="show $1 route $2"
+ if [ $3 -eq 0 ]
+ then
+ header $OUTPUT
+ vtysh -c "$CMD"
+ else
+ header "$OUTPUT- limit $3"
+ vtysh -c "$CMD" | head -n $3
+ fi
}
#
@@ -119,7 +118,7 @@ show_route_limit ipv6 bgp 500
show_route_limit ipv6 '' 500
-header Recent 100 Log Messages
+header Recent 100 Log Messages
show log tail 100
header "END OF TECH-SUPPORT BRIEF FILE"
@@ -128,19 +127,19 @@ header "END OF TECH-SUPPORT BRIEF FILE"
if [ $OUT != "1" ]; then
chgrp $DEFAULT_GROUP $OUT >& /dev/null
chmod 664 $OUT >& /dev/null
- if [ $FLAG == "0" ]; then
- gzip $OUT
- OUT=$OUT.gz
- if [ $REMOTE != "1" ]; then
+ if [ $FLAG == "0" ]; then
+ gzip $OUT
+ OUT=$OUT.gz
+ if [ $REMOTE != "1" ]; then
echo "File $OUT is the compressed file."
- fi
+ fi
fi
- if [ $REMOTE != "1" ]; then
- echo "Done."
- fi
+ if [ $REMOTE != "1" ]; then
+ echo "Done."
+ fi
fi
+
if [ $REMOTE == "1" ]; then
- perl /opt/vyatta/bin/vyatta-remote-copy.pl $2 $OUT $FLAG
+ python3 -c "from vyos.remote import upload; upload(\"$OUT\", \"$2\")"
fi
-
diff --git a/scripts/tech-support-archive b/scripts/tech-support-archive
index 9524557..2321d76 100755
--- a/scripts/tech-support-archive
+++ b/scripts/tech-support-archive
@@ -19,54 +19,52 @@ do_rotate ()
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
+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 saved 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
- 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
+echo "Saving the archives..."
+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 tar zcvf $FILE_NAME.tgz $FILE_NAME >& /dev/null
sudo rm -r $FILE_NAME
-OUT=$OUT.tgz
+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
+ python3 -c "from vyos.remote import upload; upload(\"$OUT\", \"$1\")"
fi
-
-exit
diff --git a/scripts/vyatta-image-tools.pl b/scripts/vyatta-image-tools.pl
index 092cbf7..bdee0c5 100755
--- a/scripts/vyatta-image-tools.pl
+++ b/scripts/vyatta-image-tools.pl
@@ -51,16 +51,7 @@ sub conv_file {
$file = "/$file";
} elsif (lc($topdir) eq 'disk-install') {
$file = "/lib/live/mount/persistence/$file";
- } elsif (lc($topdir) eq 'tftp') {
- $file = $filein;
- $topdir = 'url';
- } elsif (lc($topdir) eq 'http') {
- $file = $filein;
- $topdir = 'url';
- } elsif (lc($topdir) eq 'ftp') {
- $file = $filein;
- $topdir = 'url';
- } elsif (lc($topdir) eq 'scp') {
+ } elsif (grep { lc($topdir) eq $_ } ("ftp", "tftp", "http", "https", "scp", "sftp")) {
$file = $filein;
$topdir = 'url';
} else {
@@ -123,7 +114,7 @@ sub url_copy {
print "Cannot upload to http url\n";
exit 1;
}
- curl_to($from, $to);
+ upload($from, $to);
} elsif ($f_topdir eq 'url') {
if (-d $to){
$from =~ /.*\/(.*)/;
@@ -135,7 +126,7 @@ sub url_copy {
}
}
}
- curl_from($from, $to);
+ download($from, $to);
}
exit 0;
}
@@ -215,90 +206,14 @@ sub rsync {
return $?;
}
-sub conv_spec_char {
- my ($inpt_data) = @_;
- #replace #
- $inpt_data =~ s/\#/%23/g;
- #replace @
- $inpt_data =~ s/\@/%40/g;
- return $inpt_data;
-}
-
-sub prepare_login_data {
- my ($uri_data) = @_;
- # Parse protocol
- if ($uri_data =~ /ftp\:\/\//){
- $uri_data = reverse($');
- # Separate host and username login data
- $uri_data =~ m/@/;
- my $host_data = reverse($`);
- my $login_data = reverse($');
- $login_data =~ /\:/;
- my $username = $`;
- my $password = conv_spec_char($');
- return "ftp://".$username.":".$password."@".$host_data;
- }
- return $uri_data;
-}
-
-sub curl_to {
+sub upload {
my ($from, $to) = @_;
- $to = prepare_login_data($to);
- my $rc = system("curl -# -T $from $to");
- if ($to =~ /scp/ && ($rc >> 8) == 51){
- $to =~ m/scp:\/\/(.*?)\//;
- my $host = $1;
- if ($host =~ m/.*@(.*)/) {
- $host = $1;
- }
- my $rsa_key = `ssh-keyscan -t rsa $host 2>/dev/null`;
- print "The authenticity of host '$host' can't be established.\n";
- my $fingerprint = `ssh-keygen -lf /dev/stdin <<< \"$rsa_key\" | awk {' print \$2 '}`;
- chomp $fingerprint;
- print "RSA key fingerprint is $fingerprint.\n";
- if (prompt("Are you sure you want to continue connecting (yes/no) [Yes]? ", -tynd=>"y")) {
- if (! -d "$ENV{HOME}/.ssh/") {
- mkdir "$ENV{HOME}/.ssh/";
- }
- open(my $known_hosts, ">>", "$ENV{HOME}/.ssh/known_hosts")
- or die "Cannot open known_hosts: $!";
- print $known_hosts "$rsa_key\n";
- close($known_hosts);
- $rc = system("curl -# -T $from $to");
- print "\n";
- }
- }
- print "\n";
+ system("python3 -c 'from vyos.remote import upload; upload(\"$from\", \"$to\")'")
}
-sub curl_from {
+sub download {
my ($from, $to) = @_;
- $from = prepare_login_data($from);
- my $rc = system("curl -# $from > $to");
- if ($from =~ /scp/ && ($rc >> 8) == 51){
- $from =~ m/scp:\/\/(.*?)\//;
- my $host = $1;
- if ($host =~ m/.*@(.*)/) {
- $host = $1;
- }
- my $rsa_key = `ssh-keyscan -t rsa $host 2>/dev/null`;
- print "The authenticity of host '$host' can't be established.\n";
- my $fingerprint = `ssh-keygen -lf /dev/stdin <<< \"$rsa_key\" | awk {' print \$2 '}`;
- chomp $fingerprint;
- print "RSA key fingerprint is $fingerprint.\n";
- if (prompt("Are you sure you want to continue connecting (yes/no) [Yes]? ", -tynd=>"y")) {
- if (! -d "$ENV{HOME}/.ssh/") {
- mkdir "$ENV{HOME}/.ssh/";
- }
- open(my $known_hosts, ">>", "$ENV{HOME}/.ssh/known_hosts")
- or die "Cannot open known_hosts: $!";
- print $known_hosts "$rsa_key\n";
- close($known_hosts);
- $rc = system("curl -# $from > $to");
- print "\n";
- }
- }
- print "\n";
+ system("python3 -c 'from vyos.remote import download; download(\"$to\", \"$from\")'");
}
sub y_or_n {
diff --git a/scripts/vyatta-remote-copy.pl b/scripts/vyatta-remote-copy.pl
deleted file mode 100755
index 23dd135..0000000
--- a/scripts/vyatta-remote-copy.pl
+++ /dev/null
@@ -1,94 +0,0 @@
-#!/usr/bin/perl
-
-# Author: Deepti Kulkarni
-# Date: May 2010
-# Description: script to save file remotely.
-
-# **** License ****
-# This program is free software; you can redistribute it and/or modify
-# it under the terms of the GNU General Public License version 2 as
-# published by the Free Software Foundation.
-#
-# 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.
-#
-# This code was originally developed by Vyatta, Inc.
-# Portions created by Vyatta are Copyright (C) 2006, 2007, 2008 Vyatta, Inc.
-# All Rights Reserved.
-# **** End License ****
-
-use strict;
-use lib "/opt/vyatta/share/perl5";
-use IO::Prompt;
-
-my $save_file;
-
-if (defined($ARGV[0])) {
- $save_file = $ARGV[0];
-}
-my $tmp_file = $ARGV[1];
-my $flag = $ARGV[2];
-
-my $mode = 'local';
-my $proto;
-
-if ($save_file =~ /^[^\/]\w+:\//) {
-
-if ($save_file =~ /^(\w+):\/\/\w/) {
- $mode = 'url';
- $proto = lc($1);
- if ($proto eq 'ftp') {
- }
- elsif ($proto eq 'scp') {
- } else {
- print "Invalid url protocol [$proto]\n";
- exit 1;
- }
- } else {
- print "Invalid url [$save_file]\n";
- exit 1;
- }
-}
-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");
- if ($proto eq 'scp' && ($rc >> 8) == 51){
- $save_file =~ m/scp:\/\/(.*?)\//;
- my $host = $1;
- if ($host =~ m/.*@(.*)/) {
- $host = $1;
- }
- my $rsa_key = `ssh-keyscan -t rsa $host 2>/dev/null`;
- print "The authenticity of host '$host' can't be established.\n";
- my $fingerprint = `ssh-keygen -lf /dev/stdin <<< \"$rsa_key\" | awk {' print \$2 '}`;
- chomp $fingerprint;
- print "RSA key fingerprint is $fingerprint.\n";
- if (prompt("Are you sure you want to continue connecting (yes/no) [Yes]? ", -tynd=>"y")) {
- mkdir "~/.ssh/";
- open(my $known_hosts, ">>", "$ENV{HOME}/.ssh/known_hosts")
- or die "Cannot open known_hosts: $!";
- print $known_hosts "$rsa_key\n";
- close($known_hosts);
- $rc = system("curl -# -T $tmp_file $save_file");
- print "\n";
- }
- }
- system("rm -f $tmp_file");
- if ($rc) {
- print "Error saving $save_file\n";
- exit 1;
- }
-}
-
-print "Done\n";
-exit 0;