Installation script, Arch hook

This commit is contained in:
Ld-Hagen
2021-09-25 22:03:43 +03:00
parent 7c5f5ffd5f
commit 7c750ca4ba
5 changed files with 102 additions and 33 deletions

View File

@@ -1,8 +1,8 @@
# Fix Opera Linux ffmpeg & WidevineCdm # Fix Opera Linux ffmpeg & WidevineCdm
* Fix Opera html5 media content * Fix Opera html5 media content including DRM-protected one.
* It script must be execute all times opera will fails on showing html5 media content. * It script must be execute all times opera will fails on showing html5 media content.
* Now it also fixes WidevineCdm support for DRM video. You can try it on Vevo youtube channel for example. * On Debian-based and Arch-based distros it may be started automatically after Opera update.
## Requirements ## Requirements
@@ -22,35 +22,7 @@
```cd ./fix-opera-linux-ffmpeg-widevine``` ```cd ./fix-opera-linux-ffmpeg-widevine```
3. (*Optional*) You may disable **Widevine** fix if one that comes with Opera works well for you. 3. Run install script and answer few questions.
```sed -i '/FIX_WIDEVINE=/s/true/false/g' ./fix-opera.sh```
4. Run script. And if it works well got ot next step.
```sudo ./fix-opera.sh``` ```sudo ./install.sh```
5. Create a **.scripts** folder on **root**'s **home**
```sudo mkdir ~root/.scripts```
6. Copy the script into the **.scripts** folder
```sudo cp ./fix-opera.sh ~root/.scripts```
7. Choose one or both options
* (*Optional*) Create an **alias**. And then you'll be able to start it by typing ```fix-opera``` command in terminal.
```echo "alias fix-opera='sudo ~root/.scripts/fix-opera.sh' # Opera fix HTML5 media" >> ~/.bashrc```
```source ~/.bashrc```
* (*Optional*) Autostart after each opera upgrade (Debian-based distros)
```sudo cp ./99fix-opera ~root/.scripts```
```sudo ln -s ~root/.scripts/99fix-opera /etc/apt/apt.conf.d/```
8. Delete the repo
```cd .. && rm -rf ./fix-opera-linux-ffmpeg-widevine```

85
install.sh Executable file
View File

@@ -0,0 +1,85 @@
#!/bin/bash
if [[ $(whoami) != "root" ]]; then
printf 'Try to run it with sudo\n'
exit 1
fi
readonly SCRIPT_PATH=$(dirname $(readlink -f $0))
readonly INSTALL_PATH="/root/.scripts"
readonly USER_NAME="$(logname)"
readonly USER_HOME=$(sudo -u $USER_NAME sh -c 'echo $HOME')
create_hook ()
{
printf 'Choose your Linux distro:\n'
printf ' 1. Debian-based (Debian/Ubuntu/Mint/etc.)\n'
printf ' 2. Arch-based (Arch/Manjaro/etc.)\n'
printf ' 0. Other\n'
while read -p "Your choice: " DISTRIB; do
case $DISTRIB in
"1" )
cp -f $SCRIPT_PATH/scripts/99fix-opera $INSTALL_PATH
ln -sf $INSTALL_PATH/99fix-opera /etc/apt/apt.conf.d/
break;;
"2" )
cp -f $SCRIPT_PATH/scripts/fix-opera.hook $INSTALL_PATH /usr/share/libalpm/hooks
ln -sf $INSTALL_PATH/fix-opera.hook /usr/share/libalpm/hooks/
break;;
"0" )
printf "Autostart for your Linux distro is currently unsupported\n"
break;;
* )
continue;;
esac
done
}
printf 'Would you like to apply Widevine CDM fix? [y/n]'
while read FIX_WIDEVINE; do
case $FIX_WIDEVINE in
"y" | "Y")
printf 'Setting FIX_WIDEVINE to true...\n'
sed -i '/FIX_WIDEVINE=/s/false/true/g' $SCRIPT_PATH/scripts/fix-opera.sh
break;;
"n" | "N")
printf 'Setting FIX_WIDEVINE to false...\n'
sed -i '/FIX_WIDEVINE=/s/true/false/g' $SCRIPT_PATH/scripts/fix-opera.sh
break;;
* )
printf 'Would you like to apply Widevine CDM fix? [y/n]'
continue;;
esac
done
mkdir -p $INSTALL_PATH
cp -f $SCRIPT_PATH/scripts/fix-opera.sh $INSTALL_PATH
printf "Would you like to create an alias for user $USER_NAME? [y/n]"
while read CREATE_ALIAS; do
case $CREATE_ALIAS in
"y" | "Y")
echo "alias fix-opera='sudo ~root/.scripts/fix-opera.sh' # Opera fix HTML5 media" >> $USER_HOME/.bashrc
printf "Alias will be available after your next logon.\n"
break;;
"n" | "N")
break;;
* )
printf "Would you like to create an alias for user $USER_NAME? [y/n]"
continue;;
esac
done
printf "Would you like to run it automatically after each Opera update? [y/n]"
while read CREATE_HOOK; do
case $CREATE_HOOK in
"y" | "Y")
create_hook
break;;
"n" | "N")
break;;
* )
printf "Would you like to create an alias for user $USER_NAME? [y/n]"
continue;;
esac
done

View File

@@ -1,2 +1,2 @@
DPkg::Pre-Invoke {"stat -c %Z /usr/lib/x86_64-linux-gnu/opera/opera > /tmp/opera.timestamp";}; DPkg::Pre-Invoke {"stat -c %Z /usr/lib/x86_64-linux-gnu/opera/opera > /tmp/opera.timestamp";};
DPkg::Post-Invoke {"if [ `stat -c %Z /usr/lib/x86_64-linux-gnu/opera/opera` -ne `cat /tmp/opera.timestamp` ]; then ~root/.scripts/fix-opera.sh; fi; rm /tmp/opera.timestamp";}; DPkg::Post-Invoke {"if [ `stat -c %Z /usr/lib/x86_64-linux-gnu/opera/opera` -ne `cat /tmp/opera.timestamp` ]; then /root/.scripts/fix-opera.sh; fi; rm /tmp/opera.timestamp";};

12
scripts/fix-opera.hook Normal file
View File

@@ -0,0 +1,12 @@
# Fix video playback on Opera Upgrade/Install.
[Trigger]
Operation = Install
Operation = Upgrade
Type = Package
Target = opera
[Action]
Description = Fix video playback in Opera browser
When = PostTransaction
Exec = /root/.scripts/fix-opera.sh