diff --git a/amulecli/README.md b/amulecli/README.md new file mode 100644 index 0000000..71da8a4 --- /dev/null +++ b/amulecli/README.md @@ -0,0 +1,93 @@ +# aMule on the command line +- aMulecmd demo: https://youtu.be/IpHdH1mCUVc +- amule, emule, ed2k, edonkey2000, kademlia, p2p, file sharing, emule + +#### enable amule remote controls +- amule > preferences > remote controls > [x] accept external connections +- amule > preferences > remote controls > password > [0123456789] + +#### generate a remote.conf +---- + # amulecmd -h hostname -p ECport -P ECpassword -w + # amulecmd -h 192.168.1.xxx -p 4712 -P 0123456789 -w + amulecmd -h localhost -p 4712 -P 0123456789 -w +---- + +#### amulecmd.conf +- put amulecmd.conf in ~/.aMule/amulecmd.conf +- make sure all the login stuff is correct + +#### start daemon + amuled --full-daemon + + +#### start text client + amulecmd + +#### using scripts to start daemon and text client + amulecli-daemon-start ; amulecli-textmode + +#### Example Tmux Layout for Localhost + session="amule" + sessionexists=$(tmux list-sessions | grep "^$session":) + if [ -z "$sessionexists" ]; then + # create new session + tmux new-session -d -s "$session" -c "$HOME" + tmux new-window -t "$session":0 -n 'results' -c "$HOME" + tmux rename-window -t "$session":0 'results' + tmux send-keys -t "$session":0 "while true; do amulecli-results-hightop | less ; done" C-m + tmux split-window -t "$session":0 -v -l 10 -c "$HOME" + tmux send-keys -t "$session":0 'amulecli-daemon-start ; amulecli-textmode' C-m + + tmux new-window -t "$session":1 -n 'list-watch' -c "$HOME" + tmux send-keys -t "$session":1 'watch -n 5 -t amulecli-list' C-m + tmux split-window -t "$session":1 -v -l 15 -c "$HOME" + + tmux new-window -t "$session":2 -n 'servers' -c "$HOME" + tmux send-keys -t "$session":2 'watch -n 60 -t amulecli-servers' C-m + tmux split-window -t "$session":2 -v -l 10 -c "$HOME" + tmux send-keys -t "$session":2 'amulecli-textmode' C-m + + tmux new-window -t "$session":3 -n 'amulebay' -c "$HOME" + tmux send-keys -t "$session":3 "while true; do \ + tmux rename-window -t $session:3 amulebay && clear && \ + ranger ~/.aMule/Incoming ~/.aMule/Temp \ + --cmd='set preview_files false' ; done" C-m + + tmux switch-client -t "$session":0 + else + tmux switch-client -t "$session" + fi + +#### Example Tmux Layout for Server + session="amule-server" + sessionexists=$(tmux list-sessions | grep "^$session":) + if [ -z "$sessionexists" ]; then + # create new session + tmux new-session -d -s "$session" -c "$HOME" + tmux new-window -t "$session":0 -n 'results' -c "$HOME" + tmux rename-window -t "$session":0 'results' + tmux send-keys -t "$session":0 "while true; do amulecli-results-hightop --config ~/.aMule/amulecmd-server.conf | less ; done" C-m + tmux split-window -t "$session":0 -v -l 10 -c "$HOME" + tmux send-keys -t "$session":0 'amulecli-textmode --config ~/.aMule/amulecmd-server.conf' C-m + + tmux new-window -t "$session":1 -n 'list-watch' -c "$HOME" + tmux send-keys -t "$session":1 'watch -n 5 -t amulecli-list --config ~/.aMule/amulecmd-server.conf' C-m + tmux split-window -t "$session":1 -v -l 15 -c "$HOME" + + tmux new-window -t "$session":2 -n 'servers' -c "$HOME" + tmux send-keys -t "$session":2 'watch -n 60 -t amulecli-servers --config ~/.aMule/amulecmd-server.conf' C-m + tmux split-window -t "$session":2 -v -l 10 -c "$HOME" + tmux send-keys -t "$session":2 'amulecli-textmode --config ~/.aMule/amulecmd-server.conf' C-m + + tmux new-window -t "$session":3 -n 'amulebay' -c "$HOME" + tmux send-keys -t "$session":3 "while true; do \ + tmux rename-window -t $session:3 amulebay && clear && \ + ranger /run/user/1000/sshfs/heoyea@192.168.1.131/alfa/amule/completed \ + --cmd='set preview_files false' ; done" C-m + + tmux switch-client -t "$session":0 + else + tmux switch-client -t "$session" + fi + diff --git a/amulecli/amulecli-changeservers b/amulecli/amulecli-changeservers new file mode 100755 index 0000000..1643395 --- /dev/null +++ b/amulecli/amulecli-changeservers @@ -0,0 +1,37 @@ +#!/usr/bin/env sh +# author: gotbletu (@youtube|github|odysee) +# https://www.youtube.com/user/gotbletu + +helpmsg() { +cat </dev/null | grep "^ >" +} + +selected="$(domule "show servers" | fzf --prompt="amulecmd - connect to server: " | cut -d '[' -f2 | cut -d ']' -f1)" +[ -z "$selected" ] && exit +domule "connect $selected" diff --git a/amulecli/amulecli-daemon-kill b/amulecli/amulecli-daemon-kill new file mode 100755 index 0000000..d2c2ba6 --- /dev/null +++ b/amulecli/amulecli-daemon-kill @@ -0,0 +1,7 @@ +#!/usr/bin/env sh +# author: gotbletu (@youtube|github|odysee) +# https://www.youtube.com/user/gotbletu +# desc: kill local amule daemon and webui + +killall -9 amuled 2>/dev/null +killall -9 amuleweb 2>/dev/null diff --git a/amulecli/amulecli-daemon-start b/amulecli/amulecli-daemon-start new file mode 100755 index 0000000..fc19eac --- /dev/null +++ b/amulecli/amulecli-daemon-start @@ -0,0 +1,11 @@ +#!/usr/bin/env sh +# author: gotbletu (@youtube|github|odysee) +# https://www.youtube.com/user/gotbletu +# demo: https://youtu.be/IpHdH1mCUVc +# desc: start amule daemon + +# using until loop because the daemon doesnt always start +until [ "$(pidof -x amuled | wc -l)" = 1 ] ; do + amuled --full-daemon + sleep 8 +done diff --git a/amulecli/amulecli-fzf-cancel b/amulecli/amulecli-fzf-cancel new file mode 100755 index 0000000..19e13ab --- /dev/null +++ b/amulecli/amulecli-fzf-cancel @@ -0,0 +1,40 @@ +#!/usr/bin/env sh +# author: gotbletu (@youtube|github|odysee) +# https://www.youtube.com/user/gotbletu +# demo: https://youtu.be/IpHdH1mCUVc + +helpmsg() { +cat </dev/null \ + | grep "^ >" | paste -d " " - - | grep "Downloading\|Paused\|Waiting" | cut -d '>' -f2 | cut -c 2- +} +domulecmd() { + amulecmd --password "$amu_pass" --host "$amu_host" --port "$amu_port" --command "$@" 2>/dev/null +} +domule "show dl" | fzf --delimiter ' ' --with-nth='2..' --prompt="select amule file(s) to cancel: " \ + | cut -d ' ' -f1 | while read -r line; do domulecmd "cancel $line" ; done diff --git a/amulecli/amulecli-fzf-pause b/amulecli/amulecli-fzf-pause new file mode 100755 index 0000000..e073b89 --- /dev/null +++ b/amulecli/amulecli-fzf-pause @@ -0,0 +1,40 @@ +#!/usr/bin/env sh +# author: gotbletu (@youtube|github|odysee) +# https://www.youtube.com/user/gotbletu +# demo: https://youtu.be/IpHdH1mCUVc + +helpmsg() { +cat </dev/null | grep "^ >" | paste -d " " - - | grep "Downloading\|Waiting" | cut -d '>' -f2 | cut -c 2- +} +domulecmd() { + amulecmd --password "$amu_pass" --host "$amu_host" --port "$amu_port" --command "$@" 2>/dev/null +} + +domule "show dl" | fzf --delimiter ' ' --with-nth='2..' --prompt="select amule file(s) to pause: " \ + | cut -d ' ' -f1 | while read -r line; do domulecmd "pause $line" ; done diff --git a/amulecli/amulecli-fzf-resume b/amulecli/amulecli-fzf-resume new file mode 100755 index 0000000..bfe7374 --- /dev/null +++ b/amulecli/amulecli-fzf-resume @@ -0,0 +1,40 @@ +#!/usr/bin/env sh +# author: gotbletu (@youtube|github|odysee) +# https://www.youtube.com/user/gotbletu +# demo: https://youtu.be/IpHdH1mCUVc + +helpmsg() { +cat </dev/null | grep "^ >" | paste -d " " - - | grep "Paused" | cut -d '>' -f2 | cut -c 2- +} +domulecmd() { + amulecmd --password "$amu_pass" --host "$amu_host" --port "$amu_port" --command "$@" 2>/dev/null +} + +domule "show dl" | fzf --delimiter ' ' --with-nth='2..' --prompt="select amule file(s) to resume: " \ + | cut -d ' ' -f1 | while read -r line; do domulecmd "resume $line" ; done diff --git a/amulecli/amulecli-limit-download b/amulecli/amulecli-limit-download new file mode 100755 index 0000000..3a6f23f --- /dev/null +++ b/amulecli/amulecli-limit-download @@ -0,0 +1,37 @@ +#!/usr/bin/env sh +# author: gotbletu (@youtube|github|odysee) +# https://www.youtube.com/user/gotbletu + +helpmsg() { +cat </dev/null | grep '^ >' ; } +domule "set bwlimit down $1" diff --git a/amulecli/amulecli-limit-upload b/amulecli/amulecli-limit-upload new file mode 100755 index 0000000..3e046f3 --- /dev/null +++ b/amulecli/amulecli-limit-upload @@ -0,0 +1,37 @@ +#!/usr/bin/env sh +# author: gotbletu (@youtube|github|odysee) +# https://www.youtube.com/user/gotbletu + +helpmsg() { +cat </dev/null | grep '^ >' ; } +domule "set bwlimit up $1" diff --git a/amulecli/amulecli-list b/amulecli/amulecli-list new file mode 100755 index 0000000..05bba7d --- /dev/null +++ b/amulecli/amulecli-list @@ -0,0 +1,48 @@ +#!/usr/bin/env sh +# author: gotbletu (@youtube|github|odysee) +# https://www.youtube.com/user/gotbletu +# demo: https://youtu.be/IpHdH1mCUVc +# reff: https://www.verot.net/amule_monitor.htm?lang=en-GB +# http://wiki.amule.org/wiki/Making_a_handy_amulecmd_script +# usage: $ amule-list +# $ watch -t amule-list +# $ viddy -t amule-list + +helpmsg() { +cat </dev/null | grep "^ >" +} +echo " > aMulecmd: Listens on [$amu_host:$amu_port]" +domule "status" +domule "get bwlimits" # show bandwidth limits +domule "statistics" | grep 'Shared Files:' | sed 's/ \+/ /g' +echo " > ===== Downloading ==============" +domule "show dl" | cut -d' ' -f4- | sed -e 's/ \+/ /g' -e '1~2s/^/@ /' -e 's/\/ /\//g' -e '2~2s/-/ @ /g' -e '2~2s/^/ > /g' | tac | paste -d " " - - | grep "Downloading" | cut -d'@' -f1,2,5- | column -t -s'@' | cut -c-"$(tput cols)" +echo " > ===== InActive =================" +domule "show dl" | cut -d' ' -f4- | sed -e 's/ \+/ /g' -e '1~2s/^/@ /' -e 's/\/ /\//g' -e '2~2s/-/ @ /g' -e '2~2s/^/ > /g' | tac | paste -d " " - - | grep "Waiting\|Paused" | cut -d'@' -f1,2,5- | column -t -s'@' | cut -c-"$(tput cols)" +echo " > ===== Uploading ================" +domule "show ul" | sed -e 's/ \+/ /g' -e 's@http.*emule-project....@eMule@gi' -e 's@http.*aMule....@aMule@gi' -e 's@http.*adunanza....@AdunanzA@gi' diff --git a/amulecli/amulecli-log b/amulecli/amulecli-log new file mode 100755 index 0000000..e6bf403 --- /dev/null +++ b/amulecli/amulecli-log @@ -0,0 +1,34 @@ +#!/usr/bin/env sh +# author: gotbletu (@youtube|github|odysee) +# https://www.youtube.com/user/gotbletu +# usage: $ amule-log | tail -20 +# $ watch -t "amule-log | tail -20" +# $ viddy -t "amule-log | tail -20" + +helpmsg() { +cat </dev/null | grep '^ > [[:alnum:]]' +} +domule "show log" | grep -v -E 'New external connection accepted|Access granted.|External connection closed.|Connecting client: aMulecmd GIT' diff --git a/amulecli/amulecli-rescan b/amulecli/amulecli-rescan new file mode 100755 index 0000000..0c7fbf4 --- /dev/null +++ b/amulecli/amulecli-rescan @@ -0,0 +1,31 @@ +#!/usr/bin/env sh +# author: gotbletu (@youtube|github|odysee) +# https://www.youtube.com/user/gotbletu + +helpmsg() { +cat </dev/null +} +domule "reload shared" diff --git a/amulecli/amulecli-results-highbottom b/amulecli/amulecli-results-highbottom new file mode 100755 index 0000000..28f544d --- /dev/null +++ b/amulecli/amulecli-results-highbottom @@ -0,0 +1,42 @@ +#!/usr/bin/env sh +# author: gotbletu (@youtube|github|odysee) +# https://www.youtube.com/user/gotbletu +# demo: https://youtu.be/IpHdH1mCUVc +# depend: amule awk grep sed coreutils fzf +# usage: $ amule-results +# $ viddy -t amule-results +# $ while true; do amule-results | less ; done +# ^ to kill a infinite while loop, use ctrl-z to suspend, kill %1 + +helpmsg() { +cat </dev/null +} +### Note: not possible to send two commands 'Results' and 'Download ' in the same session + +## sort by highest (bottom-to-top) +domule "results" | sed '1,4d' | head -2 +domule "results" | sed -e '1,6d' -e '$d' | awk '{print $NF,$0}' | sort -n | cut -f2- -d' ' +echo ""$(domule "results" | tail -1 | sed 's/^\ //g')" ---> Sorted by Highest Sources (bottom-to-top)" diff --git a/amulecli/amulecli-results-hightop b/amulecli/amulecli-results-hightop new file mode 100755 index 0000000..f94747b --- /dev/null +++ b/amulecli/amulecli-results-hightop @@ -0,0 +1,43 @@ +#!/usr/bin/env sh +# author: gotbletu (@youtube|github|odysee) +# https://www.youtube.com/user/gotbletu +# demo: https://youtu.be/IpHdH1mCUVc +# depend: amule awk grep sed coreutils fzf +# usage: $ amule-results +# $ viddy -t amule-results +# $ while true; do amule-results | less ; done +# ^ to kill a infinite while loop, use ctrl-z to suspend, kill %1 + +helpmsg() { +cat </dev/null +} +### Note: not possible to send two commands 'Results' and 'Download ' in the same session + +## sort by highest (top-to-bottom) +echo ""$(domule "results" | tail -1 | sed 's/^\ //g')" ---> Sorted by Highest Sources (top-to-bottom)" +domule "results" | sed '1,4d' | head -2 +domule "results" | sed -e '1,6d' -e '$d' | awk '{print $NF,$0}' | sort -n | cut -f2- -d' ' | tac + diff --git a/amulecli/amulecli-results-number b/amulecli/amulecli-results-number new file mode 100755 index 0000000..1d73a19 --- /dev/null +++ b/amulecli/amulecli-results-number @@ -0,0 +1,42 @@ +#!/usr/bin/env sh +# author: gotbletu (@youtube|github|odysee) +# https://www.youtube.com/user/gotbletu +# demo: https://youtu.be/IpHdH1mCUVc +# depend: amule awk grep sed coreutils fzf +# usage: $ amule-results +# $ viddy -t amule-results +# $ while true; do amule-results | less ; done +# ^ to kill a infinite while loop, use ctrl-z to suspend, kill %1 + +helpmsg() { +cat </dev/null +} +### Note: not possible to send two commands 'Results' and 'Download ' in the same session + +## sort by numbers (top-to-bottom) +domule "results" | sed '1,4d' + diff --git a/amulecli/amulecli-servers b/amulecli/amulecli-servers new file mode 100755 index 0000000..2d1c8fa --- /dev/null +++ b/amulecli/amulecli-servers @@ -0,0 +1,35 @@ +#!/usr/bin/env sh +# author: gotbletu (@youtube|github|odysee) +# https://www.youtube.com/user/gotbletu +# demo: https://youtu.be/IpHdH1mCUVc +# usage: $ amule-servers +# $ viddy -t amule-servers + +helpmsg() { +cat </dev/null | grep "^ >" +} +domule "statistics" | grep 'Uptime\|Failed Servers\|Working Servers' | sed 's/ \+/ /g' +domule "show servers" diff --git a/amulecli/amulecli-shared b/amulecli/amulecli-shared new file mode 100755 index 0000000..56af859 --- /dev/null +++ b/amulecli/amulecli-shared @@ -0,0 +1,36 @@ +#!/usr/bin/env sh +# author: gotbletu (@youtube|github|odysee) +# https://www.youtube.com/user/gotbletu +# depend: amule grep coreutils +# usage: $ amule-shared +# $ viddy -t amule-shared +# $ amule-shared | vim -R -c "set nowrap" - +# $ amule-shared | less + +helpmsg() { +cat </dev/null | grep '^ > [[:alnum:]]' +} +domule "show shared" diff --git a/amulecli/amulecli-statistics b/amulecli/amulecli-statistics new file mode 100755 index 0000000..9c3fb3c --- /dev/null +++ b/amulecli/amulecli-statistics @@ -0,0 +1,35 @@ +#!/usr/bin/env sh +# author: gotbletu (@youtube|github|odysee) +# https://www.youtube.com/user/gotbletu +# demo: https://youtu.be/IpHdH1mCUVc +# usage: $ amule-statistics +# $ watch -t amule-statistics +# $ viddy -t amule-statistics + +helpmsg() { +cat </dev/null | grep "^ >" +} +domule "statistics" diff --git a/amulecli/amulecli-textmode b/amulecli/amulecli-textmode new file mode 100755 index 0000000..c24cd8e --- /dev/null +++ b/amulecli/amulecli-textmode @@ -0,0 +1,32 @@ +#!/usr/bin/env sh +# author: gotbletu (@youtube|github|odysee) +# https://www.youtube.com/user/gotbletu +# demo: https://youtu.be/IpHdH1mCUVc + +helpmsg() { +cat </dev/null +} +domule diff --git a/amulecli/amulecmd.conf b/amulecli/amulecmd.conf new file mode 100644 index 0000000..8a95690 --- /dev/null +++ b/amulecli/amulecmd.conf @@ -0,0 +1,19 @@ +### Amulecmd Commandline External Connection login ### +## save this config to ~/.aMule/amulecmd.conf + +## required: +## amule > preferences > remote controls > [x] accept external connections +## amule > preferences > remote controls > password > [0123456789] +## $ amulecmd -h hostname -p ECport -P ECpassword -w +## $ amulecmd -h 192.168.1.xxx -p 4712 -P 0123456789 -w +## $ amulecmd -h localhost -p 4712 -P 0123456789 -w + +# remote access password (ECPassword) +amu_pass=0123456789 + +# remote access ip address +# amu_host=192.168.1.131 +amu_host=localhost + +# remote access port (ECPort) +amu_port=4712