summary refs log tree commit diff
path: root/bin
diff options
context:
space:
mode:
authorJune McEnroe <june@causal.agency>2022-07-26 14:51:54 -0400
committerJune McEnroe <june@causal.agency>2022-07-26 14:51:54 -0400
commitacf581b2cc309b6e7e4ba057ba7b0810eff10a31 (patch)
treea0b52b754d0882547bd56d1d75b4a26f7c2fcc2c /bin
parentSet push.autoSetupRemote (diff)
downloadsrc-acf581b2cc309b6e7e4ba057ba7b0810eff10a31.tar.gz
src-acf581b2cc309b6e7e4ba057ba7b0810eff10a31.zip
Add -w to up
Diffstat (limited to 'bin')
-rw-r--r--bin/man1/up.118
-rw-r--r--bin/up.sh30
2 files changed, 29 insertions, 19 deletions
diff --git a/bin/man1/up.1 b/bin/man1/up.1
index 2240b99a..aece79bd 100644
--- a/bin/man1/up.1
+++ b/bin/man1/up.1
@@ -1,4 +1,4 @@
-.Dd June 21, 2021
+.Dd July 26, 2022
 .Dt UP 1
 .Os
 .
@@ -8,15 +8,9 @@
 .
 .Sh SYNOPSIS
 .Nm
-.Op Fl h
-.Op Ar file
-.
-.Nm
-.Fl c | t
-.Ar command
-.
-.Nm
-.Fl s
+.Op Fl c | h | s | t
+.Op Fl w Ar warn
+.Op Ar file | command
 .
 .Sh DESCRIPTION
 .Nm
@@ -65,6 +59,10 @@ Run a command with
 and
 .Xr shotty 1
 to produce an HTML file for upload.
+.It Fl w Ar warn
+Create an HTML redirect with
+.Ar warn
+in its title.
 .El
 .
 .Pp
diff --git a/bin/up.sh b/bin/up.sh
index cebc29c4..6305b1ee 100644
--- a/bin/up.sh
+++ b/bin/up.sh
@@ -4,21 +4,32 @@ set -eu
 readonly Host='temp.causal.agency'
 readonly Root='/var/www'
 
+temp=
+temp() {
+	temp=$(mktemp -d)
+	trap 'rm -r "$temp"' EXIT
+}
+
+warn=
 upload() {
 	src=$1
 	ext=${src##*.}
-	ts=$(date +'%s')
-	rand=$(openssl rand -hex 4)
-	url=$(printf '%s/%x%s.%s' "$Host" "$ts" "$rand" "$ext")
+	name=$(printf '%x%s' "$(date +%s)" "$(openssl rand -hex 4)")
+	url="${Host}/${name}.${ext}"
 	scp -q "$src" "${Host}:${Root}/${url}"
+	if test -n "$warn"; then
+		test -n "$temp" || temp
+		cat >"${temp}/warn.html" <<-EOF
+			<!DOCTYPE html>
+			<title>${warn}</title>
+			<meta http-equiv="refresh" content="0;url=${name}.${ext}">
+		EOF
+		url="${Host}/${name}.html"
+		scp -q "${temp}/warn.html" "${Host}:${Root}/${url}"
+	fi
 	echo "https://${url}"
 }
 
-temp() {
-	temp=$(mktemp -d)
-	trap 'rm -r "$temp"' EXIT
-}
-
 uploadText() {
 	temp
 	cat >"${temp}/input.txt"
@@ -64,12 +75,13 @@ uploadTerminal() {
 	upload "${temp}/term.html"
 }
 
-while getopts 'chst' opt; do
+while getopts 'chstw:' opt; do
 	case $opt in
 		(c) fn=uploadCommand;;
 		(h) fn=uploadHilex;;
 		(s) fn=uploadScreen;;
 		(t) fn=uploadTerminal;;
+		(w) warn=$OPTARG;;
 		(?) exit 1;;
 	esac
 done
9f239607b643a0873&follow=1'>build: Add scripts to EXTRA_DISTJune McEnroe 2021-05-25import: Add missing scripts/wrap-compiler-for-flag-checkJune McEnroe 2021-05-08Import LibreSSL 3.3.3June McEnroe 2021-04-18build: Remove added x509_verify.3 links 3.3.2June McEnroe 2021-04-18tls: Use EC_KEY_set_ex_dataJune McEnroe 2021-04-18Import LibreSSL 3.3.2June McEnroe 2021-03-05Bump version to 3.3.1p1 3.3.1p1June McEnroe 2021-03-05build: Add OpenSSL includes to libcompatJune McEnroe Some compat sources (getentropy_linux.c for example) require OpenSSL. Reported by Robert Scheck. 2020-12-15Import LibreSSL 3.3.1June McEnroe 2020-11-24Import LibreSSL 3.3.0June McEnroe 2020-10-22Import LibreSSL 3.2.2June McEnroe 2020-09-29Import LibreSSL 3.2.1June McEnroe 2020-09-29import: Add m4/ax_add_fortify_source.m4June McEnroe 2020-08-05build: Add README.7 to EXTRA_DIST 3.2.0June McEnroe 2020-08-03doc: Indicate that only OpenSSL 1.1.1b and newer workJune McEnroe