Last active
May 15, 2019 05:55
-
-
Save iwconfig/74cbe4158fe9c02c689d02cf9d48d857 to your computer and use it in GitHub Desktop.
Install script for ungoogled-chromium. It downloads deb files for Ubuntu Xenial Xerus 16.04 and installs with dpkg. Used on Gallium Os without problems.
This file contains 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 python | |
# -*- coding: utf-8 -*- | |
from json import dumps | |
import requests | |
import re | |
import sys | |
import os | |
# Given the extension url(s) as parameter(s) it downloads the extension(s) to '$HOME/Downloads', | |
# and creating a .json file in '/usr/share/chromium/extensions'. Next time Chromium starts up, | |
# it will load the extension(s) automatically. | |
PY3 = sys.version_info[0] == 3 | |
if PY3: | |
from urllib.request import urlretrieve | |
else: | |
from urllib import urlretrieve | |
if os.geteuid() != 0: | |
print 'This will need sudo...' | |
links = sys.argv[1:] | |
downloadlink = "https://clients2.google.com/service/update2/crx?response=redirect&prodversion=47.0&x=id%3D{}%26installsource%3Dondemand%26uc" | |
extensionids = [] | |
regexx = re.compile("http[s]?.+\/(?P<lastpart>.+)") | |
for link in links: | |
id = regexx.search(link).group("lastpart") | |
if '?hl=' in id: | |
id = id.split('?')[0] | |
extensionids.append(id) | |
headers = {"User-Agent":"Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/47.0.2526.73 Safari/537.36"} | |
for extensionid in extensionids: | |
htmldata = requests.get(link, headers=headers).content | |
name = re.compile('<h1 class="e-f-w">(.+?)</h1>').search(htmldata).group(1) | |
slugname = re.sub('[^\w\s-]', '-', re.sub('[-\s]+', '-', name)).strip() | |
version = re.compile('<span class="C-b-p-D-Xe h-C-b-p-D-md">(.+?)</span>').search(htmldata).group(1) | |
link = downloadlink.format(extensionid) | |
extensiondownload = requests.get(link,headers=headers).url | |
urlretrieve(extensiondownload, os.path.expanduser('~') + "/Downloads/{}_v{}.crx".format(slugname, version)) | |
print extensionid | |
jsondir = '/usr/share/chromium/extensions/' | |
jsonfilename = '{}{}.json'.format(jsondir, extensionid) | |
if not os.path.exists(jsondir): | |
os.system('sudo mkdir ' + jsondir) | |
os.system('sudo touch ' + jsonfilename) | |
os.system('sudo chmod 777 ' + jsonfilename) | |
with open(jsonfilename, 'w+') as f: | |
jsondata = {'external_version': version, 'external_crx': '/home/fivethous/Downloads/{}_v{}.crx'.format(slugname, version)} | |
f.write(dumps(jsondata, indent=4, sort_keys=True)) | |
f.truncate() | |
f.close() |
This file contains 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 python | |
## NOTICE ## | |
## This script is incomplete, but works alright in linux. ## | |
############################################################ | |
## | |
## Checks for new releases every 30 minutes. ## | |
## Notifies with a prompt to the github page. ## | |
## | |
## | |
from platform import linux_distribution, system | |
from urllib2 import urlopen | |
from json import load, dumps | |
from subprocess import Popen, check_call, CalledProcessError | |
from time import sleep | |
def zenity(url): | |
try: | |
check_call(['zenity', '--question', '--text', 'ungoogled-chromium update ready. Open github page?']) | |
except CalledProcessError: | |
pass | |
else: | |
Popen(['chromium', url]) | |
### SETTINGS ### | |
os = system().lower() | |
dist = linux_distribution() | |
if os == 'linux': | |
ct = 'application/vnd.debian.binary-package' | |
if os == 'darwin': | |
ct = 'application/x-apple-diskimage' | |
if os == 'windows': | |
ct = 'application/zip' | |
if dist[-1] == '': | |
dist = dist[-2] | |
### MAIN ### | |
def output(): | |
url = 'https://github.com/Eloston/ungoogled-chromium/releases/' + data['tag_name'] | |
zenity(url) | |
#def notify(message): | |
# Popen(['notify-send', message]) | |
# return | |
#notify('Download URL: %s' % i['browser_download_url']) | |
#notify('Version: %s' % data['tag_name']) | |
while True: | |
try: | |
resp = urlopen('https://api.github.com/repos/Eloston/ungoogled-chromium/releases/latest') | |
data = load(resp) | |
for i in data['assets']: | |
if i['content_type'] == ct: | |
if os == 'linux' and dist in i['name']: | |
output() | |
output() | |
else: print 'No updates for your os available.' | |
sleep(30) | |
except: | |
print 'Something went wrong. Internet connection?' | |
sleep(5) | |
continue |
This file contains 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/bash | |
clear | |
RED='\033[0;31m' | |
YELLOW='\033[1;33m' | |
NC='\033[0m' | |
echo -e "\nThis script downloads and installs the ungoogled-chromium.\n" | |
echo -e "${YELLOW}\tVersion: 53.0.2785.116-1\n" \ | |
"\tArchitecture: amd64\n" | |
echo -e "\tThese Debian packages are built for Ubuntu Xenial,\n" \ | |
"\tbut may work on other Ubuntu based distributions.\n${NC}" | |
if [ $EUID -ne 0 ]; then | |
echo -e "${RED}This needs sudo.\n${NC}" | |
exit 1 | |
fi | |
trap ctrl_c INT | |
function ctrl_c() { | |
echo -e "\n\n\n${YELLOW}CTRL-C: removing files and quitting...${NC}" | |
rm -f /tmp/xenial*.deb | |
exit | |
} | |
cd /tmp | |
echo -e "${YELLOW}\nWent into /tmp directory." | |
echo -n "Now downloading Debian packages from github...${NC}" | |
wget -q "https://github.com/Eloston/ungoogled-chromium/releases/download/53.0.2785.116-1.1/xenial_chrome-sandbox_53.0.2785.116-1_amd64.deb" \ | |
"https://github.com/Eloston/ungoogled-chromium/releases/download/53.0.2785.116-1.1/xenial_chromedriver_53.0.2785.116-1_amd64.deb" \ | |
"https://github.com/Eloston/ungoogled-chromium/releases/download/53.0.2785.116-1.1/xenial_chromium-l10n_53.0.2785.116-1_all.deb" \ | |
"https://github.com/Eloston/ungoogled-chromium/releases/download/53.0.2785.116-1.1/xenial_chromium_53.0.2785.116-1_amd64.deb" | |
echo " ${YELLOW}Done." | |
echo -e "Installing ungoogled-chromium...\n${NC}" | |
dpkg --force-overwrite -i xenial_chromium_53.0.2785.116-1_amd64.deb \ | |
xenial_chromium-l10n_53.0.2785.116-1_all.deb \ | |
xenial_chrome-sandbox_53.0.2785.116-1_amd64.deb \ | |
xenial_chromedriver_53.0.2785.116-1_amd64.deb | |
if [[ $? == 0 ]]; then | |
echo "${YELLOW}Done." | |
else | |
echo -e "${YELLOW}Something went wrong${NC}. Check the log, it might not be anything crucial." | |
fi | |
echo -ne "\nRemoving .deb files..." | |
rm -f /tmp/xenial*.deb | |
echo " Done.${NC}" | |
echo "Bye" | |
## Implement github api later | |
## https://api.github.com/repos/Eloston/ungoogled-chromium/releases |
This file contains 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
uBlock Origin: | |
https://clients2.google.com/service/update2/crx?response=redirect&prodversion=48.0&x=id%3Dcjpalhdlnbpafiamejdnhcphjbkeiagm%26installsource%3Dondemand%26uc | |
LastPass: | |
https://clients2.google.com/service/update2/crx?response=redirect&prodversion=48.0&x=id%3Dhdokiejnpimakedhajhdlcegeplioahd%26installsource%3Dondemand%26uc | |
Extension Downloader: | |
http://chrome-extension-downloader.com/extension-downloader.crx | |
Vanilla Cookie Manager: | |
https://chrome.google.com/webstore/detail/vanilla-cookie-manager/gieohaicffldbmiilohhggbidhephnjj | |
Global New Tab Shortcut: | |
https://chrome.google.com/webstore/detail/global-new-tab-shortcut/dcngopenklmnfdlfocljeaokkhcplong |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment