+---------------+ + +---------------+
| | PUB IP SSH | | |
| Home 1234 <---------------------------------------------+ piNAS |
| Server | | | |
| 33 +---------------------------------------------> 1024 |
| | Reverse SSH tunnel | | |
| | + | |
+---------------+ NAT +---------------+
ssh -f -N -p 1234 -C -R 33:localhost:1024 user@home
Last active
August 29, 2015 14:22
-
-
Save satanowski/92eb16bfa217029eab76 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
alias temp="cat /sys/bus/w1/devices/28-00000450bb38/w1_slave | tail -1 | cut -d'=' -f2" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
!/bin/bash | |
pwd=`pwd` | |
name=$(basename "$pwd") | |
arch="$name.tar.xz.gpg" | |
echo $arch | |
rm -f Thumbs.db .picasa.ini | |
tar -cf - --verbose --to-stdout \ | |
--exclude="*picasa.ini" \ | |
--exclude="*Picasa.ini" \ | |
--exclude="*Thumbs.db" \ | |
--exclude=".Trash" \ | |
--exclude=".cache" \ | |
--exclude=".DS_Store" * | \ | |
pxz -9 --threads=4 --stdout | \ | |
gpg --batch -c --cipher-algo AES256 --passphrase PASSWORD -o "../$arch" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import os, sys | |
import wiringpi2 as wi | |
from time import sleep | |
import subprocess as sub | |
try: | |
f=open('/var/run/pinas.pid', 'w') | |
if f: | |
f.write(str(os.getpid())) | |
f.close() | |
except IOError: | |
pass | |
class PiNAS(): | |
def __init__(self): | |
self.led = 27 | |
self.button = 17 | |
self._setup_pins() | |
self._led(True) | |
def _setup_pins(self): | |
wi.wiringPiSetupGpio() | |
wi.pinMode(self.led, 1) | |
wi.pinMode(self.button, 0) | |
wi.pullUpDnControl(self.button, 2) | |
def _led(self, state=False): | |
wi.digitalWrite(self.led, state and 1 or 0) | |
def _blink(self): | |
for i in range(10): | |
self._led(i % 2 > 0) | |
sleep(0.2) | |
self._led(True) | |
def _but(self): | |
return wi.digitalRead(self.button) == 0 | |
def watch(self): | |
while True: | |
if self._but(): | |
self._blink() | |
self._led(True) | |
sub.call(['shutdown', '-hP', 'now']) | |
sys.exit(0) | |
sleep(1) | |
if __name__ == '__main__': | |
pin = PiNAS() | |
pin.watch() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
find $1 -mindepth 1 -maxdepth 1 -type d | sort | while read -r dir | |
do | |
pushd "$dir" | |
~/pack.sh | |
sleep 1 | |
popd | |
done |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
LOCAL_PORT=3333 | |
REMOTE_PORT=1488 | |
SSH_PORT=1489 | |
REMOTE_HOST=home | |
REMOTE_USER=satanowski | |
ID_FILE=/home/satanowski/.ssh/id_rsa | |
COMMAND="ssh -f -N -i $ID_FILE -p $SSH_PORT -C -R $LOCAL_PORT:localhost:$REMOTE_PORT $REMOTE_USER@$REMOTE_HOST" | |
case $1 in | |
"start") | |
echo "Starting tunnel" | |
if [ -z $(pgrep -x -f "$COMMAND") ] | |
then | |
$COMMAND | |
else | |
echo "Tunnel is already ON" | |
fi | |
;; | |
"stop") | |
echo "Stopping tunnel" | |
pid=$(pgrep -x -f "$COMMAND") | |
if [ -z $pid ] | |
then | |
"Tunel is OFF - nothing to stop" | |
else | |
kill -1 $pid | |
fi | |
;; | |
"status") | |
echo -n "Tunel is: " | |
if [ -z $(pgrep -x -f "$COMMAND") ] | |
then | |
echo "OFF" | |
else | |
echo "ON" | |
fi | |
;; | |
"check") | |
if [ -z $(pgrep -x -f "$COMMAND") ] | |
then | |
$COMMAND | |
fi | |
esac |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Do not hesitate to point out my mistakes :-)