Compare commits

...

8 Commits

Author SHA1 Message Date
Ubergeek 725cd3bc58 Merge branch 'master' of ttm.sh:ubergeek/bash_tdp 2019-11-05 00:32:06 +00:00
Ubergeek 9850f7e694 Added generated_by tag 2019-11-05 00:31:56 +00:00
ubergeek 94e033cf80 Update 'README.md' 2019-11-04 19:13:54 -05:00
ubergeek 5661fb5da7 Update 'README.md' 2019-11-04 19:13:22 -05:00
ubergeek 412a3138a8 Update 'README.md' 2019-11-04 19:12:10 -05:00
Ubergeek faccd9b2c3 Added separate config file, and bummped version 2019-11-05 00:09:27 +00:00
Ubergeek a6b684a4d7 Merge branch 'master' of ttm.sh:ubergeek/bash_tdp 2019-11-04 23:49:02 +00:00
Ubergeek d4ea8579f2 Adding header 2019-11-04 23:48:48 +00:00
3 changed files with 54 additions and 11 deletions

View File

@ -1,6 +1,17 @@
# Bash TDP Generator
TDP is an acronym for "Tilde Description Protocol", as described in [TDP RFC](http://protocol.club/~datagrok/beta-wiki/tdp.html).
TDP is an acronym for *Tilde Description Protocol*, as described in [TDP RFC](http://protocol.club/~datagrok/beta-wiki/tdp.html).
## How To Use
Clone the repo. Edit setenvs.sh, and set the appropriate values for your tilde server. After that is complete, do the following:
`./gen_tdp | json_pp`
If it's valid json, json_pp should just parse it, and make you a nice json struct. If that is all good, then do this:
`./gen_tdp > tilde.json`
And then copy that file to where it needs to be.
## ToDo
* Make a separate config file
* Add info header
* None yet

38
gen_tdp
View File

@ -1,13 +1,34 @@
#!/bin/bash
###############################################################################
#
# $0 A bash script to generate the tilde.json file as described by
# http://protocol.club/~datagrok/beta-wiki/tdp.html
#
# This command takes no arguments, and sends outputs to stdout.
# Version 1.2
#
# Licensed under a the AGPL 3.0 or later, by Ubergeek (ubergeek@thunix.net)
# https://www.gnu.org/licenses/gpl-3.0.en.html
#
###############################################################################
CONFIG=./setenv.sh
if [ ! -f "$CONFIG" ]; then
echo "Config file does not exist, or not at the location specified. Please create the file, or correct the location."
exit 1
fi
. $CONFIG
cat << _EOF
{
"name" : "thunix",
"url" : "https://thunix.net",
"want_users":true,
"admin_email": "root@thunix.net",
"signup_url": "https://www.thunix.net/signup",
"description": "Thunix is a community, centered around access to a public *nix system. Thunix offers shell accounts with complete set of programming tools, and follows a continuous integration-continuous deployment of system configuration.",
"name" : "$SITE_TITLE",
"url" : "$SITE",
"want_users":$WANT_USERS,
"admin_email": "$ADMIN_EMAIL",
"signup_url": "$SIGNUP_URL",
"description": "$DESCRIPTION",
_EOF
echo -ne "\t\"user_count\":"
@ -28,13 +49,14 @@ for i in $(for i in $(members tilde); do echo $i; done | sort | uniq); do
else
echo -e "\t\t\"mtime\" : \"$(stat -c '%Y' /home/$i/public_html/index.* 2> /dev/null | head -n1)\","
fi
echo -e "\t\t\"title\" : \""$(curl -L https://www.thunix.net/~$i -so - |grep -iPo '(?<=<title>)(.*)(?=</title>)')"\""
echo -e "\t\t\"title\" : \""$(curl -L $SITE/~$i -so - |grep -iPo '(?<=<title>)(.*)(?=</title>)')"\""
if [ $count -eq $(for i in $(members tilde); do echo $i; done | sort | uniq | wc -l) ]; then
echo -e "\t}"
else
echo -e "\t},"
fi
done
echo -e "\t]"
echo -e "\t],"
echo -e "\t\"generated_by\":\"bash_tdp\""
echo "}"

10
setenv.sh Normal file
View File

@ -0,0 +1,10 @@
#!/bin/bash
# Here is where you set config variables.
export SITE_TITLE="Thunix"
export SITE="https://thunix.net"
export WANT_USERS="true"
export ADMIN_EMAIL="root@thunix.net"
export SIGNUP_URL="https://thunix.net/signup"
export DESCRIPTION="Thunix is a community, centered around access to a public *nix system. Thunix offers shell accounts with complete set of programming tools, and follows a continuous integration-continuous deployment of system configuration."