Add ssh-terminal, add Bookstack iframe (failed)

main
Sebastian Serfling 2023-08-02 21:23:49 +02:00
parent 832a0df87f
commit 6d3171f97c
10 changed files with 286 additions and 0 deletions

0
__init__.py Normal file
View File

16
asgi.py Normal file
View File

@ -0,0 +1,16 @@
"""
ASGI config for pim project.
It exposes the ASGI callable as a module-level variable named ``application``.
For more information on this file, see
https://docs.djangoproject.com/en/4.2/howto/deployment/asgi/
"""
import os
from django.core.asgi import get_asgi_application
os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'pim.settings')
application = get_asgi_application()

10
main.py Normal file
View File

@ -0,0 +1,10 @@
import base64
# String, den du in Base64 kodieren möchtest
original_string = "adm.3dfx12"
# Den String in ein Bytes-Objekt umwandeln und dann in Base64 kodieren
print("Originaler String:", original_string)
print("Base64-kodierter String:", base64_string)

22
manage.py Normal file
View File

@ -0,0 +1,22 @@
#!/usr/bin/env python
"""Django's command-line utility for administrative tasks."""
import os
import sys
def main():
"""Run administrative tasks."""
os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'settings')
try:
from django.core.management import execute_from_command_line
except ImportError as exc:
raise ImportError(
"Couldn't import Django. Are you sure it's installed and "
"available on your PYTHONPATH environment variable? Did you "
"forget to activate a virtual environment?"
) from exc
execute_from_command_line(sys.argv)
if __name__ == '__main__':
main()

130
settings.py Normal file
View File

@ -0,0 +1,130 @@
"""
Django settings for pim project.
Generated by 'django-admin startproject' using Django 4.2.4.
For more information on this file, see
https://docs.djangoproject.com/en/4.2/topics/settings/
For the full list of settings and their values, see
https://docs.djangoproject.com/en/4.2/ref/settings/
"""
from pathlib import Path
import os
# Build paths inside the project like this: BASE_DIR / 'subdir'.
BASE_DIR = Path(__file__).resolve().parent
# Quick-start development settings - unsuitable for production
# See https://docs.djangoproject.com/en/4.2/howto/deployment/checklist/
# SECURITY WARNING: keep the secret key used in production secret!
SECRET_KEY = 'django-insecure-4#5!a=35j51i$-vv$&w*ax%46oizdgfsy&2*=7phgnc&9=x#&b'
# SECURITY WARNING: don't run with debug turned on in production!
DEBUG = True
ALLOWED_HOSTS = []
# Application definition
INSTALLED_APPS = [
'django.contrib.admin',
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.messages',
'django.contrib.staticfiles',
'setup',
'django_ssh',
]
MIDDLEWARE = [
'django.middleware.security.SecurityMiddleware',
'django.contrib.sessions.middleware.SessionMiddleware',
'django.middleware.common.CommonMiddleware',
'django.middleware.csrf.CsrfViewMiddleware',
'django.contrib.auth.middleware.AuthenticationMiddleware',
'django.contrib.messages.middleware.MessageMiddleware',
'django.middleware.clickjacking.XFrameOptionsMiddleware',
]
ROOT_URLCONF = 'setup.urls'
TEMPLATES = [
{
'BACKEND': 'django.template.backends.django.DjangoTemplates',
'DIRS': [os.path.join(BASE_DIR, 'setup/template')],
'APP_DIRS': True,
'OPTIONS': {
'context_processors': [
'django.template.context_processors.debug',
'django.template.context_processors.request',
'django.contrib.auth.context_processors.auth',
'django.contrib.messages.context_processors.messages',
],
},
},
]
WSGI_APPLICATION = 'wsgi.application'
# Database
# https://docs.djangoproject.com/en/4.2/ref/settings/#databases
DATABASES = {
'default': {
'ENGINE': 'django.db.backends.mysql',
'NAME': 'Django',
'USER': 'root',
'PASSWORD': 'N53yBCswuawzBzS445VNAhWVMs3N59Gb9szEsrzXRBzarDqpdETpQeyt5v5CGe',
'HOST':'172.17.1.21',
'PORT':'3306',
}
}
# Password validation
# https://docs.djangoproject.com/en/4.2/ref/settings/#auth-password-validators
AUTH_PASSWORD_VALIDATORS = [
{
'NAME': 'django.contrib.auth.password_validation.UserAttributeSimilarityValidator',
},
{
'NAME': 'django.contrib.auth.password_validation.MinimumLengthValidator',
},
{
'NAME': 'django.contrib.auth.password_validation.CommonPasswordValidator',
},
{
'NAME': 'django.contrib.auth.password_validation.NumericPasswordValidator',
},
]
# Internationalization
# https://docs.djangoproject.com/en/4.2/topics/i18n/
LANGUAGE_CODE = 'en-us'
TIME_ZONE = 'UTC'
USE_I18N = True
USE_TZ = True
# Static files (CSS, JavaScript, Images)
# https://docs.djangoproject.com/en/4.2/howto/static-files/
STATIC_URL = 'static/'
# Default primary key field type
# https://docs.djangoproject.com/en/4.2/ref/settings/#default-auto-field
DEFAULT_AUTO_FIELD = 'django.db.models.BigAutoField'

