mirror of
https://github.com/bigbeartechworld/big-bear-scripts.git
synced 2026-07-22 05:31:58 -04:00
feat: add download-zim-files script
This commit is contained in:
23
download-zim-files/README.md
Normal file
23
download-zim-files/README.md
Normal 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
36
download-zim-files/run.sh
Normal 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"
|
||||
Reference in New Issue
Block a user