@@ -0,0 +1,88 @@
|
||||
{
|
||||
"cells": [
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 5,
|
||||
"id": "70914fb0-e3d4-4233-ad33-70a1a2517a6b",
|
||||
"metadata": {},
|
||||
"outputs": [],
|
||||
"source": [
|
||||
"import os"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 7,
|
||||
"id": "b04d189c-260b-427d-af65-9ad88ac5ecf2",
|
||||
"metadata": {},
|
||||
"outputs": [
|
||||
{
|
||||
"name": "stdout",
|
||||
"output_type": "stream",
|
||||
"text": [
|
||||
"['.bash_logout', '.bash_profile', '.bashrc', '.zshrc', '.config', '.Xclients', '.dir_colors', '.profile', '.zshenv', '.local', 'Schreibtisch', 'Downloads', 'Vorlagen', 'Öffentlich', 'Dokumente', 'Musik', 'Bilder', 'Videos', '.cache', '.mozilla', '.lyrics', '.gemini', 'my_sway_konfig', 'Projekte', '.ansible', '.ssh', '.vim', '.tmux.conf', '.npm', 'create_lxc', 'lxc_folder', '.docker', 'ebook', '.bash_history', '.zhistory', 'Nextcloud', '.yarn', '.pki', 'sonovum', '.wget-hsts', '.joplin', 'JoplinBackup', '.python_history', '.gnupg', '.gitconfig', '.gitignore', '.env', '.ollama', '.claude', '.steam', '.pulse-cookie', '.icons', 'cert', 'podcast-studio', 'scripts', 'Screenshots', '.claude.json.backup.1772740061126', '.claude.json.backup.1772740061140', '.claude.json.backup.1772740137318', '.claude.json.backup.1772740278244', '.claude.json.backup.1772740278252', '.claude.json', 'Media-Data', '.smbcredentials-media', 'nfs', '.mplayer', '.steampath', '.steampid', '.eclipse', '.swt', '.java', 'conf.ini', 'token_vaultwarden', 'jenkins_status_example', '.sigstore', 'tinydb_vs_sqlite.md', '.cargo', '.viminfo', '.ipython', '.jupyter']\n"
|
||||
]
|
||||
}
|
||||
],
|
||||
"source": [
|
||||
"print(os.listdir(\"/home/jonnybravo/\"))"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 13,
|
||||
"id": "55709fef-1402-4c9f-b2ee-2be8e55a137c",
|
||||
"metadata": {},
|
||||
"outputs": [
|
||||
{
|
||||
"name": "stdout",
|
||||
"output_type": "stream",
|
||||
"text": [
|
||||
"['ver_next_einbinden.md', 'yubikey_setup_guide.md', 'networkconfig_dns.md', 'blueray_install_manjaro.md', 'calcurse_tastenkürzel.md', 'Stretchen_laufen.md']\n"
|
||||
]
|
||||
}
|
||||
],
|
||||
"source": [
|
||||
"all_files_with_md = [ x for x in os.listdir(\"/home/jonnybravo/Dokumente\") if x.endswith(\".md\") ]\n",
|
||||
"print(all_files_with_md)"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": null,
|
||||
"id": "89b5f549-36c9-4a62-83ba-69ad84ec6be6",
|
||||
"metadata": {},
|
||||
"outputs": [],
|
||||
"source": []
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": null,
|
||||
"id": "692cc39e-ddf8-4bcb-ad08-baed47e37a74",
|
||||
"metadata": {},
|
||||
"outputs": [],
|
||||
"source": []
|
||||
}
|
||||
],
|
||||
"metadata": {
|
||||
"kernelspec": {
|
||||
"display_name": "Python 3 (ipykernel)",
|
||||
"language": "python",
|
||||
"name": "python3"
|
||||
},
|
||||
"language_info": {
|
||||
"codemirror_mode": {
|
||||
"name": "ipython",
|
||||
"version": 3
|
||||
},
|
||||
"file_extension": ".py",
|
||||
"mimetype": "text/x-python",
|
||||
"name": "python",
|
||||
"nbconvert_exporter": "python",
|
||||
"pygments_lexer": "ipython3",
|
||||
"version": "3.14.3"
|
||||
}
|
||||
},
|
||||
"nbformat": 4,
|
||||
"nbformat_minor": 5
|
||||
}
|
||||
@@ -0,0 +1,39 @@
|
||||
#! /usr/bin/env Python3
|
||||
|
||||
import os
|
||||
|
||||
class create_unit_service():
|
||||
def __init__(self, UnitName = str,systemd_sysfolder = "/etc/systemd/system", execstart = str, systemd_type = "simple") -> None:
|
||||
self.UnitName = UnitName
|
||||
self.systemd_systemfolder = systemd_sysfolder
|
||||
self.execstart = execstart
|
||||
if systemd_type == "simple" or systemd_type == "oneshot":
|
||||
self.systemd_type = systemd_type
|
||||
else:
|
||||
print("Kein richtiger Typ")
|
||||
raise "systemd_type ist nicht richtig"
|
||||
|
||||
def create_unit(self):
|
||||
UnitFile = self.systemd_systemfolder + os.sep + self.UnitName + ".service"
|
||||
if os.path.exists(self.systemd_systemfolder):
|
||||
if os.path.exists(UnitFile):
|
||||
print("Gibt es bereits")
|
||||
else:
|
||||
print("Wird angelegt !!")
|
||||
with open(UnitFile, "w") as ufile:
|
||||
print("[Unit]",
|
||||
"[Service]",
|
||||
"Type=oneshot",
|
||||
"PrivateTmp=yes",
|
||||
"DynamicUser=yes",
|
||||
"ExecStart={my_execStart}".format(my_execStart=self.execstart), file=ufile, sep="\n")
|
||||
os.popen("systemctl daemon-reload")
|
||||
|
||||
def delete_unit(self):
|
||||
pass
|
||||
|
||||
if __name__ == "__main__":
|
||||
new_unit = create_unit_service(UnitName="TestUnit",
|
||||
execstart="""/usr/bin/echo "Ich bin eine TestUnit %p" """,
|
||||
systemd_type="oneshot")
|
||||
new_unit.create_unit()
|
||||
Reference in New Issue
Block a user