aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGravatar steering72532026-07-05 22:36:07 -0600
committerGravatar steering72532026-07-05 22:36:07 -0600
commit627dbb5135e250e162991af565bcf711bea70338 (patch)
tree630b9e536c681c97328cdebd3b0b11566e4bfe04
init
-rw-r--r--README.md6
-rwxr-xr-xbust_cache5
-rw-r--r--cgitsuper.sudoers.d3
-rwxr-xr-xdownload_keys4
-rwxr-xr-xmake_new_user10
5 files changed, 28 insertions, 0 deletions
diff --git a/README.md b/README.md
new file mode 100644
index 0000000..0d4e562
--- /dev/null
+++ b/README.md
@@ -0,0 +1,6 @@
+Utility scripts, mostly for use by automation (</~cgitspace/private-htdocs.git/>).
+
+- cgitsuper.sudoers.d - /etc/sudoers.d/cgitsuper
+- bust\_cache - run (sudo as root) by bust\_cache.php
+- download\_keys - run (sudo as new user) by make\_new\_user
+- make\_new\_user - run (sudo as root) by register.php
diff --git a/bust_cache b/bust_cache
new file mode 100755
index 0000000..8097f5d
--- /dev/null
+++ b/bust_cache
@@ -0,0 +1,5 @@
+#!/bin/sh
+
+rm -rf /var/cache/cgit/*
+
+echo busted
diff --git a/cgitsuper.sudoers.d b/cgitsuper.sudoers.d
new file mode 100644
index 0000000..0790c34
--- /dev/null
+++ b/cgitsuper.sudoers.d
@@ -0,0 +1,3 @@
+cgitsuper ALL=(ALL:ALL) NOPASSWD: /opt/cgit-space/sbin/bust_cache ""
+cgitsuper ALL=(ALL:ALL) NOPASSWD: /opt/cgit-space/sbin/make_new_user
+root ALL=(ALL:ALL) NOPASSWD: /opt/cgit-space/sbin/download_keys
diff --git a/download_keys b/download_keys
new file mode 100755
index 0000000..74fd4d3
--- /dev/null
+++ b/download_keys
@@ -0,0 +1,4 @@
+#!/bin/sh
+
+mkdir -p -- "$HOME/.ssh"
+curl -- "$1" | sed '/restrict,pty /!s/^/restrict,pty /' >$HOME/.ssh/authorized_keys
diff --git a/make_new_user b/make_new_user
new file mode 100755
index 0000000..aa9f772
--- /dev/null
+++ b/make_new_user
@@ -0,0 +1,10 @@
+#!/bin/sh
+
+user="$1"
+auth_keys_url="$2"
+
+useradd -s /usr/bin/git-shell -G git -m -- "$user"
+sudo -H -u "$user" /opt/cgit-space/sbin/download_keys "$auth_keys_url"
+ln -s /home/"$user" /opt/cgit-space/users/'~'"$user"
+
+echo "User has been created."