mirror of
https://github.com/sshuttle/sshuttle.git
synced 2024-12-02 12:54:08 +01:00
76 lines
1.6 KiB
Plaintext
76 lines
1.6 KiB
Plaintext
|
description "Create a tunnel over SSH proxy"
|
||
|
author "Jim Wyllie <jwyllie83@gmail.com>"
|
||
|
|
||
|
manual
|
||
|
nice -5
|
||
|
|
||
|
# Edit this file with network prefixes that should be loaded through the SSH
|
||
|
# tunnel.
|
||
|
env PREFIX_LOCATION=/etc/sshuttle/prefixes.conf
|
||
|
|
||
|
# Try all the keys in a given key directory
|
||
|
env KEY_LOCATION=/etc/sshuttle/keys
|
||
|
|
||
|
# Routing table; defaults to 100
|
||
|
env ROUTE_TABLE=100
|
||
|
|
||
|
# fwmark; defaults to 1
|
||
|
env FWMARK=1
|
||
|
|
||
|
start on (local-filesystems and net-device-up IFACE!=lo)
|
||
|
stop on stopping network-services
|
||
|
|
||
|
#respawn
|
||
|
|
||
|
pre-start script
|
||
|
# Make sure we have created the routes
|
||
|
sudo ip rule add fwmark ${FWMARK} lookup ${ROUTE_TABLE}
|
||
|
logger "Starting sshuttle..."
|
||
|
|
||
|
if [ -f "${PREFIX_LOCATION}" ]; then
|
||
|
cat "${PREFIX_LOCATION}" | while read ROUTE; do
|
||
|
|
||
|
logger "Working on route: ${ROUTE}"
|
||
|
|
||
|
# Skip comments
|
||
|
if [ -n "$(echo ${ROUTE} | egrep "^[ ]*#")" ]; then
|
||
|
continue
|
||
|
fi
|
||
|
|
||
|
# Skip empty lines
|
||
|
if [ -z "${ROUTE}" ]; then
|
||
|
continue
|
||
|
fi
|
||
|
|
||
|
logger "Adding route command: ip route add local ${ROUTE} dev lo table ${ROUTE_TABLE}"
|
||
|
ip route add local ${ROUTE} dev lo table ${ROUTE_TABLE}
|
||
|
done
|
||
|
fi
|
||
|
end script
|
||
|
|
||
|
post-stop script
|
||
|
if [ -f "${PREFIX_LOCATION}" ]; then
|
||
|
cat "${PREFIX_LOCATION}" | while read ROUTE; do
|
||
|
|
||
|
logger "Working on route: ${ROUTE}"
|
||
|
|
||
|
# Skip comments
|
||
|
if [ -n "$(echo ${ROUTE} | egrep "^[ ]*#")" ]; then
|
||
|
continue
|
||
|
fi
|
||
|
|
||
|
# Skip empty lines
|
||
|
if [ -z "${ROUTE}" ]; then
|
||
|
continue
|
||
|
fi
|
||
|
|
||
|
logger "Deleting route command: ip route del local ${ROUTE} dev lo table ${ROUTE_TABLE}"
|
||
|
ip route del local ${ROUTE} dev lo table ${ROUTE_TABLE}
|
||
|
done
|
||
|
fi
|
||
|
|
||
|
ip rule del fwmark ${FWMARK}
|
||
|
end script
|
||
|
|
||
|
exec sleep 60
|