Allgemeine Fragen zu Problemen. Keine Fehlerberichte oder Feature-Anfragen
Moderator: Securepoint
Ludger
Beiträge: 14 Registriert: Do 24.03.2016, 17:40
Beitrag
von Ludger » Do 02.02.2017, 18:31
Hallo
evtl. kann es ja wer gebrauchen, oder gar verbessern
Code: Alles auswählen
#!/bin/bash
#
#
# Copy this script to a folder with the VPN configuration files.
#
# Then simply start the script.
#
# Example: bash ./convert.sh
#
#
outpath="converted"
fmask="Securepoint-SSL-VPN-Config*.zip"
#
#
#
cd $(dirname $0)
for file in $fmask
do
unzip -j -d ./tmp $file > /dev/null 2>&1
mkdir -p ./$outpath
cd ./tmp
fnam=$(basename -s .ovpn $(ls *.ovpn))
onam=$(basename -s .zip $file)
grep -F -v -e "ca" -e "cert" -e "key" $fnam.ovpn >../$outpath/${onam}.ovpn
echo >>../$outpath/${onam}.ovpn
echo '<ca>'>>../$outpath/${onam}.ovpn
cat $fnam-ca.pem >>../$outpath/${onam}.ovpn
echo '</ca>'>>../$outpath/${onam}.ovpn
echo >>../$outpath/${onam}.ovpn
echo '<cert>'>>../$outpath/${onam}.ovpn
cat $fnam-cert.pem >>../$outpath/${onam}.ovpn
echo '</cert>'>>../$outpath/${onam}.ovpn
echo >>../$outpath/${onam}.ovpn
echo '<key>'>>../$outpath/${onam}.ovpn
cat $fnam-cert.key >>../$outpath/${onam}.ovpn
echo '</key>'>>../$outpath/${onam}.ovpn
echo >>../$outpath/${onam}.ovpn
cd ..
rm -f -r ./tmp
done
stkh
Beiträge: 30 Registriert: Fr 23.12.2016, 10:22
Beitrag
von stkh » Do 02.02.2017, 19:31
Cool, danke. Wollte ich auch schon mal machen.
Vielleicht könnte man am Schluss die Dateien wieder als ZIP packen.
Gruß KH
Ludger
Beiträge: 14 Registriert: Do 24.03.2016, 17:40
Beitrag
von Ludger » Di 02.05.2017, 11:02
Auch möglich.
Code: Alles auswählen
#!/bin/bash
#
#
# Copy this script to a folder with the VPN configuration files.
#
# Then simply start the script.
#
# Example: bash ./convert.sh
#
#
outpath="converted"
fmask="Securepoint-SSL-VPN-Config*.zip"
#
#
#
cd $(dirname $0)
for file in $fmask
do
unzip -j -d ./tmp $file > /dev/null 2>&1
mkdir -p ./$outpath
cd ./tmp
fnam=$(basename -s .ovpn $(ls *.ovpn))
onam=$(basename -s .zip $file)
grep -F -v -e "ca" -e "cert" -e "key" $fnam.ovpn >../$outpath/${onam}.ovpn
echo >>../$outpath/${onam}.ovpn
echo '<ca>'>>../$outpath/${onam}.ovpn
cat $fnam-ca.pem >>../$outpath/${onam}.ovpn
echo '</ca>'>>../$outpath/${onam}.ovpn
echo >>../$outpath/${onam}.ovpn
echo '<cert>'>>../$outpath/${onam}.ovpn
cat $fnam-cert.pem >>../$outpath/${onam}.ovpn
echo '</cert>'>>../$outpath/${onam}.ovpn
echo >>../$outpath/${onam}.ovpn
echo '<key>'>>../$outpath/${onam}.ovpn
cat $fnam-cert.key >>../$outpath/${onam}.ovpn
echo '</key>'>>../$outpath/${onam}.ovpn
echo >>../$outpath/${onam}.ovpn
##
## if you don't want to zip the *.ovpn comment or delete following line
zip -9 -j -X ../$outpath/${onam}.zip ../$outpath/${onam}.ovpn
## to remove the *.ovpn enable following line
#rm -f ../$outpath/${onam}.ovpn
##
cd ..
rm -f -r ./tmp
done
Ich habs mal eingebaut.
kennethj
Beiträge: 408 Registriert: Di 25.04.2017, 10:17
Wohnort: Lüneburg
Kontaktdaten:
Beitrag
von kennethj » Di 02.05.2017, 15:00
Ich war mal so frei und hab das etwas umgeschrieben.
Anstelle des auskommentieren/Löschen was nach dem Konvertieren geschehen soll, muss man das beim Starten mit angeben.
Beispiel:
sh convert 1 0
Erstellt nach dem Konvertieren ein ZIP File und löscht nicht die *.ovpn Dateien.
Code: Alles auswählen
#!/bin/sh
#
# Copy this script to a folder with the VPN configuration files.
#
# Then simply start the script.
#
# Example: sh convert.sh or ./convert.sh
# For Debug Information Use sh -x convert.sh
#
if [ -z "$1" ] || [ -z "$2" ]; then
echo "No arguments provided"
echo "Usage: $0 <ZIP *.ovpn after Convert (0 or 1)> <Delete *.ovpn after Convert (0 or 1)>"
exit 1
fi
ZIP_IT=$1
DEL_IT=$2
OUTPATH="converted"
FMASK="Securepoint-SSL-VPN-Config*.zip"
#
cd "$(dirname "$0")" || exit
for IN_FILE in $FMASK; do
unzip -j -d ./tmp "$IN_FILE" > /dev/null 2>&1
mkdir -p ./$OUTPATH
cd ./tmp || exit
FNAM=$(basename -s .ovpn "$(ls ./*.ovpn)")
ONAM=$(basename -s .zip "$IN_FILE")
grep -F -v -e "ca" -e "cert" -e "key" "$FNAM.ovpn" >../$OUTPATH/"${ONAM}".ovpn
{
echo '<ca>'
cat "$FNAM"-ca.pem
echo '</ca>'
echo '<cert>'
cat "$FNAM"-cert.pem
echo '</cert>'
echo '<key>'
cat "$FNAM"-cert.key
echo '</key>'
} >>../$OUTPATH/"${ONAM}".ovpn
if [ "$ZIP_IT" = "1"]; then
zip -9 -j -X ../$OUTPATH/"${ONAM}".zip ../$OUTPATH/"${ONAM}".ovpn
fi
if [ "$DEL_IT" = "1"]; then
rm -f ../$OUTPATH/"${ONAM}".ovpn
fi
cd ..
rm -f -r ./tmp
done
Gruß
David
Securepoint
Beiträge: 444 Registriert: Di 09.02.2016, 14:01
Beitrag
von David » Fr 12.05.2017, 09:24
Ihr solltet echt an der Kommentierung eures Codes arbeiten ;-)
Mit freundlichen Grüßen
David Gundermann
Head of Mobile Security
Tel. 04131/2401-0
Fax 04131/2401-50
Securepoint GmbH
Bleckeder Landstraße 28
D-21337 Lüneburg
http://www.securepoint.de
Ludger
Beiträge: 14 Registriert: Do 24.03.2016, 17:40
Beitrag
von Ludger » Fr 12.05.2017, 14:53
David hat geschrieben: Ihr solltet echt an der Kommentierung eures Codes arbeiten ;-)
stimmt - aber braucht man bei dem kleinen niedlichen Script wirklich weitere Kommentare ????
[duck und weg]
Wobei sich mir die Frage stellt, ob es noch Clients gibt, die mit einer Inline-Configuration wie sie mit dem Script erzeugt wird nicht klarkommen.
Denn wenn es die nicht mehr gibt, dann sollte das imho direkt so erzeugt werden!!!
Franz
Beiträge: 387 Registriert: Sa 02.04.2011, 17:52
Wohnort: Westerwald
Kontaktdaten:
Beitrag
von Franz » Mo 15.05.2017, 08:50
Die Frage habe ich mir auch schon gestellt.
Bisher habe ich nur bei den Securepoint SSL-VPN-Clients beobachtet, dass es zu Fehlern beim Import kommen konnte, wenn bei der ersten importierten Konfiguration die Angaben zu Key und Zertifikaten ganz gelöscht oder auskommentiert wurde. Deswegen habe ich mit dem PowerShell-Pendant die betreffenden Zeilen nicht ganz löschen oder auskommentieren sondern nur den Pfad durch die Angabe "[inline]" ersetzen lassen. Das sieht dann auch etwas schöner aus, wenn man sich die Konfiguration im Securepoint SSL-VPN-Client anzeigen lässt.