Created
November 12, 2017 15:46
-
-
Save dmaglio/544fad8590760273950a3f4add60bcea to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/sh | |
available () { | |
command -v $1 >/dev/null 2>&1 | |
} | |
# Make sure we have wget or curl | |
if available wget; then | |
SILENT_DL="wget -qO-" | |
LOUD_DL="wget" | |
elif available curl; then | |
SILENT_DL="curl -sL" | |
LOUD_DL="curl -O" | |
else | |
echo "Install wget or curl" >&2 | |
exit 1 | |
fi | |
# Set Output dir | |
PPAPI_FLASH_INSTALL_DIR=${PPAPI_FLASH_INSTALL_DIR:-/usr/lib/adobe-flashplugin} | |
# Set temp dir | |
TMP=${TMP:-/tmp} | |
# Set staging dir | |
STAGINGDIR=$TMP/pepper-flash-staging | |
# Setup Arch | |
case $(uname -m) in | |
x86_64) ARCH=x86_64 ;; | |
i?86) ARCH=i386 ;; | |
esac | |
# Work out the VERSION | |
VERSION=$($SILENT_DL http://www.adobe.com/software/flash/about/ | grep -FA2 'Chromium-based browsers - PPAPI' | grep -Eo '([0-9]+\.){3}[0-9]+' | tail -n1) | |
# Error out if $VERISON is unset, e.g. because previous command failed | |
if [ -z "$VERSION" ]; then | |
echo "Could not work out the latest version; exiting" >&2 | |
exit 1 | |
fi | |
# Don't start repackaging if the same version is already installed | |
if [ -r "$PPAPI_FLASH_INSTALL_DIR/manifest.json" ] ; then | |
CUR_VER=$(grep -Eo '"version" *: *"([0-9]+\.){3}[0-9]+",' "$PPAPI_FLASH_INSTALL_DIR/manifest.json" | cut -d'"' -f 4) | |
if [ "$CUR_VER" = "$VERSION" ]; then | |
echo "The latest Flash ($VERSION) is already installed" | |
exit 0 | |
fi | |
fi | |
# Now we could screw things up so exit on first error | |
set -e | |
# If the staging directory is already present from the past, clear it down | |
# and re-create it. | |
if [ -d "$STAGINGDIR" ]; then | |
rm -fr "$STAGINGDIR" | |
fi | |
mkdir -p "$STAGINGDIR$PPAPI_FLASH_INSTALL_DIR" | |
cd "$STAGINGDIR" | |
# Now get the tarball | |
$LOUD_DL "http://fpdownload.adobe.com/pub/flashplayer/pdc/$VERSION/flash_player_ppapi_linux.${ARCH}.tar.gz" | |
# Extract the contents of the Google Chrome binary package | |
tar xf flash_player_ppapi_linux.${ARCH}.tar.gz -C "$STAGINGDIR$PPAPI_FLASH_INSTALL_DIR" | |
chmod -R u+w,go+r-w,a-s . | |
# Escalate privileges if needed and copy files into place | |
if [ "$UID" = 0 ]; then | |
tar --owner=0 --group=0 -cf- ".$PPAPI_FLASH_INSTALL_DIR" | tar -xf- -C / | |
elif [ -r /etc/os-release ] && grep -qx 'ID=\(ubuntu\|linuxmint\)' /etc/os-release; then | |
echo "Calling sudo ... (if prompted, please enter your password, so Flash can be copied into place)" | |
tar --owner=0 --group=0 -cf- ".$PPAPI_FLASH_INSTALL_DIR" | sudo tar -xf- -C / | |
else | |
echo "Please enter your root password so Pepper Flash can be copied into place" | |
su -c "sh -c \"tar --owner=0 --group=0 -cf- .$PPAPI_FLASH_INSTALL_DIR | tar -xf- -C /\"" | |
fi | |
# Tell the user we are done | |
printf "\nFlash installed into $PPAPI_FLASH_INSTALL_DIR\n" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/sh | |
# Discourage Ubuntu users from using this script, since they can (and should) install chromium-codecs-ffmpeg-extra directly | |
if [ -r /etc/os-release ] && grep -qx 'ID=ubuntu' /etc/os-release; then | |
echo "You should not use this script on Ubuntu, install chromium-codecs-ffmpeg-extra via apt instead." >&2 | |
read -p "Do you wish to continue anyway? [y/N]: " YN | |
case "$YN" in | |
[Yy]*) : ;; | |
[Nn]*) echo "Exiting." ; exit ;; | |
*) echo 'Answer not recognised, assuming "No". Exiting.'; exit ;; | |
esac | |
fi | |
# Make sure the user is not runing as superuser | |
if [ "$UID" = "0" ]; then | |
echo 'Do not run this script as root or via sudo. Run it as your normal user.' >&2 | |
exit 1 | |
fi | |
available () { | |
command -v $1 >/dev/null 2>&1 | |
} | |
# Make sure we have wget or curl | |
if available wget; then | |
SILENT_DL="wget -qO-" | |
LOUD_DL="wget" | |
elif available curl; then | |
SILENT_DL="curl -sL" | |
LOUD_DL="curl -O" | |
else | |
echo "Install Wget or cURL" >&2 | |
exit 1 | |
fi | |
# Set temp dir | |
TMP=${TMP:-/tmp} | |
# Set staging dir | |
STAGINGDIR=$TMP/chromium-codecs-ffmpeg-extra-staging | |
# Setup Arch | |
case $(uname -m) in | |
x86_64) ARCH=x86_64; DEB_ARCH=amd64 ;; | |
i?86) ARCH=i386; DEB_ARCH=i386 ;; | |
esac | |
# Work out the VERSION | |
UBUNTU_PACKAGE=$(${SILENT_DL} http://security.ubuntu.com/ubuntu/pool/universe/c/chromium-browser/ | sed -rn "s/.*(chromium-codecs-ffmpeg-extra_([0-9]+\.){3}[0-9]+-[0-9]ubuntu[0-9]\.([0-9]{2}\.){2}[0-9\.]*_$DEB_ARCH.deb).*/\1/p" | sort | tail -n 1) | |
VERSION=$(echo "${UBUNTU_PACKAGE}" | sed -rn "s/.*_(([0-9]+\.){3}[0-9]+)-.*/\1/p") | |
# Error out if $VERISON is unset, e.g. because previous command failed | |
if [ -z "$VERSION" ]; then | |
echo "Could not work out the latest version; exiting" >&2 | |
exit 1 | |
fi | |
# Don't start repackaging if the same version is already installed | |
if [ -r "$HOME/.local/lib/vivaldi/chromium-codecs-ffmpeg-extra-version.txt" ]; then | |
. "$HOME/.local/lib/vivaldi/chromium-codecs-ffmpeg-extra-version.txt" | |
if [ "$INSTALLED_VERSION" = "$VERSION" ]; then | |
echo "The latest chromium-codecs-ffmpeg-extra ($VERSION) is already installed" | |
exit 0 | |
fi | |
fi | |
# Now we could screw things up so exit on first error | |
set -e | |
# If the staging directory is already present from the past, clear it down | |
# and re-create it. | |
if [ -d "$STAGINGDIR" ]; then | |
rm -fr "$STAGINGDIR" | |
fi | |
mkdir "$STAGINGDIR" | |
cd "$STAGINGDIR" | |
# Now get the deb package | |
$LOUD_DL "http://security.ubuntu.com/ubuntu/pool/universe/c/chromium-browser/${UBUNTU_PACKAGE}" | |
# Extract the contents of the chromium-codecs-ffmpeg-extra package | |
if available bsdtar; then | |
DEB_EXTRACT_COMMAND='bsdtar xOf' | |
elif available ar; then | |
DEB_EXTRACT_COMMAND='ar p' | |
else | |
echo 'You must install BSD tar or GNU binutils to use this script.' >&2 | |
exit 1 | |
fi | |
$DEB_EXTRACT_COMMAND ${UBUNTU_PACKAGE} data.tar.xz | tar xJf - ./usr/lib/chromium-browser/libffmpeg.so --strip 4 | |
echo "INSTALLED_VERSION=$VERSION" > chromium-codecs-ffmpeg-extra-version.txt | |
# Install the files | |
install -Dm644 libffmpeg.so "$HOME/.local/lib/vivaldi/libffmpeg.so" | |
install -Dm644 chromium-codecs-ffmpeg-extra-version.txt "$HOME/.local/lib/vivaldi/chromium-codecs-ffmpeg-extra-version.txt" | |
# Tell the user we are done | |
cat <<EOF | |
The following files were installed onto your system: | |
$HOME/.local/lib/vivaldi/libffmpeg.so | |
$HOME/.local/lib/vivaldi/chromium-codecs-ffmpeg-extra-version.txt | |
Restart Vivaldi and test H.264/MP4 support via this page: | |
http://www.quirksmode.org/html5/tests/video.html | |
EOF |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env bash | |
available () { | |
command -v $1 >/dev/null 2>&1 | |
} | |
# Make sure we have wget or curl | |
if available wget; then | |
SILENT_DL="wget -qO-" | |
LOUD_DL="wget" | |
elif available curl; then | |
SILENT_DL="curl -s" | |
LOUD_DL="curl -O" | |
else | |
echo "Install wget or curl" >&2 | |
exit 1 | |
fi | |
# Use the architecture of the current machine or whatever the user has set | |
# externally | |
ARCH=${ARCH:-$(uname -m)} | |
if [ "$ARCH" = "x86_64" ]; then | |
WIDEVINEARCH="x64" | |
elif [[ "$ARCH" = i?86 ]]; then | |
WIDEVINEARCH="ia32" | |
else | |
echo "The architecture $ARCH is not supported." >&2 | |
exit 1 | |
fi | |
# Set Output dir | |
WIDEVINE_INSTALL_DIR=${WIDEVINE_INSTALL_DIR:-/opt/google/chrome} | |
# Set temp dir | |
TMP=${TMP:-/tmp} | |
# Set staging dir | |
STAGINGDIR=$TMP/widevine-staging | |
# Work out the latest Widevine version | |
VERSION=$($SILENT_DL https://dl.google.com/widevine-cdm/current.txt) | |
# Error out if $VERISON is unset, e.g. because previous command failed | |
if [ -z $VERSION ]; then | |
echo "Could not work out the latest version; exiting" >&2 | |
exit 1 | |
fi | |
# Don't start repackaging if the same version is already installed | |
if [ -e "$WIDEVINE_INSTALL_DIR/widevine-$VERSION" ] ; then | |
echo "The latest Widevine is already installed" | |
exit 0 | |
fi | |
# If the staging directory is already present from the past, clear it down | |
# and re-create it. | |
if [ -d "$STAGINGDIR" ]; then | |
rm -fr "$STAGINGDIR" | |
fi | |
set -e | |
mkdir -p "$STAGINGDIR" | |
cd "$STAGINGDIR" | |
# Now get the latest widevine zip for the users architecture | |
$LOUD_DL https://dl.google.com/widevine-cdm/${VERSION}-linux-${WIDEVINEARCH}.zip | |
# Extract the contents of Widevine package | |
if available unzip; then | |
unzip ${VERSION}-linux-${WIDEVINEARCH}.zip | |
elif available bsdtar; then | |
bsdtar xf ${VERSION}-linux-${WIDEVINEARCH}.zip | |
else | |
echo "Install unzip or bsdtar" >&2 | |
exit 1 | |
fi | |
# Add version number file | |
touch "widevine-$VERSION" | |
# Escalate privileges if needed and copy files into place | |
if [ "$UID" = 0 ]; then | |
install -Dm644 libwidevinecdm.so "$WIDEVINE_INSTALL_DIR/libwidevinecdm.so" | |
install -Dm644 widevine-$VERSION "$WIDEVINE_INSTALL_DIR/widevine-$VERSION" | |
elif [ -r /etc/os-release ] && grep -qx 'ID=ubuntu' /etc/os-release; then | |
echo "Calling sudo ... If prompted, please enter your password so Widevine can be copied into place" | |
sudo install -Dm644 libwidevinecdm.so "$WIDEVINE_INSTALL_DIR/libwidevinecdm.so" | |
if [ -e "$WIDEVINE_INSTALL_DIR/libwidevinecdm.so" ]; then | |
sudo install -Dm644 widevine-$VERSION "$WIDEVINE_INSTALL_DIR/widevine-$VERSION" | |
else | |
echo "Something went wrong installing libwidevinecdm.so" >&2 | |
exit 1 | |
fi | |
else | |
echo "Please enter your root password so Widevine can be copied into place" | |
su -c "sh -c \"install -Dm644 libwidevinecdm.so $WIDEVINE_INSTALL_DIR/libwidevinecdm.so && install -Dm644 widevine-$VERSION $WIDEVINE_INSTALL_DIR/widevine-$VERSION\"" | |
fi | |
# Tell the user we are done | |
echo "Widevine installed into $WIDEVINE_INSTALL_DIR" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment