From 22c47d8e386b9775b1834f4b3103b4935d0c888f Mon Sep 17 00:00:00 2001 From: chee Date: Thu, 25 Oct 2018 09:47:46 +0100 Subject: [PATCH] =?UTF-8?q?Don't=20read=20this=20=E2=80=94=20it's=20a=20se?= =?UTF-8?q?cret?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- README.md | 2 + bind_snoots | 11 +++++ contain_snoot | 124 ++++++++++++++++++++++++++++++++++++++++++++++++++ new_snoot | 40 ++++++++++++++++ say | 8 ++++ 5 files changed, 185 insertions(+) create mode 100644 README.md create mode 100755 bind_snoots create mode 100755 contain_snoot create mode 100755 new_snoot create mode 100755 say diff --git a/README.md b/README.md new file mode 100644 index 0000000..bf57467 --- /dev/null +++ b/README.md @@ -0,0 +1,2 @@ +# don't read this +it is secret diff --git a/bind_snoots b/bind_snoots new file mode 100755 index 0000000..9e5589d --- /dev/null +++ b/bind_snoots @@ -0,0 +1,11 @@ +#!/bin/sh +cd /www/snoot.club/snoots +for snoot in *; do + real="/www/snoot.club/snoots/$snoot/application/website" + pretend="/snoots/$snoot/website" + sudo mkdir -p "$pretend" + sudo umount "$pretend" 2>/dev/null + [ -e "$real" ] && sudo mount --bind "$real" "$pretend" + sudo chown root.root "/snoots/$snoot" + sudo chmod 755 "/snoots/$snoot" +done diff --git a/contain_snoot b/contain_snoot new file mode 100755 index 0000000..bdd9bca --- /dev/null +++ b/contain_snoot @@ -0,0 +1,124 @@ +#!/bin/sh + +Skeleton_Snoot="/www/snoot.club/skeleton" +Snoot_Root="/www/snoot.club/snoots" +Snoot="$1" +Public_Key="$2" +Last_Snoot_port="$(cat /www/snoot.club/last_snoot_port || echo -n 33110)" +Ssh_Port="$(($Last_Snoot_port + 1))" +Web_Port="$(($Ssh_Port + 1))" + +cd "$Snoot_Root" + +cp -r "$Skeleton_Snoot" "$Snoot" + +cd "$Snoot/application" + +./say generating package json + +>package.json cat <", + "license": "MPL-2.0", + "description": "" +} +packagejson + +./say installing javascript dependencies + +npm install micro serve-handler + +>authorized_keys echo $Public_Key + +./say generating index html + +>website/index.html cat < + + +
+      welcome to $Snoot's homepage
+
+      if you are $Snoot, then you have two choices:
+        • your ssh port is $Ssh_Port.
+          - ssh root@snoot.club -p $Ssh_Port
+          - the files for the application are in /application.
+        • your sftp user is $Snoot.
+          - sftp $Snoot@snoot.club
+          - the files for the website are in ./website
+    
+
+
+indexhtml + +cd .. + +./say generating docker compose + +>docker-compose.yml cat <nginx.conf cat < /www/snoot.club/last_snoot_port diff --git a/new_snoot b/new_snoot new file mode 100755 index 0000000..4faa00f --- /dev/null +++ b/new_snoot @@ -0,0 +1,40 @@ +#!/bin/sh +Snoot="$1" +Snoot_Root="/www/snoot.club/snoots" + +cd "$Snoot_Root" + +Existing_User="$(> /snoots/$Snoot/.ssh/authorized_keys" +sudo chmod -R 755 "/snoots/$Snoot/.ssh" +sudo chown -R root.root "/snoots/$Snoot/.ssh" + +./say containing snoot + +/www/snoot.club/contain_snoot "$Snoot" "$Public_Key" + +sudo chown -R "$Snoot.common" "$Snoot_Root/$Snoot/application/website" + +./say binding snoots + +/www/snoot.club/bind_snoots + +./say reloading nginx + +sudo nginx -s reload diff --git a/say b/say new file mode 100755 index 0000000..eb0f270 --- /dev/null +++ b/say @@ -0,0 +1,8 @@ +#!/bin/sh +debug_mode="${DEBUG-yes}" + +if [ ! -z "$debug_mode" ]; then + echo + echo "$*" + echo +fi