#
basher install luisadha/weapon-url-opener
# `weapon-url-opener(1)` installer script that fetches the canonical `setup.sh` script and runs it
# in the calling context.
# ============================================================
# Script Name : ztme-toolbox.sh (Zero Tolerance for Major Errors)
# Version : 1.3.5
# Description : Interactive Manager Collection Script for bash
# Author : Luis Adha (luisadha.my.id)
# Created Date : 2025-Feb-05 (Wedn)
# License : Apache 2.0 License
# GitHub : https://github.com/luisadha/weapon-url-opener
# ============================================================
# ============================================================
# Script Name : wuo.sh / weapon-url-opener.sh
# Version : 1.4
# Description : Switch downloader scripts easily and quickly for termux-url-opener purpose.
# Author : Luis Adha (luisadha.my.id)
# Created Date : 2025-Feb-05 (Wedn)
# License : MIT
# GitHub : https://github.com/luisadha/weapon-url-opener
# ============================================================
#set -xv
user_agent=$_
run_with_curl=false
SCRIPT_NAME=${BASH_SOURCE[0]##*/}
BIN="${PREFIX}/bin"
version_ztme="1.3.5"
version_wuo="1.4"
version_both="1.3.5(1.4)"
banner='[ZTME-TOOLBOX]'
warn='[warning]'
fail='[failure]'
succ='[success]'
a_href="https://github.com/luisadha/weapon-url-opener/blob/master/README.md"
PS3="Your choice: "
if [[ -e /proc/self/fd/63 && $(readlink /proc/self/fd/63) == pipe:* ]]; then
#echo "Skrip dijalankan via source <(curl ...)"
run_with_curl=true
user_agent='curl'
fi
if [[ ${BASH_SOURCE[0]} != "$0" && "${run_with_curl}" != "true" ]]; then
user_agent='source'
echo -e "User Agent: $(echo "$user_agent" | awk -F/ '{print $NF}')";
echo -e "\nError: Don't use \`source ${SCRIPT_NAME}' or \`. ${SCRIPT_NAME}'";
echo -e "Use \`bash ${SCRIPT_NAME}' or \`${SCRIPT_NAME}'"
return 127 2>/dev/null || exit 127
fi
mkdir -p ~/bin
touch ~/bin/termux-url-opener 2>/dev/null;
SELFMD5="$(md5sum ~/bin/ztme-toolbox.sh 2>/dev/null | cut -d' ' -f1)"
TARGETMD5="$(md5sum "$HOME/bin/termux-url-opener" | cut -d' ' -f1)"
plugin_enabled=''
if [ "$SELFMD5" = "$TARGETMD5" ]; then
# echo "MD5 cocok!"
plugin_enabled=true
else
plugin_enabled=false
# echo "MD5 berbeda!"
fi
mkdir -p ~/.tmp
echo '#!/usr/bin/bash
exec ~/.tmp/ztme-toolbox.sh --uninstall "$@"' > ~/.local/bin/wuo-uninstall.sh
chmod +x ~/.local/bin/wuo-uninstall.sh
echo '#!/usr/bin/bash
exec ~/.tmp/ztme-toolbox.sh --run-wuo "$@"' > ~/.local/bin/wuo.sh
chmod +x ~/.local/bin/wuo.sh
[ -e "$HOME/.local/bin/wuo" ] || ln -sf ~/.local/bin/wuo.sh ~/.local/bin/wuo &>/dev/null;
cp -f ~/.basher/cellar/bin/weapon-url-opener.sh ~/.tmp/ztme-toolbox.sh 2>/dev/null;
#cp -f "$0" ${PREFIX:-/usr/local}/bin/weapon-url-opener 2>/dev/null; chmod +x ${PREFIX:-/usr/local}/bin/weapon-url-opener 2>/dev/null;
clonePackage() {
# local args="$1"
if timeout 10s ping -c 1 google.com &> /dev/null; then
if [ -z "${1:-$REPO_LINK}" ]; then
echo "$warn : Broken link."
exit 1
fi
REPO_FOLDER=$(basename "${1:-$REPO_LINK}" .git)
if git clone "${1:-$REPO_LINK}.git" "$REPO_FOLDER"; then
echo "$succ : Repo's was completly cloned, please refresh!"
else
echo "$fail : Unable to clone the repository, please correct the names. "
exit 1
fi
else
echo "$fail : Couldn't connected to internet!, Abort."
exit 2
fi
}
findMatch() {
find . -maxdepth 1 -type d -exec sh -c 'for d; do [ -f "$d/${d##*/}.sh" ] && basename "$d/${d##*/}.sh" .sh; done' _ {} +
}
findMatchRecursif() {
find . -type d -exec sh -c 'for d; do [ -f "$d/${d##*/}.sh" ] && basename "$d/${d##*/}.sh" ".sh"; done' _ {} +
}
wuo() {
#!/data/data/com.termux/files/usr/bin/bash
# weapon-url-opener v1.0
# Created March 2024
# by: luisadha
# Algoritm: dynamic-condition-response using 'select do' and etc.
cat << "EOF"
_ __ __
| | / /__ ____ _____ ____ ____ __ _______/ / ____ ____ ___ ____ ___ _____
| | /| / / _ \/ __ `/ __ \/ __ \/ __ \______/ / / / ___/ /_____/ __ \/ __ \/ _ \/ __ \/ _ \/ ___/
| |/ |/ / __/ /_/ / /_/ / /_/ / / / /_____/ /_/ / / / /_____/ /_/ / /_/ / __/ / / / __/ /
|__/|__/\___/\__,_/ .___/\____/_/ /_/ \__,_/_/ /_/ \____/ .___/\___/_/ /_/\___/_/
/_/ /_/
EOF
echo -e " ╔════════════════════════════════════════════════╗"
echo -e " )⇒ Project Name :weapon-url-opener x ztme ⇐("
echo -e " )⇒ Author :luisadha ⇐("
echo -e " )⇒ Github :github.com/luisadha ⇐("
echo -e " )⇒ Telegram :@adharudin14 ⇐("
echo -e " ╚════════════════════════════════════════════════╝"
echo -e " Version: v$version_wuo"
echo -e " Tips: Use CTRL + D or CTRL + Z to force exit!\n"
#test -f ~/bin/termux-url-opener
ref_hash=$(md5sum ~/bin/termux-url-opener | awk '{print $1}'); match="";
for file in ~/bin/*.sh; do
file_hash=$(md5sum "$file" | awk '{print $1}')
if [ "$ref_hash" = "$file_hash" ]; then
match=true
toggle="$(basename "$file")"
#echo -n " IN USE: $toggle"; echo
#cocok dengan termux-url-opener
else
match=false
toggle="$(basename "$file")" #idak cocok dengan termux-ur
#echo -n " IN USE: $toggle"; echo
fi
[[ "$match" == "true" ]] && echo " IN USE: $toggle"
done
echo
#file_list=($(ls -Art ~/bin/*.sh))
#file_list=( $(for file in "${file_list[@]}"; do basename "$file"; done) )
IFS=$'\n' read -d '' -r -a file_list < <(\ls -Art ~/bin/*.sh)
IFS=$'\n' read -d '' -r -a file_list < <(printf "%s\n" "${file_list[@]}" | xargs -n1 basename)
select weapon in "${file_list[@]}" "BACK"; do
{
diff -sq ~/bin/"$weapon" ~/bin/termux-url-opener > .weapon-url-opener.status 2>/dev/null
}
[[ -n "$weapon" ]] || { break; }
if [[ "$weapon" == "BACK" ]]; then
#echo "Exiting the program"
rm -f .weapon-url-opener.status
break
else
echo "You selected $(basename "$weapon") as primary weapon"
sleep 1
cp -f ~/bin/"$(basename "$weapon")" ~/bin/termux-url-opener
break
fi
done
}
while [[ $# -gt 0 ]]; do
case "$1" in
--add-repo)
clonePackage "$2"
shift 2
;;
--uninstall)
echo "Cleaning symlink."
rm -v ~/.local/bin/wuo.sh
rm -v ~/.local/bin/wuo
rm -v ~/.tmp/ztme-toolbox.sh
rm -v ~/.local/bin/wuo-uninstall.sh;
rm -v ${BIN}/ztme-toolbox
rm -v ~/bin/ztme-toolbox.sh
sleep 0.5
echo -n "..All done";
echo -e ""
echo -e "You can make symlink again with \`weapon-url-opener' or\n"
echo -e "Procced full erases with \`basher uninstall luisadha/weapon-url-opener'\n"
echo -e ""
exit 0
;;
--wuo|--run-wuo)
wuo
shift 2
;;
-h|--help)
echo "Help messages"
exit 0
;;
*)
if [[ "$1" =~ ^https?:// ]]; then
echo "Cloning repository from: $1"
clonePackage "$1"
shift
fi
;;
esac
done
files="$(findMatch)"
echo "Preparing..." && findMatch &>/dev/null
sleep 0.8 && clear
printf %"$(tput cols)"s | tr " " "-"
#echo "-------------------------------------------"
echo "ZTME-Toolbox x Weapon Url Opener v$version_both"
echo "Run script as interactively from repository. "
#echo "-------------------------------------------"
printf %"$(tput cols)"s | tr " " "-"
echo -e "User Agent: $(echo "$user_agent" | awk -F/ '{print $NF}')"
echo -e "Info : $a_href
Author: "
printf %"$(tput cols)"s | tr " " "-"
select filename in ${files} "Add repository (weapon-url-opener status)" "Fix issue if any" Exit;
do
[[ -n $filename ]] || { echo "$warn :What's that? Please try again." >&2; continue; }
case ${filename} in
"Exit")
echo "You selected $filename ($REPLY)"
echo "Exiting.."
break
;;
"Fix issue if any")
echo "You selected $filename ($REPLY)"
echo -e "Fixing the HISTSIZE BAD NUMBER issue..."
sleep 0.5
unset HISTSIZE
# echo -e "Fixing the REQUIRED FILE NOT FOUND issue..."
# sleep 0.5
echo -n "...Done!"
;;
"Add repository (weapon-url-opener status)")
if [[ "$plugin_enabled" == "true" ]]; then
echo "Info: Feature have been applied with termux-url-opener, try sharing the repository URL you want to clone via the Android Shared.";
else
[[ ! -f ~/bin/ztme-toolbox.sh ]] && echo -e "Warning: It seems that the file named \`ztme-Toolbox' is not in dir ~/bin\n";
echo -e "Do you want apply this feature into Termux-URL-Opener? (Y) \n";
[[ "$run_with_curl" == "true" ]] && echo -e "Warning: You cannot use this feature(y) until you have installed it completely. You can ignore this warning, (n) Continue as is \n"
read -r -p "Confirm (Y/n): " enableIt
if [[ "$enableIt" == "Y" ]] || [[ "$enableIt" == "y" ]]; then
if [[ "$user_agent" == "curl" ]]; then
echo -e "\nPlease install the entire package.\n";
break
fi
echo '#!/data/data/com.termux/files/usr/bin/bash
ztme-toolbox --add-repo "$@"' > ~/bin/ztme-toolbox.sh
cp -f "$0" "${BIN}/ztme-toolbox";
chmod +x "${BIN}/ztme-toolbox";
cp -f "${BIN}/ztme-toolbox" "${HOME}/.tmp/ztme-toolbox.sh" 2>/dev/null;
chmod +x ${HOME}/.tmp/ztme-toolbox.sh 2>/dev/null;
wuo
fi
fi
echo
echo "You selected $filename ($REPLY)"
echo "$banner : Paste your repository link below :"
read -r REPO_LINK
clonePackage "$REPO_LINK"
break
;;
*)
echo "You selected $filename ($REPLY)"
echo
chmod +x "${filename}"/"${filename,,}".sh
# termux-fix-shebang ${filename}/${filename,,}.sh
./"${filename}"/"${filename,,}".sh
echo
read -t 0.1
continue
;;
esac
done
#