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} }