Compare commits

...

5 Commits

Author SHA1 Message Date
Maksim Ivanov
a46ad6f23a basic support for opera-gx (no autoupdate) 2026-03-20 17:21:53 +03:00
Maksim Ivanov
dc5682f9a7 Merge branch 'EvilSupahFly-main' 2026-03-04 20:43:47 +03:00
Maksim Ivanov
62650fe1a8 Fixed errors from PR 2026-03-04 20:42:53 +03:00
EvilSupahFly
2a33d9ba9e Updated README, install.sh 2025-12-30 22:39:15 -05:00
EvilSupahFly
fe3ce4eba2 Reworked install / uninstall
Hardened scripts a little, made them more distro agnostic
2025-12-30 19:53:58 -05:00
7 changed files with 171 additions and 99 deletions

View File

@@ -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`

163
install.sh Executable file → Normal file
View File

@@ -1,4 +1,79 @@
#!/bin/bash #!/bin/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
@@ -9,72 +84,34 @@ if [[ $(uname -m) != "x86_64" ]]; then
exit 1 exit 1
fi fi
if ! which unzip > /dev/null; then
printf '\033[1munzip\033[0m package must be installed to run this script\n'
exit 1
fi
if ! which curl > /dev/null; then
printf '\033[1mcurl\033[0m package must be installed to run this script\n'
exit 1
fi
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 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]'
@@ -82,10 +119,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
@@ -101,20 +134,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
@@ -127,4 +146,4 @@ while read RUN_NOW; do
printf "Would you like to run it now? [y/n]" printf "Would you like to run it now? [y/n]"
continue;; continue;;
esac esac
done done

View File

@@ -1,2 +1,2 @@
DPkg::Pre-Invoke {"stat -c %Z $(readlink -f $(which opera)) > /tmp/opera.timestamp 2> /dev/null || echo 0 > /tmp/opera.timestamp";}; DPkg::Pre-Invoke {"stat -c %Z $(readlink -f $(which opera)) > /tmp/opera.timestamp 2> /dev/null || echo 0 > /tmp/opera.timestamp";};
DPkg::Post-Invoke {"set NEW_OPERA=`stat -c %Z $(readlink -f $(which opera))` || exit 0; set OLD_OPERA=`cat /tmp/opera.timestamp` || exit 0; if [ "$NEW_OPERA" != "$OLD_OPERA" ]; then /root/.scripts/fix-opera.sh; fi; rm -f /tmp/opera.timestamp";}; DPkg::Post-Invoke {"set NEW_OPERA=`stat -c %Z $(readlink -f $(which opera))` || exit 0; set OLD_OPERA=`cat /tmp/opera.timestamp` || exit 0; if [ "$NEW_OPERA" != "$OLD_OPERA" ]; then /root/.scripts/fix-opera.sh; fi; rm -f /tmp/opera.timestamp";};

View File

@@ -1 +1 @@
opera-stable:in:/root/.scripts/fix-opera.sh opera-stable:in:/root/.scripts/fix-opera.sh

View File

@@ -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

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

@@ -10,22 +10,22 @@ if [[ $(uname -m) != "x86_64" ]]; then
exit 1 exit 1
fi fi
if ! which unzip > /dev/null; then if ! command -v 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 ! which curl > /dev/null; then if ! command -v 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 ! which jq > /dev/null; then if ! command -v 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
if which pacman &> /dev/null; then if command -v pacman &> /dev/null; then
ARCH_SYSTEM=true ARCH_SYSTEM=true
fi fi
@@ -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'

View File

@@ -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."