From 61a0f33939b937588224abf00ec609e748e05bd2 Mon Sep 17 00:00:00 2001 From: dennisdebel Date: Sun, 27 Jul 2014 22:31:13 +0200 Subject: [PATCH 1/8] Update README.md small swap fstab error --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 85e0cb0..5678180 100644 --- a/README.md +++ b/README.md @@ -86,7 +86,7 @@ Edit fstab again now make the swap look like this: ``` config mount option device /dev/sda2 - option enabled + option enabled 1 ``` ### Wireless configuration From fb7708cf94423daf1eb1736871acb8529141a905 Mon Sep 17 00:00:00 2001 From: dennisdebel Date: Sun, 27 Jul 2014 22:41:09 +0200 Subject: [PATCH 2/8] Update README.md pff default is 1... --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 5678180..2f91e88 100644 --- a/README.md +++ b/README.md @@ -86,7 +86,7 @@ Edit fstab again now make the swap look like this: ``` config mount option device /dev/sda2 - option enabled 1 + option enabled ``` ### Wireless configuration From a0369fff167d3aa447f44f6eb5142c17c60acb25 Mon Sep 17 00:00:00 2001 From: dennisdebel Date: Wed, 30 Jul 2014 12:25:22 +0200 Subject: [PATCH 3/8] Added instructions For running a python script as service/on boot --- README.md | 71 ++++++++++++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 70 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 2f91e88..bb2647f 100644 --- a/README.md +++ b/README.md @@ -277,7 +277,6 @@ Restart dnsmasq to apply the changes: Now all http requests will be directed to Meshenger! - ### Installing meshenger Get the dependencies and clone the git @@ -285,3 +284,73 @@ Get the dependencies and clone the git `$ opkg install python git ` `$ git clone git://github.com/jngrt/meshenger.git ` + + +### Running Meshenger on Boot + +To launch the Meshenger script (or python script in this case), we have to run it as a 'Service'. +Befor we can do so we need to know some variable. + +# Path to python +Find out where your Python binary is located: + +```$ which python``` + +This command outputs your path, for example: ` /usr/bin/python`, remember this path + +# Boot order +Alot of processes are started at boot, and we want to make sure our script runs after the system has booted completely. To find out the boot order, look in the rc.d folder: + +```$ ls /etc/rc.d``` + +This will output a list of startup sctipts with prefixes like S10-, S20-, S30-. The numbers define the boot order, the higher, the later. Remember the highest 'S'(cript) number. We need to run our script after the last one. + + +# Startup script +Create a new file in `/etc/init.d/` + +```$ vi /etc/init.d/meshenger``` + +And paste the script below and correct your path to pyton and boot order number, both found above. + +``` +#!/bin/sh /etc/rc.common +#meshenger startup script + +START=99 #the boot order number, note in our case the SAME number as the highest one found. +SERVICE_DAEMONIZE=1 #start as service, important! + +start(){ + sleep 10 #make sure booting is finished + echo 'starting meshenger' + /usr/bin/python /root/meshenger/main.py & #path to python binary, space, full path to your script + + +} + + +stop(){ + echo 'stopping meshenger' + killall python +} + +``` + +Make sure both your script (main.py) and the init.d script are executable! + +```$ chmod +x /etc/init.d/meshenger``` +```$ chmod +x /root/meshenger/main.py``` + + + +# Enabling the service +Now we have to activate the script we just pasted and make it run as service, on every (re)boot. + +```$ /etc/init.d/meshenger enable``` + +This creates a symlink in `/etc/rc.d` with the boot order number prefix you provided in the init.d script (S99-meshenger). You can also start and stop the service manually with: + +```$ /etc/init.d/meshenger start``` +```$ /etc/init.d/meshenger stop``` + +That's all, reboot and see if it works ( `$ ps | grep python` )! From 3c90a86c5fc3f08bad68df27245ec9a90805cac3 Mon Sep 17 00:00:00 2001 From: dennisdebel Date: Wed, 30 Jul 2014 12:27:36 +0200 Subject: [PATCH 4/8] markdown correction --- README.md | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index bb2647f..30bf310 100644 --- a/README.md +++ b/README.md @@ -291,14 +291,14 @@ Get the dependencies and clone the git To launch the Meshenger script (or python script in this case), we have to run it as a 'Service'. Befor we can do so we need to know some variable. -# Path to python +#### Path to python Find out where your Python binary is located: ```$ which python``` This command outputs your path, for example: ` /usr/bin/python`, remember this path -# Boot order +#### Boot order Alot of processes are started at boot, and we want to make sure our script runs after the system has booted completely. To find out the boot order, look in the rc.d folder: ```$ ls /etc/rc.d``` @@ -306,7 +306,7 @@ Alot of processes are started at boot, and we want to make sure our script runs This will output a list of startup sctipts with prefixes like S10-, S20-, S30-. The numbers define the boot order, the higher, the later. Remember the highest 'S'(cript) number. We need to run our script after the last one. -# Startup script +#### Startup script Create a new file in `/etc/init.d/` ```$ vi /etc/init.d/meshenger``` @@ -343,7 +343,7 @@ Make sure both your script (main.py) and the init.d script are executable! -# Enabling the service +#### Enabling the service Now we have to activate the script we just pasted and make it run as service, on every (re)boot. ```$ /etc/init.d/meshenger enable``` From b7459cfee3c14b6a96e1b9248487ddb595a026b7 Mon Sep 17 00:00:00 2001 From: dennisdebel Date: Sat, 16 Aug 2014 22:19:40 +0200 Subject: [PATCH 5/8] added instructions for remote ssh access --- README.md | 41 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 41 insertions(+) diff --git a/README.md b/README.md index 30bf310..b488936 100644 --- a/README.md +++ b/README.md @@ -354,3 +354,44 @@ This creates a symlink in `/etc/rc.d` with the boot order number prefix you prov ```$ /etc/init.d/meshenger stop``` That's all, reboot and see if it works ( `$ ps | grep python` )! + + + +### SSH Access from Internet (wan) + +If you want, you can hook your box up to the internet and manage it remotely. This is not in the scope of this project but I'll share the steps with you: + +#### Configure your firewall + + +``` +$ vi /etc/config/firewall + + +config 'rule' + option 'src' 'wan' + option 'dest_port' '22' + option 'target' 'ACCEPT' + option 'proto' 'tcp' + + +$ /etc/init.d/firewall restart + +``` + +#### Configure open ssh service + +Add the line below in your dropbear config + +``` +$ vi /etc/config/dropbear + + +option 'GatewayPorts' 'on' + + +$ /etc/init.d/dropbear restart + +``` +Now you can acces your router, via ssh, from the internet. +Next up, http access from the internet! From 6517baed2c90b18b7ac0fdd9d0927ed2bd049cba Mon Sep 17 00:00:00 2001 From: dennisdebel Date: Sat, 16 Aug 2014 22:29:21 +0200 Subject: [PATCH 6/8] added more instructions --- README.md | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/README.md b/README.md index b488936..e9b93fb 100644 --- a/README.md +++ b/README.md @@ -379,6 +379,23 @@ $ /etc/init.d/firewall restart ``` +Enable user iptable script: + + +``` +$ vi vi /etc/firewall.user + + +iptables -t nat -A prerouting_wan -p tcp --dport 22 -j ACCEPT +iptables -A input_wan -p tcp --dport 22 -j ACCEPT + + + +$ /etc/init.d/firewall restart + +``` + + #### Configure open ssh service Add the line below in your dropbear config From 810edef1759556311da3e3fe120bf7ba1d0ef4d3 Mon Sep 17 00:00:00 2001 From: dennisdebel Date: Sat, 16 Aug 2014 22:55:10 +0200 Subject: [PATCH 7/8] tips --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index e9b93fb..aaac0f8 100644 --- a/README.md +++ b/README.md @@ -410,5 +410,5 @@ option 'GatewayPorts' 'on' $ /etc/init.d/dropbear restart ``` -Now you can acces your router, via ssh, from the internet. +Now you can acces your router, via ssh, from the internet. Don't forget to add portforwarding on you're modem/router! Next up, http access from the internet! From 38d6147381b1b40089009cd17a8aab6ab7f8f65f Mon Sep 17 00:00:00 2001 From: dennisdebel Date: Fri, 22 Aug 2014 12:40:08 +0200 Subject: [PATCH 8/8] Update README.md --- README.md | 42 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 42 insertions(+) diff --git a/README.md b/README.md index aaac0f8..cf4a4ee 100644 --- a/README.md +++ b/README.md @@ -412,3 +412,45 @@ $ /etc/init.d/dropbear restart ``` Now you can acces your router, via ssh, from the internet. Don't forget to add portforwarding on you're modem/router! Next up, http access from the internet! + + +### HTTP Access from Internet (wan) + +If you want, you can host Meshenger or your own homepage on the internet. This is not in the scope of this project but I'll share the steps with you: + +#### Configure your firewall + +Add the following lines in your firewall config, and restart the firewall: + + +``` +$ vi /etc/config/firewall + + + +config 'redirect' + option 'src' 'wan' + option 'src_dport' '80' + option 'dest' 'lan' + option 'dest_ip' '192.168.1.1' + option 'dest_port' '80' + option 'proto' 'tcp' + +config 'rule' + option 'src' 'wan' + option 'dest_port' '80' + option 'target' 'ACCEPT' + option 'proto' 'tcp' + + + +$ /etc/init.d/firewall restart +``` + +Now either run Meshenger, or run a simple http server (to share files, or whatever) from any directory with this Python oneliner: + +``` python -m SimpleHTTPServer 80 ``` + + +After forwarding the correct ports on your home router/modem (from any ip on port 80 to your openwrt box (lan) ip on port 80) your website will now be accessible from outside (wan) through your external IP! +