Login textfarbe
This commit is contained in:
33
srv/poe_manager/create_user.py
Executable file
33
srv/poe_manager/create_user.py
Executable file
@@ -0,0 +1,33 @@
|
||||
#!/usr/bin/env python3
|
||||
import sqlite3
|
||||
from getpass import getpass
|
||||
from flask_bcrypt import Bcrypt
|
||||
|
||||
DB_PATH = "/srv/poe_manager/sqlite.db"
|
||||
bcrypt = Bcrypt()
|
||||
|
||||
def main():
|
||||
username = input("Benutzername: ")
|
||||
password = getpass("Passwort: ")
|
||||
password_confirm = getpass("Passwort bestätigen: ")
|
||||
|
||||
if password != password_confirm:
|
||||
print("Passwörter stimmen nicht überein!")
|
||||
return
|
||||
|
||||
pw_hash = bcrypt.generate_password_hash(password).decode('utf-8')
|
||||
|
||||
conn = sqlite3.connect(DB_PATH)
|
||||
cur = conn.cursor()
|
||||
try:
|
||||
cur.execute("INSERT INTO users (username, password, is_admin) VALUES (?, ?, ?)",
|
||||
(username, pw_hash, 0))
|
||||
conn.commit()
|
||||
print(f"Benutzer '{username}' erfolgreich angelegt.")
|
||||
except sqlite3.IntegrityError:
|
||||
print("Benutzername existiert bereits!")
|
||||
finally:
|
||||
conn.close()
|
||||
|
||||
if __name__ == "__main__":
|
||||
main()
|
||||
Binary file not shown.
@@ -19,11 +19,11 @@
|
||||
|
||||
<form method="post" class="w-25">
|
||||
<div class="mb-3">
|
||||
<label class="form-label">Username</label>
|
||||
<label class="form-label label text-white">Username</label>
|
||||
<input type="text" name="username" class="form-control" required>
|
||||
</div>
|
||||
<div class="mb-3">
|
||||
<label class="form-label">Password</label>
|
||||
<label class="form-label label text-white">Password</label>
|
||||
<input type="password" name="password" class="form-control" required>
|
||||
</div>
|
||||
<button class="btn btn-primary">Login</button>
|
||||
|
||||
87
usr/local/bin/custom/poe.sh.bak
Executable file
87
usr/local/bin/custom/poe.sh.bak
Executable file
@@ -0,0 +1,87 @@
|
||||
#!/bin/bash
|
||||
|
||||
USER="admin"
|
||||
PASS="Expl0rer#2022"
|
||||
IP_FILE="/usr/local/bin/custom/ips.list"
|
||||
LOGFILE="/var/log/rpi.log"
|
||||
|
||||
function disable_poe() {
|
||||
local switch_ip=$1
|
||||
local port=$2
|
||||
expect <<EOF
|
||||
set timeout 5
|
||||
spawn ssh $USER@$switch_ip
|
||||
|
||||
expect {
|
||||
"assword:" { send "$PASS\r"; exp_continue }
|
||||
"Press any key" { send "\r"; exp_continue }
|
||||
-re ".*> $" { }
|
||||
}
|
||||
send "configure terminal\r"
|
||||
expect "(config)#"
|
||||
send "interface $port\r"
|
||||
expect "(eth-$port)#"
|
||||
send "no power-over-ethernet\r"
|
||||
expect "(eth-$port)#"
|
||||
send "exit\r"
|
||||
expect "(config)#"
|
||||
send "exit\r"
|
||||
expect "#"
|
||||
send "exit\r"
|
||||
expect ">"
|
||||
send "exit\r"
|
||||
expect "Do you want to log out (y/n)?" { send "y\r" }
|
||||
expect eof
|
||||
EOF
|
||||
}
|
||||
|
||||
function enable_poe() {
|
||||
local switch_ip=$1
|
||||
local port=$2
|
||||
expect <<EOF
|
||||
set timeout 5
|
||||
spawn ssh $USER@$switch_ip
|
||||
|
||||
expect {
|
||||
"assword:" { send "$PASS\r"; exp_continue }
|
||||
"Press any key" { send "\r"; exp_continue }
|
||||
-re ".*> $" { }
|
||||
}
|
||||
send "configure terminal\r"
|
||||
expect "(config)#"
|
||||
send "interface $port\r"
|
||||
expect "(eth-$port)#"
|
||||
send "power-over-ethernet\r"
|
||||
expect "(eth-$port)#"
|
||||
send "exit\r"
|
||||
expect "(config)#"
|
||||
send "exit\r"
|
||||
expect "#"
|
||||
send "exit\r"
|
||||
expect ">"
|
||||
send "exit\r"
|
||||
expect "Do you want to log out (y/n)?" { send "y\r" }
|
||||
expect eof
|
||||
EOF
|
||||
}
|
||||
|
||||
echo "" > $LOGFILE
|
||||
while true; do
|
||||
echo "--------------------------------------------------------------------" >> $LOGFILE
|
||||
# echo "$(date '+%Y-%m-%d %H:%M:%S') Check Start" >> $LOGFILE
|
||||
while IFS=: read -r ip switch port hap; do
|
||||
ping -c 1 -W 2 $ip &> /dev/null
|
||||
if [ $? -ne 0 ]; then
|
||||
echo "$(date '+%Y-%m-%d %H:%M:%S') $ip nicht erreichbar, PoE auf Port $port am Switch $switch wird deaktiviert." >> $LOGFILE
|
||||
disable_poe $switch $port
|
||||
sleep 5
|
||||
enable_poe $switch $port
|
||||
echo "$(date '+%Y-%m-%d %H:%M:%S') PoE auf Port $port für IP $ip am Switch $switch aktiviert." >> $LOGFILE
|
||||
fi
|
||||
# if [ $? -ne 1 ]; then
|
||||
# echo "$(date '+%Y-%m-%d %H:%M:%S') $hap ist erreichbar!" >> $LOGFILE
|
||||
# fi
|
||||
done < "$IP_FILE"
|
||||
# echo "$(date '+%Y-%m-%d %H:%M:%S') Check beendet" >> $LOGFILE
|
||||
sleep 300
|
||||
done
|
||||
Reference in New Issue
Block a user