aboutsummaryrefslogtreecommitdiffstats
path: root/scripts/qs
blob: afc998f4528599f2ff1a17aed3493c6a0a410f75 (plain)
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
#!/bin/bash

PORT=8000

cat <<EOF
Quickshare (qs)
###############

Will run (port is optional and = 8000 by default):

    python3 -m SimpleHTTPServer ${PORT}

Or, if python3 is not installed on the host:

    python -m SimpleHTTPServer ${PORT}

Depending on the current lan configuration,
you can access files by going to either:

    http://${HOSTNAME}.local:${PORT}/
    http://${HOSTNAME}:${PORT}/
EOF

for ipv4 in $(ip -oneline -family inet address show \
    | sed 's/^.*inet \([0-9.]\+\).*$/\1/'); do
    echo "    http://${ipv4}:${PORT}/"
done

for ipv6 in $(ip -oneline -family inet6 address show \
    | sed 's/^.*inet6 \([0-9:a-fA-F]\+\).*$/\1/'); do
    echo "    http://[${ipv6}]:${PORT}/"
done

echo ""
echo "=================================================="

[ -e /usr/bin/python3 ] && \
    python3 -m http.server 8000 || \
    python2 -m SimpleHTTPServer 8000