code cleanup i przeniesienie configa mstmp
This commit is contained in:
parent
913af1fc76
commit
22bcedd3a5
5
app.py
5
app.py
@ -107,9 +107,10 @@ def create_conf_post():
|
|||||||
os.getcwd(), 'configs', folder, "authorized_keys")
|
os.getcwd(), 'configs', folder, "authorized_keys")
|
||||||
sshd_config_path = os.path.join(os.getcwd(), 'configs', "sshd_config")
|
sshd_config_path = os.path.join(os.getcwd(), 'configs', "sshd_config")
|
||||||
sendmail_path = os.path.join(os.getcwd(), 'configs', "sendmail.sh")
|
sendmail_path = os.path.join(os.getcwd(), 'configs', "sendmail.sh")
|
||||||
|
msmtp_conf = os.path.join(os.getcwd(), 'configs', "msmtprc")
|
||||||
|
|
||||||
subprocess.run([script_path, "-i "+ini_path, "-c "+conf_path, "-k "+pub_path, "-l "+key_length, "-n"+config_name,
|
subprocess.run([script_path, "-i "+ini_path, "-c "+conf_path, "-k "+pub_path, "-l "+key_length, "-n"+config_name,
|
||||||
"-p "+ip, "-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, "-o "+msmtp_conf," > /dev/null 2>&1 "])
|
||||||
|
|
||||||
if os.path.exists(folder):
|
if os.path.exists(folder):
|
||||||
shutil.rmtree(folder)
|
shutil.rmtree(folder)
|
||||||
|
@ -4,9 +4,9 @@ echo "Parametry podane do skryptu: $@"
|
|||||||
kitcrypto_version="0.0.3"
|
kitcrypto_version="0.0.3"
|
||||||
uvpn3_version="3.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>] [-p <vpn ipaddress>]" 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>] [-o <config for msmtp>] [-p <vpn ipaddress>]" 1>&2; exit 1; }
|
||||||
|
|
||||||
while getopts "a:b:c:d:e:i:k:l:m:n:p:" option
|
while getopts "a:b:c:d:e:i:k:l:m:n:o:p:" option
|
||||||
do
|
do
|
||||||
case "${option}"
|
case "${option}"
|
||||||
in
|
in
|
||||||
@ -19,6 +19,7 @@ do
|
|||||||
l)keylen=${OPTARG};;
|
l)keylen=${OPTARG};;
|
||||||
m)msmtp=${OPTARG};;
|
m)msmtp=${OPTARG};;
|
||||||
n)name=${OPTARG};;
|
n)name=${OPTARG};;
|
||||||
|
o)msmtp_conf=${OPTARG};;
|
||||||
p)ip=${OPTARG};;
|
p)ip=${OPTARG};;
|
||||||
*)usage;;
|
*)usage;;
|
||||||
esac
|
esac
|
||||||
@ -68,16 +69,20 @@ cp $ini /tmp/output/vpn
|
|||||||
cp $key /tmp/output/vpn
|
cp $key /tmp/output/vpn
|
||||||
|
|
||||||
if [ -n "$akeys" ]; then
|
if [ -n "$akeys" ]; then
|
||||||
cp $akeys /tmp/output/ssh
|
cp $akeys /tmp/output/ssh
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [ -n "$sshconf" ]; then
|
if [ -n "$sshconf" ]; then
|
||||||
cp $sshconf /tmp/output/ssh
|
cp $sshconf /tmp/output/ssh
|
||||||
fi
|
fi
|
||||||
|
|
||||||
mkdir /tmp/output/msmtp
|
mkdir /tmp/output/msmtp
|
||||||
if [ -n "$msmtp" ]; then
|
if [ -n "$msmtp" ]; then
|
||||||
cp $msmtp /tmp/output/msmtp
|
cp $msmtp /tmp/output/msmtp
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [ -n "$msmtp_conf" ]; then
|
||||||
|
cp $msmtp_conf /tmp/output/msmtp
|
||||||
fi
|
fi
|
||||||
|
|
||||||
mkdir /tmp/output/vpn/scripts
|
mkdir /tmp/output/vpn/scripts
|
||||||
|
14
configs/msmtprc
Normal file
14
configs/msmtprc
Normal file
@ -0,0 +1,14 @@
|
|||||||
|
|
||||||
|
account notification
|
||||||
|
host smtp.mkedziora.pl
|
||||||
|
port 587
|
||||||
|
timeout 15
|
||||||
|
protocol smtp
|
||||||
|
domain mkedziora.pl
|
||||||
|
auth on
|
||||||
|
user test
|
||||||
|
from test@mkedziora.pl
|
||||||
|
password V8ufrLgiEwRF72dM
|
||||||
|
tls on
|
||||||
|
syslog on
|
||||||
|
tls_starttls on
|
@ -1,23 +1,5 @@
|
|||||||
#!/bin/sh
|
#!/bin/sh
|
||||||
|
|
||||||
cat <<EOF > /etc/msmtprc
|
|
||||||
|
|
||||||
account notification
|
|
||||||
host smtp.mkedziora.pl
|
|
||||||
port 587
|
|
||||||
timeout 15
|
|
||||||
protocol smtp
|
|
||||||
domain mkedziora.pl
|
|
||||||
auth on
|
|
||||||
user test
|
|
||||||
from test@mkedziora.pl
|
|
||||||
password V8ufrLgiEwRF72dM
|
|
||||||
tls on
|
|
||||||
syslog on
|
|
||||||
tls_starttls on
|
|
||||||
|
|
||||||
EOF
|
|
||||||
|
|
||||||
ifconfig > /tmp/ifconfig
|
ifconfig > /tmp/ifconfig
|
||||||
cat /proc/cmdline > /tmp/cmdline
|
cat /proc/cmdline > /tmp/cmdline
|
||||||
tar -cvf /tmp/zalacznik.tar /tmp/cmdline /tmp/ifconfig
|
tar -cvf /tmp/zalacznik.tar /tmp/cmdline /tmp/ifconfig
|
||||||
|
7
utils.py
7
utils.py
@ -11,6 +11,9 @@ import db
|
|||||||
import config
|
import config
|
||||||
import ipaddress
|
import ipaddress
|
||||||
|
|
||||||
|
DELETE_TIMEOUT=30
|
||||||
|
RESTART_DELETE_THREAD=10
|
||||||
|
|
||||||
|
|
||||||
def generate_random_string(length):
|
def generate_random_string(length):
|
||||||
letters = string.ascii_letters
|
letters = string.ascii_letters
|
||||||
@ -48,7 +51,7 @@ def check_allocation_thread_function():
|
|||||||
ping_thread = PingThread(ip, x[0])
|
ping_thread = PingThread(ip, x[0])
|
||||||
ping_thread.start()
|
ping_thread.start()
|
||||||
|
|
||||||
sleep(10)
|
sleep(RESTART_DELETE_THREAD)
|
||||||
|
|
||||||
|
|
||||||
class PingThread(threading.Thread):
|
class PingThread(threading.Thread):
|
||||||
@ -65,7 +68,7 @@ class PingThread(threading.Thread):
|
|||||||
if date is None:
|
if date is None:
|
||||||
return
|
return
|
||||||
delta = datetime.datetime.utcnow() - date
|
delta = datetime.datetime.utcnow() - date
|
||||||
if delta.total_seconds() > 30:
|
if delta.total_seconds() > DELETE_TIMEOUT:
|
||||||
db.del_image_allocation_id(self.Id)
|
db.del_image_allocation_id(self.Id)
|
||||||
else:
|
else:
|
||||||
db.update_image_allocation_time(self.Id)
|
db.update_image_allocation_time(self.Id)
|
||||||
|
Loading…
Reference in New Issue
Block a user