This commit is contained in:
bel
2021-09-14 06:29:17 -06:00
commit a71c585675
36 changed files with 700 additions and 0 deletions

4
gollum/.dockerignore Normal file
View File

@@ -0,0 +1,4 @@
mnt
**.sw*
**/*.sw*
*.sw*

3
gollum/.gitignore vendored Executable file
View File

@@ -0,0 +1,3 @@
mnt/
*.sw*
goftp

15
gollum/Dockerfile Executable file
View File

@@ -0,0 +1,15 @@
FROM frolvlad/alpine-glibc:alpine-3.9_glibc-2.28
RUN apk update; \
apk add --no-cache ruby dcron bash cmake ruby-dev make icu-dev gcc libc-dev zlib-dev g++ openssl openssl-dev git; \
gem install rdoc || true; \
gem install github-linguist gollum org-ruby thin etc || true; \
gem install rdoc || true; \
apk del gcc g++ libc-dev zlib-dev openssl openssl-dev cmake make;
RUN gem install github-markup commonmarker || true;
# TODO what gems needed to render tables with markdown
ENV PORT=8080
CMD []
WORKDIR /wiki
COPY . /opt/
ENTRYPOINT ["/bin/bash", "/opt/entrypoint.sh"]

63
gollum/build_and_run.sh Executable file
View File

@@ -0,0 +1,63 @@
#! /bin/bash
set -e
set -u
cd "$(dirname "${BASH_SOURCE[0]}")"
dir="$PWD"
if [ ! -e ./goftp ]; then
pushd $GOPATH/src/local/goftp
CGO_ENABLED=0 GOOS=linux go build -o "$dir/goftp" -a -installsuffix cgo
popd
fi
img_tag="${1:-"dev:dev"}"
docker build -t "$img_tag" .
mkdir -p $PWD/mnt
sudo chmod -R 777 $PWD/mnt
rm -rf $PWD/mnt/this
mkdir -p $PWD/mnt/this/is\ a/test/path
rm -f $PWD/mnt/this/{_Header.md,file.md}
echo '# hello' > $PWD/mnt/this/file.md
pushd $PWD/mnt
if [ ! -e Home.md ]; then
echo 'immediate pages
<<ImmediatePages()>>
immediate pages from /this/
<<ImmediatePages("/this/")>>
path segments
<<PathSegments()>>
drop down
<<DropDown("title", "hidden")>>
h1, h2, h3, para
# Hello
## h2
### h3
paragraph
' > Home.md
fi
popd
function clean() {
docker rm -f gollum-dev
}
trap clean EXIT
if [ -z "${BUILD:-""}" ]; then
docker run --rm -it \
--name gollum-dev \
-e PORT=38080 \
-p 38180:38080 \
-p 38181:38081 \
-v $PWD/mnt:/wiki \
$img_tag
fi

72
gollum/config.rb Executable file
View File

@@ -0,0 +1,72 @@
=begin
This file can be used to (e.g.):
- alter certain inner parts of Gollum,
- extend it with your stuff.
It is especially useful for customizing supported formats/markups. For more information and examples:
- https://github.com/gollum/gollum#config-file
=end
module Gollum
class Macro
class ImmediatePages < Gollum::Macro
def render(toc_root_path = nil, max_depth = 1, min_depth = 0)
if toc_root_path == nil
if @page.path == "Home.md"
toc_root_path = ""
else
toc_root_path = @page.path.sub(/\.[a-z]+$/,'/')
end
end
if toc_root_path.start_with?("/")
toc_root_path[0] = ''
end
if toc_root_path != "" and not toc_root_path.end_with?("/")
toc_root_path << '/'
end
if @wiki.pages.size > 0
list_items = @wiki.pages.map do |page|
if @page.url_path != page.url_path and page.url_path.start_with?(toc_root_path)
path_display = page.url_path_display.sub(toc_root_path.gsub("-", " "), "").sub(/^\//,'')
depth = path_display.count("/")
if depth.to_i < max_depth.to_i and depth.to_i >= min_depth.to_i
" <li><a href=\"/#{page.url_path}\">#{path_display}</a></li>"
end
end
end
result = "<ul>#{list_items.join}</ul>"
end
title = toc_root_path
"<div class=\"toc\"><div class=\"toc-title\">#{title}</div>#{result}</div>"
end
end
class PathSegments < Gollum::Macro
def render(append = "")
segments = @page.path.split('/')
segments = segments.first(segments.size - 1)
if append != ""
segments << append
end
full = ""
list_items = segments.map do |segment|
full = "#{full}/#{segment}"
" / <a href=\"#{full}\">#{segment}</a>"
end
list_items.insert(0, " / <a href=\"/Home\">Home</a>")
list_items << " / <a id='last_segment' onload='load_segment();' href='#'></a>"
"<div>#{list_items.join}</div>"
end
end
class DropDown < Gollum::Macro
def render(summary, detail)
"<details><summary>#{summary}</summary><div class=\"toc\">#{detail}</div></details"
end
end
class ImgDropDown < Gollum::Macro
def render(img_link, title = "Image")
"<details><summary>#{title}</summary><div class=\"img-drop-down\"><img src=\"#{img_link}\"/></div></details"
end
end
end
end

67
gollum/custom.css Executable file
View File

@@ -0,0 +1,67 @@
#head
> .actions
> .minibutton:nth-last-child(-n+2)
, #head
> .actions
> .minibutton:nth-child(6)
, #head
> .actions
> .minibutton:nth-child(4)
{
display: none;
}
body
{
background-color: #222;
-webkit-filter: invert(85%);
filter: invert(85%);
}
img
{
-webkit-filter: invert(100%);
filter: invert(100%);
}
.img-drop-down
{
width: 100%;
}
.img-drop-down
> img
{
text-align: center;
margin: 0 auto;
padding: 1em 0;
max-width: 100%;
max-height: 400px;
display: block;
}
.markdown-body
h1
{
border-top: 1px solid #ddd;
padding-top: 10px;
}
#head
> h1
{
/*display: none;*/
width: 100%;
}
summary
> h1
, summary
> h2
, summary
> h3
, summary
> h4
{
display: inline-block;
}

