Skip to content

Commit

Permalink
GSoC 2023 Epoptes improvements (#204)
Browse files Browse the repository at this point in the history
  • Loading branch information
eltoukos committed Aug 21, 2023
1 parent 4d8f09a commit 0a6bfa8
Show file tree
Hide file tree
Showing 13 changed files with 414 additions and 97 deletions.
1 change: 0 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@ var/
# Usually these files are written by a python script from a template
# before PyInstaller builds the exe, so as to inject date/other infos into it.
*.manifest
*.spec

# Installer logs
pip-log.txt
Expand Down
2 changes: 1 addition & 1 deletion bin/epoptes
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,8 @@ from epoptes.core import logger
from epoptes.daemon import uiconnection
from epoptes.ui import gui
from epoptes.ui.common import gettext as _
from epoptes.ui.reactor import reactor
from gi.repository import Gtk
from twisted.internet import reactor
from twisted.internet.protocol import ClientCreator


Expand Down
21 changes: 15 additions & 6 deletions data/client-functions
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ ensure_display() {
local vars

test "$UID" -eq 0 || return 0
if timeout 1 xwininfo -root -size >/dev/null 2>&1; then
if timeout 1 xprop -root EPOPTES_CLIENT >/dev/null 2>&1; then
return 0
elif vars=$(./get-display); then
export $vars
Expand Down Expand Up @@ -151,12 +151,19 @@ EOF
MAC=${MAC%% *}
test -n "$MAC" || die "Empty MAC"
fi
CPU=$(awk -F': ' '/^model name/ { print $2; exit }' /proc/cpuinfo)
CPU=$(awk -F': ' '/^(model name|Model)/ { print $2; exit }' /proc/cpuinfo)
# Avoid the name "GROUPS" as it's an internal bash variable, see
# https://github.com/ltsp/ltsp/issues/389#issuecomment-1144856545
MEMBEROF=$(groups | tr ' ' ',')
RAM=$(awk '/^MemTotal:/ { print int($2/1024) }' /proc/meminfo)
VGA=$(lspci -nn -m 2>/dev/null | sed -n -e '/"VGA/s/[^"]* "[^"]*" "[^"]*" "\([^"]*\)" .*/\1/p' | tr '\n' ' ')
# Use grep to avoid syntax errors like e.g. this on rpi4:
# MODALIAS=of:NgpuT(null)Cbrcm,bcm2711-vc5
VGA=$(
DRIVER=
PCI_ID=
eval "$(grep -shE '^(DRIVER|PCI_ID)=' /sys/class/graphics/fb?/../../uevent /sys/class/drm/card?/../../uevent || true)"
echo "$DRIVER${PCI_ID:+" [$PCI_ID]"}"
)
OS=$(uname -o)

export VERSION USER NAME HOME MEMBEROF HOSTNAME IP MAC CPU RAM VGA OS
Expand Down Expand Up @@ -284,9 +291,10 @@ lock_screen() {
unlock_screen
# TODO: remove compatibility fallback after a few versions
if [ -f "./lock_screen.py" ]; then
pid=$(background -p ./lock_screen.py "$2")
pid=$(background -p exec ./lock_screen.py "$2")
else
pid=$(background -p ./lock-screen "$2")
# exec is needed to return the correct pid when /bin/sh -> bash
pid=$(background -p exec ./lock-screen "$2")
fi
xprop_set EPOPTES_LOCK_SCREEN_PID "$pid"
}
Expand Down Expand Up @@ -345,7 +353,8 @@ start_benchmark() {
# $2 = seconds to run.
stop_start_benchmark() {
test -n "$benchmark_pid" && stop_benchmark "$benchmark_pid"
iperf -c "$1" --full-duplex ${1:+-t "$2"}
# exec is needed to return the correct pid when /bin/sh -> bash
exec iperf -c "$1" --full-duplex ${1:+-t "$2"}
}

# Manually stop a previously running benchmark.
Expand Down
13 changes: 13 additions & 0 deletions debian/epoptes-firewalld.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
<?xml version="1.0" encoding="utf-8"?>
<service>
<short>Epoptes</short>
<description>Epoptes is an open source computer lab management and monitoring tool.</description>
<!-- Epoptes daemon -->
<port protocol="tcp" port="789"/>
<!-- Network benchmark using an iperf server -->
<port protocol="tcp" port="5001"/>
<!-- 5490-5499 terminal sharing, 5500-5510 reverse VNC -->
<port protocol="tcp" port="5490-5510"/>
<!-- Normal, forward VNC -->
<port protocol="tcp" port="5900-5920"/>
</service>
1 change: 1 addition & 0 deletions debian/epoptes.install
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
debian/ufw/epoptes etc/ufw/applications.d
usr/bin/
usr/lib/python*/*/*.egg-info
usr/lib/python*/*/epoptes/*/*.py
Expand Down
55 changes: 37 additions & 18 deletions debian/epoptes.postinst
Original file line number Diff line number Diff line change
@@ -1,4 +1,9 @@
#!/bin/sh
# This file is part of Epoptes, https://epoptes.org
# Copyright 2010-2023 the Epoptes team, see AUTHORS.
# SPDX-License-Identifier: GPL-3.0-or-later

# This script is also used by non-deb distributions

set -e

Expand All @@ -16,16 +21,24 @@ set -e

# $1 = version of the package being upgraded.
install() {
if [ -f /etc/default/epoptes ]; then
. /etc/default/epoptes || true
fi
for conf in /etc/default/epoptes \
/etc/epoptes/common/*.conf \
/etc/epoptes/server/*.conf; do
if [ -f "$conf" ]; then
. "$conf" || true
fi
done
SOCKET_GROUP=${SOCKET_GROUP:-epoptes}
if ! getent group "$SOCKET_GROUP" >/dev/null; then
addgroup --system "$SOCKET_GROUP"
if command -v addgroup >/dev/null; then
addgroup --system "$SOCKET_GROUP"
else
groupadd --system "$SOCKET_GROUP"
fi
fi

if ! [ -f /etc/epoptes/server.key ] || ! [ -f /etc/epoptes/server.crt ]
then
if ! [ -f /etc/epoptes/server.key ] || ! [ -f /etc/epoptes/server.crt ]; then
mkdir -p /etc/epoptes
# openssl leaves an .rnd file causing a lintian warning (bug #750099).
tmphome=$(mktemp -d)
# Generate a certificate that is valid since the Epoch,
Expand All @@ -35,9 +48,9 @@ install() {
openssl req -batch -x509 -nodes \
-newkey rsa:4096 -days $(($(date --utc +%s) / 86400 + 3652)) \
-keyout /etc/epoptes/server.key -out /etc/epoptes/server.crt ||
HOME=$tmphome openssl req -batch -x509 -nodes \
-newkey rsa:4096 -days $(($(date --utc +%s) / 86400 + 3652)) \
-keyout /etc/epoptes/server.key -out /etc/epoptes/server.crt
HOME=$tmphome openssl req -batch -x509 -nodes \
-newkey rsa:4096 -days $(($(date --utc +%s) / 86400 + 3652)) \
-keyout /etc/epoptes/server.key -out /etc/epoptes/server.crt
rm -rf "$tmphome"
chmod 600 /etc/epoptes/server.key
echo '
Expand All @@ -46,20 +59,26 @@ Please ensure that you transfer /etc/epoptes/server.crt
to your clients by issuing `epoptes-client -c` from your
regular workstations or from your LTSP chroots.' >&2
fi
# Support firewalld, mainly on Fedora
if command -v firewall-cmd >/dev/null; then
defzone=$(firewall-cmd --get-default-zone)
firewall-cmd --reload --quiet
firewall-cmd --permanent --zone="$defzone" --add-service=epoptes-firewalld
firewall-cmd --reload --quiet
fi
}

case "$1" in
configure)
install "$2"
;;
configure)
install "$2"
;;

abort-upgrade|abort-remove|abort-deconfigure)
;;
abort-upgrade | abort-remove | abort-deconfigure) ;;

*)
echo "postinst called with unknown argument \`$1'" >&2
exit 1
;;
*)
echo "postinst called with unknown argument \`$1'" >&2
exit 1
;;
esac

# dh_installdeb will replace this with shell code automatically
Expand Down
147 changes: 147 additions & 0 deletions debian/epoptes.spec
Original file line number Diff line number Diff line change
@@ -0,0 +1,147 @@
%define build_timestamp %(date +"%%Y%%m%%d")
Name: epoptes
Version: main
Release: %{build_timestamp}%{?dist}
Summary: Computer lab management tool
Summary(el_GR.UTF-8): Λογισμικό διαχείρισης εργαστηρίου υπολογιστών
License: GPLv3
Group: Networking/Remote access
Source: https://github.com/eltoukos/epoptes/archive/refs/heads/main.tar.gz
Url: https://epoptes.org
BugURL: https://github.com/epoptes/epoptes/issues
BuildRequires: desktop-file-utils
BuildRequires: intltool
BuildRequires: python3-devel
BuildRequires: python3-distutils-extra
BuildRequires: systemd
BuildRequires: systemd-rpm-macros
Requires: libfaketime
Requires: openssl
Requires: python3-twisted
Requires: socat
Recommends: epoptes-client
Recommends: iperf
Recommends: python3-gobject-base-noarch
Recommends: python3-netifaces
Recommends: screen
Recommends: tigervnc
Recommends: x11vnc
Recommends: xset
Recommends: xterm
BuildArch: noarch

%description
Epoptes is an open source computer lab management and monitoring tool. It
allows for screen broadcasting and monitoring, remote command execution,
message sending, imposing restrictions like screen locking or sound muting
the clients and much more!

Contains the server daemon and a GUI for controlling client PCs.

It supports LTSP installations, but it also works without LTSP.

%description -l el_GR.UTF-8
Ο Επόπτης είναι ανοικτό λογισμικό διαχείρισης και εποπτείας εργαστηρίου
υπολογιστών. Επιτρέπει την εκπομπή και την παρακολούθηση της οθόνης, την
απομακρυσμένη εκτέλεση εντολών, την επιβολή περιορισμών όπως το κλείδωμα της
οθόνης ή τη σίγαση του ήχου των σταθμών εργασίας και πολλά περισσότερα!

Περιέχει την υπηρεσία εξυπηρετητή και το γραφικό περιβάλλον για τον έλεγχο των
σταθμών εργασίας.

Υποστηρίζει εγκαταστάσεις με ή χωρίς LTSP.

%package client
Summary: Computer lab management tool (client)
Summary(el_GR.UTF-8): Λογισμικό διαχείρισης εργαστηρίου υπολογιστών (πελάτης)
Group: Networking/Remote access
Requires: iperf
Requires: openssl
Requires: screen
Requires: socat
Recommends: tigervnc
Recommends: x11vnc
Recommends: xset
BuildArch: noarch

%description client
Epoptes is an open source computer lab management and monitoring tool. It
allows for screen broadcasting and monitoring, remote command execution,
message sending, imposing restrictions like screen locking or sound muting
the clients and much more!

Contains the client daemon and some utilities for getting screenshots etc.

%description client -l el_GR.UTF-8
Ο Επόπτης είναι ανοικτό λογισμικό διαχείρισης και εποπτείας εργαστηρίου
υπολογιστών. Επιτρέπει την εκπομπή και την παρακολούθηση της οθόνης, την
απομακρυσμένη εκτέλεση εντολών, την επιβολή περιορισμών όπως το κλείδωμα της
οθόνης ή τη σίγαση του ήχου των σταθμών εργασίας και πολλά περισσότερα!

Περιέχει την υπηρεσία εξυπηρετητή και γραφικό περιβάλλον για τον έλεγχο των
σταθμών εργασίας.

%prep
%autosetup

%build
# Not necessary

%install
%__python3 setup.py install --root=%{buildroot} --prefix=%{_prefix}
%find_lang %{name}

install -pD -m755 %{_builddir}/%{name}-%{version}/debian/%{name}.postinst %{buildroot}%{_datadir}/%{name}/%{name}.postinst
install -pD -m644 %{_builddir}/%{name}-%{version}/debian/%{name}.service %{buildroot}%{_unitdir}/%{name}.service
mkdir -p %{buildroot}%{_sysconfdir}/firewalld/services/
install -pD -m644 %{_builddir}/%{name}-%{version}/debian/%{name}-firewalld.xml %{buildroot}%{_sysconfdir}/firewalld/services/
sed 's/twistd3/twistd-3/' -i %{buildroot}%{_unitdir}/%{name}.service
install -pD -m644 %{_builddir}/%{name}-%{version}/debian/%{name}-client.service %{buildroot}%{_unitdir}/%{name}-client.service
rm -f %{buildroot}/%{_docdir}/%{name}/README.md

%post
%systemd_post %{name}.service
if [ "$1" == 1 ]
then
# First time install, see
# https://docs.fedoraproject.org/en-US/packaging-guidelines/Scriptlets/#_syntax
/usr/share/epoptes/epoptes.postinst configure
fi

%preun
%systemd_preun %{name}.service

%postun
%systemd_postun_with_restart %{name}.service

%files -f %{name}.lang
%doc README.md
%{_bindir}/%{name}
%{_datadir}/applications/*
%{_datadir}/icons/*
%{_datadir}/ltsp/
%{_datadir}/%{name}/
%{_mandir}/man1/%{name}.1.*
%{python3_sitelib}/*
%{_unitdir}/%{name}.service
%{_sysconfdir}/firewalld/services/*

%post client
%systemd_post %{name}-client.service

%preun client
%systemd_preun %{name}-client.service

%postun client
%systemd_postun_with_restart %{name}-client.service

%files client
%{_datadir}/%{name}-client/
%{_mandir}/man8/%{name}-client.8.*
%{_sbindir}/%{name}-client
%{_sysconfdir}/xdg/autostart/%{name}-client.desktop
%{_unitdir}/%{name}-client.service

%changelog
* Sat Jun 10 2023 Myrto Georgopoulou <myrto.georgopoulou@gmail.com> 23.01-1
- Initial build
4 changes: 4 additions & 0 deletions debian/ufw/epoptes
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
[epoptes]
title=epoptes
description=Computer lab management tool
ports=789,5001,5490:5510,5900:5920/tcp

0 comments on commit 0a6bfa8

Please sign in to comment.