Skip to content

Commit

Permalink
Merge pull request #64
Browse files Browse the repository at this point in the history
RELEASE 1.1.12
  • Loading branch information
1thorsten authored Dec 29, 2021
2 parents 96fccbc + 0c7b105 commit d213e16
Show file tree
Hide file tree
Showing 14 changed files with 105 additions and 17 deletions.
2 changes: 1 addition & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ ENV PHP7_SOCK=/var/run/php/php${PHP_VERSION}-fpm.sock
ENV PHP_LOG_SYSOUT=true

# http-over-all part
ARG RELEASE="1.1.11"
ARG RELEASE="1.1.12"

ARG SSL_COUNTRY=DE
ARG SSL_STATE=Berlin
Expand Down
2 changes: 1 addition & 1 deletion incontainer/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -201,7 +201,7 @@ Options for all resources
| PROXY_MAX_SIZE | maximum size of the proxy cache (default: 10g) | - |
| PROXY_INACTIVE | data that are not accessed during the time get removed (default: 1d) | - |
| TINY_INSTANCE | configure for low requirements and low memory consumption (default: false) | - |

| FORCE_UPDATE_LOCK | timeout in seconds for repetitive call (default: 16) | - |
# <a name="special-functions"></a>Special functions
## periodic jobs
ENV: PERIODIC_JOB_INTERVAL
Expand Down
4 changes: 2 additions & 2 deletions incontainer/healthcheck.sh
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#!/usr/bin/env bash

# short name for http-over-all is sds (Software Distribution Server)
if [ ! -f "/tmp/sds.ready" ]; then exit 0; fi
if [ ! -f "/var/run/sds.ready" ]; then exit 0; fi

