view bin/moeauto @ 719:bcdf320dabf4 default tip

Rewrite the ed2k again in php Getting openssl to hash md4 is a pain.
author nanaya <me@nanaya.net>
date Sun, 10 Dec 2023 00:35:22 +0900
parents 5bafb912837e
children
line wrap: on
line source

#!/bin/sh

if [ "$#" -lt 1 ]; then
	cat <<EOF
Usage: $(basename -- "$0")
EOF
	exit 1
fi

if [ ! -r "$*" ] || [ -d "$*" ]; then
	cat <<EOF
File "$*" can't be read!
EOF
	exit 1
fi

SERVER=
while read LINE; do
	if [ -n "$(printf "%s" "${LINE}" | grep "^SERVER=")" ]; then
		SERVER=$(printf "%s" "${LINE}" | sed -e 's/SERVER=//')
	else
		[ -n "${SERVER}" ] && [ ! -z "$(printf "%s" "${LINE}" | grep -v "^$")" ] && moefetch fetch -s "${SERVER}" ${LINE}
	fi
done < "$*"