diff --git a/.drone.yml b/.drone.yml new file mode 100644 index 0000000..0cdefce --- /dev/null +++ b/.drone.yml @@ -0,0 +1,40 @@ +kind: pipeline +name: default + +steps: + - name: build + image: registry.libreschool.org/libreschool-automation/ubuntu-build:16.04 + commands: + - debuild -i -us -uc + - mkdir out && mv ../*.deb out/ + pull: always + when: + event: [ push, tag ] + + - name: sign + image: registry.libreschool.org/libreschool-automation/deb-sign:latest + settings: + files: out/*.deb + gpg_key: + from_secret: gpg_key + passphrase: + from_secret: passphrase + pull: always + when: + event: tag + + - name: gitea_release + image: plugins/gitea-release + settings: + files: out/*.deb + checksum: + - md5 + - sha1 + - sha256 + - sha512 + api_key: + from_secret: gitea_token + base_url: https://git.libreschool.org + file_exists: skip + when: + event: tag diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..7828102 --- /dev/null +++ b/.gitignore @@ -0,0 +1,6 @@ +debian/libreschool-client.substvars +debian/libreschool-client.debhelper.log +debian/debhelper-build-stamp +debian/libreschool-client/ +debian/.debhelper +*.deb diff --git a/conf/libreschool-client.conf b/conf/libreschool-client.conf new file mode 100644 index 0000000..918daa0 --- /dev/null +++ b/conf/libreschool-client.conf @@ -0,0 +1,3 @@ +[client] + +[server] diff --git a/cron/libreschool-client b/cron/libreschool-client new file mode 100644 index 0000000..6434024 --- /dev/null +++ b/cron/libreschool-client @@ -0,0 +1,2 @@ +*/5 * * * * root /usr/sbin/libreschool-client +@reboot root /usr/sbin/libreschool-client diff --git a/debian/changelog b/debian/changelog new file mode 100644 index 0000000..14c3d5d --- /dev/null +++ b/debian/changelog @@ -0,0 +1,5 @@ +libreschool-client (1.0.0) UNRELEASED; urgency=medium + + * Initial release. + + -- paolo Thu, 12 Oct 2017 22:00:00 +0200 diff --git a/debian/compat b/debian/compat new file mode 100644 index 0000000..ec63514 --- /dev/null +++ b/debian/compat @@ -0,0 +1 @@ +9 diff --git a/debian/control b/debian/control new file mode 100644 index 0000000..e9ed596 --- /dev/null +++ b/debian/control @@ -0,0 +1,13 @@ +Source: libreschool-client +Section: admin +Priority: optional +Maintainer: LibreSchool +Build-Depends: debhelper (>= 9), pkg-config +Standards-Version: 3.9.7 +Homepage: https://git.libreschool.org/LibreSchool/libreschool-client + +Package: libreschool-client +Architecture: all +Depends: python, python-configparser, python-requests, openssh-server, ${shlibs:Depends}, ${misc:Depends} +Description: LibreSchool management client + Managed by a LibreSchool server. diff --git a/debian/copyright b/debian/copyright new file mode 100644 index 0000000..36680a5 --- /dev/null +++ b/debian/copyright @@ -0,0 +1,27 @@ +Format: http://www.debian.org/doc/packaging-manuals/copyright-format/1.0/ +Upstream-Name: Doraemon Client +Source: https://github.com/bglug-it/doraemon-client + +Files: * +Copyright: Copyright 2017 BGLug +License: GPL-2+ + This program is free software; you can redistribute it + and/or modify it under the terms of the GNU General Public + License as published by the Free Software Foundation; either + version 2 of the License, or (at your option) any later + version. + . + This program is distributed in the hope that it will be + useful, but WITHOUT ANY WARRANTY; without even the implied + warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR + PURPOSE. See the GNU General Public License for more + details. + . + You should have received a copy of the GNU General Public + License along with this package; if not, write to the Free + Software Foundation, Inc., 51 Franklin St, Fifth Floor, + Boston, MA 02110-1301 USA + . + On Debian systems, the full text of the GNU General Public + License version 2 can be found in the file + `/usr/share/common-licenses/GPL-2'. diff --git a/debian/files b/debian/files new file mode 100644 index 0000000..b8f45b4 --- /dev/null +++ b/debian/files @@ -0,0 +1,2 @@ +libreschool-client_1.0.0_all.deb admin optional +libreschool-client_1.0.0_amd64.buildinfo admin optional diff --git a/debian/libreschool-client.install b/debian/libreschool-client.install new file mode 100644 index 0000000..5dbd182 --- /dev/null +++ b/debian/libreschool-client.install @@ -0,0 +1,3 @@ +libreschool-client usr/sbin +cron/libreschool-client etc/cron.d +conf/libreschool-client.conf etc/libreschool-client diff --git a/debian/rules b/debian/rules new file mode 100755 index 0000000..2d33f6a --- /dev/null +++ b/debian/rules @@ -0,0 +1,4 @@ +#!/usr/bin/make -f + +%: + dh $@ diff --git a/debian/source/format b/debian/source/format new file mode 100644 index 0000000..89ae9db --- /dev/null +++ b/debian/source/format @@ -0,0 +1 @@ +3.0 (native) diff --git a/libreschool-client b/libreschool-client new file mode 100755 index 0000000..82cef8e --- /dev/null +++ b/libreschool-client @@ -0,0 +1,113 @@ +#!/usr/bin/env python + +import configparser +import uuid +import re +import os +import socket, struct +import requests +import sys +import socket +import fileinput +import json + +def get_default_gateway_linux(): + """Read the default gateway directly from /proc.""" + with open("/proc/net/route") as fh: + for line in fh: + fields = line.strip().split() + if fields[1] != '00000000' or not int(fields[3], 16) & 2: + continue + + return socket.inet_ntoa(struct.pack("