curl -A "curl/healthcheck" -f http://localhost/ || exit 1
curl -A "curl/healthcheck" -f http://localhost/ || exit 1
8 changes: 8 additions & 0 deletions incontainer/helper.sh
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,14 @@ function initialize() {
echo "sed -i \"s|__CRYPT_KEY__|obfuscated|g\" /scripts/php/include/globals.php"
sed -i "s|__CRYPT_KEY__|${CRYPT_KEY}|g" "/scripts/php/include/globals.php"

# handle timeout for force-update operations (default are 16 seconds)
if [ -z "${FORCE_UPDATE_LOCK##*[!0-9]*}" ]; then
echo FORCE_UPDATE_LOCK="16"
FORCE_UPDATE_LOCK="16"
fi
echo "sed -i \"s|'__FORCE_UPDATE_LOCK__'|${FORCE_UPDATE_LOCK}|g\" /scripts/php/include/globals.php"
sed -i "s|'__FORCE_UPDATE_LOCK__'|${FORCE_UPDATE_LOCK}|g" "/scripts/php/include/globals.php"

echo "adjust davfs2 (/etc/davfs2/davfs2.conf)"
{
echo "ignore_dav_header 1"
Expand Down
6 changes: 4 additions & 2 deletions incontainer/http-over-all.sh
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#!/usr/bin/env bash
SDS_READY="/tmp/sds.ready"
SDS_READY="/var/run/sds.ready"
rm -f ${SDS_READY}

source /scripts/connect-services.sh
Expand Down Expand Up @@ -48,14 +48,16 @@ handle_local_paths

connect_or_update_docker "connect"

echo touch /var/run/force-update.last
touch /var/run/force-update.last

start_http_server

touch ${SDS_READY}

echo
source /etc/os-release
echo "$(date +'%T'): ready -> ${PRETTY_NAME}"

echo "$(date +'%T'): http-over-all -> RELEASE: ${RELEASE}"

trap "term_handler" EXIT
Expand Down
6 changes: 6 additions & 0 deletions incontainer/nginx-config/nginx-default
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,12 @@ server {
return 200 "Don't index this drive!";
}

location /func/nginx_status {
allow 127.0.0.1;
deny all;
stub_status;
}

# return ip address from the requestor
location /func/remote-ip {
default_type text/plain;
Expand Down
6 changes: 4 additions & 2 deletions incontainer/php/force-update.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
<?php

# rm -f /scripts/php/force-update.php ; nano /scripts/php/force-update.php
include_once "globals.php";
include_once "Log.php";
include "common_functions.php";

Expand All @@ -13,12 +14,13 @@
$remote_addr = $_REQUEST['remote_addr'] ?? $_SERVER['REMOTE_ADDR'];

$callForceUpdate = true;
$forcUpdateLock = is_int(FORCE_UPDATE_LOCK) ? FORCE_UPDATE_LOCK : 16;
$cmdOutput = "";
if (file_exists("/var/run/force-update.last")) {
$file_mtime = filemtime("/var/run/force-update.last");
list($usec, $sec) = explode(" ", microtime());
if ($sec - $file_mtime < 16) {
$cmdOutput = "avoid executing force-update.sh (previous call was ".($sec - $file_mtime)." second(s) ago)";
if ($sec - $file_mtime <= $forcUpdateLock) {
$cmdOutput = "avoid executing force-update.sh (previous call was ".($sec - $file_mtime)." second(s) ago; lock_sec: $forcUpdateLock)";
LOG::write("force-update.php", $cmdOutput);
$callForceUpdate = false;
}
Expand Down
1 change: 1 addition & 0 deletions incontainer/php/include/globals.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,5 @@
# docker run --rm php:cli-alpine php -r 'echo "CRYPT_KEY:".base64_encode(openssl_random_pseudo_bytes(32))."\n";'
# php -r "echo base64_encode(openssl_random_pseudo_bytes(32));" ; echo
const KEY = '__CRYPT_KEY__';
const FORCE_UPDATE_LOCK = '__FORCE_UPDATE_LOCK__';

14 changes: 7 additions & 7 deletions tools/doclig/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,12 @@ go 1.17

require (
github.com/docker/distribution v2.7.1+incompatible
github.com/docker/docker v20.10.10+incompatible
github.com/docker/docker v20.10.12+incompatible
)

require (
github.com/Microsoft/go-winio v0.5.1 // indirect
github.com/containerd/containerd v1.5.7 // indirect
github.com/containerd/containerd v1.5.8 // indirect
github.com/docker/go-connections v0.4.0 // indirect
github.com/docker/go-units v0.4.0 // indirect
github.com/gogo/protobuf v1.3.2 // indirect
Expand All @@ -18,13 +18,13 @@ require (
github.com/moby/term v0.0.0-20210619224110-3f7ff695adc6 // indirect
github.com/morikuni/aec v1.0.0 // indirect
github.com/opencontainers/go-digest v1.0.0 // indirect
github.com/opencontainers/image-spec v1.0.1 // indirect
github.com/opencontainers/image-spec v1.0.2 // indirect
github.com/pkg/errors v0.9.1 // indirect
github.com/sirupsen/logrus v1.8.1 // indirect
golang.org/x/net v0.0.0-20211112202133-69e39bad7dc2 // indirect
golang.org/x/sys v0.0.0-20211113001501-0c823b97ae02 // indirect
golang.org/x/net v0.0.0-20211216030914-fe4d6282115f // indirect
golang.org/x/sys v0.0.0-20211216021012-1d35b9e2eb4e // indirect
golang.org/x/time v0.0.0-20210723032227-1f47c861a9ac // indirect
google.golang.org/genproto v0.0.0-20211112145013-271947fe86fd // indirect
google.golang.org/grpc v1.42.0 // indirect
google.golang.org/genproto v0.0.0-20211223182754-3ac035c7e7cb // indirect
google.golang.org/grpc v1.43.0 // indirect
google.golang.org/protobuf v1.27.1 // indirect
)
18 changes: 18 additions & 0 deletions tools/doclig/go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@ github.com/Microsoft/hcsshim v0.8.14/go.mod h1:NtVKoYxQuTLx6gEq0L96c9Ju4JbRJ4nY2
github.com/Microsoft/hcsshim v0.8.15/go.mod h1:x38A4YbHbdxJtc0sF6oIz+RG0npwSCAvn69iY6URG00=
github.com/Microsoft/hcsshim v0.8.16/go.mod h1:o5/SZqmR7x9JNKsW3pu+nqHm0MF8vbA+VxGOoXdC600=
github.com/Microsoft/hcsshim v0.8.21/go.mod h1:+w2gRZ5ReXQhFOrvSQeNfhrYB/dg3oDwTOcER2fw4I4=
github.com/Microsoft/hcsshim v0.8.23/go.mod h1:4zegtUJth7lAvFyc6cH2gGQ5B3OFQim01nnU2M8jKDg=
github.com/Microsoft/hcsshim/test v0.0.0-20201218223536-d3e5debf77da/go.mod h1:5hlzMzRKMLyo42nCZ9oml8AdTlq/0cvIaBv6tK1RehU=
github.com/Microsoft/hcsshim/test v0.0.0-20210227013316-43a75bb4edd3/go.mod h1:mw7qgWloBUl75W/gVH3cQszUg1+gUITj7D6NY7ywVnY=
github.com/NYTimes/gziphandler v0.0.0-20170623195520-56545f4a5d46/go.mod h1:3wb06e3pkSAbeQ52E9H9iFoQsEEwGN64994WTCIhntQ=
Expand Down Expand Up @@ -88,6 +89,7 @@ github.com/buger/jsonparser v0.0.0-20180808090653-f4dd9f5a6b44/go.mod h1:bbYlZJ7
github.com/bugsnag/bugsnag-go v0.0.0-20141110184014-b1d153021fcd/go.mod h1:2oa8nejYd4cQ/b0hMIopN0lCRxU0bueqREvZLWFrtK8=
github.com/bugsnag/osext v0.0.0-20130617224835-0dd3f918b21b/go.mod h1:obH5gd0BsqsP2LwDJ9aOkm/6J86V6lyAXCoQWGw3K50=
github.com/bugsnag/panicwrap v0.0.0-20151223152923-e2c28503fcd0/go.mod h1:D/8v3kj0zr8ZAKg1AQ6crr+5VwKN5eIywRkfhyM/+dE=
github.com/cenkalti/backoff/v4 v4.1.1/go.mod h1:scbssz8iZGpm3xbr14ovlUdkxfGXNInqkPWOWmG2CLw=
github.com/census-instrumentation/opencensus-proto v0.2.1/go.mod h1:f6KPmirojxKA12rnyqOA5BBL4O983OfeGPqjHWSTneU=
github.com/cespare/xxhash v1.1.0/go.mod h1:XrSqR1VqqWfGrhpAt58auRo0WTKS1nRRg3ghfAqPWnc=
github.com/cespare/xxhash/v2 v2.1.1/go.mod h1:VGX0DQ3Q6kWi7AoAeZDth3/j3BFtOZR5XLFGgcrjCOs=
Expand Down Expand Up @@ -137,6 +139,7 @@ github.com/containerd/containerd v1.3.2/go.mod h1:bC6axHOhabU15QhwfG7w5PipXdVtMX
github.com/containerd/containerd v1.4.0-beta.2.0.20200729163537-40b22ef07410/go.mod h1:bC6axHOhabU15QhwfG7w5PipXdVtMXFTttgp+kVtyUA=
github.com/containerd/containerd v1.4.1/go.mod h1:bC6axHOhabU15QhwfG7w5PipXdVtMXFTttgp+kVtyUA=
github.com/containerd/containerd v1.4.3/go.mod h1:bC6axHOhabU15QhwfG7w5PipXdVtMXFTttgp+kVtyUA=
github.com/containerd/containerd v1.4.9/go.mod h1:bC6axHOhabU15QhwfG7w5PipXdVtMXFTttgp+kVtyUA=
github.com/containerd/containerd v1.5.0-beta.1/go.mod h1:5HfvG1V2FsKesEGQ17k5/T7V960Tmcumvqn8Mc+pCYQ=
github.com/containerd/containerd v1.5.0-beta.3/go.mod h1:/wr9AVtEM7x9c+n0+stptlo/uBBoBORwEx6ardVcmKU=
github.com/containerd/containerd v1.5.0-beta.4/go.mod h1:GmdgZd2zA2GYIBZ0w09ZvgqEq8EfBp/m3lcVZIvPHhI=
Expand All @@ -146,6 +149,8 @@ github.com/containerd/containerd v1.5.6 h1:yi692sMr9kyyaps9dyodk3vVOTNM9fIPvlZp4
github.com/containerd/containerd v1.5.6/go.mod h1:gyvv6+ugqY25TiXxcZC3L5yOeYgEw0QMhscqVp1AR9c=
github.com/containerd/containerd v1.5.7 h1:rQyoYtj4KddB3bxG6SAqd4+08gePNyJjRqvOIfV3rkM=
github.com/containerd/containerd v1.5.7/go.mod h1:gyvv6+ugqY25TiXxcZC3L5yOeYgEw0QMhscqVp1AR9c=
github.com/containerd/containerd v1.5.8 h1:NmkCC1/QxyZFBny8JogwLpOy2f+VEbO/f6bV2Mqtwuw=
github.com/containerd/containerd v1.5.8/go.mod h1:YdFSv5bTFLpG2HIYmfqDpSYYTDX+mc5qtSuYx1YUb/s=
github.com/containerd/continuity v0.0.0-20190426062206-aaeac12a7ffc/go.mod h1:GL3xCUCBDV3CZiTSEKksMWbLE66hEyuu9qyDOOqM47Y=
github.com/containerd/continuity v0.0.0-20190815185530-f2a389ac0a02/go.mod h1:GL3xCUCBDV3CZiTSEKksMWbLE66hEyuu9qyDOOqM47Y=
github.com/containerd/continuity v0.0.0-20191127005431-f65d91d395eb/go.mod h1:GL3xCUCBDV3CZiTSEKksMWbLE66hEyuu9qyDOOqM47Y=
Expand Down Expand Up @@ -178,6 +183,7 @@ github.com/containerd/ttrpc v0.0.0-20190828172938-92c8520ef9f8/go.mod h1:PvCDdDG
github.com/containerd/ttrpc v0.0.0-20191028202541-4f1b8fe65a5c/go.mod h1:LPm1u0xBw8r8NOKoOdNMeVHSawSsltak+Ihv+etqsE8=
github.com/containerd/ttrpc v1.0.1/go.mod h1:UAxOpgT9ziI0gJrmKvgcZivgxOp8iFPSk8httJEt98Y=
github.com/containerd/ttrpc v1.0.2/go.mod h1:UAxOpgT9ziI0gJrmKvgcZivgxOp8iFPSk8httJEt98Y=
github.com/containerd/ttrpc v1.1.0/go.mod h1:XX4ZTnoOId4HklF4edwc4DcqskFZuvXB1Evzy5KFQpQ=
github.com/containerd/typeurl v0.0.0-20180627222232-a93fcdb778cd/go.mod h1:Cm3kwCdlkCfMSHURc+r6fwoGH6/F1hH3S4sg0rLFWPc=
github.com/containerd/typeurl v0.0.0-20190911142611-5eb25027c9fd/go.mod h1:GeKYzf2pQcqv7tJ0AoCuuhtnqhva5LNU3U+OyKxxJpk=
github.com/containerd/typeurl v1.0.1/go.mod h1:TB1hUtrpaiO88KEK56ijojHS1+NeF0izUACaJW2mdXg=
Expand Down Expand Up @@ -235,6 +241,8 @@ github.com/docker/docker v20.10.8+incompatible h1:RVqD337BgQicVCzYrrlhLDWhq6OAD2
github.com/docker/docker v20.10.8+incompatible/go.mod h1:eEKB0N0r5NX/I1kEveEz05bcu8tLC/8azJZsviup8Sk=
github.com/docker/docker v20.10.10+incompatible h1:GKkP0T7U4ks6X3lmmHKC2QDprnpRJor2Z5a8m62R9ZM=
github.com/docker/docker v20.10.10+incompatible/go.mod h1:eEKB0N0r5NX/I1kEveEz05bcu8tLC/8azJZsviup8Sk=
github.com/docker/docker v20.10.12+incompatible h1:CEeNmFM0QZIsJCZKMkZx0ZcahTiewkrgiwfYD+dfl1U=
github.com/docker/docker v20.10.12+incompatible/go.mod h1:eEKB0N0r5NX/I1kEveEz05bcu8tLC/8azJZsviup8Sk=
github.com/docker/go-connections v0.4.0 h1:El9xVISelRB7BuFusrZozjnkIM5YnzCViNKohAFqRJQ=
github.com/docker/go-connections v0.4.0/go.mod h1:Gbd7IOopHjR8Iph03tsViu4nIes5XhDvyHbTtUxmeec=
github.com/docker/go-events v0.0.0-20170721190031-9461782956ad/go.mod h1:Uw6UezgYA44ePAFQYUehOuCzmy5zmg/+nl2ZfMWGkpA=
Expand Down Expand Up @@ -473,6 +481,8 @@ github.com/opencontainers/go-digest v1.0.0/go.mod h1:0JzlMkj0TRzQZfJkVvzbP0HBR3I
github.com/opencontainers/image-spec v1.0.0/go.mod h1:BtxoFyWECRxE4U/7sNtV5W15zMzWCbyJoFRP3s7yZA0=
github.com/opencontainers/image-spec v1.0.1 h1:JMemWkRwHx4Zj+fVxWoMCFm/8sYGGrUVojFA6h/TRcI=
github.com/opencontainers/image-spec v1.0.1/go.mod h1:BtxoFyWECRxE4U/7sNtV5W15zMzWCbyJoFRP3s7yZA0=
github.com/opencontainers/image-spec v1.0.2 h1:9yCKha/T5XdGtO0q9Q9a6T5NUCsTn/DrBg0D7ufOcFM=
github.com/opencontainers/image-spec v1.0.2/go.mod h1:BtxoFyWECRxE4U/7sNtV5W15zMzWCbyJoFRP3s7yZA0=
github.com/opencontainers/runc v0.0.0-20190115041553-12f6a991201f/go.mod h1:qT5XzbpPznkRYVz/mWwUaVBUv2rmF59PVA73FjuZG0U=
github.com/opencontainers/runc v0.1.1/go.mod h1:qT5XzbpPznkRYVz/mWwUaVBUv2rmF59PVA73FjuZG0U=
github.com/opencontainers/runc v1.0.0-rc8.0.20190926000215-3e425f80a8c9/go.mod h1:qT5XzbpPznkRYVz/mWwUaVBUv2rmF59PVA73FjuZG0U=
Expand Down Expand Up @@ -701,6 +711,8 @@ golang.org/x/net v0.0.0-20210226172049-e18ecbb05110/go.mod h1:m0MpNAwzfU5UDzcl9v
golang.org/x/net v0.0.0-20210405180319-a5a99cb37ef4/go.mod h1:p54w0d4576C0XHj96bSt6lcn1PtDYWL6XObtHCRCNQM=
golang.org/x/net v0.0.0-20211112202133-69e39bad7dc2 h1:CIJ76btIcR3eFI5EgSo6k1qKw9KJexJuRLI9G7Hp5wE=
golang.org/x/net v0.0.0-20211112202133-69e39bad7dc2/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y=
golang.org/x/net v0.0.0-20211216030914-fe4d6282115f h1:hEYJvxw1lSnWIl8X9ofsYMklzaDs90JI2az5YMd4fPM=
golang.org/x/net v0.0.0-20211216030914-fe4d6282115f/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y=
golang.org/x/oauth2 v0.0.0-20180821212333-d2e6202438be/go.mod h1:N/0e6XlmueqKjAGxoOufVs8QHGRruUQn6yWY3a++T0U=
golang.org/x/oauth2 v0.0.0-20190226205417-e64efc72b421/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw=
golang.org/x/oauth2 v0.0.0-20190604053449-0f29369cfe45/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw=
Expand Down Expand Up @@ -781,6 +793,8 @@ golang.org/x/sys v0.0.0-20210616094352-59db8d763f22 h1:RqytpXGR1iVNX7psjB3ff8y7s
golang.org/x/sys v0.0.0-20210616094352-59db8d763f22/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.0.0-20211113001501-0c823b97ae02 h1:7NCfEGl0sfUojmX78nK9pBJuUlSZWEJA/TwASvfiPLo=
golang.org/x/sys v0.0.0-20211113001501-0c823b97ae02/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.0.0-20211216021012-1d35b9e2eb4e h1:fLOSk5Q00efkSvAm+4xcoXD+RRmLmmulPn5I3Y9F2EM=
golang.org/x/sys v0.0.0-20211216021012-1d35b9e2eb4e/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo=
golang.org/x/text v0.0.0-20170915032832-14c0d48ead0c/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
Expand Down Expand Up @@ -882,6 +896,8 @@ google.golang.org/genproto v0.0.0-20201110150050-8816d57aaa9a h1:pOwg4OoaRYScjmR
google.golang.org/genproto v0.0.0-20201110150050-8816d57aaa9a/go.mod h1:FWY/as6DDZQgahTzZj3fqbO1CbirC29ZNUFHwi0/+no=
google.golang.org/genproto v0.0.0-20211112145013-271947fe86fd h1:8jqRgiTTWyKMDOM2AvhjA5dZLBSKXg1yFupPRBV/4fQ=
google.golang.org/genproto v0.0.0-20211112145013-271947fe86fd/go.mod h1:5CzLGKJ67TSI2B9POpiiyGha0AjJvZIUgRMt1dSmuhc=
google.golang.org/genproto v0.0.0-20211223182754-3ac035c7e7cb h1:ZrsicilzPCS/Xr8qtBZZLpy4P9TYXAfl49ctG1/5tgw=
google.golang.org/genproto v0.0.0-20211223182754-3ac035c7e7cb/go.mod h1:5CzLGKJ67TSI2B9POpiiyGha0AjJvZIUgRMt1dSmuhc=
google.golang.org/grpc v0.0.0-20160317175043-d3ddb4469d5a/go.mod h1:yo6s7OP7yaDglbqo1J04qKzAhqBH6lvTonzMVmEdcZw=
google.golang.org/grpc v1.19.0/go.mod h1:mqu4LbDTu4XGKhr4mRzUsmM4RtVoemTSY81AxZiDr8c=
google.golang.org/grpc v1.20.1/go.mod h1:10oTOabMzJvdu6/UiuZezV6QK5dSlG84ov/aaiqXj38=
Expand All @@ -903,6 +919,8 @@ google.golang.org/grpc v1.41.0 h1:f+PlOh7QV4iIJkPrx5NQ7qaNGFQ3OTse67yaDHfju4E=
google.golang.org/grpc v1.41.0/go.mod h1:U3l9uK9J0sini8mHphKoXyaqDA/8VyGnDee1zzIUK6k=
google.golang.org/grpc v1.42.0 h1:XT2/MFpuPFsEX2fWh3YQtHkZ+WYZFQRfaUgLZYj/p6A=
google.golang.org/grpc v1.42.0/go.mod h1:k+4IHHFw41K8+bbowsex27ge2rCb65oeWqe4jJ590SU=
google.golang.org/grpc v1.43.0 h1:Eeu7bZtDZ2DpRCsLhUlcrLnvYaMK1Gz86a+hMVvELmM=
google.golang.org/grpc v1.43.0/go.mod h1:k+4IHHFw41K8+bbowsex27ge2rCb65oeWqe4jJ590SU=
google.golang.org/protobuf v0.0.0-20200109180630-ec00e32a8dfd/go.mod h1:DFci5gLYBciE7Vtevhsrf46CRTquxDuWsQurQQe4oz8=
google.golang.org/protobuf v0.0.0-20200221191635-4d8936d0db64/go.mod h1:kwYJMbMJ01Woi6D6+Kah6886xMZcty6N08ah7+eCXa0=
google.golang.org/protobuf v0.0.0-20200228230310-ab0ca4ff8a60/go.mod h1:cfTl7dwQJ+fmap5saPgwCLgHXTUD7jkjRqWcaiX5VyM=
Expand Down
2 changes: 1 addition & 1 deletion tools/doclig/src/VERSION.txt
Original file line number Diff line number Diff line change
@@ -1 +1 @@
1.0.0
1.0.1
47 changes: 47 additions & 0 deletions tools/doclig/src/action/ServeAction.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
package action

import (
"log"
"net/http"
"os/exec"
"time"
)

func runCommand() ([]byte, error) {
out, err := exec.Command("/bin/sh", "-c", "sudo /scripts/force-update.sh").CombinedOutput()

if err != nil {
log.Printf("cmd.Run() failed with %s\n", err)
return nil, err
}

return out, nil
}

func funcForceUpdate(w http.ResponseWriter, r *http.Request) {
start := time.Now()

output, err := runCommand()
if err != nil {
w.WriteHeader(http.StatusInternalServerError)
_, _ = w.Write([]byte("500 - Could run /force-update -> " + err.Error()))
return
}

w.Write(output)
log.Printf("- %v - %v (%s)\n", r.RemoteAddr, r.RequestURI, time.Since(start))
}

func Serve(addr *string) {
http.HandleFunc("/force-update", funcForceUpdate)
http.HandleFunc("/force-update/", funcForceUpdate)

fs := http.FileServer(http.Dir("/var/www/html"))
http.Handle("/", fs)

log.Printf("Listening on %s...", *addr)
err := http.ListenAndServe(*addr, nil)
if err != nil {
log.Fatal(err)
}
}
4 changes: 3 additions & 1 deletion tools/doclig/src/args.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,17 +10,19 @@ type Args struct {
Image *string
User *string
Password *string
ListenAddr *string
SourcePaths []string
DestinationPath *string
}

func HandleArgs() *Args {
var args Args

args.Action = flag.String("action", "", "check-image, copy, prune, pull")
args.Action = flag.String("action", "", "check-image, copy, prune, pull, serve")
args.Image = flag.String("image", "", "full image name (action: check-image, copy, pull)")
args.User = flag.String("user", "", "username for docker registry (action: pull)")
args.Password = flag.String("password", "", "password for docker registry (action: pull)")
args.ListenAddr = flag.String("listen-addr", ":80", "TCP address for the server to listen on (action: serve)")
var sourceDirs string
flag.StringVar(&sourceDirs, "srcPaths", "", "comma separated source directories (action: copy)")
args.DestinationPath = flag.String("dst", "", "destination dir (action: copy)")
Expand Down
2 changes: 2 additions & 0 deletions tools/doclig/src/doclig.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,5 +24,7 @@ func main() {
action.CheckImage(args.Image)
} else if *args.Action == "prune" {
action.PruneImages()
} else if *args.Action == "serve" {
action.Serve(args.ListenAddr)
}
}

0 comments on commit d213e16

Please sign in to comment.