5
REWARN_AT_SOONEST=3 #days
6
MAX_TRIES_PER_100_DAYS=5
7
WARN_DIR=~/.config/chromium/Ubuntu/stale-flashplayer-warned
8
OBSELETE_PACKAGES="flashplugin-installer adobe-flash-player"
9
GOOD_PACKAGE=adobe-flashplugin
13
mkdir -p "${WARN_DIR}"
14
if find $WARN_DIR -mtime -100 -type f |wc -l |xargs test $MAX_TRIES_PER_100_DAYS -ge; then
16
if find "${WARN_DIR}" -mtime "-${REWARN_AT_SOONEST}" -type f |wc -l |xargs test 1 -gt; then # not warned in N days
17
if id -Gn |grep \\bsudo\\b >/dev/null; then # user could change things
18
for pkg in ${OBSELETE_PACKAGES}; do
19
if test -f /var/lib/dpkg/info/${pkg}.list; then # likely installed
20
dpkg -l flashplugin-installer >/dev/null && found_obselete="$pkg $found_obselete"
24
echo "Even if we warned about this bad flash, user can not update it."
25
zenity --info --text "Your computer has an outdated version of Flash plugin. You should install '$GOOD_PACKAGE' package." &
26
echo >"${WARN_DIR}/sudo-not-available" # rate limited, but never grows count more than 1
29
echo "Already warned about Flash in last $REWARN_AT_SOONEST days. Skipping."
32
if test "${found_obselete}"; then
33
# do we have a better suggestion?
34
have_better_package=""
35
apt-cache search "${GOOD_PACKAGE}" >/dev/null && have_better_package=$GOOD_PACKAGE
36
warn_file="${WARN_DIR}/$(date +%Y%m%d)"
39
if test "$have_better_package"; then
40
zenity --question --text="The Flash player plugin you have installed is out of date. Do you wish to update it now?" --title="Update flash?" --ok-label "Update" --cancel-label "Skip"
43
trap "rm \"$warn_file\"; zenity --info --text 'Will try again later.'" ERR
44
gksu --message "Step 1/2. Retrieve new package list. Requires owner verification" -- apt-get update
45
gksu --message "Step 2/2. Install new package. Requires owner verification" -- apt-get -y install ${GOOD_PACKAGE}
49
zenity --question --text="The Flash player plugin you have installed is out of date. Do you wish to enable the Canonical Partner software source and update it now?" --title="Update flash?" --ok-label "Enable and update" --cancel-label "Skip"
52
trap "rm \"$warn_file\"; zenity --info --text 'Will try again later.'" ERR
53
partner_file=$(mktemp canonical-partner-new-source-XXXXXX)
54
distro=$(lsb_release -c -s)
55
echo "deb http://archive.canonical.com/ubuntu ${distro:-vivid} partner" >${partner_file}
56
gksu --message "Step 1/3. Create a new partner source. Requires owner verification" -- mv "${partner_file}" /etc/apt/sources.d/canonical-partners.list
57
gksu --message "Step 2/3. Retrieve new package list. Requires owner verification" -- apt-get update
58
gksu --message "Step 3/3. Install new package. Requires owner verification" -- apt-get -y install ${GOOD_PACKAGE}
64
echo "Already warned about Flash more than $MAX_TRIES_PER_100_DAYS times in 100 days."
1
FLASH_STALENESS_REWARN_AT_SOONEST=3 #days
2
FLASH_STALENESS_MAX_TRIES_PER_100_DAYS=5
3
FLASH_STALENESS_WARN_DIR=~/.config/chromium/Ubuntu/stale-flashplayer-warned
4
FLASH_STALENESS_OBSELETE_PACKAGES="flashplugin-installer adobe-flash-player"
5
FLASH_STALENESS_GOOD_PACKAGE=adobe-flashplugin