poprawa tworzenia obrazow

This commit is contained in:
Mateusz779 2023-04-19 13:46:25 +02:00
parent 92d7143ac0
commit 8d2455724e
3 changed files with 24 additions and 9 deletions

4
app.py
View File

@ -61,6 +61,7 @@ def create_conf_post():
config_name = request.form['config_name']
token_name = request.form['token_name']
key_length = request.form['key_length']
ip = request.form['ip']
folder = utils.generate_random_string(5)
try:
os.mkdir(os.path.join(os.getcwd(), 'configs', folder))
@ -76,14 +77,13 @@ def create_conf_post():
ini_path = os.path.join(os.getcwd(), 'configs', "uVPN.ini")
conf_path = os.path.join(os.getcwd(), 'configs', "uVPN.conf")
pub_path = os.path.join(os.getcwd(), 'configs', "server.pub")
scripts_path = os.path.join(os.getcwd(), 'configs', "scripts/")
authorized_keys_path = os.path.join(
os.getcwd(), 'configs', folder, "authorized_keys")
sshd_config_path = os.path.join(os.getcwd(), 'configs', "sshd_config")
sendmail_path = os.path.join(os.getcwd(), 'configs', "sendmail.sh")
subprocess.run([script_path, "-i "+ini_path, "-c "+conf_path, "-k "+pub_path, "-l "+key_length, "-n"+config_name,
"-s "+scripts_path, "-a "+authorized_keys_path, "-d "+sshd_config_path, "-m "+sendmail_path, " > /dev/null 2>&1 "])
"-p "+ip, "-a "+authorized_keys_path, "-d "+sshd_config_path, "-m "+sendmail_path, " > /dev/null 2>&1 "])
if os.path.exists(folder):
shutil.rmtree(folder)

View File

@ -4,9 +4,9 @@ echo "Parametry podane do skryptu: $@"
kitcrypto_version="0.0.3"
uvpn3_version="3.0.3"
usage() { echo "Usage: [-a <root ssh authorized_keys>] [-b add executable to output] [-c <conf file>] [-d <sshd_config>] [-i <ini config>] [-k <pub server key>] [-l <priv key lenght>] [-m <msmtp script>] [-n <name>] [-s <dir with scripts>]" 1>&2; exit 1; }
usage() { echo "Usage: [-a <root ssh authorized_keys>] [-b add executable to output] [-c <conf file>] [-d <sshd_config>] [-i <ini config>] [-k <pub server key>] [-l <priv key lenght>] [-m <msmtp script>] [-n <name>] [-p <vpn ipaddress>]" 1>&2; exit 1; }
while getopts "a:b:c:d:e:i:k:l:m:n:s:" option
while getopts "a:b:c:d:e:i:k:l:m:n:p:" option
do
case "${option}"
in
@ -19,7 +19,7 @@ do
l)keylen=${OPTARG};;
m)msmtp=${OPTARG};;
n)name=${OPTARG};;
s)scripts=${OPTARG};;
p)ip=${OPTARG};;
*)usage;;
esac
done
@ -66,9 +66,6 @@ cd $CONFIGS
cp $conf /tmp/output/vpn
cp $ini /tmp/output/vpn
cp $key /tmp/output/vpn
if [ -n "$scripts" ]; then
cp -r $scripts /tmp/output/vpn
fi
if [ -n "$akeys" ]; then
cp $akeys /tmp/output/ssh
@ -83,8 +80,24 @@ if [ -n "$msmtp" ]; then
cp $msmtp /tmp/output/msmtp
fi
mkdir /tmp/output/vpn/scripts
cat <<EOF> /tmp/output/vpn/scripts/starttap.sh
#!/bin/sh
ifconfig uvpnT2 $ip netmask 255.255.255.0 up
EOF
cat <<EOF> /tmp/output/vpn/scripts/arpinggw.sh
#!/bin/sh
ip -s -s neigh flush all dev uvpnT2
EOF
chmod +x /tmp/output/vpn/scripts/starttap.sh
chmod +x /tmp/output/vpn/scripts/arpinggw.sh
sed -i '/^private_key/c\private_key uVPN.priv' /tmp/output/vpn/$(basename "$conf")
sed -i '/^tap_name/c\tap_name uvpnT2' /tmp/output/vpn/$(basename "$conf")
sed -i '/^name/c\name '"$name" /tmp/output/vpn/$(basename "$conf")
sed -i '/^servers_config/c\servers_config '"$(basename "$ini")" /tmp/output/vpn/$(basename "$conf")
sed -i '1s/.*/['"$name"']/' /tmp/output/vpn/$(basename "$ini")

View File

@ -76,6 +76,8 @@ form textarea {
<input type="text" name="token_name" required><br><br>
<label>Długość klucza:</label><br>
<input type="number" name="key_length" min="1024" required><br><br>
<label>Adres ip VPN:</label><br>
<input type="text" name="ip" required><br><br>
<label>Konfiguracja authorized_keys:</label><br>
<textarea name="authorized_keys_config" rows="4" cols="50"></textarea><br><br>
<input type="submit" value="Wyślij">