daily pastebin goal
29%
SHARE
TWEET

Untitled

a guest Jul 21st, 2017 56 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. DBCLIENT="$(which dbclient)"
  2.  
  3. [ -z "$INJECT_USERNAME" ] && INJECT_USERNAME="root"
  4. [ -z "$INJECT_PASSWORD" ] && INJECT_PASSWORD="1q2w3e"
  5.  
  6. doremote() {
  7.   DROPBEAR_PASSWORD="$INJECT_PASSWORD" "$DBCLIENT" -y -y -A -l "$INJECT_USERNAME" "$INJECT_HOST" "$@"
  8. }
  9.  
  10. inject_headl() {
  11.   echo " - $1"
  12. }
  13.  
  14. inject_litp() {
  15.   echo -n " - $1 "
  16. }
  17.  
  18. inject_progr() {
  19.   echo -n '[ '
  20.   case $? in
  21.     0) echo 'ok ]' ;;
  22.     *) echo 'failed ]'; return 1 ;;
  23.   esac
  24. }
  25.  
  26. # inject SOURCE
  27. inject() {
  28.   if [ -z "$1" ]; then
  29.     echo 'USAGE: inject SOURCE'
  30.     return 1
  31.   fi
  32.  
  33.   local PSRC=".${1}.isp"
  34.   local DEST='~/.'"$$_$(basename "$1")"
  35.   echo "inject: $1 -> $PSRC -> $INJECT_USERNAME@$INJECT_HOST:$DEST"
  36.  
  37.   inject_litp patch
  38.   cp -f "$1" "$PSRC"
  39.   if [ "$(tail -n 1 "$1")" != 'rm -f "$0"' ]; then
  40.     echo 'rm -f "$0"' >> "$PSRC"
  41.   fi
  42.   [ -f ".${1}.isp" ]
  43.   inject_progr || return 1
  44.  
  45.   inject_litp upload
  46.   cat ".${1}.isp" | doremote "cat > $DEST" &>/dev/null
  47.   inject_progr || return 1
  48.  
  49.   inject_headl 'first clean'
  50.   rm -f ".${1}.isp"
  51.   inject_litp 'make executable'
  52.   doremote "chmod +x $DEST" &>/dev/null
  53.   inject_progr || return 1
  54.  
  55.   inject_headl 'execute'
  56.   doremote "$DEST" 2>&1 | tail -n +3
  57.   echo -n '   '
  58.   inject_progr || return 1
  59. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top