Add separate files for installing brave-extensions
This commit is contained in:
parent
d18e6cd765
commit
7689e2774b
2 changed files with 51 additions and 45 deletions
50
scripts/PopOS/software/brave-extensions.sh
Normal file
50
scripts/PopOS/software/brave-extensions.sh
Normal file
|
@ -0,0 +1,50 @@
|
||||||
|
#!/bin/bash
|
||||||
|
# Elevate script
|
||||||
|
if [ ! "$UID" -eq 0 ]
|
||||||
|
then
|
||||||
|
exec sudo bash "$0" "$USER"
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Download and extract `youtube-music-dl`
|
||||||
|
archiveName=$(sudo -u $1 mktemp)
|
||||||
|
sudo -u $1 wget https://github.com/dougppaz/youtube-music-dl/releases/download/v1.2.1/youtube-music-dl.zip -O $archiveName
|
||||||
|
extensionName=youtube-music-dl
|
||||||
|
|
||||||
|
contextRoot=$(sudo -u $1 mktemp -d)
|
||||||
|
extensionDir=$contextRoot/$extensionName
|
||||||
|
keyFile=$extensionDir.pem
|
||||||
|
extensionFile=$extensionDir.crx
|
||||||
|
manifestFile=$extensionDir/manifest.json
|
||||||
|
|
||||||
|
extensionRoot=/usr/share/brave-extensions
|
||||||
|
destination=$extensionRoot/$extensionName.crx
|
||||||
|
|
||||||
|
# Prepare extension
|
||||||
|
mkdir -p $extensionRoot
|
||||||
|
sudo -u $1 unzip $archiveName -d $extensionDir
|
||||||
|
sudo -u $1 brave-browser --pack-extension=$extensionDir
|
||||||
|
rm $archiveName
|
||||||
|
|
||||||
|
# Tamper manifest file
|
||||||
|
manifest="$(cat $manifestFile | jq ". + {key: "'"'"$(openssl rsa -in $keyFile -pubout -outform DER | openssl base64 -A)"'"'"}")"
|
||||||
|
manifest="$(echo $manifest | jq ".background.persistent = false")"
|
||||||
|
echo $manifest | sudo -u $1 tee $manifestFile
|
||||||
|
|
||||||
|
# Pack extension
|
||||||
|
extensionID=$(openssl rsa -in $keyFile -pubout -outform DER | sha256sum | head -c32 | tr 0-9a-f a-p)
|
||||||
|
extensionVersion=$(cat $manifestFile | jq -r '.version')
|
||||||
|
sudo -u $1 brave-browser --pack-extension=$extensionDir --pack-extension-key=$keyFile
|
||||||
|
|
||||||
|
# Install extension and preinstall it
|
||||||
|
cp $extensionFile $extensionRoot
|
||||||
|
configRoot=/opt/brave.com/brave/extensions/
|
||||||
|
rm -rf $contextRoot
|
||||||
|
chmod -R a+rx $extensionRoot
|
||||||
|
chmod -R u+w $extensionRoot
|
||||||
|
mkdir -p $configRoot
|
||||||
|
{
|
||||||
|
echo "{"
|
||||||
|
echo ' "external_crx": "'"$destination"'",'
|
||||||
|
echo ' "external_version": "'"$extensionVersion"'"'
|
||||||
|
echo "}"
|
||||||
|
} | tee $configRoot/$extensionID.json
|
|
@ -2,7 +2,7 @@
|
||||||
# Elevate script
|
# Elevate script
|
||||||
if [ ! "$UID" -eq 0 ]
|
if [ ! "$UID" -eq 0 ]
|
||||||
then
|
then
|
||||||
exec sudo bash "$0" "$USER"
|
exec sudo bash "$0"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Prepare
|
# Prepare
|
||||||
|
@ -13,47 +13,3 @@ echo "deb [signed-by=/usr/share/keyrings/brave-browser-archive-keyring.gpg arch=
|
||||||
# Install Brave
|
# Install Brave
|
||||||
apt update
|
apt update
|
||||||
apt install -y brave-browser
|
apt install -y brave-browser
|
||||||
|
|
||||||
# Download and extract `youtube-music-dl`
|
|
||||||
archiveName=$(sudo -u $1 mktemp)
|
|
||||||
sudo -u $1 wget https://github.com/dougppaz/youtube-music-dl/releases/download/v1.2.1/youtube-music-dl.zip -O $archiveName
|
|
||||||
extensionName=youtube-music-dl
|
|
||||||
|
|
||||||
contextRoot=$(sudo -u $1 mktemp -d)
|
|
||||||
extensionDir=$contextRoot/$extensionName
|
|
||||||
keyFile=$extensionDir.pem
|
|
||||||
extensionFile=$extensionDir.crx
|
|
||||||
manifestFile=$extensionDir/manifest.json
|
|
||||||
|
|
||||||
extensionRoot=/usr/share/brave-extensions
|
|
||||||
destination=$extensionRoot/$extensionName.crx
|
|
||||||
|
|
||||||
# Prepare extension
|
|
||||||
mkdir -p $extensionRoot
|
|
||||||
sudo -u $1 unzip $archiveName -d $extensionDir
|
|
||||||
sudo -u $1 brave-browser --pack-extension=$extensionDir
|
|
||||||
rm $archiveName
|
|
||||||
|
|
||||||
# Tamper manifest file
|
|
||||||
manifest="$(cat $manifestFile | jq ". + {key: "'"'"$(openssl rsa -in $keyFile -pubout -outform DER | openssl base64 -A)"'"'"}")"
|
|
||||||
manifest="$(echo $manifest | jq ".background.persistent = false")"
|
|
||||||
echo $manifest | sudo -u $1 tee $manifestFile
|
|
||||||
|
|
||||||
# Pack extension
|
|
||||||
extensionID=$(openssl rsa -in $keyFile -pubout -outform DER | sha256sum | head -c32 | tr 0-9a-f a-p)
|
|
||||||
extensionVersion=$(cat $manifestFile | jq -r '.version')
|
|
||||||
sudo -u $1 brave-browser --pack-extension=$extensionDir --pack-extension-key=$keyFile
|
|
||||||
|
|
||||||
# Install extension and preinstall it
|
|
||||||
cp $extensionFile $extensionRoot
|
|
||||||
configRoot=/opt/brave.com/brave/extensions/
|
|
||||||
rm -rf $contextRoot
|
|
||||||
chmod -R a+rx $extensionRoot
|
|
||||||
chmod -R u+w $extensionRoot
|
|
||||||
mkdir -p $configRoot
|
|
||||||
{
|
|
||||||
echo "{"
|
|
||||||
echo ' "external_crx": "'"$destination"'",'
|
|
||||||
echo ' "external_version": "'"$extensionVersion"'"'
|
|
||||||
echo "}"
|
|
||||||
} | tee $configRoot/$extensionID.json
|
|
||||||
|
|
Loading…
Reference in a new issue