#!/bin/bash
### This script installs a service that checks and maintains 
### the VPN connection.
### The name of the service is cs_vpn_connection, however it is
### displayed on the service list as "ShrewVPN Connection to CS."
### The script that is executed is 'C:\Tools\vpn_connect_cs.sh'
### and it will take the arguments '-r CS -a' (which means that 
### it will start the connection named CS, automatically). 
### The description of this service on the service list will be
### "Opens the VPN connection to the CS". 
### This service depends on the services: ipsecd, iked, dtpd, and netman,
### so, before starting, it will wait for them to be started first.
### The option 'preshutdown' means that the windows will notify 
### the service when the system prepares to shut down.
### The 'user' option tells the system to run this service (command)
### with the same credentials as the user 'Administrator'
### (cygrunsrv is going to ask for the password of this user).

cygrunsrv --install cs_vpn_connection --disp "ShrewVPN Connection to CS." \
          --path "/cygdrive/c/Tools/vpn_connect_cs.sh" --args "-r CS -a"  \
          --desc "Opens the VPN connection to the CS."                    \
          --dep ipsecd --dep iked --dep dtpd --dep netman                 \
          --preshutdown --user Administrator
          
          