diff options
Diffstat (limited to 'config')
-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 |
5 files changed, 34 insertions, 11 deletions
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'" |