-
Notifications
You must be signed in to change notification settings - Fork 0
/
run-file-server.sh
executable file
·64 lines (53 loc) · 1.88 KB
/
run-file-server.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
#!/usr/bin/env bash
# all of these stem from https://www.shellcheck.net/wiki/
set -o pipefail # propagate errors
set -u # exit on undefined
set -e # exit on non-zero return value
#set -f # disable globbing/filename expansion
shopt -s failglob # error on unexpaned globs
shopt -s inherit_errexit # Bash disables set -e in command substitution by default; reverse this behavior
kernel="$(uname)"
iptables_filename=/etc/iptables/iptables.rules
trap cleanup EXIT
cleanup () {
if [ "$kernel" = Linux ]; then
set -x
sudo systemctl stop tailscaled
sudo pkill ssh
# @TODO delete rule instead of restarting?
# [root@frame ~]# nft add rule ip filter TCP tcp dport 80 accept
# [root@frame ~]# nft -a list chain ip filter TCP
# table ip filter {
# chain TCP { # handle 4
# tcp dport 80 accept # handle 31
# }
# }
# [root@frame ~]# nft delete rule ip filter TCP handle 31
sudo systemctl restart nftables
set +x
fi
sudo -k
set +x
}
if [ "$kernel" = Darwin ]; then
# default lima port 60906
# colima port: "$( grep Port ~/.colima/ssh_config | awk '{ print $2 }' )"
#
# forward tailscale ip port 80 to localhost (lima vm)
port="$(./run-file-server-extract.sh port)"
id_file="$(./run-file-server-extract.sh id_file)"
set -x
sudo ssh -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null -p "${port}" -f -NT -L podcast-svc-org:80:localhost:10080 lima@localhost -i "$id_file"
elif [ "$kernel" = Linux ]; then
set -x
sudo systemctl start tailscaled
sudo ssh -NT -f -i ~/.ssh/podman-remote -L frame:80:localhost:10080 "$USER"@localhost
nft add rule ip filter TCP tcp dport 80 accept
else
exit 1
fi
bash ~/Documents/scripts/bin/darwin/docker run --rm --name blub -p 10080:8080 \
-v "$PWD"/etc/nginx/conf.d/default.conf:/etc/nginx/conf.d/default.conf \
-v "$PWD":/data \
-it \
docker.io/library/nginx:1.25.5-alpine