summaryrefslogtreecommitdiffstats
path: root/util
diff options
context:
space:
mode:
Diffstat (limited to 'util')
-rw-r--r--util/Makefile22
-rw-r--r--util/README.markdown27
-rw-r--r--util/archlive/archlive.tarbin0 -> 58785 bytes
-rw-r--r--util/archlive/readme7
-rw-r--r--util/auto/krebs61
-rwxr-xr-xutil/bin/TouchpadToggle8
-rwxr-xr-xutil/bin/anonbox.net57
-rwxr-xr-xutil/bin/dic78
-rwxr-xr-xutil/bin/galileo3
-rwxr-xr-xutil/bin/google.suggest8
-rwxr-xr-xutil/bin/graphitec5
-rwxr-xr-xutil/bin/hrefs20
-rwxr-xr-xutil/bin/jbo42
-rwxr-xr-xutil/bin/krebdate10
-rwxr-xr-xutil/bin/lgoinstall131
-rwxr-xr-xutil/bin/magic63
-rwxr-xr-xutil/bin/make-data-url7
-rwxr-xr-xutil/bin/make-realwallpaper302
-rwxr-xr-xutil/bin/mic.stt12
-rwxr-xr-xutil/bin/my-global-ipv4-addr52
-rwxr-xr-xutil/bin/naturalvoices.att18
-rwxr-xr-xutil/bin/nextpath12
-rwxr-xr-xutil/bin/pigbin5
-rwxr-xr-xutil/bin/randline2
-rwxr-xr-xutil/bin/sshkill33
-rwxr-xr-xutil/bin/statsc4
-rwxr-xr-xutil/bin/text2speech.google10
-rwxr-xr-xutil/bin/timer14
-rwxr-xr-xutil/bin/translate.google13
-rwxr-xr-xutil/bin/ukrepl109
-rwxr-xr-xutil/bin/untouch8
-rwxr-xr-xutil/bin/uriparse28
-rwxr-xr-xutil/bin/wiki.firstpar23
-rwxr-xr-xutil/bin/wikipedia5
-rwxr-xr-xutil/bin/with6
-rw-r--r--util/lib/geo/Makefile15
-rw-r--r--util/lib/geo/index.js48
-rw-r--r--util/lib/geo/package.json7
-rwxr-xr-xutil/lib/naturalvoices/att.sh33
-rw-r--r--util/lib/stt/README.md4
-rw-r--r--util/lib/stt/google.sh40
-rw-r--r--util/morse/COPYING14
-rw-r--r--util/morse/Makefile3
-rw-r--r--util/morse/README32
-rwxr-xr-xutil/morse/morse.sh160
-rwxr-xr-xutil/t/anonbox.net/got-some-valid-looking-email16
-rwxr-xr-xutil/t/dic/can-scrape6
-rwxr-xr-xutil/t/naturalvoices/att-produces-output10
-rw-r--r--util/t/stt/stt-works-with-espeak10
-rwxr-xr-xutil/t/uriparse/parse-retard-uri13
-rwxr-xr-xutil/t/uriparse/parse-url13
51 files changed, 1629 insertions, 0 deletions
diff --git a/util/Makefile b/util/Makefile
new file mode 100644
index 00000000..5096506b
--- /dev/null
+++ b/util/Makefile
@@ -0,0 +1,22 @@
+usage:;cat Makefile
+
+test:
+ @export PATH="$(CURDIR)/bin:$(PATH)"; \
+ tests="`find t -type f -executable`"; \
+ i=1; \
+ n=`echo "$$tests" | wc -l`; \
+ echo $$i..$$n; \
+ for exe in $$tests; do \
+ if ./$$exe; then \
+ echo ok $$i - $$exe; \
+ else \
+ echo not ok $$i - $$exe; \
+ touch .test-not-ok; \
+ fi & \
+ i=$$(( i+1 )); \
+ done; \
+ wait; \
+ if test -e .test-not-ok; then \
+ rm .test-not-ok; \
+ exit 23; \
+ fi
diff --git a/util/README.markdown b/util/README.markdown
new file mode 100644
index 00000000..78b9b81a
--- /dev/null
+++ b/util/README.markdown
@@ -0,0 +1,27 @@
+# various utils
+
+## //util/bin/with
+
+ execute a command with an extended/modified environment
+
+### usage
+
+ with ENV COMMAND
+
+ where `ENV` is the name of the environment and
+ `COMMAND` your to-be-executed command (-line).
+
+### environment
+
+ `env_dir` defines the directory where environment files are searched
+ (default: `$HOME/.env.d`).
+
+### example
+
+ cat > ~/.env.d/frh-ire <<EOF
+ export api_url=...
+ export api_key=...
+ export api_hash=...
+ EOF
+
+ with frh-ire //ext/solus/bin/client info
diff --git a/util/archlive/archlive.tar b/util/archlive/archlive.tar
new file mode 100644
index 00000000..13878e24
--- /dev/null
+++ b/util/archlive/archlive.tar
Binary files differ
diff --git a/util/archlive/readme b/util/archlive/readme
new file mode 100644
index 00000000..bb23a942
--- /dev/null
+++ b/util/archlive/readme
@@ -0,0 +1,7 @@
+change key in root-image/root/.ssh/authorized_keys
+change target hidden service in root-image/etc/systemd/scripts/nc_onion
+
+run build.sh (as root)
+
+archlive will send the hidden service every minute to configured targets hidden service
+stop with systemctl stop krebs-init
diff --git a/util/auto/krebs b/util/auto/krebs
new file mode 100644
index 00000000..eb6c25a8
--- /dev/null
+++ b/util/auto/krebs
@@ -0,0 +1,61 @@
+#! /bin/sh
+# krebs autoinstall script
+set -euf
+# see punanin docs
+
+function bailout()
+{
+ exit 1
+}
+function punani()
+{
+ return 0
+}
+
+function generate_config()
+{
+ # $1 -
+ [ -e $1 ] && exit 0
+ cat >$1 <<EOF
+#Uncomment this line to start ,otherwise the installer will bail out
+#I_AM_WILLING_TO_LET_KREBS_TAKE_OVER_MY_SYSTEM_MY_LIFE_AND_ALL_OF_MY_CHILDREN="Totally sure"
+
+# 1 - will do you no harm. this is what you want
+VERKREBSUNGSLEVEL=kindergarten
+# 2 - will verkrebs your computer, hard
+#VERKREBSUNGSLEVEL=aggressiv
+# 3 - will definitly fuck up something of value, be aware
+#VERKREBSUNGSLEVEL=auftoeteneingestellt
+
+#Optional Modules to activate
+# Choose from :
+# $(find $(dirname $1) -type d -mindepth 1 -maxdepth 1)
+# OPTIONAL_MODULES=""
+EOF
+
+}
+
+function edit_config()
+{
+ # $1 - krebsdir
+ CONF=$1/krebs_config
+ generate_config $CONF
+ $EDITOR $CONF
+
+ source $CONF
+ if [ ! -n "${I_AM_WILLING_TO_LET_KREBS_TAKE_OVER_MY_SYSTEM_MY_LIFE_AND_ALL_OF_MY_CHILDREN+x}" ];
+ then
+ printf "So you are not willing to give krebs all the necessary rights\n"
+ printf "Cannot continue...\n"
+ rm $CONF
+ printf "I hate you by the way..."
+ bailout
+ fi
+ make -C $1
+}
+punani -Ei git make
+KREBSDIR=${1-/krebs}
+[ ! -e $KREBSDIR ] && git clone https://github.com/krebscode/painload ${KREBSDIR}|| printf "painload already deployed\n"
+
+edit_config ${KREBSDIR}
+make -C ${KREBSDIR}
diff --git a/util/bin/TouchpadToggle b/util/bin/TouchpadToggle
new file mode 100755
index 00000000..17fd46b8
--- /dev/null
+++ b/util/bin/TouchpadToggle
@@ -0,0 +1,8 @@
+#!/bin/sh
+#
+#This script toggles the touchpad on a netbook using synclient.
+
+status=`synclient|awk '/TouchpadOff/{printf$3}'`
+status=`expr \( $status + 1 \) \% 2`
+synclient TouchpadOff=$status
+
diff --git a/util/bin/anonbox.net b/util/bin/anonbox.net
new file mode 100755
index 00000000..3b648afb
--- /dev/null
+++ b/util/bin/anonbox.net
@@ -0,0 +1,57 @@
+#! /bin/bash
+#### anonbox.net [--check]
+#### anonbox account creator
+set -euf
+
+##
+script_begin_date="`date --rfc-3339=ns`"
+
+##
+GET() {
+ wget --quiet --no-check-certificate -O- https://anonbox.net/en/
+}
+
+## retrieve data
+eval "$(${GET-GET} |
+ sed -n '
+s^<dd><p>\([[:alnum:]@.]\+\)</p></dd>$\
+ email="\1" ; p
+s^<dd><p><a href="\([^"\\]\+\)">.*</a></p></dd>$\
+ uri="\1/" ; p
+s^<dd><p>\([0-9]\+\)/\([0-9]\+\)/\([0-9]\+\) \([0-9]\+\):\([0-9]\+\) \([ap]\).m.</p></dd>$\
+ Y=20\3 ; \
+ m=\1 ; \
+ d=\2 ; \
+ H=\4 ; \
+ M=\5 ; \
+ p=\6 ; p')"
+
+## make best-before-date RFC-3339-(seconds)-conform
+case "$p" in
+ p) H="`echo $H+12 | bc`" ;;
+esac
+s=00
+z=+02:00
+best_before="$Y-$m-$d $H:$M$z"
+
+##
+script_end_date="`date --rfc-3339=ns`"
+
+##
+for key in email uri best_before script_begin_date script_end_date ; do
+ eval "val=\"\$$key\""
+ echo "$key=\"$val\""
+done
+
+##
+if echo "$*" | tr "$IFS" ' ' | egrep -q "(^| )--check( |$)"; then
+ file="/tmp/save-$email"
+ echo "file=\"$file\""
+ echo >&2
+ echo "# downloading email..." >&2
+ while ! curl -ksS "$uri" | tee "$file" | grep .; do
+ sleep 10
+ done
+fi
+
+#### end of file.
diff --git a/util/bin/dic b/util/bin/dic
new file mode 100755
index 00000000..b3dac847
--- /dev/null
+++ b/util/bin/dic
@@ -0,0 +1,78 @@
+#! /bin/sh
+# usage: dic WORD [LANG]
+# where LANG may be one of en, fr, es, it, ch, ru, pt, pl
+# multiple WORDs may be seperated by + like this: multiple+words
+set -euf
+
+main() {
+
+ case $# in
+ 1|2) :;; # ok
+ *) usage; exit 23;;
+ esac
+
+ # all three are used by GET
+ search="$1"
+ langlang="${2-en}de"
+ lang="de"
+
+ GET | simplify | tac
+}
+
+GET() {
+ curl -sS -b 'LEOABTEST=T; browser=webkit%3B5%3Bajax' \
+ "https://dict.leo.org/dictQuery/m-vocab/$langlang/query.xml?tolerMode=nof&lp=$langlang&lang=$lang&rmWords=off&rmSearch=on&search=$search&searchLoc=0&resultOrder=basic&multiwordShowSingle=on"
+}
+
+simplify() {
+ sed '
+ s|<repr>|\nREPR: |g
+ s|</repr>|\n|g
+ ' | grep ^REPR |
+ sed '
+ s/^REPR: //
+ 1~2{s/$//}
+ 2~2{s/$//}
+ ' |
+ tr -d \\n |
+ sed '
+ s// - /g
+ s//\n/g
+
+ #q
+
+ s/&#8660;/⇔/g
+ s/&#160;/ /g; # &nbsp;
+ s/ */ /g
+
+ # <!-- undefined_translation: en:pl_ext -->
+ s/ *<!--[^>]*-->//g
+
+ s|<i> *|/|g
+ s| *</i>|/|g
+
+ s:<sup>1</sup>:¹:g; s:<sup>2</sup>:²:g; s:<sup>3</sup>:³:g;
+ s:<sup>:^(:g
+ s:</sup>:):g
+
+ s:<sub>0</sub>:₀:g;
+ s:<sub>1</sub>:₁:g; s:<sub>2</sub>:₂:g; s:<sub>3</sub>:₃:g;
+ s:<sub>4</sub>:₄:g; s:<sub>5</sub>:₅:g; s:<sub>6</sub>:₆:g;
+ s:<sub>7</sub>:₇:g; s:<sub>8</sub>:₈:g; s:<sub>9</sub>:₉:g;
+ s:<sub>:_(:g
+ s:</sub>:):g
+
+ s:<b> *::g
+ s: *</b>::g
+
+ s|<small> *||g
+ s| *</small>||g
+
+ '
+}
+
+usage() {
+ sed -rn '/^# usage:/,/^[^#]/{/^#/{s/# //;p}}' "$0" >&2
+}
+
+main "$@"
diff --git a/util/bin/galileo b/util/bin/galileo
new file mode 100755
index 00000000..854f1302
--- /dev/null
+++ b/util/bin/galileo
@@ -0,0 +1,3 @@
+#!/bin/sh
+export voice=klara
+./wiki.firstpar http://de.m.wikipedia.org/wiki/::Random | xargs ./naturalvoices.att
diff --git a/util/bin/google.suggest b/util/bin/google.suggest
new file mode 100755
index 00000000..9bde17dc
--- /dev/null
+++ b/util/bin/google.suggest
@@ -0,0 +1,8 @@
+#! /bin/sh
+
+uri="http://google.com/complete/search?output=json&q=$*"
+
+curl -sS "$uri" | sed -n '
+ s:^window.google.ac.h(\|)$::gp
+'
+echo
diff --git a/util/bin/graphitec b/util/bin/graphitec
new file mode 100755
index 00000000..52aa9834
--- /dev/null
+++ b/util/bin/graphitec
@@ -0,0 +1,5 @@
+#!/bin/sh
+H=${GRAPHITE_HOST:-localhost}
+P=${GRAPHITE_PORT:-2003}
+curr=$(date '+%s')
+printf "%s %s %s\n" $1 $2 $curr | nc -q0 $H $P
diff --git a/util/bin/hrefs b/util/bin/hrefs
new file mode 100755
index 00000000..3a1a51de
--- /dev/null
+++ b/util/bin/hrefs
@@ -0,0 +1,20 @@
+#! /bin/sh
+
+_hrefs() {
+ sed -n 's/href="\([^"]\+\)"/\n&\n/gp' |
+ sed -n 's/^href="\([^"]\+\)"$/\1/p'; }
+
+_add_prefix_to_relative_hrefs() {
+ sed '/^http:/!s^'"$1"''; }
+
+_main() {
+ case $# in
+ (0) _hrefs;;
+ (1) _hrefs | _add_prefix_to_relative_hrefs "$1";;
+ (*)
+ echo "bad command line: $0 $*" >&2; exit 23;;
+ esac; }
+
+set -euf
+_main "$@"
+#### end of file.
diff --git a/util/bin/jbo b/util/bin/jbo
new file mode 100755
index 00000000..76f86680
--- /dev/null
+++ b/util/bin/jbo
@@ -0,0 +1,42 @@
+#! /bin/sh
+# usage: jbo WORDS...
+set -euf
+
+if test $# = 0; then
+ while read line; do
+ if test "${clear-}" = true; then
+ echo -n 'c'
+ fi
+ "$0" "$line"
+ done
+ exit
+fi
+
+echo "$*" |
+tr 'h' "'" |
+jbofihe -H |
+tr '\n' ' ' |
+sed -r '
+ s@</?(HTML|HEAD|TITLE|BODY|FONT)[^>]*>@@g
+ s@Lojban translation@@
+' | {
+ sed 's:<SUB>[^>]*</SUB>:\n&\n:g' |
+ sed '/^<SUB>/y/0123456789/₀₁₂₃₄₅₆₇₈₉/' |
+ tr -d '\n' |
+ sed 's:</\?SUB>::g'
+} |
+sed -r '
+ s|<B>||g; s|</B>||g
+
+ s|<I> </I>|<I>_</I>|g
+ s|<I>||g; s|</I>||g
+
+ #s|<U>||g; s|</U>||g
+ s|<U>||g; s|</U>||g
+
+ s|&lt;|<|g
+ s|&gt;|>|g
+
+ s@^ *@@
+ $s/$/\n/
+'
diff --git a/util/bin/krebdate b/util/bin/krebdate
new file mode 100755
index 00000000..b2aa02d2
--- /dev/null
+++ b/util/bin/krebdate
@@ -0,0 +1,10 @@
+#! /bin/sh
+set -euf
+
+if test "${nosudo-false}" != true -a `id -u` != 0; then
+ echo "we're going sudo..." >&2
+ exec sudo "$0" "$@"
+ exit 23 # go to hell
+fi
+
+date --date="`ssh krebs 'date --rfc-3339=s'`"
diff --git a/util/bin/lgoinstall b/util/bin/lgoinstall
new file mode 100755
index 00000000..37ce6e16
--- /dev/null
+++ b/util/bin/lgoinstall
@@ -0,0 +1,131 @@
+#! /bin/sh
+#
+# usage: lgoinstall [path [OPTIONS...]]
+#
+# This script tries to goinstall ${OPTIONS...} local/$(basename $path)
+#
+# path defaults to $PWD
+#
+# target=local/$(basename $path)
+# ensure there's a symlink local/$target somewhere in $GOROOT or $GOPATH
+# goinstall $target
+#
+# TODO use the same argument order as goinstall
+#
+set -euf
+
+#fqtarget="$(readlink -f "$PWD")"
+fqtarget="$(cd "${1-$PWD}" && echo "$PWD")"
+target="local/$(basename "$fqtarget")"
+
+#
+# resolve PATH [relpath [FS]] # ====> abspath...
+#
+# Resolve relpath to abspath for each component x separated by FS in PATH
+# where x/relpath is an existing file.
+#
+# relpath defaults to ""
+# FS defaults to ":"
+#
+# Example:
+#
+# resolve "/bin:/usr/bin" sh # ====> /bin/sh
+#
+resolve() {
+ set -- "$1" "${2+/$2}" "${3-:}" "$IFS"
+ IFS="$3"
+ for i in $1; do
+ ! test -x "$i$2" || echo "$i$2"
+ done
+ unset i
+ IFS="$3"
+}
+
+#
+# xargstest TEST_ARGS...
+#
+# Read filenames from stdin and
+# write each filename that satisfies test # $TEST_ARGS to stdout.
+#
+# Each %x in TEST_ARGS gets replaced by the readlink -f of the filename.
+#
+# Example:
+#
+# xargstest -d %x <<EOF
+# /bin/sh
+# /usr
+# EOF
+# # ====> /usr
+#
+xargstest() {
+ while read x; do
+ fqx="$(readlink -f "$x")"
+ if sub %x "$x" sub %fqx "$fqx" test "$@"; then
+ #if test "${@//%x/$fqx}"; then
+ echo "$x"
+ fi
+ done | grep .
+}
+
+sub() {
+ sub1="$1"
+ sub2="$2"
+ shift 2
+ set -- "${@//$sub1/$sub2}"
+ unset sub1 sub2
+ "$@"
+}
+
+path="${GOROOT-}${GOPATH+:$GOPATH}"
+
+#
+# if there's a src/$target that points to $fqtarget, then succeed
+#
+if x="`resolve "$path" src/$target | xargstest "$fqtarget" = %fqx`"
+then
+ echo "good $target: $x -> $fqtarget" >&2
+ shift # off $1 = $fqtarget
+ echo goinstall "$@" "$target" >&2
+ exec goinstall "$@" "$target"
+fi
+
+#
+# if there's some other src/$target then die
+#
+if x="`resolve "$path" src/$target | xargstest ! -x %x -o "$fqtarget" != %fqx`"
+then
+ echo bad $target: $x >&2
+ echo check your GOROOT and/or GOPATH or eliminate that $target >&2
+ exit 23
+fi
+
+#
+# if we've no Go-source in $fqtarget then die to prevent clobbering $GOPATH.
+#
+if ! ls | grep '\.go$'; then
+ echo "$1 seems to contain no Go-source... abort." >&2
+ exit 23
+fi
+
+#
+# if we can write to some src/local then symlink $PWD and retry
+#
+if x="`resolve "$path" src/local | xargstest -w %x`"
+then
+ #echo writable src/local: $x
+ ln -vsnf $fqtarget $x
+ exec "$0" "$@"
+fi
+
+#
+# if we can write to some src then mkdir src/local and retry
+#
+if x="`resolve "$path" src | xargstest -w %x`"
+then
+ #echo writable src: $x
+ mkdir "$x/local"
+ exec "$0" "$@"
+fi
+
+echo "This script failed: good luck, you're on your own!" >&2
+exit 23
diff --git a/util/bin/magic b/util/bin/magic
new file mode 100755
index 00000000..a404c0c3
--- /dev/null
+++ b/util/bin/magic
@@ -0,0 +1,63 @@
+#! /bin/sh
+set -euf
+
+bs="# begin krebs magic <$2>"
+es="# end krebs magic <$2>"
+
+has() {
+ grep -q "^$bs$" $3 && grep -q "^$es$" $3
+}
+
+create() {
+ destroy "$@"
+ cat>>$3<<EOF
+$bs
+`cat`
+$es
+EOF
+}
+
+retrieve() {
+ sed -n "/^$bs$/,/^$es$/p" $3 | sed '1d;$d'
+}
+
+update() {
+ ! has "$@" || create "$@"
+}
+
+destroy() {
+ if has "$@"; then
+ cache="`cat $3`"
+ echo "$cache" | sed "/^$bs$/,/^$es$/d" >$3
+ fi
+}
+help() {
+cat <<EOF
+Usage: $0 FUNCTION DELIMITER_NAME FILE
+$0 creates,updates or destroys magic inside a file.
+It can be used to reliably add or remove custom lines.
+For example add own lines in /etc/rc.local to auto-load
+scripts.
+
+FUNCTION:
+ create -- creates new magic in file, takes stdin as content in magic
+ update -- updates already existing magic with text from stdin
+ destroy -- destroys magic boundary
+ retrieve -- retrieve the content of magic and writes to stdout
+
+Not yet implemented is the handling of magic not starting with the
+shell comment symbol "#".
+
+EOF
+
+}
+case $1 in
+ (create) create "$@" ;;
+ (retrieve) retrieve "$@" ;;
+ (update) update "$@" ;;
+ (destroy) destroy "$@" ;;
+ (*)
+ help >&2
+ echo 'Error 1: You are made of stupid!' >&2
+ exit 23
+esac
diff --git a/util/bin/make-data-url b/util/bin/make-data-url
new file mode 100755
index 00000000..a9d014e6
--- /dev/null
+++ b/util/bin/make-data-url
@@ -0,0 +1,7 @@
+#! /bin/sh
+set -euf
+for path; do
+ type="`file -bi "$path"`"
+ data="`base64 -w 0 "$path"`"
+ echo "data:$type;base64,$data"
+done
diff --git a/util/bin/make-realwallpaper b/util/bin/make-realwallpaper
new file mode 100755
index 00000000..5e05d0ee
--- /dev/null
+++ b/util/bin/make-realwallpaper
@@ -0,0 +1,302 @@
+#!/bin/sh
+set -euf
+
+###### USAGE #####
+#run in new directory(will be polluted with images
+#just run ./make-realwallpaper
+
+main() {
+ # fetch source images in parallel
+ #fetch nightmap-old-raw.jpg \
+ # http://awka.sourceforge.net/Night_le_huge.jpg &
+ fetch nightmap-raw.jpg \
+ http://www.zeitnews.org/sites/default/files/users/20/article_slideshow_images/nasa-noaa-satellite-reveals-new-views-earth-night-1354814354_0.jpg &
+ fetch daymap-raw.png \
+ http://www.nnvl.noaa.gov/images/globaldata/SnowIceCover_Daily.png &
+ fetch clouds-raw.jpg \
+ http://user.chol.com/~winxplanet/cloud_data/clouds_2048.jpg &
+ fetch krebs.sat.tle \
+ http://www.celestrak.com/NORAD/elements/stations.txt &
+ wait
+
+ #check_type nightmap-old-raw.jpg image
+ check_type nightmap-raw.jpg image
+ check_type daymap-raw.png image
+ check_type clouds-raw.jpg image
+
+ in_size=2048x1024
+ xplanet_out_size=1466x1200
+ out_geometry=1366x768+100+160
+
+ nightsnow_color='#0c1a49' # nightmap
+ #nightsnow_color='#0a3b5c' # nightmap-old
+
+ # normalize *-raw.* to *.png
+ #nightmap-old-raw.jpg
+ for raw in \
+ nightmap-raw.jpg \
+ daymap-raw.png \
+ clouds-raw.jpg \
+ ;
+ do
+ normal=${raw%-raw.*}.png
+ if needs_rebuild $normal $raw; then
+ echo "make $normal; normalize $raw" >&2
+ convert $raw -scale $in_size $normal
+ fi
+ done
+
+ # create nightmap-fullsnow
+ if needs_rebuild nightmap-fullsnow.png; then
+ convert -size $in_size xc:$nightsnow_color nightmap-fullsnow.png
+ fi
+
+ # extract daymap-snowmask from daymap-final
+ if needs_rebuild daymap-snowmask.png daymap.png; then
+ convert daymap.png -threshold 95% daymap-snowmask.png
+ fi
+
+ # extract nightmap-lightmask from nightmap
+ if needs_rebuild nightmap-lightmask.png nightmap.png; then
+ convert nightmap.png -threshold 25% nightmap-lightmask.png
+ fi
+
+ # create layers
+ make_layer nightmap-snowlayer.png nightmap-fullsnow.png daymap-snowmask.png
+ make_layer nightmap-lightlayer.png nightmap.png nightmap-lightmask.png
+
+ # apply layers
+ flatten nightmap-lightsnowlayer.png \
+ nightmap-lightlayer.png \
+ nightmap-snowlayer.png
+
+ flatten nightmap-final.png \
+ nightmap-lightsnowlayer.png \
+ nightmap.png
+ # nightmap-old.png
+
+ # make all unmodified files as final
+ for normal in \
+ daymap.png \
+ clouds.png \
+ ;
+ do
+ final=${normal%.png}-final.png
+ needs_rebuild $final &&
+ ln $normal $final
+ done
+
+ # make_gcloud_cloudmask
+
+ map=daymap-final.png
+ night_map=nightmap-final.png
+ cloud_map=clouds-final.png
+ gcloud_map=gcloud-cloudmask.png
+ satellite_file=krebs.sat
+
+ # create xplanet output
+ cat >xplanet.config <<EOF
+[earth]
+"Earth"
+map=$map
+night_map=$night_map
+cloud_map=$cloud_map
+cloud_threshold=10
+shade=15
+EOF
+
+ # create xplanet output satellite version
+ cat >xplanet-sat.config <<EOF
+[earth]
+"Earth"
+map=$map
+night_map=$night_map
+cloud_map=$cloud_map
+cloud_threshold=10
+satellite_file=$satellite_file
+shade=15
+EOF
+
+# # create xplanet output gcloud version
+# cat >xplanet-gcloud.config <<EOF
+#[earth]
+#"