Created
May 10, 2021 18:29
-
-
Save rehmatworks/621b614b09ad81880aa5b31e34a00459 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
echo """#!/bin/bash | |
theUrl=$1 | |
theFileName=$2 | |
theDirectoryName=$3 | |
if [ -z "$theUrl" ]; then | |
echo "Please provide a URL" | |
else | |
echo "Processing $theUrl" | |
if curl --output /dev/null --silent --head --fail "$theUrl"; then | |
echo "Downloading file $theFileName from $theUrl" | |
wget -q "$theUrl" -O "$theFileName" | |
if [ -z "$theDirectoryName" ]; then | |
thePath="apkmartdl/" | |
else | |
thePath="apkmartdl/$theDirectoryName/" | |
fi | |
if [ ! -f $theFileName ]; then | |
echo "File $theFileName does not exist." | |
else | |
echo "Uploading file $theFileName to cloud storage" | |
rclone copy "$theFileName" bb:"$thePath" | |
theDLLink="https://dl.apkmart.net/file/$thePath$theFileName" | |
theFileSize=`du -h "$theFileName" | cut -f1` | |
echo "File uploaded. Downlad link is $theDLLink and file size is $theFileSize" | |
echo "Deleting file $theFileName from local server." | |
rm "$theFileName" | |
fi | |
else | |
echo "The URL is invalid" | |
fi | |
fi""" > ~/upload.sh && \ | |
chmod +x ~/upload.sh |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment