Easy-LAN-Share/share.sh

18 lines
452 B
Bash
Raw Permalink Normal View History

2021-07-21 15:39:53 +00:00
#!/bin/sh
# Get IP address
echo "Your IP address is "$(ip route get 1.1.1.1 | grep -oP 'src \K[^ ]+')
2021-07-21 15:55:44 +00:00
if [ "$#" -eq 1 ]; then
2021-07-21 16:23:37 +00:00
ln -s "$1" share # Link file to current directory
2021-07-21 15:39:53 +00:00
else
2021-07-21 15:58:34 +00:00
touch share.txt # Create the file
2021-07-21 15:39:53 +00:00
xdg-open share.txt # Open file in default editor
fi
trap 'rm share share.txt' INT # Remove files upon interrupt
2021-08-21 15:14:25 +00:00
2021-07-21 15:39:53 +00:00
# Start Python's HTTP server
echo "Press Ctrl-C to stop the server when you are done"
2021-07-21 19:05:29 +00:00
python3 -m http.server