aboutsummaryrefslogtreecommitdiff
path: root/workstation/setup.py
diff options
context:
space:
mode:
authoralex <alex@pdp7.net>2023-04-01 17:37:26 +0200
committeralex <alex@pdp7.net>2023-04-01 17:37:26 +0200
commita23827ca5a1fd948f79452e40fbf46cfe8ad1d62 (patch)
tree32ea1b3fdd9152a0abc8b2b9d71a030204d9af7c /workstation/setup.py
parent3b2dfba62d970e4612a5e90051f6cb5d1aa1824e (diff)
Add workstation setup
Diffstat (limited to 'workstation/setup.py')
-rwxr-xr-xworkstation/setup.py41
1 files changed, 41 insertions, 0 deletions
diff --git a/workstation/setup.py b/workstation/setup.py
new file mode 100755
index 00000000..ec63c9e8
--- /dev/null
+++ b/workstation/setup.py
@@ -0,0 +1,41 @@
+#!/usr/bin/env python3
+import pathlib
+import shutil
+import subprocess
+import textwrap
+
+
+def _(t):
+ return textwrap.dedent(t).lstrip()
+
+
+if not shutil.which("rclone"):
+ subprocess.run(["sudo", "dnf", "install", "-y", "rclone"], check=True)
+
+if not pathlib.Path(".config/rclone/rclone.conf").exists():
+ print(_("""
+ Visit https://nextcloud.pdp7.net/nextcloud/index.php/settings/user/security , create an app password
+ """))
+
+ subprocess.run(["rclone", "config", "create", "nextcloud", "webdav", "url=https://nextcloud.pdp7.net/nextcloud/remote.php/dav/files/alex/", "vendor=nextcloud", "user=alex", "--all"], check=True)
+
+
+pathlib.Path("Nextcloud").mkdir(exist_ok=True)
+
+
+nextcloud_service_path = pathlib.Path(".config/systemd/user/nextcloud.service")
+nextcloud_service_path.parent.mkdir(parents=True, exist_ok=True)
+
+
+with open(nextcloud_service_path, "w", encoding="utf8") as f:
+ f.write(_("""
+ [Unit]
+
+ [Service]
+ ExecStart=/usr/bin/rclone mount --vfs-cache-mode=full --dir-perms 700 --file-perms 600 nextcloud: /home/alex/Nextcloud/
+
+ [Install]
+ WantedBy=default.target
+ """))
+
+subprocess.run(["systemctl", "--user", "enable", "--now", "nextcloud"], check=True)