58
setup/template/setup.html Normal file
View File

@ -0,0 +1,58 @@
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/html">
<head>
<title>Meine Webseite</title>
</head>
<body>
<form method="post">
{% csrf_token %}
<p>IP-Adresse</p>
<textarea name="ipadresse" rows="1" cols="10"></textarea>
<p>Password</p>
<textarea name="password" rows="1" cols="50"></textarea>
<p>Firmenname</p>
<textarea name="firmenname" rows="1" cols="50"></textarea>
<p>Firmenkürzel (zb. STI für Stines)</p>
<textarea name="firmenkürzel" rows="1" cols="50"></textarea>
<p>Subnetz (zb. 172.<span style="font-weight: bold">17</span>.1.1)</p>
<textarea name="subnetz" rows="1" cols="50"></textarea>
<p>Domain</p>
<textarea name="domain" rows="1" cols="50"></textarea>
<table>
<tr>
<td><p>Router</p></td>
<td><input type="checkbox" name="router"></td>
</tr>
<tr>
<td><p>Terminal-Server</p></td>
<td><input type="checkbox" name="terminalserver"></td>
</tr>
<tr>
<td><p>Exchange-Server</p></td>
<td><input type="checkbox" name="exchangeserver"></td>
</tr>
<tr>
<td><p>Mail-Server</p></td>
<td><input type="checkbox" name="mailserver"></td>
</tr>
<tr>
<td><p>App-Server</p></td>
<td><input type="checkbox" name="appserver"></td>
</tr>
<tr>
<td><p>Daten-Server</p></td>
<td><input type="checkbox" name="datenserver"></td>
</tr>
<tr>
<td><p>Web-Server</p></td>
<td><input type="checkbox" name="CMS"></td>
</tr>
<tr>
<td><p>Bitwarden-Server</p></td>
<td><input type="checkbox" name="Bitwarden"></td>
</tr>
</table><br>
<input style="margin-top:10px" type="submit" value="Speichern">
</form>
</body>
</html>

View File

@ -0,0 +1,18 @@
<!-- ssh_terminal.html -->
<!DOCTYPE html>
<html>
<head>
<title>SSH Terminal</title>
</head>
<body>
{% if output %}
<h3>Verbindung zum Server herstellen:</h3>
<iframe src='{{ output }}' width="100%" height="600"></iframe>
{% endif %}
<h1>Folgende Schritte sind durch zuführen:</h1>
<iframe src='http://wiki.stines.de/?iframe=true' width="100%" height="600"></iframe>
</body>
</html>

8
setup/urls.py Normal file
View File

@ -0,0 +1,8 @@
from django.urls import path
from . import views
urlpatterns = [
path('', views.daten_eingeben, name='index'),
path('ssh-terminal/', views.ssh_terminal, name='ssh-terminal'),
]

8
urls.py Normal file
View File

@ -0,0 +1,8 @@
from django.contrib import admin
from django.urls import include, path
urlpatterns = [
path("", include("setup.urls")),
]

16
wsgi.py Normal file
View File

@ -0,0 +1,16 @@
"""
WSGI config for pim project.
It exposes the WSGI callable as a module-level variable named ``application``.
For more information on this file, see
https://docs.djangoproject.com/en/4.2/howto/deployment/wsgi/
"""
import os
from django.core.wsgi import get_wsgi_application
os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'pim.settings')
application = get_wsgi_application()