Raspberry PI的MakeOVPN.sh文件意外结束

时间:2015-07-24 14:15:53

标签: shell raspberry-pi sh raspberry-pi2

任何人都可以帮助我 MakeOVPN.sh 的意外文件结尾。我在Raspberry PI 2上运行shell时遇到了错误。我尝试在Raspberry PI 2上为我自己设置VPN。请参阅下面的.sh代码。

#!/bin/bash

#Default Variable Declarations
DEFAULT="Default.txt"
FILEEXT=".ovpn"
CRT=".crt"
KEY=".3des.key"
CA="ca.crt"
TA="ta.key"
NAME="${1}"

if [ -z "${NAME}" ];
  echo "Please enter an existing Client Name:"
  read NAME
if


#1st Verify That client public key exists
if [ ! -f $NAME$CRT ];
  echo "[ERROR]: Client public key certificate not found : $NAME$CRT"
  exit
if
  echo "Client's cert found : $NAME$CRT"


#Then, Verify that there is a private key for that client
if [ ! -f $NAME$KEY ];
  echo "[ERROR]: Client 3des Private key not found : $NAME$KEY"
  KEY="${NODES_KEY}"
if
  echo "Clients Private key found : $NAME$KEY"

if [ ! -f $NAME$KEY ];
  echo "[ERROR]: Client Private Key not found: $NAME$KEY"
  exit
if


#Confirm the CA Public key exists
if [ ! -f $CA ];
  echo "[ERROR]: CA public key not found : $CA"
  exit
if
  echo "CA public key found : $CA"


#CONFIRM the tls-auth ta key file exists
if [ ! -f $TA ];
  echo "[ERROR]: tls-auth key not found : $TA"
  exit
if
  echo "tls-auth Private key found: $TA"
#Ready to make a new .opvn file - start by populating with the default file
cat $DEFAULT > $NAME$FILEEXT

#Now, append the CA Public Cert
echo "<ca>" >> $NAME$FILEEXT
cat $CA >> $NAME$FILEEXT
echo "</ca>" >> $NAME$FILEEXT

#Next append the client Public Cert
echo "<cert>" >> $NAME$FILEEXT
cat $NAME$CRT | sed -ne '/-BEGIN CERTIFICATE-/,/-END CERTIFICATE-/p'
$NAME$FILEEXT
echo "</cert>" >> $NAME$FILEEXT

#Then, append the certificate private key
echo "<key>" >> $NAME$FILEEXT
cat $NAME$KEY >> $NAME$FILEEXT
echo "</key>" >>  $NAME$FILEEXT

#Finally, append the TA private key
echo "<tls-auth>" >> $NAME$FILEEXT
cat $TA >> $NAME$FILEEXT
echo "</tls-auth>" >> $NAME$FILEEXT

echo "Done $NAME$FILEEXT successfully created."
#Script written by Eric Jodoin

谢谢。

0 个答案:

没有答案