MAD_wrap.sh
Custom Build
Made this as it suits my needs better. Within seconds spawn a fresh uploads.txt and begin uploading.
This is helped massively by the MAD plugin made for use with make_topic.sh - location of the archive at upload doesn't really matter for the actual topic creation process. Very convenient.
Your mileage may vary...
#!/bin/bash
#***********************************************************
# MAD_wrap.sh - mad.sh custom wrapper by nukacola
# usage: ./MAD_wrap.sh [OPTIONS] [FILE1]..[FILE2]..[FILE3]..etc
# "best used as right click action in your preferred file manager"
#***********************************************************
r="$(tput sgr0)"
b="$(tput bold)"
tag_db="/path/to/tag_db.txt"
tag () { for u in "$@"; do printf '%b\n' "$(grep -Po "^$u=\K.*" "$tag_db")"; done }
#***********************************************************
while getopts "::clnxz" opt; do case "$opt" in
c) chk=1 ;;
l) run=1 ;;
n) new=1 ;;
x) ext=1 ;;
z) sel=1 ;;
*) exit 1;;
esac; done; shift "$((OPTIND-1))"
#***********************************************************
mad="/path/to/mad.sh"
mad_dir=$(dirname $mad)
uploadstxt="${mad_dir}/uploads.txt"
defaults="$(tag default_hosts)"
mapfile -d ',' -t d_hosts < <(printf '%s\n' "$defaults")
[[ "$ext" ]] && d_hosts+=("fdot" "upee" "qx" "envs" "x0")
hosts_list="$(printf '%s\n' "${d_hosts[*]}" | tr ' ' ',')"
prompt_hosts="${b}$(tag s_line)\n$(tag c_hosts)${r}$(tag d_prompt)\n"
#***********************************************************
[[ "$new" ]] && uploadstxt="${RANDOM}_MAD_up.txt"
[[ "$sel" ]] && read -rp "$(echo -e "${prompt_hosts}\n${defaults}")"$'\n\n' z_sel
[[ "$z_sel" == "d" ]] && z_sel="$hosts_list"
[[ "$sel" ]] && mapfile -d "," -t z_hosts <<< "${z_sel}"
#***********************************************************
add_to_uploads () {
#********Z********#
[[ "$sel" ]] && for host in "${z_hosts[@]}"; do {
printf '%s\n' "${filepath}|${host}" >> "$uploadstxt";}
done && printf "\\n" >> "$uploadstxt" && return 0
#********D********#
for host in "${d_hosts[@]}"; do {
printf '%s\n' "${filepath}|${host}" >> "$uploadstxt";}
done && printf "\\n" >> "$uploadstxt" && return 0
}
#***********************************************************
for fp in "$@"; do {
filepath="$(echo -n "$(realpath "$fp")")"
[[ ! -f "$filepath" ]] && {
echo -e "\nfile not found. skipping\n"
continue
}; add_to_uploads
} done
[[ "$chk" ]] && nano "$uploadstxt"
sleep 2; [[ "$run" ]] && {
"$mad" uploads "$uploadstxt"
}; exit 0