update quicktinc

This commit is contained in:
Frieder Schlesier 2019-02-01 13:57:36 +01:00
parent 2bc57dc9d0
commit 77941e497c
2 changed files with 55 additions and 54 deletions

View File

@ -212,6 +212,7 @@ install_i3() {
libreoffice-l10n-en-gb \
network-manager-gnome \
ntfs-3g \
nmap \
pulseaudio \
rxvt-unicode-256color \
scrot \

View File

@ -26,16 +26,17 @@ Options:
--up Also start the daemon
Example:
$0 --net=demonet --node=node23 --public-ip=8.9.10.11 --private-ip=10.0.0.23 --connect-to=node1 --connect-to=node2 --up
$0 --n=demonet --o=node23 --p=8.9.10.11 --v=10.0.0.23 --c=node1 --connect-to=node2 --up
$0 --net=demonet --node=node23 --public-ip=8.9.10.11 --private-ip=10.0.0.23 --connect-to=node1 --connect-to=node2
$0 -n=demonet -o=node23 -p=8.9.10.11 -v=10.0.0.23 -c=node1 -c=node2
Report bugs to <https://github.com/j3k0/quicktinc>
"
exit 1
}
for i in "$@"
do
function parse_args() {
for i in "$@"
do
case $i in
-n=*|--net=*)
NET_NAME="${i#*=}"
@ -65,28 +66,26 @@ do
TINC_HOME="${i#*=}"
shift # past argument=value
;;
--up)
TINC_UP=YES
;;
*)
# unknown option
usage
;;
esac
done
done
if [ "_$NET_NAME" = "_" ]; then usage; fi
if [ "_$NODE_NAME" = "_" ]; then usage; fi
if [ "_$PRIVATE_IP" = "_" ]; then usage; fi
if [ "_$PUBLIC_IP" = "_" ]; then usage; fi
if [ "_$NET_NAME" = "_" ]; then usage; fi
if [ "_$NODE_NAME" = "_" ]; then usage; fi
if [ "_$PRIVATE_IP" = "_" ]; then usage; fi
if [ "_$PUBLIC_IP" = "_" ]; then usage; fi
if [ "_$INTERFACE" = "_" ]; then
if [ "_$INTERFACE" = "_" ]; then
INTERFACE=tun0
fi
fi
if [ "_$TINC_HOME" = "_" ]; then
if [ "_$TINC_HOME" = "_" ]; then
TINC_HOME=/etc/tinc
fi
fi
}
function tinc() {
docker run --rm --net=host --device=/dev/net/tun --cap-add NET_ADMIN --volume $TINC_HOME:/etc/tinc $IMAGE -n $NET_NAME "$@"
@ -127,16 +126,15 @@ EOF
}
run_container() {
# if [ "_$TINC_UP" != "_" ]; then
NAME=tinc_$NET_NAME_$NODE_NAME
docker run -d --restart=always --name=$NAME --net=host --device=/dev/net/tun --cap-add NET_ADMIN --volume $TINC_HOME:/etc/tinc $IMAGE -n $NET_NAME start -D
echo "Docker container started with name: $NAME"
# fi
}
main() {
local cmd=$1
shift
if [[ -z "$cmd" ]]; then
usage
@ -144,9 +142,11 @@ main() {
case "$cmd" in
init)
parse_args $@
init_node
;;
run)
parse_args $@
run_container
;;
esac