Brave browser fetch script that makes .pet
So, here is a script to fetch the latest Brave browser and make it into a .pet file. It also has a basic version check so if ran via cron it should hopefully just cleanly exit if there is no need to update the .pet.
The idea of this script is to experiment with automating the pet creation of a program (Brave browser in this case) and automate keeping up with version updates. You can probably run this via cron and maybe add to the end some way to copy/upload the resulting pet to somewhere people can download it.
UPDATE: Decided to do a Google Drive folder to hold scripts and tests if anyone wants to try it out:
https://drive.google.com/drive/folders/ ... 4CUTEeBvPr
Code: Select all
#!/bin/bash
########################################################################
##
## Brave browser fetch for Puppy plus pet making
##
## Tested: Bookwormpup64
##
## Requires: bash, curl, jq, grep, head
##
## Version: 1.1
##
########################################################################
## Basic deps check
APPARRAY=(curl jq grep head)
function check_deps(){
for APP in "${APPARRAY[@]}"
do
which $APP > /dev/null 2>&1
rc=$?
if [ $rc == 0 ]; then
continue
fi
echo "deps not satisfied, please open script to verify"
exit 1
done
}
check_deps
## Get version numbers
ver=$(curl --silent "https://api.github.com/repos/brave/brave-browser/releases/latest" | jq --raw-output '.assets[] .browser_download_url' | grep 'linux-amd64' | head -n1 | cut -d/ -f8)
verl=$(cat ./version)
## Do we need to update?
if [ "$ver" == "$verl" ]; then
echo 'No new version detected, exiting'
exit 0
fi
## Updating version file
echo "$ver" > ./version
## Get the latest url release
url=$(curl --silent "https://api.github.com/repos/brave/brave-browser/releases/latest" | jq --raw-output '.assets[] .browser_download_url' | grep 'linux-amd64' | head -n1)
## Get it
wget -O './brave.zip' "$url" -q --show-progress
## extract it
mkdir -p "./brave-$ver/opt/brave-browser"
unzip brave.zip -d "./brave-$ver/opt/brave-browser"
## make it run in root
sed -i '$ d' "./brave-$ver/opt/brave-browser/brave-browser"
echo '"$HERE/brave" --no-sandbox "$@" || true' >> "./brave-$ver/opt/brave-browser/brave-browser"
#### Experimental pet making
mkdir -p "./brave-$ver/usr"
mkdir -p "./brave-$ver/usr/bin"
mkdir -p "./brave-$ver/usr/share"
mkdir -p "./brave-$ver/usr/share/applications"
cp "./brave-$ver/opt/brave-browser/product_logo_256.png" "./brave-$ver"
cat <<EOT >> "./brave-$ver/usr/share/applications/brave.desktop"
[Desktop Entry]
Encoding=UTF-8
Name=Brave web browser
Icon=product_logo_256.png
Comment=Brave web browser
Exec=brave-browser
Terminal=false
Type=Application
Categories=X-Internet-browser
GenericName=Brave web browser
EOT
ln -s /opt/brave-browser/brave-browser "./brave-$ver/usr/bin/brave-browser"
## make the pet
dir2pet -s -i="noarch" -n -c=Internet -x "brave-$ver"
## Cleanup
rm -rf "./brave-$ver"
rm ./brave.zip