feat: add download-zim-files script

This commit is contained in:
Christopher
2024-07-12 12:15:50 -05:00
parent fd09bc224e
commit 205a485ff8
2 changed files with 59 additions and 0 deletions

View File

@@ -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)" -- <url> <custom_destination_directory>
```
Replace `<url>` with the URL of the ZIM file you want to download, and `<custom_destination_directory>` with the path to the directory where you want to save the ZIM file.
If `<custom_destination_directory>` 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
```

36
download-zim-files/run.sh Normal file
View File

@@ -0,0 +1,36 @@
#!/bin/bash
# Check if URL is provided
if [ -z "$1" ]; then
echo "Usage: $0 <url> [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"