1. Josh VanderLinden
  2. autotunnel

Commits

Josh VanderLinden  committed f547e0f

Adding manpage; simplifying profiles

  • Participants
  • Parent commits 443ab25
  • Branches master

Comments (0)

Files changed (7)

File PKGBUILD

View file
 # Maintainer: Josh VanderLinden <arch@cloudlery.com>
 pkgname=autotunnel
-pkgver=0.2.1
+pkgver=0.3.0
 pkgrel=1
 pkgdesc="Easily create tunnels, reverse tunnels, and socks proxies"
 arch=('any')
   'systemd: preferred method of operation'
 )
 backup=(
-  'etc/autotunnel/default.conf'
+  'etc/autotunnel.d/default.conf'
   'etc/supervisor.d/autotunnel.ini'
 )
+install=autotunnel.install
 md5sums=() #generate with 'makepkg -g'
 
 package() {
   cd ..
 
-  mkdir -p ${pkgdir}/etc/autotunnel
+  mkdir -p ${pkgdir}/etc/autotunnel.d
   mkdir -p ${pkgdir}/etc/supervisor.d
   mkdir -p ${pkgdir}/usr/local/bin
   mkdir -p ${pkgdir}/usr/lib/systemd/system
+  mkdir -p ${pkgdir}/usr/share/man/man1
 
-  cp default.conf ${pkgdir}/etc/autotunnel/
+  cp default.conf ${pkgdir}/etc/autotunnel.d/
   cp autotunnel.ini ${pkgdir}/etc/supervisor.d/
   cp autotunnel ${pkgdir}/usr/local/bin/
   cp *.service ${pkgdir}/usr/lib/systemd/system/
+
+  # manpage
+  rst2man2 README.rst > autotunnel.1
+  gzip autotunnel.1
+  mkdir man1
+  mv autotunnel.1.gz ${pkgdir}/usr/share/man/man1
 }
 
 # vim:set ts=2 sw=2 et:

File README.rst

View file
+==========
+autotunnel
+==========
+
+This program is intended to make it easy to establish a single or multiple
+tunnels between your machine and another machine running SSH. It also has the
+ability to create reverse tunnels and setup a SOCKS proxy.
+
+One interesting option offered by ``autotunnel`` is that of profiles. You may
+have multiple profiles of tunnels, each to different systems with different
+settings.  All profiles should be saved in `/etc/autotunnel.d` as `.conf`
+files. For example, the default profile is `/etc/autotunnel.d/default.conf`.
+
+There are two ways to call ``autotunnel``:
+
+#. to launch and create the tunnels
+#. to kill an existing set of tunnels for a given profile
+
+Options
+=======
+
+If you run ``autotunnel`` by itself, your default profile will be launched.
+Alternatively, you may launch a specific profile as such ``autotunnel
+specific-profile``.
+
+If you wish to kill an existing set up tunnels for a given profile, you should
+use the ``-k`` parameter before the profile name::
+
+    autotunnel -k specific-profile
+
+Start Tunnels Automatically at Boot
+===================================
+
+.. important::
+
+    It's very important that you setup pre-shared key (PSK) authentication
+    between your local system and the remote systems you plan to establish
+    tunnels with if you want the tunnels to activate at boot time. You'll want
+    to setup PSK authentication for your local `root` user to the remote
+    system(s). Alternatively, you may edit the ``systemd`` unit files or
+    ``supervisord`` configuration files to launch the tunnels as a user of your
+    choice.
+
+    Setting up pre-shared key authentication is easy to do, and the Internet
+    will be of much help to you if you're unfamiliar with it. However, I'll
+    give a quick overview. As root, type this command::
+
+        ssh-keygen
+
+    Accept all defaults. Now copy your public key to the remote host. Again, as
+    root, run this command::
+
+        ssh-copy-id remote_user@remote_host
+
+    Obviously, replace `remote_user` and `remote_host` with the appropriate
+    information. Then enter the password for `remote_user` on `remote_host`. If
+    all went well, you should now be able to SSH into `remote_host` as
+    `remote_user` without entering a password. If not, Google is your friend.
+
+systemd
+-------
+
+You have two options for starting the tunnels automatically at boot time. The
+first, and recommended solution, is to use ``systemd``. All you need to do is
+run the following command as root, and the tunnels defined in your default
+profile will be established the next time you reboot.
+
+::
+
+    systemctl enable autotunnel
+
+If you wish to have a specific tunnel profile launch at boot time, simply use
+the template unit file::
+
+    systemctl enable autotunnel@profile
+
+supervisord
+-----------
+
+If you're using ``supervisord``, you should be good to go automatically,
+assuming your system is configured to read `.ini` files from
+`/etc/supervisor.d`. A configuration file for the default profile should be
+installed there by default. If you wish for other profiles to be launched
+automatically, copy this file and replace this line::
+
+    command=/usr/local/bin/autotunnel default
+
+With::
+
+    command=/usr/local/bin/autotunnel specific-profile

File autotunnel

View file
 
 get_config() {
   CONFIG=$1
-  [[ -z ${CONFIG} ]] && CONFIG=/etc/autotunnel/default.conf
-  [[ ! -f ${CONFIG} ]] && echo "Invalid configuration file ${CONFIG}" && exit 1
+  if [[ -z ${CONFIG} ]]; then
+    CONFIG=/etc/autotunnel/default.conf
+  fi
 
-  echo "Reading config from ${CONFIG}"
-  source ${CONFIG}
+  CFGFILE=/etc/autotunnel.d/${CONFIG}.conf
+  [[ ! -f ${CFGFILE} ]] && echo "Invalid configuration file ${CFGFILE}" && exit 1
+
+  echo "Reading config from ${CFGFILE}"
+  source ${CFGFILE}
 }
 
 if [[ "$1" == "-k" ]]; then
 [[ ! -z ${DEBUG} ]] && echo ${CMD}
 
 $CMD
+
+# vim:set ts=2 sw=2 et:

File autotunnel.ini

View file
 [program:Tunnel]
-command=/usr/local/bin/autotunnel /etc/autotunnel/default.conf
+command=/usr/local/bin/autotunnel default
 numprocs=1
 autostart=true
 autorestart=true

File autotunnel.install

View file
+pre_install() {
+  [[ -d /etc/autotunnel ]] && mv /etc/autotunnel{,.d}
+}
+
+pre_upgrade() {
+  pre_install
+}
+
+# vim:set ts=2 sw=2 et:

File autotunnel.service

View file
 [Service]
 Type=simple
 Restart=restart-always
-ExecStart=/usr/local/bin/autotunnel /etc/autotunnel/default.conf
-ExecStop=/usr/local/bin/autotunnel -k /etc/autotunnel/default.conf
+ExecStart=/usr/local/bin/autotunnel default
+ExecStop=/usr/local/bin/autotunnel -k default
 
 [Install]
 WantedBy=multi-user.target

File autotunnel@.service

View file
 [Service]
 Type=simple
 Restart=restart-always
-ExecStart=/usr/local/bin/autotunnel /etc/autotunnel/%i.conf
-ExecStop=/usr/local/bin/autotunnel -k /etc/autotunnel/%i.conf
+ExecStart=/usr/local/bin/autotunnel %i
+ExecStop=/usr/local/bin/autotunnel -k %i
 
 [Install]
 WantedBy=multi-user.target