Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- DBCLIENT="$(which dbclient)"
- [ -z "$INJECT_USERNAME" ] && INJECT_USERNAME="root"
- [ -z "$INJECT_PASSWORD" ] && INJECT_PASSWORD="1q2w3e"
- doremote() {
- DROPBEAR_PASSWORD="$INJECT_PASSWORD" "$DBCLIENT" -y -y -A -l "$INJECT_USERNAME" "$INJECT_HOST" "$@"
- }
- inject_headl() {
- echo " - $1"
- }
- inject_litp() {
- echo -n " - $1 "
- }
- inject_progr() {
- echo -n '[ '
- case $? in
- 0) echo 'ok ]' ;;
- *) echo 'failed ]'; return 1 ;;
- esac
- }
- # inject SOURCE
- inject() {
- if [ -z "$1" ]; then
- echo 'USAGE: inject SOURCE'
- return 1
- fi
- local PSRC=".${1}.isp"
- local DEST='~/.'"$$_$(basename "$1")"
- echo "inject: $1 -> $PSRC -> $INJECT_USERNAME@$INJECT_HOST:$DEST"
- inject_litp patch
- cp -f "$1" "$PSRC"
- if [ "$(tail -n 1 "$1")" != 'rm -f "$0"' ]; then
- echo 'rm -f "$0"' >> "$PSRC"
- fi
- [ -f ".${1}.isp" ]
- inject_progr || return 1
- inject_litp upload
- cat ".${1}.isp" | doremote "cat > $DEST" &>/dev/null
- inject_progr || return 1
- inject_headl 'first clean'
- rm -f ".${1}.isp"
- inject_litp 'make executable'
- doremote "chmod +x $DEST" &>/dev/null
- inject_progr || return 1
- inject_headl 'execute'
- doremote "$DEST" 2>&1 | tail -n +3
- echo -n ' '
- inject_progr || return 1
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement