diff options
author | B Stack <bgstack15@gmail.com> | 2020-12-10 13:25:27 -0500 |
---|---|---|
committer | B Stack <bgstack15@gmail.com> | 2020-12-10 13:25:27 -0500 |
commit | 1f05dba5702e3a9b13e9795310200821dd1e520c (patch) | |
tree | b79ee1ade76d9cab46f282e269ba9b67ec1e1e8b | |
parent | add initial Makefile for install, uninstall (diff) | |
download | hex-zero-1f05dba5702e3a9b13e9795310200821dd1e520c.tar.gz hex-zero-1f05dba5702e3a9b13e9795310200821dd1e520c.tar.bz2 hex-zero-1f05dba5702e3a9b13e9795310200821dd1e520c.zip |
add debian/ and improve installation
-rw-r--r-- | .gitignore | 5 | ||||
-rw-r--r-- | README.debian | 12 | ||||
-rwxr-xr-x | cleanup.py | 2 | ||||
-rw-r--r-- | config/80_hex-zero_cron | 2 | ||||
-rw-r--r-- | config/Makefile | 29 | ||||
-rw-r--r-- | config/hex-zero.conf.example | 4 | ||||
-rw-r--r-- | config/hex-zero.etc.default | 4 | ||||
-rwxr-xr-x | config/hex-zero.init | 6 | ||||
-rw-r--r-- | debian/README.Debian | 5 | ||||
-rw-r--r-- | debian/changelog | 5 | ||||
-rw-r--r-- | debian/clean | 1 | ||||
-rw-r--r-- | debian/control | 40 | ||||
-rw-r--r-- | debian/copyright | 366 | ||||
-rw-r--r-- | debian/hex-zero.lintian-overrides | 7 | ||||
-rw-r--r-- | debian/install | 1 | ||||
-rw-r--r-- | debian/links | 1 | ||||
-rw-r--r-- | debian/patches/series | 1 | ||||
-rw-r--r-- | debian/postinst | 42 | ||||
-rw-r--r-- | debian/postrm | 26 | ||||
-rw-r--r-- | debian/prerm | 28 | ||||
-rwxr-xr-x | debian/rules | 15 | ||||
-rw-r--r-- | debian/source/format | 1 | ||||
-rw-r--r-- | debian/source/lintian-overrides | 1 | ||||
-rw-r--r-- | debian/source/local-options | 2 | ||||
-rw-r--r-- | debian/watch | 2 | ||||
-rwxr-xr-x | hex-zero.wsgi | 4 | ||||
-rwxr-xr-x | hex_zero.py (renamed from hex-zero.py) | 0 |
27 files changed, 586 insertions, 26 deletions
@@ -6,3 +6,8 @@ up/ .*.swp *.conf *.log +debian/.debhelper/ +debian/*debhelper* +debian/files +debian/*.substvars +debian/hex-zero/ diff --git a/README.debian b/README.debian deleted file mode 100644 index a0104b2..0000000 --- a/README.debian +++ /dev/null @@ -1,12 +0,0 @@ -apt-get install uwsgi uwsgi-plugin-python3 python3-flask python3-alembic python3-click python3-decorator python3-flask-migrate python3-flask-script python3-flask-sqlalchemy python3-humanize python3-itsdangerous python3-jinja2 python3-mako python3-markupsafe python3-editor python3-magic python3-requests python3-six python3-validators python3-werkzeug -# need to find short-url (1.2.2) -sudo su hex-zero -c 'pip3 --user install short_url' - -# apache -a2enmod proxy -a2enmod rewrite -a2enmod proxy_http - -# to run: -cd /var/www/0x0 -ps -o user=,pid=,command:80= -u hex-zero | awk '/runserver/{print $2}' | xargs sudo kill ; sudo su hex-zero -c './fhost.py runserver' @@ -19,7 +19,7 @@ """ import os, sys, time, datetime -from fhost import app +from hex_zero import app os.chdir(os.path.dirname(sys.argv[0])) os.chdir(app.config["FHOST_STORAGE_PATH"]) diff --git a/config/80_hex-zero_cron b/config/80_hex-zero_cron new file mode 100644 index 0000000..6672c34 --- /dev/null +++ b/config/80_hex-zero_cron @@ -0,0 +1,2 @@ +# File /etc/cron.d/80_hex-zero.cron +45 3 * * * hex-zero /usr/bin/python3 /var/www/hex-zero/cleanup.py 1>/dev/null 2>&1 diff --git a/config/Makefile b/config/Makefile index 76b69d3..74cb73f 100644 --- a/config/Makefile +++ b/config/Makefile @@ -15,6 +15,7 @@ # build-devuan: APPNAME = hex-zero +APPNAME_ = hex_zero APPVERSION = 0.0.1 SRCDIR = $(CURDIR)/..# because Makefile is in config/ inside this repo prefix = /usr @@ -29,6 +30,7 @@ SYSVDIR = $(SYSCONFDIR)/init.d SYSDDIR = $(DESTDIR)$(prefix)/lib/systemd/system LOGDIR = $(DESTDIR)/var/log/hex-zero APACHEDIR = $(SYSCONFDIR)/httpd/conf.d# for debian use '$(SYSCONFDIR)/apache2/sites-available' +CRONDIR = $(SYSCONFDIR)/cron.d # variables for deplist DEPTYPE = dep @@ -55,6 +57,10 @@ with_apache ?= YES with_nsfw ?= NO with_init ?= YES with_systemd ?= NO +with_cronjob ?= YES + +all: + -@echo "Nothing to build." && ${truebin} install: install_files @@ -78,9 +84,16 @@ install_files: ${installbin} -m0755 -d ${LOGDIR} ${APPDIR} ${APPDIR}/up ${DOCDIR} ${DEFAULTDIR} ${installbin} -m0644 -t ${APPDIR} ${SRCDIR}/front.html.in ${installbin} -m0644 ${SRCDIR}/config/${APPNAME}.conf.example ${APPDIR}/${APPNAME}.conf - ${installbin} -m0755 -t ${APPDIR} ${SRCDIR}/${APPNAME}.py ${SRCDIR}/${APPNAME}.wsgi + ${installbin} -m0755 -t ${APPDIR} ${SRCDIR}/${APPNAME_}.py ${SRCDIR}/${APPNAME}.wsgi \ + ${SRCDIR}/check-for-short_url.sh ${installbin} -m0644 -t ${DOCDIR} ${SRCDIR}/README* ${installbin} -m0644 ${SRCDIR}/config/${APPNAME}.etc.default ${DEFAULTDIR}/${APPNAME} + + @# the migrations directory is required for the db upgrade command to execute correctly + ${installbin} -m0755 -d ${APPDIR}/migrations/versions + ${installbin} -m0644 -t ${APPDIR}/migrations ${SRCDIR}/migrations/*.ini ${SRCDIR}/migrations/README + ${installbin} -m0755 -t ${APPDIR}/migrations ${SRCDIR}/migrations/*.py* + ${installbin} -m0644 -t ${APPDIR}/migrations/versions ${SRCDIR}/migrations/versions/*py ifeq ($(with_apache),YES) ${installbin} -m0755 -d ${APACHEDIR} ${installbin} -m0644 ${SRCDIR}/config/${APPNAME}.conf.apache ${APACHEDIR}/${APPNAME}.conf @@ -98,19 +111,27 @@ ifeq ($(with_systemd),YES) ${installbin} -m0755 -d ${SYSDDIR} ${installbin} -m0644 ${SRCDIR}/config/0x0.service -t ${SYSDDIR} endif +ifeq ($(with_cronjob),YES) + ${installbin} -m0755 -d ${CRONDIR} + ${installbin} -m0644 -t ${CRONDIR} ${SRCDIR}/config/80_${APPNAME}_cron +endif uninstall: @${echobin} SRCDIR=${SRCDIR} - ${rmbin} -f ${APPDIR}/${APPNAME}.conf ${APPDIR}/${APPNAME}.py ${APPDIR}/${APPNAME}.wsgi \ - ${APPDIR}/front.html.in ${DOCDIR}/* ${DEFAULTDIR}/${APPNAME} || : + ${rmbin} -f ${APPDIR}/${APPNAME}.conf ${APPDIR}/${APPNAME_}.py ${APPDIR}/${APPNAME}.wsgi \ + ${APPDIR}/check-for-short_url.sh \ + ${APPDIR}/front.html.in ${DOCDIR}/* ${DEFAULTDIR}/${APPNAME} \ + ${APPDIR}/migrations/versions/* ${APPDIR}/migrations/* \ + 1>/dev/null 2>&1 || : ${rmbin} -f ${APACHEDIR}/${APPNAME}.conf || : ${rmbin} -f ${APPDIR}/nsfw_model/* ${APPDIR}/nsfw_detect.py || : ${rmbin} -f ${SYSVDIR}/${APPNAME} || : ${rmbin} -f ${SYSDDIR}/0x0.service || : + ${rmbin} -f ${CRONDIR}/80_${APPNAME}_cron || : # remove all installed directories that are now blank. ${rmdirbin} ${APPDIR}/up ${DEFAULTDIR} ${SYSVDIR} ${APPDIR} \ ${APACHEDIR} ${SYSDDIR} ${DOCDIR} ${LOGDIR} 2>/dev/null || : clean: - @${echobin} "target $@ not implemented yet! Gotta say unh." && ${falsebin} + -@${echobin} "target $@ not implemented yet! Gotta say unh." && ${falsebin} diff --git a/config/hex-zero.conf.example b/config/hex-zero.conf.example index 71d93e3..3b62410 100644 --- a/config/hex-zero.conf.example +++ b/config/hex-zero.conf.example @@ -1,5 +1,5 @@ # vim: syntax=python -FHOST_STORAGE_PATH = "/var/www/0x0/up" +FHOST_STORAGE_PATH = "/var/www/hex-zero/up" FHOST_USE_X_ACCEL_REDIRECT = False # use True for nginx USE_X_SENDFILE = False # supposed to use True when using anything other than nginx, but True fails in my apache2 setup MAX_CONTENT_LENGTH = 512 * 1024 * 1024 @@ -26,7 +26,7 @@ FHOST_MIME_BLACKLIST = [ ] # template for front page of app -FHOST_FRONTPAGE = "/var/www/0x0/front.html.in" +FHOST_FRONTPAGE = "/var/www/hex-zero/front.html.in" ADMIN_EMAIL = "root@d2-03a" # with this, as well as use this for printing the base url of the app diff --git a/config/hex-zero.etc.default b/config/hex-zero.etc.default index c8d8da7..b0ad710 100644 --- a/config/hex-zero.etc.default +++ b/config/hex-zero.etc.default @@ -2,6 +2,6 @@ export UWSGI_USER=hex-zero export UWSGI_BIN=/usr/bin/uwsgi_python3 export LISTEN_HOST=localhost export LISTEN_PORT=3031 -export PIDFILE=/run/hex-zero.pid +export PIDFILE=/var/run/hex-zero.pid export LOGFILE=/var/log/hex-zero/hex-zero.log -export UWSGI_OPTS="--http-socket ${LISTEN_HOST}:${LISTEN_PORT} --wsgi-file /var/www/0x0/hex-zero.py --callable app --log-x-forwarded-for --logto ${LOGFILE} --touch-reload /var/www/0x0/hex-zero.py --touch-reload /var/www/0x0/hex-zero.conf --pidfile ${PIDFILE}" +export UWSGI_OPTS="--http-socket ${LISTEN_HOST}:${LISTEN_PORT} --wsgi-file /var/www/hex-zero/hex_zero.py --callable app --log-x-forwarded-for --logto ${LOGFILE} --touch-reload /var/www/hex-zero/hex_zero.py --touch-reload /var/www/hex-zero/hex-zero.conf --pidfile ${PIDFILE} --uid ${UWSGI_USER}" diff --git a/config/hex-zero.init b/config/hex-zero.init index 46bb29c..6717ada 100755 --- a/config/hex-zero.init +++ b/config/hex-zero.init @@ -17,7 +17,7 @@ PATH=/sbin:/usr/sbin:/bin:/usr/bin DESC="hex-zero" NAME=hex-zero -DAEMON=/var/www/0x0/hex-zero.wsgi +DAEMON=/var/www/hex-zero/hex-zero.wsgi DAEMON_ARGS="" PIDFILE=/var/run/$NAME.pid SCRIPTNAME=/etc/init.d/$NAME @@ -54,8 +54,8 @@ do_start() #su $USER -c "$DAEMON" & # The above code will not work for interpreted scripts, use the next # six lines below instead (Ref: #643337, start-stop-daemon(8) ) - test -r /var/www/0x0/check-for-short_url.sh && { - /bin/sh /var/www/0x0/check-for-short_url.sh || { + test -r /var/www/hex-zero/check-for-short_url.sh && { + /bin/sh /var/www/hex-zero/check-for-short_url.sh || { # the init script is somehow prevent all displayed output even when directly outputing it to /dev/pts/3 echo "Please run something similar to the following, before running hex-zero:" echo "sudo su ${USER} -c 'pip3 --user install short_url'" diff --git a/debian/README.Debian b/debian/README.Debian new file mode 100644 index 0000000..3babcfe --- /dev/null +++ b/debian/README.Debian @@ -0,0 +1,5 @@ +hex-zero for Devuan + +0x0 file upload and hosting service in Flask. + + -- B. Stack <bgstack15@gmail.com> Thu, 10 Dec 2020 08:10:02 -0500 diff --git a/debian/changelog b/debian/changelog new file mode 100644 index 0000000..aeec6c0 --- /dev/null +++ b/debian/changelog @@ -0,0 +1,5 @@ +hex-zero (0.0.1-1) obs; urgency=low + + * Initial release. Closes: packages-want#000 + + -- B. Stack <bgstack15@gmail.com> Thu, 10 Dec 2020 08:10:02 -0500 diff --git a/debian/clean b/debian/clean new file mode 100644 index 0000000..4a97dfa --- /dev/null +++ b/debian/clean @@ -0,0 +1 @@ +# You must remove unused comment lines for the released package. diff --git a/debian/control b/debian/control new file mode 100644 index 0000000..2e46114 --- /dev/null +++ b/debian/control @@ -0,0 +1,40 @@ +Source: hex-zero +Section: web +Priority: optional +Maintainer: B. Stack <bgstack15@gmail.com> +Build-Depends: debhelper-compat (= 12) +Standards-Version: 4.5.0 +Homepage: https://gitlab.com/bgstack15/hex-zero + +Package: hex-zero +Architecture: all +Multi-Arch: foreign +Pre-Depends: adduser +Depends: apache2, + lsb-base, + python3-alembic, + python3-click, + python3-decorator, + python3-editor, + python3-flask, + python3-flask-migrate, + python3-flask-script, + python3-flask-sqlalchemy, + python3-humanize, + python3-itsdangerous, + python3-jinja2, + python3-magic, + python3-mako, + python3-markupsafe, + python3-requests, + python3-six, + python3-validators, + python3-werkzeug, + python3:any, + uwsgi-core, + uwsgi-plugin-python3, + ${misc:Depends}, + ${shlibs:Depends} +Description: 0x0 file uploading and hosting service + Using Flask, wsgi, and a http reverse proxy, hex-zero + is a small file hosting and uploading service. diff --git a/debian/copyright b/debian/copyright new file mode 100644 index 0000000..343411d --- /dev/null +++ b/debian/copyright @@ -0,0 +1,366 @@ +Format: https://www.debian.org/doc/packaging-manuals/copyright-format/1.0/ +Upstream-Name: hex-zero +Upstream-Contact: B. Stack <bgstack15@gmail.com> +Source: https://gitlab.com/bgstack15/hex-zero +# +# Please double check copyright with the licensecheck(1) command. + +Files: .gitignore + README.debian + check-for-short_url.sh + config/Makefile + config/hex-zero.conf.apache + config/hex-zero.conf.example + config/hex-zero.etc.default + hex-zero.wsgi +Copyright: B. Stack <bgstack15@gmail.com> +License: CC-BY-SA 4.0 + +Files: cleanup.py + hex_zero.py + nsfw_detect.py + README.rst + config/0x0.service + config/cleanup_0x0 + config/nginx.conf + migrations/README + migrations/alembic.ini + migrations/env.py + migrations/script.py.mako + migrations/versions/0cd36ecdd937_.py + migrations/versions/7e246705da6a_.py + nsfw_model/deploy.prototxt + requirements.txt +Copyright: 2020 Mia Herkt +License: EUPL 1.2 + Licensed under the EUPL, Version 1.2 or - as soon as approved + by the European Commission - subsequent versions of the EUPL + (the "License"); + You may not use this work except in compliance with the License. + You may obtain a copy of the license at: + . + https://joinup.ec.europa.eu/software/page/eupl + . + Unless required by applicable law or agreed to in writing, + software distributed under the License is distributed on an + "AS IS" basis, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, + either express or implied. + See the License for the specific language governing permissions + and limitations under the License. + +Files: config/hex-zero.init +Copyright: B. Stack <bgstack15@gmail.com> +License: CC-BY-SA 4.0 + +Files: nsfw_model/LICENSE.md +Copyright: 2016 Yahoo Inc. +License: BSD-2-Clause + Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: + . + 1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. + . + 2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. + . + THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +#---------------------------------------------------------------------------- +# xml and html files (skipped): +# front.html.in + +#---------------------------------------------------------------------------- +# huge files (skipped): +# nsfw_model/resnet_50_1by2_nsfw.caffemodel + +#---------------------------------------------------------------------------- +# Files marked as NO_LICENSE_TEXT_FOUND may be covered by the following +# license/copyright files. + +#---------------------------------------------------------------------------- +# License file: LICENSE + EUROPEAN UNION PUBLIC LICENCE v. 1.2 + EUPL © the European Union 2007, 2016 + . + This European Union Public Licence (the ‘EUPL’) applies to the Work (as defined + below) which is provided under the terms of this Licence. Any use of the Work, + other than as authorised under this Licence is prohibited (to the extent such + use is covered by a right of the copyright holder of the Work). + . + The Work is provided under the terms of this Licence when the Licensor (as + defined below) has placed the following notice immediately following the + copyright notice for the Work: + . + Licensed under the EUPL + . + or has expressed by any other means his willingness to license under the EUPL. + . + 1. Definitions + . + In this Licence, the following terms have the following meaning: + . + - ‘The Licence’: this Licence. + . + - ‘The Original Work’: the work or software distributed or communicated by the + Licensor under this Licence, available as Source Code and also as Executable + Code as the case may be. + . + - ‘Derivative Works’: the works or software that could be created by the + Licensee, based upon the Original Work or modifications thereof. This Licence + does not define the extent of modification or dependence on the Original Work + required in order to classify a work as a Derivative Work; this extent is + determined by copyright law applicable in the country mentioned in Article 15. + . + - ‘The Work’: the Original Work or its Derivative Works. + . + - ‘The Source Code’: the human-readable form of the Work which is the most + convenient for people to study and modify. + . + - ‘The Executable Code’: any code which has generally been compiled and which is + meant to be interpreted by a computer as a program. + . + - ‘The Licensor’: the natural or legal person that distributes or communicates + the Work under the Licence. + . + - ‘Contributor(s)’: any natural or legal person who modifies the Work under the + Licence, or otherwise contributes to the creation of a Derivative Work. + . + - ‘The Licensee’ or ‘You’: any natural or legal person who makes any usage of + the Work under the terms of the Licence. + . + - ‘Distribution’ or ‘Communication’: any act of selling, giving, lending, + renting, distributing, communicating, transmitting, or otherwise making + available, online or offline, copies of the Work or providing access to its + essential functionalities at the disposal of any other natural or legal + person. + . + 2. Scope of the rights granted by the Licence + . + The Licensor hereby grants You a worldwide, royalty-free, non-exclusive, + sublicensable licence to do the following, for the duration of copyright vested + in the Original Work: + . + - use the Work in any circumstance and for all usage, + - reproduce the Work, + - modify the Work, and make Derivative Works based upon the Work, + - communicate to the public, including the right to make available or display + the Work or copies thereof to the public and perform publicly, as the case may + be, the Work, + - distribute the Work or copies thereof, + - lend and rent the Work or copies thereof, + - sublicense rights in the Work or copies thereof. + . + Those rights can be exercised on any media, supports and formats, whether now + known or later invented, as far as the applicable law permits so. + . + In the countries where moral rights apply, the Licensor waives his right to + exercise his moral right to the extent allowed by law in order to make effective + the licence of the economic rights here above listed. + . + The Licensor grants to the Licensee royalty-free, non-exclusive usage rights to + any patents held by the Licensor, to the extent necessary to make use of the + rights granted on the Work under this Licence. + . + 3. Communication of the Source Code + . + The Licensor may provide the Work either in its Source Code form, or as + Executable Code. If the Work is provided as Executable Code, the Licensor + provides in addition a machine-readable copy of the Source Code of the Work + along with each copy of the Work that the Licensor distributes or indicates, in + a notice following the copyright notice attached to the Work, a repository where + the Source Code is easily and freely accessible for as long as the Licensor + continues to distribute or communicate the Work. + . + 4. Limitations on copyright + . + Nothing in this Licence is intended to deprive the Licensee of the benefits from + any exception or limitation to the exclusive rights of the rights owners in the + Work, of the exhaustion of those rights or of other applicable limitations + thereto. + . + 5. Obligations of the Licensee + . + The grant of the rights mentioned above is subject to some restrictions and + obligations imposed on the Licensee. Those obligations are the following: + . + Attribution right: The Licensee shall keep intact all copyright, patent or + trademarks notices and all notices that refer to the Licence and to the + disclaimer of warranties. The Licensee must include a copy of such notices and a + copy of the Licence with every copy of the Work he/she distributes or + communicates. The Licensee must cause any Derivative Work to carry prominent + notices stating that the Work has been modified and the date of modification. + . + Copyleft clause: If the Licensee distributes or communicates copies of the + Original Works or Derivative Works, this Distribution or Communication will be + done under the terms of this Licence or of a later version of this Licence + unless the Original Work is expressly distributed only under this version of the + Licence — for example by communicating ‘EUPL v. 1.2 only’. The Licensee + (becoming Licensor) cannot offer or impose any additional terms or conditions on + the Work or Derivative Work that alter or restrict the terms of the Licence. + . + Compatibility clause: If the Licensee Distributes or Communicates Derivative + Works or copies thereof based upon both the Work and another work licensed under + a Compatible Licence, this Distribution or Communication can be done under the + terms of this Compatible Licence. For the sake of this clause, ‘Compatible + Licence’ refers to the licences listed in the appendix attached to this Licence. + Should the Licensee's obligations under the Compatible Licence conflict with + his/her obligations under this Licence, the obligations of the Compatible + Licence shall prevail. + . + Provision of Source Code: When distributing or communicating copies of the Work, + the Licensee will provide a machine-readable copy of the Source Code or indicate + a repository where this Source will be easily and freely available for as long + as the Licensee continues to distribute or communicate the Work. + . + Legal Protection: This Licence does not grant permission to use the trade names, + trademarks, service marks, or names of the Licensor, except as required for + reasonable and customary use in describing the origin of the Work and + reproducing the content of the copyright notice. + . + 6. Chain of Authorship + . + The original Licensor warrants that the copyright in the Original Work granted + hereunder is owned by him/her or licensed to him/her and that he/she has the + power and authority to grant the Licence. + . + Each Contributor warrants that the copyright in the modifications he/she brings + to the Work are owned by him/her or licensed to him/her and that he/she has the + power and authority to grant the Licence. + . + Each time You accept the Licence, the original Licensor and subsequent + Contributors grant You a licence to their contributions to the Work, under the + terms of this Licence. + . + 7. Disclaimer of Warranty + . + The Work is a work in progress, which is continuously improved by numerous + Contributors. It is not a finished work and may therefore contain defects or + ‘bugs’ inherent to this type of development. + . + For the above reason, the Work is provided under the Licence on an ‘as is’ basis + and without warranties of any kind concerning the Work, including without + limitation merchantability, fitness for a particular purpose, absence of defects + or errors, accuracy, non-infringement of intellectual property rights other than + copyright as stated in Article 6 of this Licence. + . + This disclaimer of warranty is an essential part of the Licence and a condition + for the grant of any rights to the Work. + . + 8. Disclaimer of Liability + . + Except in the cases of wilful misconduct or damages directly caused to natural + persons, the Licensor will in no event be liable for any direct or indirect, + material or moral, damages of any kind, arising out of the Licence or of the use + of the Work, including without limitation, damages for loss of goodwill, work + stoppage, computer failure or malfunction, loss of data or any commercial + damage, even if the Licensor has been advised of the possibility of such damage. + However, the Licensor will be liable under statutory product liability laws as + far such laws apply to the Work. + . + 9. Additional agreements + . + While distributing the Work, You may choose to conclude an additional agreement, + defining obligations or services consistent with this Licence. However, if + accepting obligations, You may act only on your own behalf and on your sole + responsibility, not on behalf of the original Licensor or any other Contributor, + and only if You agree to indemnify, defend, and hold each Contributor harmless + for any liability incurred by, or claims asserted against such Contributor by + the fact You have accepted any warranty or additional liability. + . + 10. Acceptance of the Licence + . + The provisions of this Licence can be accepted by clicking on an icon ‘I agree’ + placed under the bottom of a window displaying the text of this Licence or by + affirming consent in any other similar way, in accordance with the rules of + applicable law. Clicking on that icon indicates your clear and irrevocable + acceptance of this Licence and all of its terms and conditions. + . + Similarly, you irrevocably accept this Licence and all of its terms and + conditions by exercising any rights granted to You by Article 2 of this Licence, + such as the use of the Work, the creation by You of a Derivative Work or the + Distribution or Communication by You of the Work or copies thereof. + . + 11. Information to the public + . + In case of any Distribution or Communication of the Work by means of electronic + communication by You (for example, by offering to download the Work from a + remote location) the distribution channel or media (for example, a website) must + at least provide to the public the information requested by the applicable law + regarding the Licensor, the Licence and the way it may be accessible, concluded, + stored and reproduced by the Licensee. + . + 12. Termination of the Licence + . + The Licence and the rights granted hereunder will terminate automatically upon + any breach by the Licensee of the terms of the Licence. + . + Such a termination will not terminate the licences of any person who has + received the Work from the Licensee under the Licence, provided such persons + remain in full compliance with the Licence. + . + 13. Miscellaneous + . + Without prejudice of Article 9 above, the Licence represents the complete + agreement between the Parties as to the Work. + . + If any provision of the Licence is invalid or unenforceable under applicable + law, this will not affect the validity or enforceability of the Licence as a + whole. Such provision will be construed or reformed so as necessary to make it + valid and enforceable. + . + The European Commission may publish other linguistic versions or new versions of + this Licence or updated versions of the Appendix, so far this is required and + reasonable, without reducing the scope of the rights granted by the Licence. New + versions of the Licence will be published with a unique version number. + . + All linguistic versions of this Licence, approved by the European Commission, + have identical value. Parties can take advantage of the linguistic version of + their choice. + . + 14. Jurisdiction + . + Without prejudice to specific agreement between parties, + . + - any litigation resulting from the interpretation of this License, arising + between the European Union institutions, bodies, offices or agencies, as a + Licensor, and any Licensee, will be subject to the jurisdiction of the Court + of Justice of the European Union, as laid down in article 272 of the Treaty on + the Functioning of the European Union, + . + - any litigation arising between other parties and resulting from the + interpretation of this License, will be subject to the exclusive jurisdiction + of the competent court where the Licensor resides or conducts its primary + business. + . + 15. Applicable Law + . + Without prejudice to specific agreement between parties, + . + - this Licence shall be governed by the law of the European Union Member State + where the Licensor has his seat, resides or has his registered office, + . + - this licence shall be governed by Belgian law if the Licensor has no seat, + residence or registered office inside a European Union Member State. + . + Appendix + . + ‘Compatible Licences’ according to Article 5 EUPL are: + . + - GNU General Public License (GPL) v. 2, v. 3 + - GNU Affero General Public License (AGPL) v. 3 + - Open Software License (OSL) v. 2.1, v. 3.0 + - Eclipse Public License (EPL) v. 1.0 + - CeCILL v. 2.0, v. 2.1 + - Mozilla Public Licence (MPL) v. 2 + - GNU Lesser General Public Licence (LGPL) v. 2.1, v. 3 + - Creative Commons Attribution-ShareAlike v. 3.0 Unported (CC BY-SA 3.0) for + works other than software + - European Union Public Licence (EUPL) v. 1.1, v. 1.2 + - Québec Free and Open-Source Licence — Reciprocity (LiLiQ-R) or Strong + Reciprocity (LiLiQ-R+). + . + The European Commission may update this Appendix to later versions of the above + licences without producing a new version of the EUPL, as long as they provide + the rights granted in Article 2 of this Licence and protect the covered Source + Code from exclusive appropriation. + . + All other changes or additions to this Appendix require the production of a new + EUPL version. diff --git a/debian/hex-zero.lintian-overrides b/debian/hex-zero.lintian-overrides new file mode 100644 index 0000000..b886dee --- /dev/null +++ b/debian/hex-zero.lintian-overrides @@ -0,0 +1,7 @@ +initial-upload-closes-no-bugs +dir-or-file-in-var-www +copyright-not-using-common-license-for-lgpl +run-parts-cron-filename-contains-illegal-chars +executable-not-elf-or-script var/www/hex-zero/migrations/env.py +executable-not-elf-or-script var/www/hex-zero/migrations/script.py.mako +uses-dpkg-database-directly prerm diff --git a/debian/install b/debian/install new file mode 100644 index 0000000..4a97dfa --- /dev/null +++ b/debian/install @@ -0,0 +1 @@ +# You must remove unused comment lines for the released package. diff --git a/debian/links b/debian/links new file mode 100644 index 0000000..4a97dfa --- /dev/null +++ b/debian/links @@ -0,0 +1 @@ +# You must remove unused comment lines for the released package. diff --git a/debian/patches/series b/debian/patches/series new file mode 100644 index 0000000..4a97dfa --- /dev/null +++ b/debian/patches/series @@ -0,0 +1 @@ +# You must remove unused comment lines for the released package. diff --git a/debian/postinst b/debian/postinst new file mode 100644 index 0000000..ff6d28f --- /dev/null +++ b/debian/postinst @@ -0,0 +1,42 @@ +#!/bin/sh +# Reference: https://salsa.debian.org/sssd-team/sssd/-/blob/experimental/debian/sssd-common.postinst +set -e + +#DEBHELPER# + +OUT=/dev/null +USERNAME=hex-zero +HOME=/var/www/hex-zero + +case "$1" in + configure) + update-rc.d hex-zero defaults + if ! getent passwd ${USERNAME} 1>${OUT} 2>&1 ; + then + echo "Creating ${USERNAME} system user & group..." + adduser --quiet --system --home $HOME \ + --disabled-password --group \ + --gecos "0x0 system user" \ + ${USERNAME} > ${OUT} + fi + if ! test -r /var/www/hex-zero/db.sqlite || test $( stat -c "%s" /var/www/hex-zero/db.sqlite 2>/dev/null ) -lt 50 ; + then + echo "Initializing sqlite database for hex-zero" + su ${USER} -c 'cd /var/www/hex-zero ; /var/www/hex-zero/hex_zero.py db init' 2>/dev/null || : + su ${USER} -c 'cd /var/www/hex-zero ; /var/www/hex-zero/hex_zero.py db upgrade' + fi + chown ${USERNAME}:${USERNAME} \ + ${HOME} ${HOME}/* \ + /var/log/hex-zero /var/log/hex-zero/*log 1>/${OUT} 2>&1 || : + ;; + + abort-upgrade|abort-remove|abort-deconfigure) + ;; + + *) + echo "postinst called with unknown argument \`$1'" >&2 + exit 1 + ;; +esac + +exit 0 diff --git a/debian/postrm b/debian/postrm new file mode 100644 index 0000000..1d20f2a --- /dev/null +++ b/debian/postrm @@ -0,0 +1,26 @@ +#!/bin/sh +set -e + +#DEBHELPER# +D=/var/www/hex-zero + +case "$1" in + purge) + update-rc.d -f hex-zero remove + rm -f ${D}/db.sqlite \ + ${D}/migrations/__pycache__/* \ + ${D}/migrations/* \ + ${D}/migrations/versions/* 1>/dev/null 2>&1 || : + rmdir ${D}/migrations/__pycache__ ${D}/migrations/versions 1>/dev/null 2>&1 || : + rmdir ${D}/migrations 1>/dev/null 2>&1 || : + ;; + remove|upgrade|failed-upgrade|abort-install|abort-upgrade|disappear) + ;; + + *) + echo "postrm called with unknown argument \`$1'" >&2 + exit 1 + ;; +esac + +exit 0 diff --git a/debian/prerm b/debian/prerm new file mode 100644 index 0000000..09ab27b --- /dev/null +++ b/debian/prerm @@ -0,0 +1,28 @@ +#!/bin/sh +# Reference /home/var/lib/dpkg/info/postfix.prerm +set -e + +case "$1" in + remove) + test -x /usr/sbin/invoke-rc.d && \ + INIT="invoke-rc.d hex-zero" || \ + INIT="/etc/init.d/hex-zero" + ${INIT} stop + rm -f /var/www/hex-zero/.sqlite_history || : + ;; + + upgrade|deconfigure) + ;; + + failed-upgrade) + ;; + + *) + echo "prerm called with unknown argument \`$1'" >&2 + exit 1 + ;; +esac + +#DEBHELPER# + +exit 0 diff --git a/debian/rules b/debian/rules new file mode 100755 index 0000000..6ee96b2 --- /dev/null +++ b/debian/rules @@ -0,0 +1,15 @@ +#!/usr/bin/make -f +# You must remove unused comment lines for the released package. +#export DH_VERBOSE = 1 +#export DEB_BUILD_MAINT_OPTIONS = hardening=+all +#export DEB_CFLAGS_MAINT_APPEND = -Wall -pedantic +#export DEB_LDFLAGS_MAINT_APPEND = -Wl,--as-needed + +%: + dh $@ --sourcedirectory=config + +override_dh_auto_install: + dh_auto_install -- prefix=/usr \ + DEFAULTDIR='$$(DESTDIR)/etc/default' \ + APACHEDIR='$$(SYSCONFDIR)/apache2/sites-available' + #APPDIR='$$(SHAREDIR)/$$(APPNAME)' diff --git a/debian/source/format b/debian/source/format new file mode 100644 index 0000000..163aaf8 --- /dev/null +++ b/debian/source/format @@ -0,0 +1 @@ +3.0 (quilt) diff --git a/debian/source/lintian-overrides b/debian/source/lintian-overrides new file mode 100644 index 0000000..24463f4 --- /dev/null +++ b/debian/source/lintian-overrides @@ -0,0 +1 @@ +syntax-error-in-dep5-copyright diff --git a/debian/source/local-options b/debian/source/local-options new file mode 100644 index 0000000..00131ee --- /dev/null +++ b/debian/source/local-options @@ -0,0 +1,2 @@ +#abort-on-upstream-changes +#unapply-patches diff --git a/debian/watch b/debian/watch new file mode 100644 index 0000000..76575dc --- /dev/null +++ b/debian/watch @@ -0,0 +1,2 @@ +# You must remove unused comment lines for the released package. +version=3 diff --git a/hex-zero.wsgi b/hex-zero.wsgi index c3f7747..65972f6 100755 --- a/hex-zero.wsgi +++ b/hex-zero.wsgi @@ -6,10 +6,10 @@ test -z "${LISTEN_HOST}" && export LISTEN_HOST=localhost test -z "${LISTEN_PORT}" && export LISTEN_PORT=3031 test -z "${PIDFILE}" && export PIDFILE=/var/run/hex-zero.pid test -z "${LOGFILE}" && export LOGFILE=/var/log/hex-zero/hex-zero.log -test -z "${UWSGI_OPTS}" && export UWSGI_OPTS="--http-socket ${LISTEN_HOST}:${LISTEN_PORT} --wsgi-file /var/www/0x0/hex-zero.py --callable app --log-x-forwarded-for --logto ${LOGFILE} --touch-reload /var/www/0x0/hex-zero.py --touch-reload /var/www/0x0/hex-zero.conf --pidfile ${PIDFILE} --uid ${UWSGI_USER}" +test -z "${UWSGI_OPTS}" && export UWSGI_OPTS="--http-socket ${LISTEN_HOST}:${LISTEN_PORT} --wsgi-file /var/www/hex-zero/hex_zero.py --callable app --log-x-forwarded-for --logto ${LOGFILE} --touch-reload /var/www/hex-zero/hex_zero.py --touch-reload /var/www/hex-zero/hex-zero.conf --pidfile ${PIDFILE} --uid ${UWSGI_USER}" # check for short_url -/var/www/0x0/check-for-short_url.sh || exit 1 +/var/www/hex-zero/check-for-short_url.sh || exit 1 test -n "${FORCE_KILL_OLD_UWSGI}" && { ps -o user=,pid=,command:80= -u "${UWSGI_USER}" | awk '/hex-zero\.py/{print $2}' | xargs --no-run-if-empty kill diff --git a/hex-zero.py b/hex_zero.py index 81c8169..81c8169 100755 --- a/hex-zero.py +++ b/hex_zero.py |