Merge branch 'main' into feature/opensuse-support

# Conflicts:
#	install.sh
#	scripts/99fix-opera
#	scripts/fix-opera.sh
This commit is contained in:
Thomas Wunner
2026-05-16 14:49:54 +02:00
6 changed files with 194 additions and 81 deletions

View File

@@ -8,22 +8,17 @@
## 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`
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`
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.
## Usage
@@ -39,7 +34,11 @@
`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`

View File

@@ -1,5 +1,79 @@
#!/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
printf 'Try to run it with sudo\n'
exit 1
@@ -10,72 +84,49 @@ if [[ $(uname -m) != "x86_64" ]]; then
exit 1
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'
exit 1
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'
exit 1
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'
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 ' 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
}
readonly USER_NAME="${SUDO_USER:-$(logname)}"
readonly USER_HOME=$(getent passwd "$USER_NAME" | cut -d: -f6)
mkdir -p $INSTALL_PATH
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]'
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
sed -i '/FIX_WIDEVINE=/s/false/true/g' $INSTALL_PATH/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
sed -i '/FIX_WIDEVINE=/s/true/false/g' $INSTALL_PATH/fix-opera.sh
break;;
* )
printf 'Would you like to apply Widevine CDM fix? [y/n]'
@@ -83,10 +134,6 @@ while read FIX_WIDEVINE; do
esac
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]"
while read CREATE_ALIAS; do
case $CREATE_ALIAS in
@@ -102,20 +149,6 @@ while read CREATE_ALIAS; do
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 run it automatically after each Opera update?? [y/n]"
continue;;
esac
done
printf "Would you like to run it now? [y/n]"
while read RUN_NOW; do
case $RUN_NOW in

31
scripts/fix-opera.sh Executable file → Normal file
View File

@@ -49,6 +49,10 @@ if [ -x "$(command -v opera-beta)" ]; then
OPERA_VERSIONS+=("opera-beta")
fi
if [ -x "$(command -v opera-gx)" ]; then
OPERA_VERSIONS+=("opera-gx")
fi
#Getting download links
printf 'Getting download links...\n'
@@ -100,6 +104,16 @@ for opera in ${OPERA_VERSIONS[@]}; do
EXECUTABLE=$(command -v "$opera")
if [[ "$ARCH_SYSTEM" == true ]]; then
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
OPERA_DIR=$(dirname $(readlink -f $EXECUTABLE))
fi
@@ -131,6 +145,23 @@ for opera in ${OPERA_VERSIONS[@]}; do
cp -f "$FIX_DIR/$WIDEVINE_MANIFEST_NAME" "$OPERA_WIDEVINE_DIR"
chmod 0644 "$OPERA_WIDEVINE_DIR/$WIDEVINE_MANIFEST_NAME"
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
done

View File

@@ -1,11 +1,61 @@
#!/bin/bash
set -euo pipefail
readonly INSTALL_PATH="/root/.scripts"
readonly USER_NAME="$(logname)"
readonly USER_HOME=$(sudo -u $USER_NAME sh -c 'echo $HOME')
#
# This uninstall does NOT remove system packages. It only removes the hooks, aliases and scripts implemented by fix-opera's 'install.sh'.
#
rm /etc/apt/apt.conf.d/99fix-opera
rm /usr/share/libalpm/hooks/fix-opera.hook
rm /etc/dnf/plugins/post-transaction-actions.d/fix-opera.action
sed -i '/alias fix-opera/d' $USER_HOME/.bashrc
rm -rf $INSTALL_PATH
INSTALL_PATH="/root/.scripts"
# --- privilege check ---
if [[ "$(id -u)" -ne 0 ]]; then
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."