f around with if statements

This commit is contained in:
2024-12-11 20:05:47 +01:00
parent df6a41aa37
commit d8009184fc

View File

@ -1,42 +1,42 @@
#!/usr/bin/bash #!/usr/bin/bash
IGREEN="\033[0;92m" # Intense Green
IYELLOW="\033[0;93m" # Intense Yellow
IRED='\033[0;91m' # Intense Red
NO_COLOR="\033[0m" # Text Reset
[[ -z $1 ]] && exit 1 [[ -z $1 ]] && exit 1
if [[ -z $2 ]]; then if [[ -z $2 ]]; then
echo 'output=$([[ $(hostname) = \s\a\t\a\n ]] && cargo run -- add_url "$1" || ./Hentai add_url "$1")' output=$([[ $(hostname) = \s\a\t\a\n ]] && cargo run -- add_url "$1" || ./Hentai add_url "$1")
else else
echo 'output=$([[ $(hostname) = \s\a\t\a\n ]] && cargo run -- add_custom_name "$1" "$2" || ./Hentai add_custom_name "$1" "$2")' output=$([[ $(hostname) = \s\a\t\a\n ]] && cargo run -- add_custom_name "$1" "$2" || ./Hentai add_custom_name "$1" "$2")
fi fi
output="https://rule34.xxx/index.php?page=post&s=list&tags=donnard # Artists/donnard/Rule34" # output="https://rule34.xxx/index.php?page=post&s=list&tags=donnard # Artists/donnard/Rule34"
[[ $output =~ "#" ]] || (echo "$output" && exit) echo "$output"
[[ $output =~ "#" ]] || exit 1
url=$(echo "$output" | awk '{print $1}') url=$(echo "$output" | awk '{print $1}')
path=$(echo "$output" | awk '{print $3}') path=$(echo "$output" | awk '{print $3}')
echo "$url"
echo "$path"
if [[ $(hostname) = \s\a\t\a\n ]]; then if [[ $(hostname) = \s\a\t\a\n ]]; then
[[ -d ./Artists ]] || mkdir ./Artists [[ -d ./Artists ]] || mkdir ./Artists
rm -rf ./gallery-dl/*.sqlite3 ./gallery-dl/log.txt ./Artists/* || exit 1 rm -rf ./gallery-dl/*.sqlite3 ./gallery-dl/log.txt ./Artists/* || exit 1
fi fi
echo "command: gallery-dl --config ./gallery-dl/config.json --directory $path $url"
for ((n=0;n<5;n++)); do for ((n=0;n<5;n++)); do
gallery-dl --config ./gallery-dl/config.json --directory "$path" "$url" gallery-dl --config ./gallery-dl/config.json --directory "$path" "$url"
if [[ $(echo $?) -eq 0 ]]; then [[ $(echo $?) -eq 0 ]] && (echo -e "${IGREEN}Success${NO_COLOR}"; break)
break
fi
echo -e "${IYELLOW}download failed${NO_COLOR}" echo -e "${IYELLOW}download failed${NO_COLOR}"
if [[ $(ping -qc 3 v4.ip.hopeless-cloud.xyz > /dev/null 2>&1) -ne 0 ]]; then [[ $(ping -c 3 v4.ip.hopeless-cloud.xyz > /dev/null 2>&1) -ne 0 ]] && (echo -e "${IRED}no internet${NO_COLOR}"; exit 1)
echo -e "${IYELLOW}no internet${NO_COLOR}" [[ $(ping -c 3 v6.ip.hopeless-cloud.xyz > /dev/null 2>&1) -ne 0 ]] && (echo -e "${IRED}no internet${NO_COLOR}"; exit 1)
exit 1
elif [[ $(ping -qc 3 v6.ip.hopeless-cloud.xyz > /dev/null 2>&1) -ne 0 ]]; then
echo -e "${IYELLOW}no internet${NO_COLOR}"
exit 1
fi
echo -e "${IGREEN}has internet${NO_COLOR}" echo -e "${IGREEN}has internet${NO_COLOR}"
done done