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 \ libreoffice-l10n-en-gb \
network-manager-gnome \ network-manager-gnome \
ntfs-3g \ ntfs-3g \
nmap \
pulseaudio \ pulseaudio \
rxvt-unicode-256color \ rxvt-unicode-256color \
scrot \ scrot \

View File

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