From 2a41dbc9ddce204c5d327d60231d6bcacd589e5b Mon Sep 17 00:00:00 2001 From: Gorgone Date: Mon, 24 Feb 2020 08:57:05 +0100 Subject: [PATCH] add ssh-editor plugin --- support/functions/_plugin_ssh_editor | 69 ++++++++++++++++++++++++++++ 1 file changed, 69 insertions(+) create mode 100644 support/functions/_plugin_ssh_editor diff --git a/support/functions/_plugin_ssh_editor b/support/functions/_plugin_ssh_editor new file mode 100644 index 0000000..1f6bd2f --- /dev/null +++ b/support/functions/_plugin_ssh_editor @@ -0,0 +1,69 @@ +#!/bin/bash + +#simplebuild_plugin ssh_editor + +ssh_editor(){ +if [ ! -n "$1" ]; +then + loginname="$(whoami)"; + password="$(whoami |rev)"; + ip="192.168.1."; + port="22"; + replace_target="y"; + stop_target="y"; + targetcam="/usr/bin/oscam_unstable"; + toolchain="openpli40"; + remote_command="/usr/bin/oscam_unstable -b -r 2 -c /etc/tuxbox/config"; +else + [ -f "$profdir/$1" ] && source "$profdir/$1"; +fi; +i=0; +config_parts=$($gui $st_ --title "-[ SSH Transfer Setup ]-" --form " " 15 65 8 \ +"loginname :" 1 1 "$loginname" 1 18 40 39 \ +"password :" 2 1 "$password" 2 18 40 39 \ +"ip/dyndns :" 3 1 "$ip" 3 18 40 39 \ +"port :" 4 1 "$port" 4 18 6 5 \ +"toolchain :" 5 1 "$toolchain" 5 18 40 39 \ +"targetcam :" 6 1 "$targetcam" 6 18 40 39 \ +"replace_target :" 7 1 "$replace_target" 7 18 1 1 \ +"stop_target :" 8 1 "$stop_target" 8 18 1 1 ) +return_value=$?;[ "$return_value" == "1" ] && bye;[ ! "$return_value" == "0" ] && ssh_editor; +remote_command_new=$($gui $st_ --title " -[ Remote Commands ]- " --inputbox '' 7 60 "$remote_command"); +return_value=$?;[ "$return_value" == "1" ] && bye;[ ! "$return_value" == "0" ] && ssh_editor; +config_file_name=$($gui $st_ --title " -[ $txt_ssh_profiles $txt_name ]- " --inputbox "$txt_ssh_profiles $txt_name $txt_example_name" 8 60 $(echo $toolchain| rev)); +return_value=$?;[ "$return_value" == "1" ] && bye;[ ! "$return_value" == "0" ] && ssh_editor;[ "${#config_file_name}" -lt "1" ] && ssh_editor; +for e in $config_parts; +do + case $i in + 0) echo "loginname=\"$e\"" >"$profdir/$config_file_name.ssh";; + 1) echo "password=\"$e\"" >>"$profdir/$config_file_name.ssh";; + 2) echo "ip=\"$e\"" >>"$profdir/$config_file_name.ssh";; + 3) echo "port=\"$e\"" >>"$profdir/$config_file_name.ssh";; + 4) echo "toolchain=\"$e\"" >>"$profdir/$config_file_name.ssh";; + 5) echo "targetcam=\"$e\"" >>"$profdir/$config_file_name.ssh";; + 6) echo "replace_target=\"$e\"" >>"$profdir/$config_file_name.ssh";; + 7) echo "stop_target=\"$e\"" >>"$profdir/$config_file_name.ssh";; + esac; + ((i++)); +done +echo "remote_command=\"$remote_command_new\"" >>"$profdir/$config_file_name.ssh";_list_ssh_profiles;}; + +ssh_profiles(){ _list_ssh_profiles;exit;}; +_list_ssh_profiles(){ cd $profdir;[ ! $menucall == "yes" ] && clear && echo -e $c_l && ologo; +if [ "$(ls -A $profdir/*.ssh 2>/dev/null)" ]; +then + sshprofiles=(*.ssh); + echo -e $y_l"\n $txt_ssh_profiles $txt_found $txt_for ( ./$(basename $0) upload name.ssh )"; + echo -e $w_l" =================================================\n"; + i=0; + for e in ${sshprofiles[@]}; + do + ((i++)); + echo -e $w_l" ($i) > $e"; + done; +else + echo -e $y_l"\n $txt_ssh_profiles $txt_found $txt_for ( ./$(basename $0) upload name.ssh )"; + echo -e $w_l" =================================================\n"; + echo -e $r_l" > $txt_error: $w_l$txt_ssh_profiles $txt_not_found"; +fi; +echo -e "\n$rs_";};