Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/bin/sh
- # version: 1.0.0, 22-jul-2022, by eibgrad
- # function usage()
- usage() {
- echo 'Usage: merlin-installer.sh [options] pastebin-id [pastebin-id ...]'
- echo
- echo ' Download and install merlin script(s).'
- echo
- echo ' Options:'
- echo ' --noexec do NOT install script(s); only download to stdout'
- echo ' --nocom remove blank lines and pure/non-functional comments'
- echo ' --comp same as --nocom, plus remove leading whitespace'
- echo ' --debug install script(s) w/ debugging mode enabled'
- echo ' -h,--help this usage information'
- echo
- echo ' Note: use of --nocom or --comp implies --noexec'
- echo
- }
- # handle -h|--help option
- for opt; do case $opt in -h|--help) usage; exit 0;; esac; done
- # process command line options
- while [ $# -gt 0 ]; do
- case "$1" in
- '--noexec') noexec=;;
- '--nocom') nocom=; unset comp; noexec=;;
- '--comp') comp=; unset nocom; noexec=;;
- '--debug') debug=; export DEBUG=;;
- *) if echo "$1" | grep -q '^-'; then
- echo "error: unknown option: $1"; exit 1
- else
- break 2
- fi;;
- esac
- shift
- done
- [ "$1" ] || { echo "info: nothing to do"; exit 0; }
- # configure curl command
- CURL="curl -kLs -H 'Cache-Control: no-cache'"
- # assume remaining command line arguments are pastebin ids
- while [ $# -gt 0 ]; do
- # verify this is a known, supported merlin script
- case "$1" in
- 'hvHHic1V') ;; # merlin-ac68u-add-networks.sh
- 'AGNF8cC8') ;; # merlin-dns-monitor.sh
- 'F2GmyrCC') ;; # merlin-ovpn-client-killswitch.sh
- 'wyKu0pww') ;; # merlin-ovpn-client-watchdog.sh
- '9jHRA6DG') ;; # merlin-ovpn-lan2wan-by-domain.sh
- 'i8hpNGpq') ;; # merlin-ovpn-plex-pbr.sh
- 'SqReWZnB') ;; # merlin-ovpn-port-forward.sh
- 'MkKb9tia') ;; # merlin-ovpn-server-restart.sh
- 'kTThBV46') ;; # merlin-ovpn-sync-routes.sh
- 'MLtSBb6E') ;; # merlin-pptp-gw-override.sh
- 'b7p6f102') ;; # merlin-wol-port-forward.sh
- *) echo "error: file not found: $1"; shift; continue;;
- esac
- # configure url for raw pull (obscure from hosting site)
- url="$(echo wastebin | sed s/w/p/).com/raw/$1"
- if [ ${noexec+x} ]; then
- # retrieve, clean, and dump script to stdout
- if [ ${nocom+x} ]; then
- # remove blank lines and pure/non-functional comments
- $CURL $url | tr -d '\r' | sed -r '/^\s*($|#(\s|#|$))/d'; echo
- elif [ ${comp+x} ]; then
- # same as --nocom, plus remove leading whitespace
- $CURL $url | tr -d '\r' | sed -r 's/^\s*//;/^($|#(\s|#|$))/d'; echo
- else
- $CURL $url | tr -d '\r'; echo
- fi
- else
- # retrieve, clean, and execute the script
- $CURL $url | tr -d '\r' | sh
- fi
- shift
- done
- exit 0
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement