mirror of
https://github.com/pivpn/pivpn.git
synced 2024-12-18 10:50:16 +00:00
Prevent overwriting files
This commit is contained in:
parent
4e0f9ac0ff
commit
d8d89c758b
1 changed files with 16 additions and 1 deletions
|
@ -8,6 +8,7 @@ OKEY=".key"
|
|||
KEY=".3des.key"
|
||||
CA="ca.crt"
|
||||
TA="ta.key"
|
||||
INDEX="/etc/openvpn/easy-rsa/keys/index.txt"
|
||||
INSTALL_USER=$(cat /etc/pivpn/INSTALL_USER)
|
||||
|
||||
# Functions def
|
||||
|
@ -44,7 +45,7 @@ function keyPASS() {
|
|||
stty -echo
|
||||
while true
|
||||
do
|
||||
printf "Enter the password for the Client: "
|
||||
printf "Enter the password for the client: "
|
||||
read -r PASSWD
|
||||
printf "\n"
|
||||
printf "Enter the password again to verify: "
|
||||
|
@ -111,6 +112,20 @@ if [[ -z "$NAME" ]]; then
|
|||
exit 1
|
||||
fi
|
||||
|
||||
# Check if name is already in use
|
||||
while read -r line || [ -n "$line" ]; do
|
||||
if [ "$(echo "$line" | sed -e 's/^.*CN=\([^/]*\)\/.*/\1/')" = "$NAME" ]; then
|
||||
echo "Name is already in use"
|
||||
exit 1
|
||||
fi
|
||||
done <$INDEX
|
||||
|
||||
# Check if name is reserved
|
||||
if [ "$NAME" = "ta" ] || [ "$NAME" = "server" ] || [ "$NAME" = "ca" ]; then
|
||||
echo "Sorry, this name is unavailable, please choose another one"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
cd /etc/openvpn/easy-rsa || exit
|
||||
source /etc/openvpn/easy-rsa/vars
|
||||
|
||||
|
|
Loading…
Reference in a new issue