Add nginx public share stuff - should probably move some stuff to ansible?

This commit is contained in:
Daniel Flanagan 2022-02-01 17:10:13 -06:00
parent 5acb13e483
commit 4527c3c87c
Signed by: lytedev
GPG key ID: 5B2020A0F9921EF4
13 changed files with 240 additions and 78 deletions

View file

@ -9,20 +9,20 @@ dfp="$(realpath "$(dirname "$0")"/../..)"
detect_os() {
# NixOS
if head /etc/os-release --lines 1 | grep 'NixOS$' >/dev/null 2>&1; then
ln -s "$dfp/os/linux/nix" "$ENV_PATH/os-linux-nix" >/dev/null 2>&1
if head /etc/os-release --lines 1 | grep 'NixOS$' > /dev/null 2>&1; then
ln -s "$dfp/os/linux/nix" "$ENV_PATH/os-linux-nix" > /dev/null 2>&1
return
fi
# Arch Linux
if head /etc/os-release --lines 1 | grep 'Arch Linux' >/dev/null 2>&1; then
ln -s "$dfp/os/linux/arch" "$ENV_PATH/os-linux-arch" >/dev/null 2>&1
if head /etc/os-release --lines 1 | grep 'Arch Linux' > /dev/null 2>&1; then
ln -s "$dfp/os/linux/arch" "$ENV_PATH/os-linux-arch" > /dev/null 2>&1
return
fi
# Pacman-based
if command -v pacman; then
ln -s "$dfp/os/linux/arch" "$ENV_PATH/os-linux-arch" >/dev/null 2>&1
ln -s "$dfp/os/linux/arch" "$ENV_PATH/os-linux-arch" > /dev/null 2>&1
return
fi
@ -32,12 +32,12 @@ detect_os() {
exit 3
}
if command -v git >/dev/null 2>&1; then
if command -v git > /dev/null 2>&1; then
if [ -f "$dfp/common/envs" ]; then
# TODO: more shared init stuff?
mkdir -p $ENV_PATH
mkdir -p "$ENV_PATH"
detect_os
ls -la -R $ENV_PATH/*
ls -la -R "$ENV_PATH/*"
find "$ENV_PATH" | while read -r s; do
f="$s/dotfiles-init.d.sh"
if [ -f "$f" ]; then
@ -48,7 +48,10 @@ if command -v git >/dev/null 2>&1; then
$dfp/common/bin/dotfiles-setup
else
git clone "https://git.lyte.dev/lytedev/dotfiles.git" "$XDG_CONFIG_HOME/lytedev-dotfiles"
cd "$XDG_CONFIG_HOME/lytedev-dotfiles" || { echo "Could not cd to dotfiles dir"; exit 2; }
cd "$XDG_CONFIG_HOME/lytedev-dotfiles" || {
echo "Could not cd to dotfiles dir"
exit 2
}
. ./common/bin/dotfiles-init
fi
else

View file

@ -22,3 +22,4 @@ host/laptop/postmates-macbook
host/laptop/uber-macbook
host/laptop/val-macbook
host/layer/personal
host/layer/nginx-user-public

View file

@ -142,7 +142,7 @@ alias cdltl "cd (ltld)"
alias p "ping 8.8.8.8"
function pp --description "Keeps trying to ping 8.8.8.8 forever"
while not ping -n 1 -t 5 8.8.8.8
while not ping -n 1 -w 5 8.8.8.8
sleep 1
end
end

View file

@ -25,4 +25,6 @@ else if command --search --quiet vi
set --export --universal VISUAL vi
end
set --export --universal SOPS_AGE_KEY_FILE "$XDG_CONFIG_HOME/sops/age/keys.txt"
# has_command fd && set -Ux FZF_DEFAULT_COMMAND 'fd --type f --hidden --follow --exclude .git'

View file

@ -3,7 +3,7 @@
htop_version=3.1.2
config_reader_min_version=2
fields=0 48 17 18 38 39 40 2 46 47 49 1
sort_key=47
sort_key=46
sort_direction=-1
tree_sort_key=0
tree_sort_direction=1

View file

@ -1,5 +1,5 @@
{
"coc.preferences.formatOnSaveFiletypes": ["elixir", "ex", "exs", "typescript", "css", "markdown"],
"coc.preferences.formatOnSaveFiletypes": ["elixir", "ex", "exs", "typescript", "css", "markdown", "sh", "bash"],
"languageserver": {
"nim": {
"command": "nimlsp",
@ -17,9 +17,55 @@
},
"elixir.pathToElixirLS": "~/.elixir-ls/release/language_server.sh",
"rust-analyzer.checkOnSave.command": "clippy",
"diagnostic-languageserver.filetypes": {
"diagnostic-languageserver": {
"enable": true,
"mergeConfig": true,
"linters": {
"shellcheck": {
"command": "shellcheck",
"debounce": 100,
"args": [
"-x",
"--format",
"json1",
"-"
],
"sourceName": "shellcheck",
"parseJson": {
"errorsRoot": "comments",
"line": "line",
"column": "column",
"endLine": "endLine",
"endColumn": "endColumn",
"message": "${message} [${code}]",
"security": "level"
},
"securities": {
"error": "error",
"warning": "warning",
"info": "info",
"style": "hint"
}
}
},
"filetypes": {
"elixir": ["mix_credo", "mix_credo_compile"],
"eelixir": ["mix_credo", "mix_credo_compile"]
"eelixir": ["mix_credo", "mix_credo_compile"],
"sh": "shellcheck",
"bash": "shellcheck"
},
"formatters": {
"shfmt": {
"command": "shfmt",
"args": ["-i", "2", "-bn", "-ci", "-sr", "-kp"]
}
},
"formatFiletypes": {
"elixir": "mix_format",
"eelixir": "mix_format",
"sh": "shfmt",
"bash": "shfmt"
}
}
}

View file

@ -1,26 +1,28 @@
unbind C-b
set -g prefix C-s
bind-key s send-prefix
bind s send-prefix
bind-key v split-window -h
bind-key b split-window
bind-key T source-file "$HOME/.tmux.conf" \; display-message "Reloaded $HOME/.tmux.conf"
bind-key O display-message "#(tmux-save-buffer '#S')"
bind-key H set -s status
bind-key -n C-l select-pane -R
bind-key -n C-k select-pane -U
bind-key -n C-j select-pane -D
bind-key -n C-h select-pane -L
bind-key -n C-t new-window
bind-key Tab next-window
bind-key -n C-Tab next-window
bind-key -n C-S-Tab previous-window
bind v split-window -h
bind b split-window
bind T source-file "$HOME/.tmux.conf" \; display-message "Reloaded $HOME/.tmux.conf"
bind O display-message "#(tmux-save-buffer '#S')"
bind D attach-session -t . -c '#{pane_current_path}' \; display-message "Set session path to #{pane_current_path}"
bind H set -s status
bind -n C-l select-pane -R
bind -n C-k select-pane -U
bind -n C-j select-pane -D
bind -n C-h select-pane -L
bind -n C-t new-window
bind Tab next-window
bind -n C-Tab next-window
bind -n C-S-Tab previous-window
bind s run "tmux split-window -l 12 'tmuxswitcher'"
bind M-l source-file "$XDG_CONFIG_HOME/tmux/layouts/dev.tmux"
set -g update-environment "WAYLAND_DISPLAY DISPLAY"
# TODO: check if kitty is installed?
set -g default-terminal "kitty"
set -g mouse on
set -g escape-time 0
@ -42,7 +44,11 @@ set -g window-status-separator ""
set -g window-status-current-format " #W"
set -g status-left "#h:#S #W"
set -g status-right-length 280
set -g status-right "#(kubeline && printf ' ')#{pane_current_path} #(cd '#{pane_current_path}' && git rev-parse --abbrev-ref --sq HEAD | tr -d \"'\")#{pane_current_command}"
set -g status-right "#(kubeline && printf ' ')"
set -ag status-right "#(pwd | $XDG_CONFIG_HOME/lytedev-dotfiles/common/bin/glancepath) "
set -ag status-right "#(cd '#{pane_current_path}' && git rev-parse --abbrev-ref --sq HEAD | tr -d \"'\")"
set -ag status-right "#{pane_current_command}"
set -g message-style "fg=colour7 bg=colour18"
set -g pane-active-border-style bg=black,fg=blue
set -g pane-border-style bg=black,fg=colour18
@ -54,29 +60,27 @@ set -g window-status-current-format ""
# present a menu of urls to open from the visible pane
# TODO: fzf-ify this
bind-key u capture-pane \;\
save-buffer /tmp/tmux-buffer \;\
split-window -l 10 "urlscan /tmp/tmux-buffer"
# bind u capture-pane \;\
# save-buffer /tmp/tmux-buffer \;\
# split-window -l 10 "urlscan /tmp/tmux-buffer"
bind-key -T copy-mode-vi "y" send-keys -X copy-pipe-and-cancel 'wl-copy'
bind-key -T copy-mode-vi MouseDragEnd1Pane send-keys -X copy-pipe-and-cancel 'wl-copy'; \
bind -T copy-mode-vi "y" send-keys -X copy-pipe-no-clear 'wl-copy' \; display-message 'Copied to clipboard!'
bind -T copy-mode-vi MouseDragEnd1Pane send-keys -X copy-pipe-no-clear 'wl-copy' \; display-message 'Copied to clipboard!'
bind-key K kill-pane
bind-key C-S-k kill-window
bind K kill-pane
bind C-S-k kill-window
# TODO: handle tmux nesting by being able to toggle the prefix (and indicate in status bar?)
# bind -T root F12 \
# set prefix None \;\
# set key-table off \;\
# set status off \
# if -F "#{pane_in_mode}" "send-keys -X cancel" \;\
# refresh-client -S \;\
# TODO: styles after `set -u key-table`
#if -F '#{pane_in_mode}' 'send-keys -X cancel' \;\
bind -T root F12 set -g prefix None \; set -g key-table off \; display-message "Keys OFF" \; refresh-client -S
# bind -T off F12 \
# set -u prefix \;\
# set -u key-table \;\
# set status on \;\
# refresh-client -S
# TODO: styles after `set -u key-table`
bind -T off F12 \
set -g -u prefix \;\
set -g -u key-table \;\
display-message "Keys ON" \;\
refresh-client -S
source-file "$ENV_PATH/*/tmux.d.conf"

View file

@ -0,0 +1 @@
</body>

View file

@ -0,0 +1,60 @@
<!doctype html>
<head>
<meta charset="utf-8"/>
<meta name="viewport" content="width=device-width, initial-scale=1"/>
<style>
*, *::before, *::after {
margin: 0;
padding: 0;
box-sizing: border-box;
}
@font-face {
font-family: 'IosevkaLyte';
font-display: swap;
font-weight: 400;
font-stretch: normal;
font-style: normal;
src: url('https://files.lyte.dev/iosevkalyte/woff2/iosevkalyte-regular.woff2') format('woff2'), url('https://files.lyte.dev/iosevkalyte/ttf/iosevkalyte-regular.ttf') format('truetype');
}
@media (prefers-color-scheme: dark) {
html {
color: #fff;
background-color: #111;
}
a {
color: #0af;
}
a:visited {
color: #faf;
}
}
html {
font-family: IosevkaLyte;
}
pre, code {
font: inherit;
}
a {
display: inline-block;
padding: 0.15em 0;
}
hr {
display: none;
}
h1, pre {
display: block;
max-width: 800px;
margin: 0.5em auto;
}
</style>
</head>
<body>

View file

@ -0,0 +1,11 @@
#!/usr/bin/env fish
set me (status -f)
set dfp $argv[1]
set h $argv[2]
set c $argv[3]
pushd (dirname $me)
sudo ln -s (pwd)/user-public-http.conf /etc/nginx/user-public-http.conf
sudo ln -s (pwd)/user-public-server.conf /etc/nginx/user-public-server.conf
sudo ln -s (pwd)/.nginx-autoindex-before.html /usr/share/nginx/html/.nginx-autoindex-before.html
sudo ln -s (pwd)/.nginx-autoindex-after.html /usr/share/nginx/html/.nginx-autoindex-after.html

View file

@ -0,0 +1,13 @@
disable_symlinks off;
# for wasm games
types {
application/octet-stream clr;
application/octet-stream pdb;
}
gzip on;
gzip_min_length 10240;
gzip_proxied expired no-cache no-store private auth;
gzip_types text/plain text/css text/xml text/javascript application/x-javascript application/json application/xml application/wasm;
gzip_disable msie6;

View file

@ -0,0 +1,13 @@
# need CORS?
# location ~* \.(eot|ttf|woff|woff2)$ {
# add_header Access-Control-Allow-Origin *;
# }
location ~ ^/~(.+?)(/.*)?$ {
disable_symlinks off;
alias /home/$1/public$2;
index index.html index.htm;
autoindex on;
add_before_body "/.nginx-autoindex-before.html";
add_after_body "/.nginx-autoindex-after.html";
}

View file

@ -0,0 +1,8 @@
#!/usr/bin/env fish
set me (status -f)
set dfp $argv[1]
set h $argv[2]
set c $argv[3]
pushd (dirname $me)
# l app $c/app