From 45272a19a21f1f308a7aa5c73926939ead990914 Mon Sep 17 00:00:00 2001 From: Teddysun Date: Wed, 7 Nov 2018 21:17:07 +0900 Subject: [PATCH] Update comments Signed-off-by: Teddysun --- docker/l2tp/l2tp.sh | 9 ++------- docker/l2tp/l2tpctl.sh | 9 ++------- 2 files changed, 4 insertions(+), 14 deletions(-) diff --git a/docker/l2tp/l2tp.sh b/docker/l2tp/l2tp.sh index 1ad0609..3be44e1 100644 --- a/docker/l2tp/l2tp.sh +++ b/docker/l2tp/l2tp.sh @@ -1,4 +1,4 @@ -#!/bin/bash +#!/bin/sh PATH=/bin:/sbin:/usr/bin:/usr/sbin:/usr/local/bin:/usr/local/sbin:~/bin export PATH # @@ -23,12 +23,7 @@ fi ip link delete dummy0 >/dev/null 2>&1 rand(){ - index=0 - str="" - for i in {a..z}; do arr[index]=${i}; index=$(expr ${index} + 1); done - for i in {A..Z}; do arr[index]=${i}; index=$(expr ${index} + 1); done - for i in {0..9}; do arr[index]=${i}; index=$(expr ${index} + 1); done - for i in {1..10}; do str="$str${arr[$RANDOM%$index]}"; done + str=$(cat /dev/urandom | tr -dc 'a-zA-Z0-9' | fold -w 10 | head -n 1) echo ${str} } diff --git a/docker/l2tp/l2tpctl.sh b/docker/l2tp/l2tpctl.sh index 89b97f2..4dc121d 100644 --- a/docker/l2tp/l2tpctl.sh +++ b/docker/l2tp/l2tpctl.sh @@ -1,4 +1,4 @@ -#!/bin/bash +#!/bin/sh PATH=/bin:/sbin:/usr/bin:/usr/sbin:/usr/local/bin:/usr/local/sbin:~/bin export PATH # @@ -11,12 +11,7 @@ export PATH # https://github.com/xelerance/xl2tpd rand(){ - index=0 - str="" - for i in {a..z}; do arr[index]=${i}; index=$(expr ${index} + 1); done - for i in {A..Z}; do arr[index]=${i}; index=$(expr ${index} + 1); done - for i in {0..9}; do arr[index]=${i}; index=$(expr ${index} + 1); done - for i in {1..10}; do str="$str${arr[$RANDOM%$index]}"; done + str=$(cat /dev/urandom | tr -dc 'a-zA-Z0-9' | fold -w 10 | head -n 1) echo ${str} }