Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/bin/bash
- #
- # Requires Zenity to handle GUI output. Creates a GUI walkthrough to use the built-in
- # HTTP server in Python for simple sharing on a LAN. SECURE YOUR NETWORKS.
- # Run this script a second time to kill the server via killall.
- # Take out the gksudo portion if you need to
- running=$(ps aux | grep -c "python -m SimpleHTTPServer")
- # my copy of grep always returns itself, hence it must be greater than 1. Adjust as needed.
- if [ "$running" -gt "1" ];then
- #this is inelegant as all hell, but I can't think of another way if it's running in the bg that can be handled from a GUI interface.
- gksudo killall python -m SimpleHTTPServer
- notify-send --icon=notification-network-wireless-disconnected "Stopped simple sharing."
- else
- ans=`$(zenity --question --text "This will start a local webserver; to kill it, run this script again. Please choose your directory to share in the next step. Do you wish to continue?"); echo $?`
- if [ "$ans" -lt "1" ]; then
- rawfile=$(zenity --file-selection "--directory" --separator="*" --multiple)
- localip=$(ifconfig | grep -e addr: | grep -e Bcast | awk '{print $2}'| awk -F ":" '{print $2}')
- cd $rawfile
- zenity --info --text "This script will start a webserver at $localip on port 8000 showing directory $rawfile."
- notify-send --icon=notification-network-wireless-full "Serving $rawfile on port 8000"
- python -m SimpleHTTPServer &
- fi
- fi
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement