summarylogtreecommitdiffstats
path: root/register_widevine_firefox
blob: fbbc6753d67e6edfa764e9a13014a2c6744c7fc6 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
#!/bin/bash

if [[ ! -e "${HOME}/.mozilla/firefox" ]]
then
    echo "No firefox profiles found for user ${USER}"
    exit
fi

cd ${HOME}/.mozilla/firefox/
if [[ $(grep '\[Profile[^0]\]' profiles.ini) ]]
    then PROFPATH=$(grep -E '^\[Profile|^Path|^Default' profiles.ini | grep '^Path' | cut -c6-)
    else PROFPATH=$(grep 'Path=' profiles.ini | sed 's/^Path=//')
fi
PROFS=($PROFPATH)

for prof in "${PROFS[@]}"
do
    WIDEVINE_PATH="${HOME}/.mozilla/firefox/${prof}/gmp-widevinecdm"
    if [[ -e "${WIDEVINE_PATH}" ]]
    then
        if [[ -L "${WIDEVINE_PATH}" ]]
        then
           rm "${WIDEVINE_PATH}"
        else
           rm -r "${WIDEVINE_PATH}"
        fi
        ln -s /opt/WidevineCdm/firefox/gmp-widevinecdm "${WIDEVINE_PATH}"
        echo "Widevine already registered for profile ${prof}; re-registered"
    else
        if [[ -L "${WIDEVINE_PATH}" ]]
        then
           rm "${WIDEVINE_PATH}"
        fi
        ln -s /opt/WidevineCdm/firefox/gmp-widevinecdm "${HOME}/.mozilla/firefox/${prof}/gmp-widevinecdm"
        echo "Widevine registered for profile ${prof}"
    fi
done