mirror of
https://github.com/Ld-Hagen/fix-opera-linux-ffmpeg-widevine.git
synced 2026-07-11 23:37:27 +03:00
Merge branch 'main' into feature/opensuse-support
# Conflicts: # install.sh # scripts/99fix-opera # scripts/fix-opera.sh
This commit is contained in:
23
README.md
23
README.md
@@ -8,22 +8,17 @@
|
|||||||
|
|
||||||
## Requirements
|
## Requirements
|
||||||
|
|
||||||
1. **curl** (Is needed for downloading the ffmpeg lib and widevine)
|
1. **curl** (is needed for downloading the ffmpeg lib and widevine)
|
||||||
|
|
||||||
**unzip** (Is needed for unpacking the downloaded file)
|
**unzip** (is needed for unpacking the downloaded file)
|
||||||
|
|
||||||
**git** (Is needed for fetching this script)
|
**git** (is needed for fetching this script)
|
||||||
|
|
||||||
**jq** (Is needed for parsing JSON from github)
|
**jq** (is needed for parsing JSON from github)
|
||||||
|
|
||||||
For Debian-based systems: `sudo apt install curl unzip git jq`
|
2. (*Optional*) **python3-dnf-plugin-post-transaction-actions** (is needed for autoupdate in RedHat-based systems)
|
||||||
|
|
||||||
For Arch-based systems: `sudo pacman -S curl unzip git jq`
|
The main installer - `install.sh` - auto-detects your distro and installs the both the appropriate and the optional requirements by itself, if they're missing.
|
||||||
|
|
||||||
For RedHat-based systems: `sudo dnf install curl unzip git jq`
|
|
||||||
|
|
||||||
3. (*Optional*) **python3-dnf-plugin-post-transaction-actions** (Is needed for autoupdate in RedHat-based systems)
|
|
||||||
`dnf install python3-dnf-plugin-post-transaction-actions`
|
|
||||||
|
|
||||||
## Usage
|
## Usage
|
||||||
|
|
||||||
@@ -39,7 +34,11 @@
|
|||||||
|
|
||||||
`sudo ./scripts/fix-opera.sh`
|
`sudo ./scripts/fix-opera.sh`
|
||||||
|
|
||||||
4. Run install script and answer few questions.
|
4. Make install.sh executable
|
||||||
|
|
||||||
|
`chmod +x ./install.sh`
|
||||||
|
|
||||||
|
5. Run install script and answer few questions.
|
||||||
|
|
||||||
`sudo ./install.sh`
|
`sudo ./install.sh`
|
||||||
|
|
||||||
|
|||||||
151
install.sh
151
install.sh
@@ -1,5 +1,79 @@
|
|||||||
#!/usr/bin/env bash
|
#!/usr/bin/env bash
|
||||||
|
|
||||||
|
set -euo pipefail
|
||||||
|
|
||||||
|
detect_pkg_manager() {
|
||||||
|
if command -v apt-get >/dev/null 2>&1; then
|
||||||
|
PKG_MGR="apt"
|
||||||
|
elif command -v dnf >/dev/null 2>&1; then
|
||||||
|
PKG_MGR="dnf"
|
||||||
|
elif command -v pacman >/dev/null 2>&1; then
|
||||||
|
PKG_MGR="pacman"
|
||||||
|
elif command -v zypper >/dev/null 2>&1; then
|
||||||
|
PKG_MGR="zypper"
|
||||||
|
elif command -v emerge >/dev/null 2>&1; then
|
||||||
|
PKG_MGR="portage"
|
||||||
|
else
|
||||||
|
PKG_MGR="unknown"
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [[ "$PKG_MGR" == "unknown" ]]; then
|
||||||
|
echo "Unsupported package manager"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
install_deps() {
|
||||||
|
DEPS=(curl unzip jq)
|
||||||
|
|
||||||
|
case "$PKG_MGR" in
|
||||||
|
apt)
|
||||||
|
apt-get update
|
||||||
|
apt-get install -y "${DEPS[@]}"
|
||||||
|
;;
|
||||||
|
dnf)
|
||||||
|
dnf install -y "${DEPS[@]} python3-dnf-plugin-post-transaction-actions"
|
||||||
|
;;
|
||||||
|
pacman)
|
||||||
|
pacman -Sy --needed --noconfirm "${DEPS[@]}"
|
||||||
|
;;
|
||||||
|
zypper)
|
||||||
|
zypper install -y "${DEPS[@]}"
|
||||||
|
;;
|
||||||
|
portage)
|
||||||
|
emerge --ask=n "${DEPS[@]}"
|
||||||
|
;;
|
||||||
|
*)
|
||||||
|
echo "Unsupported package manager. Install dependencies manually:"
|
||||||
|
echo " ${DEPS[*]}"
|
||||||
|
exit 1
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
}
|
||||||
|
|
||||||
|
install_hook () {
|
||||||
|
case "$PKG_MGR" in
|
||||||
|
apt)
|
||||||
|
cp -f "$SCRIPT_PATH/scripts/99fix-opera" "$INSTALL_PATH"
|
||||||
|
ln -sf "$INSTALL_PATH/99fix-opera" /etc/apt/apt.conf.d/99fix-opera
|
||||||
|
;;
|
||||||
|
pacman)
|
||||||
|
cp -f "$SCRIPT_PATH/scripts/fix-opera.hook" "$INSTALL_PATH"
|
||||||
|
ln -sf "$INSTALL_PATH/fix-opera.hook" /usr/share/libalpm/hooks/fix-opera.hook
|
||||||
|
;;
|
||||||
|
dnf)
|
||||||
|
dnf install -y python3-dnf-plugin-post-transaction-actions
|
||||||
|
cp -f "$SCRIPT_PATH/scripts/fix-opera.action" "$INSTALL_PATH"
|
||||||
|
ln -sf "$INSTALL_PATH/fix-opera.action" \
|
||||||
|
/etc/dnf/plugins/post-transaction-actions.d/fix-opera.action
|
||||||
|
;;
|
||||||
|
*)
|
||||||
|
echo "Automatic hook installation not supported for this system."
|
||||||
|
return 1
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
}
|
||||||
|
|
||||||
if [[ $(whoami) != "root" ]]; then
|
if [[ $(whoami) != "root" ]]; then
|
||||||
printf 'Try to run it with sudo\n'
|
printf 'Try to run it with sudo\n'
|
||||||
exit 1
|
exit 1
|
||||||
@@ -10,72 +84,49 @@ if [[ $(uname -m) != "x86_64" ]]; then
|
|||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if ! command -v unzip 2>&1 /dev/null; then
|
if ! which unzip > /dev/null; then
|
||||||
printf '\033[1munzip\033[0m package must be installed to run this script\n'
|
printf '\033[1munzip\033[0m package must be installed to run this script\n'
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if ! command -v curl 2>&1 /dev/null; then
|
if ! which curl > /dev/null; then
|
||||||
printf '\033[1mcurl\033[0m package must be installed to run this script\n'
|
printf '\033[1mcurl\033[0m package must be installed to run this script\n'
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if ! command -v jq 2>&1 /dev/null; then
|
if ! which jq > /dev/null; then
|
||||||
printf '\033[1mjq\033[0m package must be installed to run this script\n'
|
printf '\033[1mjq\033[0m package must be installed to run this script\n'
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
readonly SCRIPT_PATH=$(dirname $(readlink -f $0))
|
readonly SCRIPT_PATH=$(dirname $(readlink -f $0))
|
||||||
readonly INSTALL_PATH="/root/.scripts"
|
readonly INSTALL_PATH="/root/.scripts"
|
||||||
readonly USER_NAME="$(logname)"
|
readonly USER_NAME="${SUDO_USER:-$(logname)}"
|
||||||
readonly USER_HOME=$(sudo -u $USER_NAME sh -c 'echo $HOME')
|
readonly USER_HOME=$(getent passwd "$USER_NAME" | cut -d: -f6)
|
||||||
|
mkdir -p $INSTALL_PATH
|
||||||
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 ' 3. RedHat-based (RedHat/Fedora/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/
|
|
||||||
printf 'Now the script will run automatically every time apt installs or updates Opera.\n'
|
|
||||||
break;;
|
|
||||||
"2" )
|
|
||||||
cp -f $SCRIPT_PATH/scripts/fix-opera.hook $INSTALL_PATH
|
|
||||||
ln -sf $INSTALL_PATH/fix-opera.hook /usr/share/libalpm/hooks/
|
|
||||||
printf 'Now the script will run automatically every time pacman installs or updates Opera.\n'
|
|
||||||
break;;
|
|
||||||
"3" )
|
|
||||||
dnf install python3-dnf-plugin-post-transaction-actions -y
|
|
||||||
cp -f $SCRIPT_PATH/scripts/fix-opera.action $INSTALL_PATH
|
|
||||||
ln -sf $INSTALL_PATH/fix-opera.action /etc/dnf/plugins/post-transaction-actions.d/
|
|
||||||
printf 'Now the script will run automatically every time dnf installs or updates Opera.\n'
|
|
||||||
break;;
|
|
||||||
"0" )
|
|
||||||
printf "Autostart for your Linux distro is currently unsupported\n"
|
|
||||||
break;;
|
|
||||||
* )
|
|
||||||
continue;;
|
|
||||||
esac
|
|
||||||
done
|
|
||||||
}
|
|
||||||
|
|
||||||
printf 'Installing script to your system...\n'
|
printf 'Installing script to your system...\n'
|
||||||
|
|
||||||
|
detect_pkg_manager
|
||||||
|
install_deps
|
||||||
|
|
||||||
|
read -p "Enable automatic execution after Opera updates? [y/N] " AUTO
|
||||||
|
[[ "$AUTO" =~ ^[Yy]$ ]] && install_hook
|
||||||
|
|
||||||
|
mkdir -p "$INSTALL_PATH"
|
||||||
|
cp -f "$SCRIPT_PATH/scripts/fix-opera.sh" "$INSTALL_PATH"
|
||||||
|
chmod +x "$INSTALL_PATH/fix-opera.sh"
|
||||||
|
|
||||||
printf 'Would you like to apply Widevine CDM fix? [y/n]'
|
printf 'Would you like to apply Widevine CDM fix? [y/n]'
|
||||||
while read FIX_WIDEVINE; do
|
while read FIX_WIDEVINE; do
|
||||||
case $FIX_WIDEVINE in
|
case $FIX_WIDEVINE in
|
||||||
"y" | "Y")
|
"y" | "Y")
|
||||||
printf 'Setting FIX_WIDEVINE to true...\n'
|
printf 'Setting FIX_WIDEVINE to true...\n'
|
||||||
sed -i '/FIX_WIDEVINE=/s/false/true/g' $SCRIPT_PATH/scripts/fix-opera.sh
|
sed -i '/FIX_WIDEVINE=/s/false/true/g' $INSTALL_PATH/fix-opera.sh
|
||||||
break;;
|
break;;
|
||||||
"n" | "N")
|
"n" | "N")
|
||||||
printf 'Setting FIX_WIDEVINE to false...\n'
|
printf 'Setting FIX_WIDEVINE to false...\n'
|
||||||
sed -i '/FIX_WIDEVINE=/s/true/false/g' $SCRIPT_PATH/scripts/fix-opera.sh
|
sed -i '/FIX_WIDEVINE=/s/true/false/g' $INSTALL_PATH/fix-opera.sh
|
||||||
break;;
|
break;;
|
||||||
* )
|
* )
|
||||||
printf 'Would you like to apply Widevine CDM fix? [y/n]'
|
printf 'Would you like to apply Widevine CDM fix? [y/n]'
|
||||||
@@ -83,10 +134,6 @@ while read FIX_WIDEVINE; do
|
|||||||
esac
|
esac
|
||||||
done
|
done
|
||||||
|
|
||||||
mkdir -p $INSTALL_PATH
|
|
||||||
cp -f $SCRIPT_PATH/scripts/fix-opera.sh $INSTALL_PATH
|
|
||||||
chmod +x $INSTALL_PATH/fix-opera.sh
|
|
||||||
|
|
||||||
printf "Would you like to create an alias for user $USER_NAME? [y/n]"
|
printf "Would you like to create an alias for user $USER_NAME? [y/n]"
|
||||||
while read CREATE_ALIAS; do
|
while read CREATE_ALIAS; do
|
||||||
case $CREATE_ALIAS in
|
case $CREATE_ALIAS in
|
||||||
@@ -102,20 +149,6 @@ while read CREATE_ALIAS; do
|
|||||||
esac
|
esac
|
||||||
done
|
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 run it automatically after each Opera update?? [y/n]"
|
|
||||||
continue;;
|
|
||||||
esac
|
|
||||||
done
|
|
||||||
|
|
||||||
printf "Would you like to run it now? [y/n]"
|
printf "Would you like to run it now? [y/n]"
|
||||||
while read RUN_NOW; do
|
while read RUN_NOW; do
|
||||||
case $RUN_NOW in
|
case $RUN_NOW in
|
||||||
|
|||||||
@@ -1 +1 @@
|
|||||||
opera-stable:in:/root/.scripts/fix-opera.sh
|
opera-stable:in:/root/.scripts/fix-opera.sh
|
||||||
@@ -13,4 +13,4 @@ Depends = bash
|
|||||||
Depends = curl
|
Depends = curl
|
||||||
Depends = unzip
|
Depends = unzip
|
||||||
Depends = jq
|
Depends = jq
|
||||||
Exec = /root/.scripts/fix-opera.sh
|
Exec = /root/.scripts/fix-opera.sh
|
||||||
31
scripts/fix-opera.sh
Executable file → Normal file
31
scripts/fix-opera.sh
Executable file → Normal file
@@ -49,6 +49,10 @@ if [ -x "$(command -v opera-beta)" ]; then
|
|||||||
OPERA_VERSIONS+=("opera-beta")
|
OPERA_VERSIONS+=("opera-beta")
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
if [ -x "$(command -v opera-gx)" ]; then
|
||||||
|
OPERA_VERSIONS+=("opera-gx")
|
||||||
|
fi
|
||||||
|
|
||||||
#Getting download links
|
#Getting download links
|
||||||
printf 'Getting download links...\n'
|
printf 'Getting download links...\n'
|
||||||
|
|
||||||
@@ -100,6 +104,16 @@ for opera in ${OPERA_VERSIONS[@]}; do
|
|||||||
EXECUTABLE=$(command -v "$opera")
|
EXECUTABLE=$(command -v "$opera")
|
||||||
if [[ "$ARCH_SYSTEM" == true ]]; then
|
if [[ "$ARCH_SYSTEM" == true ]]; then
|
||||||
OPERA_DIR=$(dirname $(cat $EXECUTABLE | grep exec | cut -d ' ' -f 2))
|
OPERA_DIR=$(dirname $(cat $EXECUTABLE | grep exec | cut -d ' ' -f 2))
|
||||||
|
elif head -1 "$EXECUTABLE" | grep -q 'bash\|sh'; then
|
||||||
|
# The executable is a shell wrapper (e.g. openSUSE packages Opera as a wrapper
|
||||||
|
# script). readlink -f on a script returns the script itself, not the real binary,
|
||||||
|
# so we parse the LIBDIR variable directly from the wrapper instead.
|
||||||
|
PARSED_LIBDIR=$(grep '^LIBDIR=' "$EXECUTABLE" | head -1 | sed 's/LIBDIR=//;s/"//g' | sed "s/\\\$PROGNAME/$opera/g")
|
||||||
|
if [[ -n "$PARSED_LIBDIR" && -d "$PARSED_LIBDIR" ]]; then
|
||||||
|
OPERA_DIR="$PARSED_LIBDIR"
|
||||||
|
else
|
||||||
|
OPERA_DIR=$(dirname $(readlink -f $EXECUTABLE))
|
||||||
|
fi
|
||||||
else
|
else
|
||||||
OPERA_DIR=$(dirname $(readlink -f $EXECUTABLE))
|
OPERA_DIR=$(dirname $(readlink -f $EXECUTABLE))
|
||||||
fi
|
fi
|
||||||
@@ -131,6 +145,23 @@ for opera in ${OPERA_VERSIONS[@]}; do
|
|||||||
cp -f "$FIX_DIR/$WIDEVINE_MANIFEST_NAME" "$OPERA_WIDEVINE_DIR"
|
cp -f "$FIX_DIR/$WIDEVINE_MANIFEST_NAME" "$OPERA_WIDEVINE_DIR"
|
||||||
chmod 0644 "$OPERA_WIDEVINE_DIR/$WIDEVINE_MANIFEST_NAME"
|
chmod 0644 "$OPERA_WIDEVINE_DIR/$WIDEVINE_MANIFEST_NAME"
|
||||||
printf "[\n {\n \"preload\": \"$OPERA_WIDEVINE_DIR\"\n }\n]\n" > "$OPERA_WIDEVINE_CONFIG"
|
printf "[\n {\n \"preload\": \"$OPERA_WIDEVINE_DIR\"\n }\n]\n" > "$OPERA_WIDEVINE_CONFIG"
|
||||||
|
|
||||||
|
# Newer Chromium-based Opera versions (110+) no longer read widevine_config.json.
|
||||||
|
# On zypper-based systems (openSUSE) Opera reads OPERA_FLAGS from /etc/default/opera,
|
||||||
|
# so we inject --widevine-cdm-path there as well to cover both loading mechanisms.
|
||||||
|
if command -v zypper &>/dev/null && [[ -f /etc/default/$opera ]]; then
|
||||||
|
OPERA_DEFAULT="/etc/default/$opera"
|
||||||
|
CDM_FLAG="--widevine-cdm-path=$OPERA_WIDEVINE_DIR"
|
||||||
|
if grep -q 'OPERA_FLAGS=' "$OPERA_DEFAULT"; then
|
||||||
|
# Append the flag if not already present
|
||||||
|
if ! grep -qF -- "$CDM_FLAG" "$OPERA_DEFAULT"; then
|
||||||
|
sed -i "s|OPERA_FLAGS=\"\(.*\)\"|OPERA_FLAGS=\"\1 $CDM_FLAG\"|" "$OPERA_DEFAULT"
|
||||||
|
fi
|
||||||
|
else
|
||||||
|
echo "OPERA_FLAGS=\"$CDM_FLAG\"" >> "$OPERA_DEFAULT"
|
||||||
|
fi
|
||||||
|
printf "Widevine CDM path added to %s\n" "$OPERA_DEFAULT"
|
||||||
|
fi
|
||||||
fi
|
fi
|
||||||
done
|
done
|
||||||
|
|
||||||
|
|||||||
66
uninstall.sh
66
uninstall.sh
@@ -1,11 +1,61 @@
|
|||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
|
set -euo pipefail
|
||||||
|
|
||||||
readonly INSTALL_PATH="/root/.scripts"
|
#
|
||||||
readonly USER_NAME="$(logname)"
|
# This uninstall does NOT remove system packages. It only removes the hooks, aliases and scripts implemented by fix-opera's 'install.sh'.
|
||||||
readonly USER_HOME=$(sudo -u $USER_NAME sh -c 'echo $HOME')
|
#
|
||||||
|
|
||||||
rm /etc/apt/apt.conf.d/99fix-opera
|
INSTALL_PATH="/root/.scripts"
|
||||||
rm /usr/share/libalpm/hooks/fix-opera.hook
|
|
||||||
rm /etc/dnf/plugins/post-transaction-actions.d/fix-opera.action
|
# --- privilege check ---
|
||||||
sed -i '/alias fix-opera/d' $USER_HOME/.bashrc
|
if [[ "$(id -u)" -ne 0 ]]; then
|
||||||
rm -rf $INSTALL_PATH
|
echo "Please run this script with sudo or as root"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
# --- user resolution ---
|
||||||
|
USER_NAME="${SUDO_USER:-$(logname)}"
|
||||||
|
USER_HOME=$(getent passwd "$USER_NAME" | cut -d: -f6)
|
||||||
|
|
||||||
|
# --- package manager detection ---
|
||||||
|
detect_pkg_manager() {
|
||||||
|
if command -v apt-get >/dev/null 2>&1; then
|
||||||
|
PKG_MGR="apt"
|
||||||
|
elif command -v dnf >/dev/null 2>&1; then
|
||||||
|
PKG_MGR="dnf"
|
||||||
|
elif command -v pacman >/dev/null 2>&1; then
|
||||||
|
PKG_MGR="pacman"
|
||||||
|
else
|
||||||
|
PKG_MGR="unknown"
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
remove_hook() {
|
||||||
|
case "$PKG_MGR" in
|
||||||
|
apt)
|
||||||
|
rm -f /etc/apt/apt.conf.d/99fix-opera
|
||||||
|
;;
|
||||||
|
pacman)
|
||||||
|
rm -f /usr/share/libalpm/hooks/fix-opera.hook
|
||||||
|
;;
|
||||||
|
dnf)
|
||||||
|
rm -f /etc/dnf/plugins/post-transaction-actions.d/fix-opera.action
|
||||||
|
;;
|
||||||
|
*)
|
||||||
|
echo "No supported package manager hook to remove"
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
}
|
||||||
|
|
||||||
|
detect_pkg_manager
|
||||||
|
remove_hook
|
||||||
|
|
||||||
|
# --- remove alias ---
|
||||||
|
if [[ -f "$USER_HOME/.bashrc" ]]; then
|
||||||
|
sed -i '/alias fix-opera=.*Opera fix HTML5 media/d' "$USER_HOME/.bashrc"
|
||||||
|
fi
|
||||||
|
|
||||||
|
# --- remove installed files ---
|
||||||
|
rm -rf "$INSTALL_PATH"
|
||||||
|
|
||||||
|
echo "Opera Widevine fix has been removed."
|
||||||
|
|||||||
Reference in New Issue
Block a user