13
gollum/custom.js Executable file
View File

@@ -0,0 +1,13 @@
function load_segment() {
var elem = document.getElementById("last_segment")
if (elem) {
var arr = window.location.href.split('/')
elem.innerHTML = arr[arr.length-1]
elem.setAttribute("href", window.location.href.split('#')[0])
} else {
setTimeout(function() {
load_segment()
}, 50)
}
}
load_segment()

27
gollum/entrypoint.sh Executable file
View File

@@ -0,0 +1,27 @@
#! /bin/bash
function main() {
set -e
cd /wiki
git init || true
crontab /opt/routine.cron
bash /opt/index.sh
/opt/goftp \
-port $((PORT+1)) \
-root /wiki/uploads-ftp \
& gollum \
--port $PORT \
--no-live-preview \
--config /opt/config.rb \
--collapse-tree \
--allow-uploads=dir \
--css \
--js \
"$@"
}
if [ "$0" == "${BASH_SOURCE[0]}" ]; then
main "$@"
fi

88
gollum/index.sh Executable file
View File

@@ -0,0 +1,88 @@
#! /bin/bash
function main() {
set -e
fill_missing_files
format_files
init_git
}
function fill_missing_files() {
pushd "${1:-/wiki}" > /dev/null 2>&1
fill_if_missing ./Home.md
fill_if_missing ./_Header.md
find ./* -type d | while read -r i; do
i="${i%/}"
fill_if_missing "$i.md"
fill_if_missing "$i/_Header.md"
done
rm -f .git/hooks/pre-commit || true
for i in .git/hooks/pre-commit custom.css custom.js; do
fill_if_missing ./$i "$(cat /opt/${i##*/})"
done
mkdir -p ./uploads-ftp
cp /opt/favicon.ico . || true
popd > /dev/null 2>&1
}
function format_files() {
pushd ${1:-/wiki} > /dev/null 2>&1
local patterns=('^[0-9][0-9]*\. *' ' 1. ')
local f="/tmp/switch"
find . -type f -name "*.md" | grep -v '\/_[^\/]*.md' | while read -r path; do
for ((i=0; i<${#patterns[@]}; i+=2)); do
local from="${patterns[i]}"
local to="${patterns[i+1]}"
if [ -n "$(grep "${from// /.}" "$path")" ]; then
cat "$path" \
| sed "s/$from/$to/g" \
> "$f"
cp "$f" "$path"
fi
done
done
rm -f "$f"
popd > /dev/null 2>&1
}
function init_git() {
pushd ${1:-/wiki} > /dev/null 2>&1
git config user.email bel@bel.bel
git config user.name bel
git add -A :/
if [ "${JUST_ADD:-""}" != "true" ]; then
JUST_ADD=true git commit --author="auto <>" -m "routine" || true
fi
popd > /dev/null 2>&1
}
function fill_if_missing() {
local relative_path="$1"
shift
mkdir -p "$(dirname "$relative_path")"
local full_path="$(printf "%s/%s" \
"$(realpath \
"$(dirname "$relative_path")" \
)" \
"$(basename "$relative_path")" \
)"
if [ ! -e "$full_path" ]; then
if [ "$#" -gt 0 ]; then
echo "$@" > "$full_path"
elif [[ "$relative_path" == *"_Header.md" ]]; then
echo "<<PathSegments()>>" > "$full_path"
else
echo "<<ImmediatePages()>>" > "$full_path"
fi
fi
chmod +x "$full_path"
}
if [ "$0" == "${BASH_SOURCE[0]}" ]; then
main "$@"
fi

5
gollum/pre-commit Executable file
View File

@@ -0,0 +1,5 @@
#!/bin/sh
echo DO INDEX.sh;
git status;
JUST_ADD=true bash /opt/index.sh || true;

1
gollum/review Executable file
View File

@@ -0,0 +1 @@
ruby scripting is fantastic and fun, but tags/metadata are hard

1
gollum/routine.cron Executable file
View File

@@ -0,0 +1 @@
0 0/2 * * * /bin/bash /opt/index.sh

9
kanboard/kanboard/kanboard.sh Executable file
View File

@@ -0,0 +1,9 @@
#! /bin/bash
echo USER admin PASS admin ON 8036
docker run --rm -it \
--name kanboard \
-p 8036:80 \
-v $(pwd)/kanboard-data:/var/www/app/data \
kanboard/kanboard:v1.2.5

View File

View File

@@ -0,0 +1,36 @@
FROM kanboard/kanboard:v1.2.14
RUN apk update \
&& apk add --no-cache \
postgresql \
dcron \
curl \
&& mkdir -p /var/lib/postgresql/12/main \
&& chown -R postgres:postgres /var/lib/postgresql \
&& chmod -R 750 /var/lib/postgresql \
&& su postgres -c "initdb -D /var/lib/postgresql/12/main/" \
&& mkdir -p /var/run/postgresql/ \
&& chown -R postgres:postgres /var/run/postgresql \
&& chmod -R 750 /var/run/postgresql
RUN su postgres -c 'postgres --config-file=/var/lib/postgresql/12/main/postgresql.conf -D /var/lib/postgresql/12/main' \
& until su postgres -c 'psql --command "CREATE USER admin WITH SUPERUSER PASSWORD '"'"'admin'"'"';"'; do sleep 1; done \
&& su postgres -c 'psql --command "CREATE DATABASE db;"' \
&& su postgres -c 'psql --command "GRANT ALL PRIVILEGES ON DATABASE db TO admin;"' \
&& kill %1 \
&& wait
RUN mkdir -p \
/etc/nginx/ssl \
/var/www/app/data \
/var/www/app/plugins \
&& chown -R nginx:nginx /var/www/app
RUN echo '0 */4 * * * bash -c "true; bash /backup.sh &>> /tmp/backup.log"' >> /etc/crontabs/root
ENV DATABASE_URL=postgres://admin:admin@127.0.0.1/db
COPY backup.sh /backup.sh
COPY restore.sh /restore.sh
CMD []
ENTRYPOINT ["bash", "-c", "true; clean() { bash /backup.sh; echo cleaned; exit 0; }; set -e; crond; (set -m; su postgres -c 'postgres --config-file=/var/lib/postgresql/12/main/postgresql.conf -D /var/lib/postgresql/12/main' & wait) &> /var/log/postgres.log & disown; until psql $DATABASE_URL < /dev/null; do sleep 1; done; bash /restore.sh; trap clean EXIT ERR INT; echo rm and start; rm -rf /etc/services.d/cron; bash /usr/local/bin/entrypoint.sh"]

View File

@@ -0,0 +1,14 @@
#! /bin/bash
date
mkdir -p /mnt/save
d=/mnt/save/$(date +%Y-%m-%d-%H-%M-%S).dump
echo backing up as $d...
pg_dump $DATABASE_URL --clean \
> $d \
|| rm -f $d
total=$(ls /mnt/save/* | wc -l)
to_del=$((total-${BACKUPS:-10}))
if ((to_del>0)); then
rm -f $(ls /mnt/save/* | head -n $to_del)
fi

View File

@@ -0,0 +1 @@
docker build -t bel/kanboard:v0.1 .

View File

@@ -0,0 +1,24 @@
data_directory = '/var/lib/postgresql/10/main' # use data in another directory
hba_file = '/etc/postgresql/10/main/pg_hba.conf' # host-based authentication file
ident_file = '/etc/postgresql/10/main/pg_ident.conf' # ident configuration file
external_pid_file = '/var/run/postgresql/10-main.pid' # write an extra PID file
port = 5432 # (change requires restart)
max_connections = 100 # (change requires restart)
unix_socket_directories = '/var/run/postgresql' # comma-separated list of directories
ssl = on
ssl_cert_file = '/etc/ssl/certs/ssl-cert-snakeoil.pem'
ssl_key_file = '/etc/ssl/private/ssl-cert-snakeoil.key'
shared_buffers = 128MB # min 128kB
dynamic_shared_memory_type = posix # the default is the first option
log_line_prefix = '%m [%p] %q%u@%d ' # special values:
log_timezone = 'America/Denver'
cluster_name = '10/main' # added to process titles if nonempty
stats_temp_directory = '/var/run/postgresql/10-main.pg_stat_tmp'
datestyle = 'iso, mdy'
timezone = 'America/Denver'
lc_messages = 'C.UTF-8' # locale for system error message
lc_monetary = 'C.UTF-8' # locale for monetary formatting
lc_numeric = 'C.UTF-8' # locale for number formatting
lc_time = 'C.UTF-8' # locale for time formatting
default_text_search_config = 'pg_catalog.english'
include_dir = 'conf.d' # include files ending in '.conf' from

View File

@@ -0,0 +1,18 @@
#! /bin/bash
until psql $DATABASE_URL < /dev/null; do
sleep 1
done
for f in /mnt/save/$(ls /mnt/save | sort -r); do
echo restore $f
psql $DATABASE_URL < $f &> /dev/null
ret=$?
echo restore result: $ret
# TODO server isn't started to assert db is OK
exit $ret
if [ $ret == 0 ]; then
if curl -sS -i localhost:80 | grep login; then
exit $ret
fi
fi
done

View File

@@ -0,0 +1,3 @@
#! /bin/bash
docker-compose up

View File

@@ -0,0 +1,33 @@
version: '2'
volumes:
restyaboard_db:
driver: local
restyaboard_media:
driver: local
services:
restyaboard:
image: restyaplatform/restyaboard:dev
environment:
POSTGRES_DB: restyaboard
POSTGRES_HOST: postgres
POSTGRES_PASSWORD: admin
POSTGRES_USER: admin
SMTP_DOMAIN: domain
SMTP_USERNAME: user
SMTP_PASSWORD: pass
SMTP_SERVER: server
SMTP_PORT: 465
TZ: Etc/UTC
volumes:
- restyaboard_media:/usr/share/nginx/html/media
ports:
- "8344:80"
postgres:
image: postgres:9-alpine
environment:
POSTGRES_DB: restyaboard
POSTGRES_HOST: postgres
POSTGRES_PASSWORD: admin
POSTGRES_USER: admin
volumes:
- restyaboard_db:/var/lib/postgresql/data

1
kanboard/restya/review Executable file
View File

@@ -0,0 +1 @@
cannot sign up/log in without valid smtp

View File

@@ -0,0 +1,11 @@
#! /bin/bash
img="staannoe/tracks"
tag="latest"
docker pull $img:$tag
docker run --rm -it \
--name ${img##*/} \
-p 8344:80 \
-v $(pwd)/mnt:/data \
$img:$tag

1
kanboard/tracks/review Executable file
View File

@@ -0,0 +1 @@
too much, red* was better

2
leanote/.gitignore vendored Executable file
View File

@@ -0,0 +1,2 @@
data
files

54
leanote/Dockerfile Executable file
View File

@@ -0,0 +1,54 @@
FROM frolvlad/alpine-glibc:alpine-3.9_glibc-2.28 as builder
RUN apk add --no-cache \
libc-dev \
gcc \
go \
git \
mongodb \
mongodb-tools
RUN mkdir -p /go/src \
&& mkdir -p /go/pkg \
&& mkdir -p /go/bin
ENV GOPATH=/go
RUN go get github.com/revel/cmd/revel \
&& go get github.com/leanote/leanote/app \
&& go get github.com/golang/dep/cmd/dep \
&& cd $GOPATH/src/github.com/revel/cmd/revel && go install \
&& cd $GOPATH/src/github.com/golang/dep/cmd/dep && go install \
&& sed -i 's/Get[\t ][ \t]*\/[\t ][\t ]*.*$/Get \/ Auth.Login/' $GOPATH/src/github.com/leanote/leanote/conf/routes
RUN mkdir -p /mnt/data \
&& mongod --dbpath /mnt/data \
& mongorestore -h localhost -d leanote --dir $GOPATH/src/github.com/leanote/leanote/mongodb_backup/leanote_install_data/ \
&& kill %1
FROM frolvlad/alpine-glibc:alpine-3.9_glibc-2.28
WORKDIR /opt
ENV GOPATH=/go
RUN apk add --no-cache \
fcron \
bash \
mongodb \
go \
gcc libc-dev \
&& crond \
&& addgroup -S user && adduser -S -G user user \
&& mkdir -p \
/mnt/data \
$GOPATH/src/github.com/leanote/leanote/files
COPY --from=builder /go/src $GOPATH/src
COPY --from=builder /go/pkg $GOPATH/pkg
COPY --from=builder /go/bin $GOPATH/bin
COPY --from=builder /mnt/data /mnt/data
ENV PATH=${PATH}:$GOPATH/bin
RUN chown -R user /mnt $GOPATH
USER user
CMD []
ENTRYPOINT ["bash", "-c", "mongod --dbpath /mnt/data & revel run github.com/leanote/leanote"]

28
leanote/build_and_run.sh Executable file
View File

@@ -0,0 +1,28 @@
#! /bin/bash
set -e
img="bel/leanote"
tag="v0.0"
docker build -t $img:$tag .
if [ ! -d "$PWD/data" ]; then
mkdir "$PWD/data" "$PWD/files"
sudo chmod -R 777 "$PWD/data"
docker run --rm -it \
--entrypoint cp \
-v "$(pwd):/mnt2" \
$img:$tag \
-r /mnt/data /mnt2/
fi
sudo chmod -R 777 "$PWD/data" "$PWD/files"
docker run --rm -it \
--name ${img##*/} \
-p 9000:9000 \
-v "$(pwd)/data:/mnt/data" \
-v "$(pwd)/files:/go/src/github.com/leanote/leanote/files" \
$img:$tag

1
leanote/review Executable file
View File

@@ -0,0 +1 @@
requires mongo and only mongo. Defer.

15
mytinytodo/build_and_run.sh Executable file
View File

@@ -0,0 +1,15 @@
#! /bin/bash
img="php"
tag="7.1.26-alpine3.9"
docker pull $img:$tag
cp $PWD/entrypoint.sh $PWD/mnt/entrypoint.sh
docker run --rm -it \
--entrypoint sh \
--name ${img##*/} \
-p 8345:8080 \
-v $(pwd)/mnt:/mnt \
$img:$tag \
/mnt/entrypoint.sh

28
mytinytodo/entrypoint.sh Executable file
View File

@@ -0,0 +1,28 @@
#! /bin/sh
cd /mnt
apk add --no-cache \
ca-certificates \
bash \
git
#if [ ! -d ./mytinytodo ]; then
if [ ! -d ./mytinytodo2 ]; then
#wget https://bitbucket.org/maxpozdeev/mytinytodo/downloads/mytinytodo-v1.4.3.zip
#unzip mytinytodo-v1.4.3.zip
git clone https://github.com/ptrckkk/myTinyTodo.git mytinytodo2
fi
if [ -z "$(grep invert ./mytinytodo2/themes/default/style.css)" ]; then
echo '
body {
filter: invert(80%);
background-color: #222;
}
' | tr '\n' ' ' >> ./mytinytodo2/themes/default/style.css
fi
#cd mytinytodo
cd mytinytodo2
php -S 0.0.0.0:8080

23
mytinytodo/mnt/entrypoint.sh Executable file
View File

@@ -0,0 +1,23 @@
#! /bin/sh
cd /mnt
apk add --no-cache \
ca-certificates \
bash \
git
#if [ ! -d ./mytinytodo ]; then
if [ ! -d ./mytinytodo2 ]; then
#wget https://bitbucket.org/maxpozdeev/mytinytodo/downloads/mytinytodo-v1.4.3.zip
#unzip mytinytodo-v1.4.3.zip
git clone https://github.com/ptrckkk/myTinyTodo.git mytinytodo2
fi
if [ -z "$(grep invert ./mytinytodo2/themes/default/style.css)" ]; then
echo 'body { filter: invert(80%); background-color: #222; }' >> ./mytinytodo2/themes/default/style.css
fi
#cd mytinytodo
cd mytinytodo2
php -S 0.0.0.0:8080

16
no/mininote/build_and_run.sh Executable file
View File

@@ -0,0 +1,16 @@
#! /bin/bash
img="bel/mininote"
tag="latest"
cd "$(dirname "${BASH_SOURCE[0]}")"
git clone https://github.com/n1try/mininote
pushd ./mininote
docker build -t $img:$tag .
popd
docker run --rm -it \
--name ${img##*/} \
-p 8344:3000 \
-v $(pwd)/mnt:/app/data \
$img:$tag

1
no/mininote/review Executable file
View File

@@ -0,0 +1 @@
cute but not super effective--each notebook is a user/pass and it's just a flat sheet to manually save

5
no/tiddlywiki/review Executable file
View File

@@ -0,0 +1,5 @@
ehhhhh
- supports everything except nested storage
- can manually list and script titles but tags was a nightmare
- got stuck and froze every so often

11
no/trilium/build_and_run.sh Executable file
View File

@@ -0,0 +1,11 @@
#! /bin/bash
img="zadam/trilium"
tag="0.29.1"
docker pull $img:$tag
docker run --rm -it \
--name ${img##*/} \
-p 8344:8080 \
-v $(pwd)/mnt:/root/trilium-data \
$img:$tag

6
no/trilium/review Executable file
View File

@@ -0,0 +1,6 @@
shit because it doesnt work on firefox
Great aside from shit mobile view. Good for gcp!
SO close, cannot mark as complete