diff --git a/download-zim-files/README.md b/download-zim-files/README.md new file mode 100644 index 0000000..112ed80 --- /dev/null +++ b/download-zim-files/README.md @@ -0,0 +1,23 @@ +# Run command + +```bash +bash -c "$(wget -qLO - https://raw.githubusercontent.com/bigbeartechworld/big-bear-scripts/master/download-zim-files/run.sh)" +``` + +# How to use + +Run the script with the URL of the ZIM file as the first argument, like so: + +```bash +bash -c "$(wget -qLO - https://raw.githubusercontent.com/bigbeartechworld/big-bear-scripts/master/download-zim-files/run.sh)" -- +``` + +Replace `` with the URL of the ZIM file you want to download, and `` with the path to the directory where you want to save the ZIM file. + +If `` is not provided, the script will use the default destination directory `/DATA/AppData/big-bear-kiwix-serve/zim`. + +Example: + +```bash +bash -c "$(wget -qLO - https://raw.githubusercontent.com/bigbeartechworld/big-bear-scripts/master/download-zim-files/run.sh)" -- https://download.kiwix.org/zim/wikipedia_en_ray_charles_2022-12.zim +``` diff --git a/download-zim-files/run.sh b/download-zim-files/run.sh new file mode 100644 index 0000000..45d81ec --- /dev/null +++ b/download-zim-files/run.sh @@ -0,0 +1,36 @@ +#!/bin/bash + +# Check if URL is provided +if [ -z "$1" ]; then + echo "Usage: $0 [destination_directory]" + exit 1 +fi + +URL=$1 +FILENAME=$(basename "$URL") +DEFAULT_DESTINATION="/DATA/AppData/big-bear-kiwix-serve/zim" +DESTINATION=${2:-$DEFAULT_DESTINATION} + +# Download the file to the home directory +wget -P ~/ "$URL" + +# Check if the download was successful +if [ $? -ne 0 ]; then + echo "Download failed!" + exit 1 +fi + +# Create the destination directory if it doesn't exist +mkdir -p "$DESTINATION" + +# Move the file to the desired directory +mv ~/"$FILENAME" "$DESTINATION" + +# Check if the move was successful +if [ $? -ne 0 ]; then + echo "Move failed!" + exit 1 +fi + +echo "Download and move completed successfully!" +echo "File moved to $DESTINATION"