Compare commits
No commits in common. "058f230ef0c079ad72243b392964330d851c10c6" and "7af9c89a1961eb04eabc7c0d0fbac9f319235c7b" have entirely different histories.
058f230ef0
...
7af9c89a19
|
@ -1,7 +0,0 @@
|
||||||
#!/bin/bash
|
|
||||||
# Brutally reset file permissions to sane defaults for files/folders that have
|
|
||||||
# been tainted by a poorly mounted NTFS drive (777).
|
|
||||||
pushd "$1"
|
|
||||||
fdfind -t f -x chmod 644
|
|
||||||
fdfind -t d -x chmod 755
|
|
||||||
popd
|
|
|
@ -31,14 +31,10 @@ check_cheat() {
|
||||||
|
|
||||||
check_python_packages() {
|
check_python_packages() {
|
||||||
echo "# Python user packages"
|
echo "# Python user packages"
|
||||||
# For some reason different order of arguments makes pip crash on some
|
pip3 list -o --user
|
||||||
# systems… Not going to bother here.
|
|
||||||
pip3 list --user -o 2> /dev/null \
|
|
||||||
|| pip3 list -o --user 2> /dev/null \
|
|
||||||
|| echo "Failure…"
|
|
||||||
}
|
}
|
||||||
|
|
||||||
(( $+commands[nvim] )) && check_neovim
|
(( $+commands[nvim] )) && check_neovim
|
||||||
(( $+commands[alacritty] )) && check_alacritty
|
(( $+commands[alacritty] )) && check_alacritty
|
||||||
(( $+commands[cheat] )) && check_cheat
|
(( $+commands[cheat] )) && check_cheat
|
||||||
(( $+commands[pip3] )) && check_python_packages
|
check_python_packages
|
||||||
|
|
|
@ -1,49 +0,0 @@
|
||||||
#!/bin/bash -e
|
|
||||||
# Upload a text file to a server through SSH so that it can be shared.
|
|
||||||
# This script expects the server can serve files on the Web. Also expects curl.
|
|
||||||
# It uses an HTML template instead of the raw text file because browsers
|
|
||||||
# sometimes do not expect UTF-8 by default and this is always what I upload.
|
|
||||||
#
|
|
||||||
# You need to provide those 3 env variables:
|
|
||||||
# - REMOTE_DEST: the SSH destination to reach
|
|
||||||
# - REMOTE_WWW: the remote path where the HTML file will be stored
|
|
||||||
# - REMOTE_URL: the URL of the directory to print; file name is appended
|
|
||||||
|
|
||||||
usage() {
|
|
||||||
echo "Usage: $0 text_file"
|
|
||||||
echo "Upload a text file to a simple HTML template on a server."
|
|
||||||
}
|
|
||||||
|
|
||||||
[ $# -ne 1 ] && usage && exit
|
|
||||||
|
|
||||||
# If a file exists at that path, it is sourced; you can put your env vars here.
|
|
||||||
CONFIG_PATH="$HOME/.config/upload-text.conf"
|
|
||||||
[ -f "$CONFIG_PATH" ] && . "$CONFIG_PATH"
|
|
||||||
|
|
||||||
# Generate a simple HTML page from the content.
|
|
||||||
BASENAME="$(basename "$1")"
|
|
||||||
HTML_FILE="$(mktemp)"
|
|
||||||
cat << EOF > "$HTML_FILE"
|
|
||||||
<!doctype html>
|
|
||||||
<html>
|
|
||||||
<head>
|
|
||||||
<meta charset="UTF-8">
|
|
||||||
<title>$BASENAME</title>
|
|
||||||
<style>
|
|
||||||
body { max-width: 40em; }
|
|
||||||
</style>
|
|
||||||
</head>
|
|
||||||
<body>
|
|
||||||
$(cat "$1")
|
|
||||||
</body>
|
|
||||||
</html>
|
|
||||||
EOF
|
|
||||||
|
|
||||||
# Upload the HTML file through SSH. Using SSH rather than SCP allows us to write
|
|
||||||
# the file in one connection while setting appropriate rights.
|
|
||||||
REMOTE_FILE="$(mktemp -u -p "$REMOTE_WWW" XXXXXXXXXX.html)"
|
|
||||||
cat "$HTML_FILE" | ssh -q "$REMOTE_DEST" "umask 027; cat > '$REMOTE_FILE'"
|
|
||||||
rm "$HTML_FILE"
|
|
||||||
|
|
||||||
# Show the remote file path.
|
|
||||||
echo "$REMOTE_URL/$(basename "$REMOTE_FILE")"
|
|
Loading…
Reference in a new issue