scripts

misc scripts and tools
git clone git://git.2f30.org/scripts
Log | Files | Refs

commit 4a737a0c46944b9b80a013cc2a79a71f66929a25
parent a66a2ea64de28308e2e269fb562baaf56c01f782
Author: zerous Naveen Narayanan <zerous@nocebo.space>
Date:   Mon, 30 Jul 2018 21:36:55 +0300

2f30-vpn Linux support

Diffstat:
M2f30-vpn | 56+++++++++++++++++++++++++++++++++++++++++++++++++-------
1 file changed, 49 insertions(+), 7 deletions(-)

diff --git a/2f30-vpn b/2f30-vpn @@ -1,7 +1,7 @@ #!/bin/sh -e basedir=/tmp/tinc/2f30 - +os=$(uname) command -v tincd >/dev/null || { echo tincd is not installed 1>&2 exit 1 @@ -19,7 +19,7 @@ fi cat << EOF Welcome to the 2f30 VPN generation script. This script will generate the necessary tinc configuration -files for use on an OpenBSD client. +files for use on an OpenBSD/Linux client. EOF @@ -28,15 +28,48 @@ mkdir -p $basedir/hosts echo -n "Machine name (not FQDN): " read name +echo -n "IP address (ask sin@2f30.org to get one): " +read address + +if test $os = Linux; then +command -v ip >/dev/null || { + echo ip is not installed 1>&2 + exit 1 +} + +echo -n "Device (tun is the default): " +read device + +if test -z $device; then + device="tun" +fi + +cat > $basedir/tinc.conf << EOF +Name = $name +AddressFamily = ipv4 +Device = /dev/net/$device +ConnectTo = hydra +EOF + +cat > $basedir/tinc-up << EOF +ip link set \$INTERFACE up +ip addr add $address dev \$INTERFACE +EOF +chmod +x $basedir/tinc-up + +cat > $basedir/tinc-down << EOF +ip addr del $address dev \$INTERFACE +ip link set \$INTERFACE down +EOF +chmod +x $basedir/tinc-down + +elif test $os = OpenBSD; then echo -n "Device (tun0 is the default): " read device if test -z $device; then device="tun0" fi -echo -n "IP address (ask sin@2f30.org to get one): " -read address - cat > $basedir/tinc.conf << EOF Name = $name AddressFamily = ipv4 @@ -53,6 +86,9 @@ cat > $basedir/tinc-down << EOF ifconfig $device down EOF chmod +x $basedir/tinc-down +else +echo os not supported 1>&2 +fi cat > $basedir/hosts/hydra << EOF Address = vpn.2f30.org @@ -84,8 +120,13 @@ EOF echo cat << EOF -Configuration complete. Move $basedir to /etc/tinc -and adjust ownership: +Configuration complete. Move $basedir to /etc/tinc. + +EOF + +if test $os = OpenBSD; then +cat << EOF +Adjust ownership: chown -R root:_tinc /etc/tinc/2f30 @@ -107,6 +148,7 @@ interface as shown below: pass on $device EOF +fi cat << EOF There is a recursive DNS resolver on the VPN. It also acts