Commit 429516fb authored by rgaudin's avatar rgaudin
Browse files

Merge branch 'dev' for buster and 2.1.0

parents 8f30e5fd a1fb68b8
Pipeline #162201 failed with stage
in 135 minutes and 56 seconds
......@@ -20,3 +20,4 @@ qemu-system-arm
xz-*.tar.gz
xz-*
etcher-cli
aria2c
......@@ -31,6 +31,11 @@ build-pibox-image:
- mkdir -p etcher-cli
- tar xf balena-etcher-cli-1.4.8-linux-x64.tar.gz -C etcher-cli --strip-components=1
# download aria2c (not used but packaged)
- wget http://download.kiwix.org/dev/aria2c-linux64.zip
- unzip aria2c-linux64.zip
- rm aria2c-linux64.zip
# Install python dependancies
- pip3 install -U pip
- pip3 install -r requirements-linux.txt
......
......@@ -61,6 +61,11 @@ matrix:
- mkdir -p etcher-cli
- tar xf balena-etcher-cli-1.4.8-darwin-x64.tar.gz -C etcher-cli --strip-components=1
# Bundle aria2c
- wget http://download.kiwix.org/dev/aria2c-darwin.zip
- unzip aria2c-darwin.zip
- rm aria2c-darwin.zip
# Run PyInstaller
- pyinstaller --log-level=DEBUG kiwix-hotspot-macos.spec
......@@ -150,6 +155,11 @@ matrix:
- mkdir -p etcher-cli
- tar xf balena-etcher-cli-1.4.8-linux-x64.tar.gz -C etcher-cli --strip-components=1
# Bundle aria2c
- wget http://download.kiwix.org/dev/aria2c-linux64.zip
- unzip aria2c-linux64.zip
- rm aria2c-linux64.zip
# Install python dependancies
- pip3 install -r requirements-linux.txt
......
2.1.0
* Using aria2 to download content (metalink and resume)
* Using mirror.download.kiwix.org for retrieving catalog (gzip'd)
* Removed 8GB target size
* system locale to en_US (was en_GB*)
* Updated kiwix-serve to 3.0.1
* Updated to raspbian 2019-07-10 (buster)
* Base image 1GB lighter to download
* Added support for Pi4
* WPA password must be at least 8chars.
* Fixed bug for ZIMs with UTF-8 title/desc on windows
* Changed data partition label to HSPOT_DATA
* Internal scripts (captive_portal, time) to use python3
* Tested on the following revisions:
* Raspberry Pi 4 Model B Rev 1.1 / b03111 / Pi 4B v1.1 2GB (Sony UK)
* Raspberry Pi 3 Model B Plus Rev 1.3 / a020d3 / Pi 3B+ v1.3 1GB (Sony UK)
* Raspberry Pi 3 Model B Rev 1.2 / a02082 / Pi 3B v1.2 1GB (Sony UK)
* Raspberry Pi Model B Rev 2 / 000e / Pi B v2.0 512MB (Sony UK)
* Raspberry Pi Model B Rev 2 / 000f / Pi B v2.0 512MB (Egoman)
* Raspberry Pi Zero W Rev 1.1 / 9000c1 / Pi Zero W v1.1 512MB (Sony UK)
2.0.8
* Updated kiwix-serve to 2.1.0
......
......@@ -33,10 +33,11 @@ language_name: "English"
# versions
qemu_kernel_version: "4.10.0"
kernel_version: "4.14.34"
kiwix_version: "2.1.0"
kiwix_version: "3.0.1"
kalite_version: "0.17.4"
edupi_version: "1.4.10"
python3_version: "3.5"
php_version: "7.3"
# Apps path
venvs_root: /home/{{ username }}/venvs
......
#!/usr/bin/env python
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
import re
import subprocess
def has_internet():
try:
with open("/tmp/has_internet", "r") as f:
......@@ -14,46 +15,46 @@ def has_internet():
TRANSLATIONS = {
"fr": {
"banner": u"Bienvenue sur «<em>{{ hotspot_name }}</em>» "
u"(<a href=\"http://{{ fqdn }}/\">{{ fqdn }}</a>)",
"title": u"<em>{{ project_name }}</em> est une ressource de "
u"contenus libres d'accès.",
"reminder": u"Merci de vous rappeler des points suivants :",
"access": u"L'accès à ces contenus ne se fait "
u"<strong>qu'à travers <em>http://{{ fqdn }}/</em></strong>. "
u"<u>Souvenez-vous en !</u>",
"internet": u"Cette ressource peut fournir un accès à Internet. "
u"Dans ce cas, il faudra vous <em>identifier</em> pour y accèder.",
"prompt": u"Cette page vous sera alors présenté <strong>après 15mn</strong> "
u"d'inactivité.",
"https": u"Surfant sur un site sécurisé, le navigateur pourrait vous afficher "
u"un <em>avertissement de sécurité</em> au lieu d'afficher cette page. "
u"Ouvrez-en simplement une nouvelle "
u"sur un site non-sécurisé et identifiez-vous à nouveau.",
"go_button": u"Aller à {{ fqdn }}",
"internet_button": u"M'identifier et accèder à Internet",
"banner": "Bienvenue sur «<em>{{ hotspot_name }}</em>» "
'(<a href="http://{{ fqdn }}/">{{ fqdn }}</a>)',
"title": "<em>{{ project_name }}</em> est une ressource de "
"contenus libres d'accès.",
"reminder": "Merci de vous rappeler des points suivants :",
"access": "L'accès à ces contenus ne se fait "
"<strong>qu'à travers <em>http://{{ fqdn }}/</em></strong>. "
"<u>Souvenez-vous en !</u>",
"internet": "Cette ressource peut fournir un accès à Internet. "
"Dans ce cas, il faudra vous <em>identifier</em> pour y accèder.",
"prompt": "Cette page vous sera alors présenté <strong>après 15mn</strong> "
"d'inactivité.",
"https": "Surfant sur un site sécurisé, le navigateur pourrait vous afficher "
"un <em>avertissement de sécurité</em> au lieu d'afficher cette page. "
"Ouvrez-en simplement une nouvelle "
"sur un site non-sécurisé et identifiez-vous à nouveau.",
"go_button": "Aller à {{ fqdn }}",
"internet_button": "M'identifier et accèder à Internet",
},
"en": {
"banner": u"Entering “<em>{{ hotspot_name }}</em>” "
u"(<a href=\"http://{{ fqdn }}/\">{{ fqdn }}</a>)",
"title": u"<em>{{ project_name }}</em> is a free-to-use, content-enabled box.",
"reminder": u"Please, keep the following in mind:",
"access": u"Access to this box's content is done "
u"<strong>solely via <em>http://{{ fqdn }}/</em></strong>. "
u"<u>Remember-it !</u>",
"internet": u"This box may also provide access to Internet. "
u"You need to <em>log-in</em> to the network to access it.",
"prompt": u"You will then be prompted with this page <strong>after "
u"every 15mn</strong> of inactivity.",
"https": u"When browsing a secure website, your browser might display "
u"a <em>Security Warning</em> instead of displaying this page. "
u"Just open a new page onto a non-secure website to log-in again.",
"go_button": u"Go to {{ fqdn }}",
"internet_button": u"Log me in and access Internet",
"banner": "Entering “<em>{{ hotspot_name }}</em>” "
'(<a href="http://{{ fqdn }}/">{{ fqdn }}</a>)',
"title": "<em>{{ project_name }}</em> is a free-to-use, content-enabled box.",
"reminder": "Please, keep the following in mind:",
"access": "Access to this box's content is done "
"<strong>solely via <em>http://{{ fqdn }}/</em></strong>. "
"<u>Remember-it !</u>",
"internet": "This box may also provide access to Internet. "
"You need to <em>log-in</em> to the network to access it.",
"prompt": "You will then be prompted with this page <strong>after "
"every 15mn</strong> of inactivity.",
"https": "When browsing a secure website, your browser might display "
"a <em>Security Warning</em> instead of displaying this page. "
"Just open a new page onto a non-secure website to log-in again.",
"go_button": "Go to {{ fqdn }}",
"internet_button": "Log me in and access Internet",
},
}
header = u"""<!DOCTYPE html>
header = """<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
......@@ -71,7 +72,7 @@ header = u"""<!DOCTYPE html>
<link rel="stylesheet" type="text/css" href="/hotspot-static/branding/style.css" />
</head>"""
parta = u"""
parta = """
<body class="">
<header>
<section>
......@@ -91,16 +92,16 @@ parta = u"""
<p style="text-decoration: underline;">{reminder}</p>
<ul><li>{access}</li>"""
partb = u"""<li>{internet}</li><li>{prompt}</li>"""
partb = """<li>{internet}</li><li>{prompt}</li>"""
partc = u"""<li>{https}</li></ul>
partc = """<li>{https}</li></ul>
<p><a class="button" href="http://{{ fqdn }}">{go_button}</a>"""
partd = u""" <a class="button neutral" href="/register">{internet_button}</a>"""
partd = """ <a class="button neutral" href="/register">{internet_button}</a>"""
parte = u"""</p></div>"""
parte = """</p></div>"""
footer = u"""
footer = """
<footer>
<div class="row">
<div class="col third i18n_switch"></div>
......@@ -113,10 +114,12 @@ footer = u"""
def get_translation_for(accept_lang_header, default="en"):
chosen_lang = default
langs = [lang_item.replace("_", "-").split("-")[0].lower()
for lang_code in accept_lang_header.split(",")
for lang_item in lang_code.split(";")
if "q=" not in lang_item]
langs = [
lang_item.replace("_", "-").split("-")[0].lower()
for lang_code in accept_lang_header.split(",")
for lang_item in lang_code.split(";")
if "q=" not in lang_item
]
for lang in langs:
if lang in TRANSLATIONS.keys():
......@@ -127,15 +130,33 @@ def get_translation_for(accept_lang_header, default="en"):
def allow_host(ipaddress):
passlist_output = subprocess.check_output(
"sudo iptables -t nat -nL CAPTIVE_PASSLIST", shell=True)
passlist = [re.split(r"\s+", line)[3]
for line in passlist_output.split("\n") if "--" in line]
passlist_ps = subprocess.run(
["/usr/bin/sudo", "/usr/sbin/iptables", "-t", "nat", "-nL", "CAPTIVE_PASSLIST"],
capture_output=True,
text=True,
)
passlist = [
re.split(r"\s+", line)[3]
for line in passlist_ps.stdout.split("\n")
if "--" in line
]
if ipaddress in passlist:
return
subprocess.check_output(
"sudo iptables -t nat -I CAPTIVE_PASSLIST 1 -s {ip} -j ACCEPT"
.format(ip=ipaddress), shell=True)
subprocess.run(
[
"/usr/bin/sudo",
"/usr/sbin/iptables",
"-t",
"nat",
"-I",
"CAPTIVE_PASSLIST",
"1",
"-s",
str(ipaddress),
"-j",
"ACCEPT",
]
)
def application(env, start_response):
......
......@@ -6,4 +6,4 @@ gid = {{ group }}
socket = :3031
wsgi-file = /var/www/captiveportal/cap.py
process = 3
plugin = python
plugin = python3
#!/usr/bin/env python
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
""" hardware clock management UI
......@@ -11,13 +11,12 @@
# https://afterthoughtsoftware.com/products/rasclock
# https://www.cyberciti.biz/faq/howto-set-date-time-from-linux-command-prompt/
import re
import urllib
import subprocess
header = u"""<html><head><meta charset="utf-8"><style type="text/css">th { text-align: left; }</style></head>"""
header = """<html><head><meta charset="utf-8"><style type="text/css">th { text-align: left; }</style></head>"""
body = u"""<body>
body = """<body>
<h1><a href="/">Pi Time</a></h1>
{output}
<table>
......@@ -48,7 +47,7 @@ body = u"""<body>
</form>
"""
footer = u"</html>"
footer = "</html>"
date_bin = "/bin/date"
hwclock_bin = "/sbin/hwclock"
......@@ -56,10 +55,13 @@ tdctl_bin = "/usr/bin/timedatectl"
def get_output(command):
try:
return subprocess.check_output(["sudo"] + command).strip()
except Exception as exp:
return "ERROR: {}".format(exp)
ps = subprocess.run(["sudo"] + command, capture_output=True, text=True)
stdout = ps.stdout.strip()
if ps.returncode == 0:
return stdout
if ps.returncode == 1 and "hwclock" in command[0]:
return "ERROR: no hardware clock installed?"
return "ERROR: {}".format(stdout)
def application(env, start_response):
......
......@@ -6,4 +6,4 @@ gid = {{ group }}
socket = :3032
wsgi-file = /var/www/clock/clock.py
process = 1
plugin = python
plugin = python3
---
- name: Unblock wlan
command: rfkill unblock wlan
when: (ansible_architecture == 'x86_64' or ansible_architecture == 'i386')
- name: Unblock RF
command: rfkill unblock all
ignore_errors: yes
tags: master
......@@ -42,5 +41,17 @@
systemd:
daemon-reload: yes
- name: unmask hostapd
become: true
command: systemctl unmask hostapd
tags: master
- name: unmask hostapd
become: true
systemd:
masked: no
name: hostapd
tags: master
- include_tasks: enable_service.yml service=hostapd
tags: master
---
- name: Install iptables
apt:
name: iptables
name: iptables,arptables,ebtables
state: latest
autoremove: yes
autoclean: yes
tags: master
- name: use iptables instead of the default nftables
command: update-alternatives --set {{ item }} /usr/sbin/{{ item }}-legacy
with_items:
- iptables
- ip6tables
- arptables
- ebtables
when: ansible_distribution_release == "buster"
tags: master
- name: Authorize routing
replace:
dest: /etc/sysctl.conf
......
......@@ -25,7 +25,7 @@
- include_tasks: enable_service.yml service=memcached
when: ansible_local.config.wikifundi_languages | length
- include_tasks: enable_service.yml service=php7.0-fpm
- include_tasks: enable_service.yml service=php{{ php_version }}-fpm
when: ansible_local.config.wikifundi_languages | length
- include_tasks: enable_vhost.yml name={{ item }}.wikifundi
......
LANG=en_US.UTF-8
LC_ALL=en_US.UTF-8
LANGUAGE=en_US.UTF-8
deb http://raspbian.raspberrypi.org/raspbian/ buster main contrib non-free rpi
#deb-src http://raspbian.raspberrypi.org/raspbian/ buster main contrib non-free rpi
deb http://deb.debian.org/debian/ buster main contrib non-free
deb http://security.debian.org/debian-security buster/updates main contrib non-free
# buster-updates, previously known as 'volatile'
deb http://deb.debian.org/debian/ buster-updates main contrib non-free
# buster-backports, previously on backports.debian.org
deb http://deb.debian.org/debian/ buster-backports main contrib non-free
deb http://raspbian.raspberrypi.org/raspbian/ jessie main contrib non-free rpi
#deb-src http://raspbian.raspberrypi.org/raspbian/ jessie main contrib non-free rpi
deb http://deb.debian.org/debian/ jessie main contrib non-free
deb http://security.debian.org/debian-security jessie/updates main contrib non-free
# jessie-updates, previously known as 'volatile'
deb http://deb.debian.org/debian/ jessie-updates main contrib non-free
# jessie-backports, previously on backports.debian.org
deb http://deb.debian.org/debian/ jessie-backports main contrib non-free
[Unit]
Description=Ublock RF devices
DefaultDependencies=no
[Service]
Type=oneshot
RemainAfterExit=yes
ExecStart=/usr/sbin rfkill ublock all
......@@ -28,7 +28,7 @@
- name: download exfat kernel module
unarchive:
src: "{{ mirror }}/dev/exfat_{{ kernel_version }}.tar"
src: "{{ mirror }}/dev/exfat_{{ kernel_version }}_buster.tar"
dest: /tmp/
remote_src: True
tags: master
......@@ -38,6 +38,7 @@
with_items:
- "{{ kernel_version }}"
- "{{ kernel_version }}-v7"
- "{{ kernel_version }}-v7l"
tags: master
- name: make temp directories to fool depmod
......@@ -47,9 +48,10 @@
with_items:
- "{{ kernel_version }}"
- "{{ kernel_version }}-v7"
- "{{ kernel_version }}-v7l"
tags: master
- name: create symlinks to fool depmod
- name: create symlinks to fool depmod (qemu)
file:
src: /lib/modules/{{ item }}+
dest: /tmp/{{ item }}/lib/modules/{{ qemu_kernel_version }}
......@@ -57,6 +59,52 @@
with_items:
- "{{ kernel_version }}"
- "{{ kernel_version }}-v7"
- "{{ kernel_version }}-v7l"
when: running_kernel_version.stdout[:7] == qemu_kernel_version
tags: master
- name: create symlinks to fool depmod on Pi 1
file:
src: /lib/modules/{{ item }}+
dest: /tmp/{{ item }}/lib/modules/{{ item }}
state: link
with_items:
- "{{ kernel_version }}"
- "{{ kernel_version }}-v7"
- "{{ kernel_version }}-v7l"
when: running_kernel_version.stdout[:7] == kernel_version
tags: master
- name: create symlinks to fool depmod on Pi 2
file:
src: /lib/modules/{{ item }}+
dest: /tmp/{{ kernel_version }}/lib/modules/{{ item }}+
state: link
with_items:
- "{{ kernel_version }}"
- "{{ kernel_version }}-v7"
- "{{ kernel_version }}-v7l"
when: running_kernel_version.stdout[:7] == kernel_version
tags: master
- name: create symlinks to fool depmod on Pi 3
file:
src: /lib/modules/{{ item }}+
dest: /tmp/{{ item }}/lib/modules/{{ item }}+
state: link
with_items:
- "{{ kernel_version }}"
- "{{ kernel_version }}-v7"
- "{{ kernel_version }}-v7l"
when: running_kernel_version.stdout[:7] == kernel_version
tags: master
- name: create symlinks to fool depmod on Pi 4
file:
src: /lib/modules/{{ kernel_version }}-v7l+
dest: /tmp/{{ kernel_version }}-v7/lib/modules/{{ kernel_version }}-v7l+
state: link
when: running_kernel_version.stdout[:7] == kernel_version
tags: master
- name: regenerate modules list
......@@ -64,6 +112,7 @@
with_items:
- "{{ kernel_version }}"
- "{{ kernel_version }}-v7"
- "{{ kernel_version }}-v7l"
tags: master
- name: add exfat module to startup list
......@@ -83,35 +132,45 @@
when: has_exfat.stdout.strip()|int == 0
tags: master
- name: remove raspi sources
file:
path: /etc/apt/sources.list.d/raspi.list
state: absent
- name: create systemd-service to ublock RF on start
copy:
src: unblock-rf.service
dest: /etc/systemd/system/unblock-rf.service
tags: master
- name: Run apt update
apt:
update_cache: yes
- name: reload systemd
command: systemctl daemon-reload
tags: master
- name: install stretch debian keyring
apt:
deb: http://ftp.fr.debian.org/debian/pool/main/d/debian-archive-keyring/debian-archive-keyring_2017.5_all.deb
when: ansible_distribution_release == "stretch"
tags: master
# - name: remove raspi sources
# file:
# path: /etc/apt/sources.list.d/raspi.list
# state: absent
# tags: master
- name: install jessie debian keyring
apt:
deb: http://ftp.fr.debian.org/debian/pool/main/d/debian-archive-keyring/debian-archive-keyring_2017.5~deb8u1_all.deb
when: ansible_distribution_release == "jessie"
tags: master
# - name: Run apt update
# apt:
# update_cache: yes
# tags: master
- name: Drop a complete sources.list
copy:
src: sources_{{ ansible_distribution_release }}.list
dest: /etc/apt/sources.list
when: ansible_distribution == "Debian"
tags: master
# - name: install buster debian keyring
# apt:
# deb: http://ftp.fr.debian.org/debian/pool/main/d/debian-archive-keyring/debian-archive-keyring_2019.1_all.deb
# when: ansible_distribution_release == "buster"
# tags: master
# - name: install stretch debian keyring
# apt:
# deb: http://ftp.fr.debian.org/debian/pool/main/d/debian-archive-keyring/debian-archive-keyring_2017.5_all.deb
# when: ansible_distribution_release == "stretch"
# tags: master
# - name: Drop a complete sources.list
# copy:
# src: sources_{{ ansible_distribution_release }}.list
# dest: /etc/apt/sources.list
# when: ansible_distribution == "Debian"
# tags: master
- name: Run apt update
apt:
......@@ -133,7 +192,7 @@
- name: Install or upgrade all required package
apt:
name: python-dev,git,sudo,lsb-release,vim,locate,git,unzip,bash-completion,aptitude,ntpdate,fake-hwclock,hdparm,ncurses-term,libffi-dev,libssl-dev,tree,screen,iftop,tmux,mtr-tiny,libwww-perl,httpie,lshw,hwinfo,sqlite3,elinks,mosh,curl,apt-transport-https,tar,exfat-utils,gzip,hostname,liblzma5,pkg-config,systemd,systemd-sysv,tzdata,wget,xz-utils,adduser,libpam-systemd,policykit-1
name: python-dev,git,sudo,lsb-release,vim,locate,git,unzip,bash-completion,aptitude,ntpdate,fake-hwclock,hdparm,ncurses-term,libffi-dev,libssl-dev,tree,screen,iftop,tmux,mtr-tiny,libwww-perl,httpie,lshw,hwinfo,sqlite3,elinks,mosh,curl,apt-transport-https,tar,exfat-fuse,exfat-utils,gzip,hostname,liblzma5,pkg-config,systemd,systemd-sysv,tzdata,wget,xz-utils,adduser,libpam-systemd,policykit-1,python3-setuptools
state: latest
autoremove: yes
autoclean: yes
......@@ -142,11 +201,6 @@
- import_tasks: clean_apt.yml
tags: master
- name: install newer exfat-utils from bower
apt:
deb: "{{ mirror }}/dev/exfat-utils_1.2.8-1_armhf.deb"
tags: master
- name: Install avahi packages
apt:
name: "{{ item }}"
......@@ -213,6 +267,13 @@
- en_US.UTF-8
tags: master
- name: set default locale to en_US
copy:
src: locale
dest: /etc/default/locale
mode: 0644
tags: master
- name: Copy a blank rc.local
copy:
src: rc.local
......@@ -307,6 +368,14 @@
notify: update timezone