From c0df5a2e1c90c3fec532da64dc71f9a1c31ab048 Mon Sep 17 00:00:00 2001 From: david Date: Wed, 29 Dec 2021 22:22:38 -0800 Subject: [PATCH] feat: added chromium install scripts, installs ungoogled from releases, widevine and uci chromium launcher script. --- all/modules/chromium/chromium-install.sh | 20 +++++++ all/modules/chromium/chromium.inst | 9 --- all/modules/chromium/chromium.sh | 2 + all/modules/chromium/ungoogled-install.sh | 59 +++++++++++++++++++ all/modules/chromium/widevine-install.sh | 71 +++++++++++++++++++++++ 5 files changed, 152 insertions(+), 9 deletions(-) create mode 100755 all/modules/chromium/chromium-install.sh delete mode 100755 all/modules/chromium/chromium.inst create mode 100755 all/modules/chromium/ungoogled-install.sh create mode 100755 all/modules/chromium/widevine-install.sh diff --git a/all/modules/chromium/chromium-install.sh b/all/modules/chromium/chromium-install.sh new file mode 100755 index 0000000..05555d3 --- /dev/null +++ b/all/modules/chromium/chromium-install.sh @@ -0,0 +1,20 @@ +#!/bin/bash + +function chromium_install { + +source $BASH_SHELL_BASE/module.lib +module_load helpers +NAME="chromium" +DIR=$(adirname "$0") +BIN=${1:-/opt/bin/$NAME} +# [[ $(chown :users $DIR/$NAME.sh) ]] || sudo chown :users $DIR/$NAME.sh +[[ $(chmod 755 $DIR/$NAME.sh) ]] || sudo chmod 755 $DIR/$NAME.sh +ln -sf $DIR/$NAME.sh $BIN +echo link created +ls -la /opt/bin | grep chromium +echo with permissions +ls -la $DIR | grep chromium.sh +} + +# if script was executed then call the function +(return 0 2>/dev/null) || chromium_install $@ diff --git a/all/modules/chromium/chromium.inst b/all/modules/chromium/chromium.inst deleted file mode 100755 index 8c9f626..0000000 --- a/all/modules/chromium/chromium.inst +++ /dev/null @@ -1,9 +0,0 @@ -#!/bin/bash -source $BASH_SHELL_BASE/module.lib -module_load helpers -NAME=${1:-$(filename $0)} -DIR=$(adirname "$0") -BIN=${1:-/opt/bin/$NAME} -chown :users $DIR/$NAME.sh -chmod 755 $DIR/$NAME.sh -ln -sf $DIR/$NAME.sh $BIN diff --git a/all/modules/chromium/chromium.sh b/all/modules/chromium/chromium.sh index 2878e3c..15fea02 100755 --- a/all/modules/chromium/chromium.sh +++ b/all/modules/chromium/chromium.sh @@ -8,6 +8,8 @@ chromium_() { # local DEFAULT="$HOME/.local/share/chromium" local exe="/usr/bin/chromium" + [[ $1 == "-version" ]] && $exe -version && return + [[ $1 == -g ]] && exe=$(command -v google-chrome) && shift echo execuatble to be used: $exe if [[ ! -f $exe ]]; then diff --git a/all/modules/chromium/ungoogled-install.sh b/all/modules/chromium/ungoogled-install.sh new file mode 100755 index 0000000..24b0621 --- /dev/null +++ b/all/modules/chromium/ungoogled-install.sh @@ -0,0 +1,59 @@ +#!/bin/bash +ungoogled_install() { + module_load confirm + module_load helpers + + SDIR=$(adirname ${1:-$(dirname ${BASH_SOURCE[0]})}) + + if [[ ! $(which lastversion) ]]; then + echo lastversion is not installed + echo it is a required dependency for this script + echo see https://github.com/dvershinin/lastversion + return + fi + + CUR_VERSION=$( /usr/bin/chromium -version | grep -oP '(?<=Chromium )[^ ]*') + + _repo="Eloston/ungoogled-chromium-binaries" + + NEW_VERSION=$(lastversion ${_repo}) + + echo "Ungoogled: Current Version : $CUR_VERSION => New Version: $NEW_VERSION" + + [[ $NEW_VERSION = $CUR_VERSION ]] && [[ ! ${1} == "-f" ]] && echo Latest version is already installed + + _temp=/tmp/ungoogled_chromium + echo $_temp to download deb and install + mkdir -p $_temp || exit &> /dev/null + pushd $_temp &> /dev/null || exit + + # echo downloading common deb + # lastversion ${_repo} --format assets --filter common_ -d common.deb + # lastversion ${_repo} --format assets --filter mium_.+amd64.deb -d chromium. + # echo installing common libraries + # sudo dpkg -i common.deb + # echo installing ungoogled-chromium + # sudo dpkg -i chromium.deb + + echo done installing, removing $_temp + rm -r $_temp &> /dev/null || true + + popd >/dev/null + +confirm "do you want to install WidevineCDM for digital streaming rights?" +if [ $? -eq 0 ]; then + module_load widevine-install + widevine_install +fi + +confirm "do you want to install the uci chromium start script in /opt/bin ?" +if [ $? -eq 0 ]; then + module_load chromium-install + chromium_install +fi + + +} + +# # if script was executed then call the function +(return 0 2>/dev/null) || ungoogled_install $@ diff --git a/all/modules/chromium/widevine-install.sh b/all/modules/chromium/widevine-install.sh new file mode 100755 index 0000000..4ebbb40 --- /dev/null +++ b/all/modules/chromium/widevine-install.sh @@ -0,0 +1,71 @@ +#!/bin/bash +# -eux +function confirm() +{ + echo -n "$@ " + read -e answer + for response in y Y yes YES Yes Sure sure SURE OK ok Ok + do + if [ "_$answer" == "_$response" ] + then + return 0 + fi + done + + # Any answer other than the list above is considered a "no" answer + return 1 +} + +function widevine_install { + +_chrome_ver=$( /usr/bin/chromium -version | grep -oP '(?<=Chromium )[^ ]*') + +_l_target_dir=~/.local/lib/WidevineCdm +_target_dir=/usr/lib/chromium/WidevineCdm +_sudo="sudo" + +if [[ "${1}" == "-l" ]]; then + _sudo="" + _target_dir=$_l_target_dir + shift +fi + +echo "install widevineCDM for chromium version $_chrome_ver" +echo "into $_target_dir" + +confirm "confirm (y/n)" || exit + +_temp=/tmp/chromium_widevine +echo using $_temp to download deb and extract widevine +mkdir -p $_temp || exit &> /dev/null +pushd $_temp &> /dev/null || exit + +# Download deb, which has corresponding Widevine version +# Support resuming partially downloaded (or skipping re-download) with -c flag +if [[ "${1}" == "-u" ]]; then + _un="un" +fi +_url=https://dl.google.com/linux/deb/pool/main/g/google-chrome-${_un}stable/google-chrome-${_un}stable_${_chrome_ver}-1_amd64.deb +echo downloading $_url + +wget -c $_url || exit + +# Unpack deb +rm -r unpack_deb &> /dev/null || true +mkdir -p unpack_deb +echo extracting package... +dpkg-deb -R google-chrome-stable_${_chrome_ver}-1_amd64.deb unpack_deb || exit +echo removing any old WidevineCDM installs at $_target_dir +$_sudo rm -r $_target_dir &> /dev/null || true +echo moving WidevineCDM to target $_target_dir +$_sudo mv unpack_deb/opt/google/chrome/WidevineCdm $_target_dir &> /dev/null || exit +[[ $_sudo ]] && $_sudo chown -R root:root $_target_dir +echo done, removing $_temp +rm -r $_temp &> /dev/null || true +popd &> /dev/null + +} + +# if script was executed then call the function +(return 0 2>/dev/null) || widevine_install $@ +