Compare commits
10 Commits
49da1df840
...
007c787d5a
| Author | SHA1 | Date | |
|---|---|---|---|
| 007c787d5a | |||
| ccca2fb98b | |||
| a2118e0e01 | |||
| 5958fa673e | |||
| 6e78099872 | |||
| 89813a9739 | |||
| bed43b33dd | |||
| 8875490fe1 | |||
|
|
9ee348848c | ||
|
|
67a832062c |
28
README.md
28
README.md
@ -4,7 +4,11 @@ Dies erzeugt ein neues GIT Repository auf ein Asustor NAS (Only GIT installed).
|
|||||||
|
|
||||||
## Version
|
## Version
|
||||||
|
|
||||||
V 1.1
|
V 1.2.2
|
||||||
|
|
||||||
|
## TODO
|
||||||
|
- **TODO:** User abfangen wenn Remote nicht erkennt.
|
||||||
|
- **TODO:** History einbauen
|
||||||
|
|
||||||
## Installation
|
## Installation
|
||||||
|
|
||||||
@ -12,6 +16,25 @@ Dies erzeugt ein neues GIT Repository auf ein Asustor NAS (Only GIT installed).
|
|||||||
|
|
||||||
## Changelog
|
## Changelog
|
||||||
|
|
||||||
|
### V 1.2.2
|
||||||
|
- `main.py`
|
||||||
|
- Added username and mail support
|
||||||
|
|
||||||
|
|
||||||
|
### V 1.2.1
|
||||||
|
- `main.py`
|
||||||
|
- Added " " zu "_" und Illigale Zeichen abfangen
|
||||||
|
- Ackknowlege vom User bekommen
|
||||||
|
- Added Try-Except block um SSH Ausführung
|
||||||
|
- **TODO:** User abfangen wenn Remote nicht erkennt.
|
||||||
|
- **TODO:** History einbauen
|
||||||
|
|
||||||
|
### V 1.2
|
||||||
|
- `main.py`
|
||||||
|
- Added Remote Adresse zu ändern (Local & Public)
|
||||||
|
- Added Multiuser
|
||||||
|
- Added Port ändern
|
||||||
|
|
||||||
### V 1.1
|
### V 1.1
|
||||||
- `README.md` erstellt
|
- `README.md` erstellt
|
||||||
- `main.py` -> Tippfehler korrigiert
|
- `main.py` -> Tippfehler korrigiert
|
||||||
@ -19,6 +42,9 @@ Dies erzeugt ein neues GIT Repository auf ein Asustor NAS (Only GIT installed).
|
|||||||
- Start des Projektes
|
- Start des Projektes
|
||||||
- `main.py` angefertigt
|
- `main.py` angefertigt
|
||||||
|
|
||||||
|
## Wichtige Info
|
||||||
|
- Um zu schauen welchen Upstream branch es gibt, nutze:
|
||||||
|
>git ls-remote --heads origin
|
||||||
|
|
||||||
|
|
||||||
## Beitragende
|
## Beitragende
|
||||||
|
|||||||
64
main.py
64
main.py
@ -1,9 +1,28 @@
|
|||||||
import subprocess
|
import subprocess
|
||||||
|
import socket
|
||||||
|
|
||||||
|
username = input("Hallo, wie lautet ihr Username? (Achte bitte auf Groß und Kleinschrift): ")
|
||||||
|
hostname = input(f"\nSuper, {username}. Jetzt bräuchte ich noch die Remote-adresse (NAS IP): ")
|
||||||
|
localhostname = input(f"\nJetzt bräuchte ich noch die Local-adresse (z.b aus Host datei): ")
|
||||||
|
port= "22"
|
||||||
|
port = input(f"\nStandartport {port} nutzen? (y/j/PORT-Nr) ")
|
||||||
|
if port.lower() in ["ja","j","y"] or not port.isdigit():
|
||||||
|
port= "22"
|
||||||
|
|
||||||
|
iligal_signs = "/\\\"[]{}%&§=<>|"
|
||||||
|
ili_signs_tab = str.maketrans(iligal_signs,"-" * len(iligal_signs))
|
||||||
|
project_name = input("\nPerfekt, gibt mir bitte noch den Projektnamen (Leerzeichen werden automatisch zu _ ersetzt): ")
|
||||||
|
project_name= project_name.replace(" ","_")
|
||||||
|
project_name= project_name.translate(ili_signs_tab)
|
||||||
|
|
||||||
|
ack = input(f"\nOkay > {username} <, bitte prüfe ob der Name so richtig ist: > {project_name} <\nfür den Host > {hostname} < auf dem Port > {port} < (y/n)? ")
|
||||||
|
if ack.lower() == "y" or ack.lower() == "j":
|
||||||
|
print("\nSuper, ich lege los!")
|
||||||
|
name = input("Wie ist dein Name für den Remotehost? ")
|
||||||
|
mail = input("Wie ist deine E-Mail für den Remotehost? ")
|
||||||
|
else:
|
||||||
|
exit()
|
||||||
|
|
||||||
project_name = input("Geben Sie den Projektnamen ein: ")
|
|
||||||
hostname = "192.168.2.106"
|
|
||||||
username = "yannick"
|
|
||||||
port = "22" # Anpassen, falls ein anderer Port verwendet wird
|
|
||||||
|
|
||||||
# Befehle für die SSH-Verbindung
|
# Befehle für die SSH-Verbindung
|
||||||
commands = [
|
commands = [
|
||||||
@ -18,21 +37,36 @@ commands = [
|
|||||||
"cd ../",
|
"cd ../",
|
||||||
f"cd {project_name}",
|
f"cd {project_name}",
|
||||||
"git init",
|
"git init",
|
||||||
'git config --global user.email "y-esser@t-online.de"',
|
f'git config --global user.email "{mail}"',
|
||||||
'git config --global user.name "Yannick"',
|
f'git config --global user.name "{name}"',
|
||||||
"touch README.txt",
|
"touch README.txt",
|
||||||
"git add .",
|
"git add .",
|
||||||
'git commit -am "INIT"',
|
'git commit -am "INIT"',
|
||||||
f"git remote add origin ssh://{username}@{hostname}/share/Public/git/{project_name}.git"
|
f"git remote add origin ssh://{username}@{hostname}:{port}/share/Public/git/{project_name}.git"
|
||||||
]
|
]
|
||||||
|
|
||||||
# SSH-Verbindung herstellen und Befehle ausführen
|
# SSH-Verbindung herstellen und Befehle ausführen
|
||||||
command_string = " && ".join(commands)
|
try:
|
||||||
subprocess.run(["ssh", "-p", port, f"{username}@{hostname}", command_string])
|
socket.gethostbyname(hostname)
|
||||||
print("Bitte gehe selber per ssh auf das nas um ein >git push origin master< zu machen um das vollständig ab zu schließen")
|
except socket.gaierror as e:
|
||||||
print(f"cd share/Public/git/{project_name}")
|
print(f"Fehler beim Auflösen des Hostnames: {e}")
|
||||||
print("git push origin master")
|
else:
|
||||||
print(f'git clone "ssh://yannick@192.168.2.106/share/Public/git/{project_name}.git"')
|
try:
|
||||||
|
# TODO User abfangen wenn nicht existent
|
||||||
|
# command = f"ssh -p {port} {username}@{hostname} echo"
|
||||||
|
# completed_process = subprocess.run(command,shell=True,capture_output=True)
|
||||||
|
# if completed_process.returncode == 0:
|
||||||
|
# pass
|
||||||
|
# else:
|
||||||
|
# print(f"Der Benutzer {username} exsistiert nicht auf dem Server: {hostname}")
|
||||||
|
# exit()
|
||||||
|
|
||||||
# Temporäre Datei entfernen (nicht erforderlich, da direkt übergeben)
|
command_string = " && ".join(commands)
|
||||||
# subprocess.run(["del", "commands.sh"], shell=True)
|
subprocess.run(["ssh", "-p", port, f"{username}@{hostname}", command_string])
|
||||||
|
print("Bitte gehe nun selber via ssh, etc. zum Git Repos, um ein >git push origin master< zu machen um das vollständig ab zu schließen")
|
||||||
|
print("Hier sind Hilfreiche Befehle:")
|
||||||
|
print(f"\ncd share/Public/git/{project_name}")
|
||||||
|
print("\ngit push origin master")
|
||||||
|
print(f'\ngit clone "ssh://{username}@{localhostname}:{port}/share/Public/git/{project_name}.git"')
|
||||||
|
except subprocess.CalledProcessError as e:
|
||||||
|
print(f"Leider ist da was Fehlgeschlagen: {e}")
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user